Skip to content

Commit

Permalink
CogVM source as per VMMaker.oscog-eem.2175
Browse files Browse the repository at this point in the history
CoInterpreter:
If a context's method is assigned to, any machine code pcs must be mapped to
bytecode ones *before* the method is changed because otherwise subsequent reads
of the context's pc will attempt to map using the wrong method, causing a crash.
  • Loading branch information
eliotmiranda committed Mar 21, 2017
1 parent 54bab0a commit 3bfd04a
Show file tree
Hide file tree
Showing 54 changed files with 2,249 additions and 431 deletions.
2 changes: 1 addition & 1 deletion nsspur64src/vm/cogit.h
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.2174 uuid: eefef0d3-2df8-4fe7-9f71-2aca68641ba6
CCodeGenerator VMMaker.oscog-eem.2175 uuid: eb79e804-a80b-4ad3-bd19-9c60a24a14f1
*/


Expand Down
97 changes: 85 additions & 12 deletions nsspur64src/vm/cointerp.c
@@ -1,9 +1,9 @@
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2167 uuid: eff5a996-2b02-4ebf-85ff-fd672ba46fc4
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2175 uuid: eb79e804-a80b-4ad3-bd19-9c60a24a14f1
from
CoInterpreter VMMaker.oscog-eem.2167 uuid: eff5a996-2b02-4ebf-85ff-fd672ba46fc4
CoInterpreter VMMaker.oscog-eem.2175 uuid: eb79e804-a80b-4ad3-bd19-9c60a24a14f1
*/
static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2167 uuid: eff5a996-2b02-4ebf-85ff-fd672ba46fc4 " __DATE__ ;
static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.2175 uuid: eb79e804-a80b-4ad3-bd19-9c60a24a14f1 " __DATE__ ;
char *__interpBuildInfo = __buildInfo;


Expand Down Expand Up @@ -2522,7 +2522,7 @@ static signed char primitiveAccessorDepthTable[MaxPrimitiveIndex + 2 /* 577 */]
};
sqInt checkedPluginName;
char expensiveAsserts = 0;
const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.2167";
const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.2175";
sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */;
volatile int sendTrace;

Expand Down Expand Up @@ -6506,6 +6506,7 @@ interpret(void)
sqInt object3;
int onCurrentPage;
sqInt opType;
sqInt pc;
sqInt referent;
sqInt result;
sqInt senderOop;
Expand All @@ -6514,6 +6515,8 @@ interpret(void)
char * theFP;
StackPage *thePage;
StackPage * thePage1;
sqInt thePC;
sqInt thePC1;
sqInt top;
sqInt value;

Expand Down Expand Up @@ -6750,7 +6753,10 @@ interpret(void)
obj1 = longAt(localFP + FoxIFReceiver);
if ((byte3 <= ReceiverIndex)
&& ((((longAt(obj1)) & (classIndexMask())) == ClassMethodContextCompactIndex)
&& (((((longAt((obj1 + BaseHeaderSize) + (((sqInt)((usqInt)(SenderIndex) << (shiftForWord()))))))) & 7) == 1)))) {
&& ((((((longAt((obj1 + BaseHeaderSize) + (((sqInt)((usqInt)(SenderIndex) << (shiftForWord()))))))) & 7) == 1))
|| ((byte3 == MethodIndex)
&& (((((int) ((thePC = longAt((top + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord()))))))))) < 0)
&& ((((thePC) & 7) == 1))))))) {
/* begin instVar:ofContext:put: */
assert(isMarriedOrWidowedContext(obj1));
assert(!((isObjImmutable(obj1))));
Expand Down Expand Up @@ -6814,6 +6820,19 @@ interpret(void)
GIV(stackPointer) = localSP;
GIV(framePointer) = localFP;
externalDivorceFrameandContext(theFP, obj1);
if ((byte3 == MethodIndex)
&& (((((int) ((thePC1 = longAt((obj1 + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord()))))))))) < 0)
&& ((((thePC1) & 7) == 1)))) {
/* begin ensureContextHasBytecodePC: */
assert(!(isMarriedOrWidowedContext(obj1)));
pc = longAt((obj1 + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord())))));
if (((((pc) & 7) == 1))
&& (((pc = (pc >> 3))) < 0)) {
pc = mustMapMachineCodePCcontext(pc, obj1);
assert(!(isOopForwarded(obj1)));
longAtput((obj1 + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord())))), pc);
}
}
/* begin storePointer:ofObject:withValue: */
assert(!(isForwarded(obj1)));
if ((assert(isNonImmediate(obj1)),
Expand Down Expand Up @@ -7279,7 +7298,7 @@ interpret(void)
sqInt context;
sqInt i;
sqInt initialIP;
sqInt newClosure;
usqInt newClosure;
usqInt newClosure1;
usqInt newObj;
sqInt numArgs;
Expand Down Expand Up @@ -12909,9 +12928,12 @@ interpret(void)
sqInt anObject;
sqInt obj;
int onCurrentPage;
sqInt pc;
sqInt senderOop;
char * theFP;
StackPage * thePage;
sqInt thePC;
sqInt thePC1;
sqInt variableIndex;

VM_LABEL(extStoreReceiverVariableBytecode);
Expand All @@ -12923,7 +12945,10 @@ interpret(void)
obj = longAt(localFP + FoxIFReceiver);
if ((variableIndex <= ReceiverIndex)
&& ((((longAt(obj)) & (classIndexMask())) == ClassMethodContextCompactIndex)
&& (((((longAt((obj + BaseHeaderSize) + (((sqInt)((usqInt)(SenderIndex) << (shiftForWord()))))))) & 7) == 1)))) {
&& ((((((longAt((obj + BaseHeaderSize) + (((sqInt)((usqInt)(SenderIndex) << (shiftForWord()))))))) & 7) == 1))
|| ((variableIndex == MethodIndex)
&& (((((int) ((thePC = longAt((anObject + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord()))))))))) < 0)
&& ((((thePC) & 7) == 1))))))) {
/* begin instVar:ofContext:put: */
assert(isMarriedOrWidowedContext(obj));
assert(!((isObjImmutable(obj))));
Expand Down Expand Up @@ -12987,6 +13012,19 @@ interpret(void)
GIV(stackPointer) = localSP;
GIV(framePointer) = localFP;
externalDivorceFrameandContext(theFP, obj);
if ((variableIndex == MethodIndex)
&& (((((int) ((thePC1 = longAt((obj + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord()))))))))) < 0)
&& ((((thePC1) & 7) == 1)))) {
/* begin ensureContextHasBytecodePC: */
assert(!(isMarriedOrWidowedContext(obj)));
pc = longAt((obj + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord())))));
if (((((pc) & 7) == 1))
&& (((pc = (pc >> 3))) < 0)) {
pc = mustMapMachineCodePCcontext(pc, obj);
assert(!(isOopForwarded(obj)));
longAtput((obj + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord())))), pc);
}
}
/* begin storePointer:ofObject:withValue: */
assert(!(isForwarded(obj)));
if ((assert(isNonImmediate(obj)),
Expand Down Expand Up @@ -13157,9 +13195,12 @@ interpret(void)
{
sqInt obj;
int onCurrentPage;
sqInt pc;
sqInt senderOop;
char * theFP;
StackPage * thePage;
sqInt thePC;
sqInt thePC1;
sqInt value;
sqInt variableIndex;

Expand All @@ -13173,7 +13214,10 @@ interpret(void)
obj = longAt(localFP + FoxIFReceiver);
if ((variableIndex <= ReceiverIndex)
&& ((((longAt(obj)) & (classIndexMask())) == ClassMethodContextCompactIndex)
&& (((((longAt((obj + BaseHeaderSize) + (((sqInt)((usqInt)(SenderIndex) << (shiftForWord()))))))) & 7) == 1)))) {
&& ((((((longAt((obj + BaseHeaderSize) + (((sqInt)((usqInt)(SenderIndex) << (shiftForWord()))))))) & 7) == 1))
|| ((variableIndex == MethodIndex)
&& (((((int) ((thePC = longAt((value + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord()))))))))) < 0)
&& ((((thePC) & 7) == 1))))))) {
/* begin instVar:ofContext:put: */
assert(isMarriedOrWidowedContext(obj));
assert(!((isObjImmutable(obj))));
Expand Down Expand Up @@ -13237,6 +13281,19 @@ interpret(void)
GIV(stackPointer) = localSP;
GIV(framePointer) = localFP;
externalDivorceFrameandContext(theFP, obj);
if ((variableIndex == MethodIndex)
&& (((((int) ((thePC1 = longAt((obj + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord()))))))))) < 0)
&& ((((thePC1) & 7) == 1)))) {
/* begin ensureContextHasBytecodePC: */
assert(!(isMarriedOrWidowedContext(obj)));
pc = longAt((obj + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord())))));
if (((((pc) & 7) == 1))
&& (((pc = (pc >> 3))) < 0)) {
pc = mustMapMachineCodePCcontext(pc, obj);
assert(!(isOopForwarded(obj)));
longAtput((obj + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord())))), pc);
}
}
/* begin storePointer:ofObject:withValue: */
assert(!(isForwarded(obj)));
if ((assert(isNonImmediate(obj)),
Expand Down Expand Up @@ -14946,7 +15003,7 @@ interpret(void)
sqInt context;
sqInt i;
sqInt initialIP;
sqInt newClosure;
usqInt newClosure;
usqInt newClosure1;
usqInt newObj;
sqInt numArgs;
Expand Down Expand Up @@ -18932,7 +18989,7 @@ checkStackIntegrity(void)
sqInt i;
sqInt methodField;
sqInt ok;
usqInt oop;
sqInt oop;
char *theFP;
StackPage *thePage;
char *theSP;
Expand Down Expand Up @@ -22974,7 +23031,7 @@ printFrameWithSP(char *theFP, char *theSP)
usqInt index;
sqInt methodField;
usqInt numArgs;
usqInt numTemps;
sqInt numTemps;
char *rcvrAddress;
sqInt rcvrOrClosure;
sqInt theMethod;
Expand Down Expand Up @@ -44462,7 +44519,7 @@ scavengeFutureSurvivorSpaceStartingAt(sqInt initialAddress)
usqInt numSlots1;
usqInt numSlots2;
sqInt obj;
sqInt ptr;
usqInt ptr;
usqInt slotBytes;

ptr = initialAddress;
Expand Down Expand Up @@ -66665,9 +66722,11 @@ static sqInt NoDbgRegParms
externalInstVarofContextput(sqInt index, sqInt maybeMarriedContext, sqInt anOop)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
int onCurrentPage;
sqInt pc;
sqInt senderOop;
char *theFP;
StackPage *thePage;
sqInt thePC;

assert(isContext(maybeMarriedContext));
/* begin externalWriteBackHeadFramePointers */
Expand Down Expand Up @@ -66720,6 +66779,20 @@ externalInstVarofContextput(sqInt index, sqInt maybeMarriedContext, sqInt anOop)
}
else {
externalDivorceFrameandContext(theFP, maybeMarriedContext);
if ((index == MethodIndex)
&& (((((int) ((thePC = longAt((maybeMarriedContext + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord()))))))))) < 0)
&& ((((thePC) & 7) == 1)))) {
/* begin ensureContextHasBytecodePC: */
assert(!(isMarriedOrWidowedContext(maybeMarriedContext)));
pc = longAt((maybeMarriedContext + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord())))));
if (((((pc) & 7) == 1))
&& (((pc = (pc >> 3))) < 0)) {
pc = mustMapMachineCodePCcontext(pc, maybeMarriedContext);
assert(!(isOopForwarded(maybeMarriedContext)));
longAtput((maybeMarriedContext + BaseHeaderSize) + (((sqInt)((usqInt)(InstructionPointerIndex) << (shiftForWord())))), pc);

}
}
/* begin storePointer:ofObject:withValue: */
assert(!(isForwarded(maybeMarriedContext)));
if ((assert(isNonImmediate(maybeMarriedContext)),
Expand Down
2 changes: 1 addition & 1 deletion nsspur64src/vm/cointerp.h
@@ -1,5 +1,5 @@
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2167 uuid: eff5a996-2b02-4ebf-85ff-fd672ba46fc4
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.2175 uuid: eb79e804-a80b-4ad3-bd19-9c60a24a14f1
*/


Expand Down

0 comments on commit 3bfd04a

Please sign in to comment.