Revision: 3161 Author: eliot Date: 2014-12-05 19:12:21 -0800 (Fri, 05 Dec 2014) Log Message: ----------- CogVM source as per VMMaker.oscog-eem.969 Two more cases where the mnu compilation break point needs to be checked. Use numBytesOf: for length of selector. Rename checkValidInlineCacheTag: to validInlineCacheTag:. Add a debug lookup routine that only looks up (and follows forwarding pointers). Modified Paths: -------------- branches/Cog/nscogsrc/vm/cogit.c branches/Cog/nscogsrc/vm/cogit.h branches/Cog/nscogsrc/vm/cointerp.c branches/Cog/nscogsrc/vm/cointerp.h branches/Cog/nscogsrc/vm/gcc3x-cointerp.c branches/Cog/nsspursrc/vm/cogit.c branches/Cog/nsspursrc/vm/cogit.h branches/Cog/nsspursrc/vm/cointerp.c branches/Cog/nsspursrc/vm/cointerp.h branches/Cog/nsspursrc/vm/gcc3x-cointerp.c branches/Cog/nsspurstacksrc/vm/gcc3x-interp.c branches/Cog/nsspurstacksrc/vm/interp.c branches/Cog/sistasrc/vm/cogit.c branches/Cog/sistasrc/vm/cogit.h branches/Cog/sistasrc/vm/cointerp.c branches/Cog/sistasrc/vm/cointerp.h branches/Cog/sistasrc/vm/gcc3x-cointerp.c branches/Cog/spursistasrc/vm/cogit.c branches/Cog/spursistasrc/vm/cogit.h branches/Cog/spursistasrc/vm/cointerp.c branches/Cog/spursistasrc/vm/cointerp.h branches/Cog/spursistasrc/vm/gcc3x-cointerp.c branches/Cog/spursrc/vm/cogit.c branches/Cog/spursrc/vm/cogit.h branches/Cog/spursrc/vm/cointerp.c branches/Cog/spursrc/vm/cointerp.h branches/Cog/spursrc/vm/gcc3x-cointerp.c branches/Cog/spurstack64src/vm/gcc3x-interp.c branches/Cog/spurstack64src/vm/interp.c branches/Cog/spurstacksrc/vm/gcc3x-interp.c branches/Cog/spurstacksrc/vm/interp.c branches/Cog/src/vm/cogit.c branches/Cog/src/vm/cogit.h branches/Cog/src/vm/cointerp.c branches/Cog/src/vm/cointerp.h branches/Cog/src/vm/cointerpmt.c branches/Cog/src/vm/cointerpmt.h branches/Cog/src/vm/gcc3x-cointerp.c branches/Cog/src/vm/gcc3x-cointerpmt.c branches/Cog/stacksrc/vm/gcc3x-interp.c branches/Cog/stacksrc/vm/interp.c Property Changed: ---------------- branches/Cog/platforms/Cross/vm/sqSCCSVersion.h Modified: branches/Cog/nscogsrc/vm/cogit.c =================================================================== --- branches/Cog/nscogsrc/vm/cogit.c 2014-12-05 23:14:12 UTC (rev 3160) +++ branches/Cog/nscogsrc/vm/cogit.c 2014-12-06 03:12:21 UTC (rev 3161) @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CCodeGenerator VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 from - StackToRegisterMappingCogit VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + StackToRegisterMappingCogit VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -839,7 +839,6 @@ static void maybeCompileRetryonPrimitiveFail(AbstractInstruction *retryInst, sqInt primIndex) NoDbgRegParms; static sqInt allYoungObjectsAgeInFullGC(void); static sqInt cacheTagIsMarked(sqInt cacheTag) NoDbgRegParms; -static sqInt checkValidInlineCacheTag(sqInt cacheTag) NoDbgRegParms; static sqInt checkValidOopReference(sqInt anOop) NoDbgRegParms; static sqInt compactClassFieldMask(void); static sqInt couldBeObject(sqInt oop) NoDbgRegParms; @@ -891,6 +890,7 @@ static sqInt shouldAnnotateObjectReference(sqInt anOop) NoDbgRegParms; static sqInt slotOffsetOfInstVarIndex(sqInt index) NoDbgRegParms; static sqInt smallIntegerIsOnlyImmediateType(void); +static sqInt validInlineCacheTag(sqInt cacheTag) NoDbgRegParms; static CogSimStackEntry * ensureSpilledAtfrom(CogSimStackEntry * self_in_ensureSpilledAtfrom, sqInt baseOffset, sqInt baseRegister) NoDbgRegParms; static CogSimStackEntry * mergeAtfrom(CogSimStackEntry * self_in_mergeAtfrom, sqInt baseOffset, sqInt baseRegister) NoDbgRegParms; static CogSimStackEntry * popToReg(CogSimStackEntry * self_in_popToReg, sqInt reg) NoDbgRegParms; @@ -8903,7 +8903,7 @@ } } else { - if (!(asserta(checkValidInlineCacheTag(cacheTag1)))) { + if (!(asserta(validInlineCacheTag(cacheTag1)))) { return 5; } } @@ -8915,7 +8915,7 @@ } } else { - if (!(asserta(checkValidInlineCacheTag(cacheTag1)))) { + if (!(asserta(validInlineCacheTag(cacheTag1)))) { return 7; } } @@ -9005,7 +9005,7 @@ /* linked non-super send, cacheTag is a cacheTag */ - if (!(checkValidInlineCacheTag(selectorOrCacheTag))) { + if (!(validInlineCacheTag(selectorOrCacheTag))) { print("cache tag leak in CM "); printHex(((sqInt)cogMethod)); print(" @ "); @@ -9366,7 +9366,7 @@ sqInt size; sqInt target; - compilationBreakpointisMNUCase((cPIC->selector), lengthOf((cPIC->selector)), isMNUCase); + compilationBreakpointisMNUCase((cPIC->selector), numBytesOf((cPIC->selector)), isMNUCase); allocateOpcodesbytecodes(5, 0); assert(!(inlineCacheTagIsYoung(caseNTag))); assert((caseNMethod != null) @@ -9501,7 +9501,7 @@ if (isYoung(selector)) { return 0; } - compilationBreakpointisMNUCase(selector, lengthOf(selector), 1); + compilationBreakpointisMNUCase(selector, numBytesOf(selector), 1); assert(endCPICCase0 != null); startAddress = allocate(closedPICSize); if (startAddress == 0) { @@ -9539,7 +9539,7 @@ sqInt mapSize; sqInt startAddress; - compilationBreakpointisMNUCase(selector, lengthOf(selector), 0); + compilationBreakpointisMNUCase(selector, numBytesOf(selector), 0); startAddress = allocate(openPICSize); if (startAddress == 0) { return ((CogMethod *) InsufficientCodeSpace); @@ -9579,7 +9579,7 @@ if (isYoung(selector)) { return ((CogMethod *) YoungSelectorInPIC); } - compilationBreakpointisMNUCase(selector, lengthOf(selector), isMNUCase); + compilationBreakpointisMNUCase(selector, numBytesOf(selector), isMNUCase); startAddress = allocate(closedPICSize); if (startAddress == 0) { return ((CogMethod *) InsufficientCodeSpace); @@ -9936,6 +9936,7 @@ void *targetEntry; assert(case1Method != null); + compilationBreakpointisMNUCase((cPIC->selector), numBytesOf((cPIC->selector)), isMNUCase); compilePICProlog(numArgs); assert(!(inlineCacheTagIsYoung(case1Tag))); if ((!isMNUCase) @@ -10029,6 +10030,7 @@ AbstractInstruction *jumpNext; sqInt jumpTarget; + compilationBreakpointisMNUCase((cPIC->selector), numBytesOf((cPIC->selector)), 1); compilePICProlog(numArgs); jumpNext = compileCPICEntry(); /* begin MoveCw:R: */ @@ -14009,7 +14011,7 @@ void setSelectorOfto(CogMethod *cogMethod, sqInt aSelectorOop) { - compilationBreakpointisMNUCase(aSelectorOop, lengthOf(aSelectorOop), 0); + compilationBreakpointisMNUCase(aSelectorOop, numBytesOf(aSelectorOop), 0); assert(((cogMethod->cmType)) == CMMethod); (cogMethod->selector = aSelectorOop); if (isYoung(aSelectorOop)) { @@ -15480,15 +15482,6 @@ } static sqInt -checkValidInlineCacheTag(sqInt cacheTag) -{ - return (cacheTag == ConstZero) - || ((((cacheTag & ((1 << (shiftForWord())) - 1)) == 0) - && (((cacheTag >= (1 << (compactClassFieldLSB()))) && (cacheTag <= ((compactClassIndexOfHeader(-1)) << (compactClassFieldLSB())))))) - || (checkValidObjectReference(cacheTag))); -} - -static sqInt checkValidOopReference(sqInt anOop) { return ((anOop & 1)) @@ -16631,6 +16624,15 @@ return 1; } +static sqInt +validInlineCacheTag(sqInt cacheTag) +{ + return (cacheTag == ConstZero) + || ((((cacheTag & ((1 << (shiftForWord())) - 1)) == 0) + && (((cacheTag >= (1 << (compactClassFieldLSB()))) && (cacheTag <= ((compactClassIndexOfHeader(-1)) << (compactClassFieldLSB())))))) + || (checkValidObjectReference(cacheTag))); +} + static CogSimStackEntry * ensureSpilledAtfrom(CogSimStackEntry * self_in_ensureSpilledAtfrom, sqInt baseOffset, sqInt baseRegister) { Modified: branches/Cog/nscogsrc/vm/cogit.h =================================================================== --- branches/Cog/nscogsrc/vm/cogit.h 2014-12-05 23:14:12 UTC (rev 3160) +++ branches/Cog/nscogsrc/vm/cogit.h 2014-12-06 03:12:21 UTC (rev 3161) @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CCodeGenerator VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 */ Modified: branches/Cog/nscogsrc/vm/cointerp.c =================================================================== --- branches/Cog/nscogsrc/vm/cointerp.c 2014-12-05 23:14:12 UTC (rev 3160) +++ branches/Cog/nscogsrc/vm/cointerp.c 2014-12-06 03:12:21 UTC (rev 3161) @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 from - CoInterpreter VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CoInterpreter VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1142,6 +1142,7 @@ static sqInt lookupInMethodCacheSelclassTag(sqInt selector, sqInt classTag) NoDbgRegParms; static sqInt lookupMethodInClass(sqInt class) NoDbgRegParms; static sqInt lookupMethodNoMNUEtcInClass(sqInt class) NoDbgRegParms; +sqInt lookupSelectorinClass(sqInt selector, sqInt class); sqInt makePointwithxValueyValue(sqInt xValue, sqInt yValue); static void mapInterpreterOops(void); static sqInt markAndTraceAndMaybeFreeStackPages(sqInt fullGCFlag) NoDbgRegParms; @@ -2097,7 +2098,7 @@ /* 574 */ (void (*)(void))0, /* 575 */ (void (*)(void))0, 0 }; -const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.968"; +const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.969"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; volatile int sendTrace; @@ -4841,6 +4842,7 @@ GIV(framePointer) = localFP; ceEnterCogCodePopReceiverReg(); + null; goto l300; } localIP = pointerForOop(longAt(localFP + FoxIFSavedIP)); @@ -4858,7 +4860,7 @@ /* begin fetchNextBytecode */ currentBytecode = (byteAtPointer(++localIP)) + GIV(bytecodeSetSelector); - /* return self */ + null; l300: /* end baseFrameReturn */; goto l299; } @@ -47695,6 +47697,80 @@ } +/* Lookup selector in class. Answer the method or nil. This is a debugging + routine. */ + +sqInt +lookupSelectorinClass(sqInt selector, sqInt class) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + sqInt currentClass; + sqInt dictionary; + sqInt header; + sqInt index; + sqInt length; + sqInt mask; + sqInt meth; + sqInt methodArray; + sqInt nextSelector; + sqInt sz; + sqInt wrapAround; + + currentClass = class; + while (currentClass != GIV(nilObj)) { + dictionary = longAt((currentClass + BaseHeaderSize) + (MethodDictionaryIndex << (shiftForWord()))); + if (dictionary == GIV(nilObj)) { + return null; + } + /* begin lookupMethodFor:InDictionary: */ + /* begin numSlotsOf: */ + header = longAt(dictionary); + sz = ((header & TypeMask) == HeaderTypeSizeAndClass + ? (longAt(dictionary - (BytesPerWord * 2))) & AllButTypeMask + : header & SizeMask); + length = ((usqInt) (sz - BaseHeaderSize)) >> (shiftForWord()); + mask = (length - SelectorStart) - 1; + + /* It is assumed that there are some nils in this dictionary, and search will + stop when one is encountered. However, if there are no nils, then wrapAround + will be detected the second time the loop gets to the end of the table. */ + + index = SelectorStart + (mask & (((selector & 1) + ? (selector >> 1) + : (((usqInt) (longAt(selector))) >> HashBitsOffset) & HashMaskUnshifted))); + wrapAround = 0; + while (1) { + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + if (nextSelector == GIV(nilObj)) { + meth = null; + goto l1; + } + + if (nextSelector == selector) { + methodArray = longAt((dictionary + BaseHeaderSize) + (MethodArrayIndex << (shiftForWord()))); + meth = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); + goto l1; + } + index += 1; + if (index == length) { + if (wrapAround) { + meth = null; + goto l1; + } + wrapAround = 1; + index = SelectorStart; + } + } + meth = null; + l1: /* end lookupMethodFor:InDictionary: */; + if (!(meth == null)) { + return meth; + } + currentClass = longAt((currentClass + BaseHeaderSize) + (SuperclassIndex << (shiftForWord()))); + } + return null; +} + + /* make a Point xValue@yValue. We know both will be integers so no value nor root checking is needed */ Modified: branches/Cog/nscogsrc/vm/cointerp.h =================================================================== --- branches/Cog/nscogsrc/vm/cointerp.h 2014-12-05 23:14:12 UTC (rev 3160) +++ branches/Cog/nscogsrc/vm/cointerp.h 2014-12-06 03:12:21 UTC (rev 3161) @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 */ @@ -234,6 +234,7 @@ sqInt literalofMethod(sqInt offset, sqInt methodPointer); void longPrintOop(sqInt oop); sqInt longStoreBytecodeForHeader(sqInt methodHeader); +sqInt lookupSelectorinClass(sqInt selector, sqInt class); sqInt methodClassAssociationOf(sqInt methodPointer); sqInt methodClassOf(sqInt methodPointer); sqInt methodPrimitiveIndex(void); Modified: branches/Cog/nscogsrc/vm/gcc3x-cointerp.c =================================================================== --- branches/Cog/nscogsrc/vm/gcc3x-cointerp.c 2014-12-05 23:14:12 UTC (rev 3160) +++ branches/Cog/nscogsrc/vm/gcc3x-cointerp.c 2014-12-06 03:12:21 UTC (rev 3161) @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 from - CoInterpreter VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CoInterpreter VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1145,6 +1145,7 @@ static sqInt lookupInMethodCacheSelclassTag(sqInt selector, sqInt classTag) NoDbgRegParms; static sqInt lookupMethodInClass(sqInt class) NoDbgRegParms; static sqInt lookupMethodNoMNUEtcInClass(sqInt class) NoDbgRegParms; +sqInt lookupSelectorinClass(sqInt selector, sqInt class); sqInt makePointwithxValueyValue(sqInt xValue, sqInt yValue); static void mapInterpreterOops(void); static sqInt markAndTraceAndMaybeFreeStackPages(sqInt fullGCFlag) NoDbgRegParms; @@ -2100,7 +2101,7 @@ /* 574 */ (void (*)(void))0, /* 575 */ (void (*)(void))0, 0 }; -const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.968"; +const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.969"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; volatile int sendTrace; @@ -4850,6 +4851,7 @@ GIV(framePointer) = localFP; ceEnterCogCodePopReceiverReg(); + null; goto l300; } localIP = pointerForOop(longAt(localFP + FoxIFSavedIP)); @@ -4867,7 +4869,7 @@ /* begin fetchNextBytecode */ currentBytecode = (byteAtPointer(++localIP)) + GIV(bytecodeSetSelector); - /* return self */ + null; l300: /* end baseFrameReturn */; goto l299; } @@ -47704,6 +47706,80 @@ } +/* Lookup selector in class. Answer the method or nil. This is a debugging + routine. */ + +sqInt +lookupSelectorinClass(sqInt selector, sqInt class) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + sqInt currentClass; + sqInt dictionary; + sqInt header; + sqInt index; + sqInt length; + sqInt mask; + sqInt meth; + sqInt methodArray; + sqInt nextSelector; + sqInt sz; + sqInt wrapAround; + + currentClass = class; + while (currentClass != GIV(nilObj)) { + dictionary = longAt((currentClass + BaseHeaderSize) + (MethodDictionaryIndex << (shiftForWord()))); + if (dictionary == GIV(nilObj)) { + return null; + } + /* begin lookupMethodFor:InDictionary: */ + /* begin numSlotsOf: */ + header = longAt(dictionary); + sz = ((header & TypeMask) == HeaderTypeSizeAndClass + ? (longAt(dictionary - (BytesPerWord * 2))) & AllButTypeMask + : header & SizeMask); + length = ((usqInt) (sz - BaseHeaderSize)) >> (shiftForWord()); + mask = (length - SelectorStart) - 1; + + /* It is assumed that there are some nils in this dictionary, and search will + stop when one is encountered. However, if there are no nils, then wrapAround + will be detected the second time the loop gets to the end of the table. */ + + index = SelectorStart + (mask & (((selector & 1) + ? (selector >> 1) + : (((usqInt) (longAt(selector))) >> HashBitsOffset) & HashMaskUnshifted))); + wrapAround = 0; + while (1) { + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + if (nextSelector == GIV(nilObj)) { + meth = null; + goto l1; + } + + if (nextSelector == selector) { + methodArray = longAt((dictionary + BaseHeaderSize) + (MethodArrayIndex << (shiftForWord()))); + meth = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); + goto l1; + } + index += 1; + if (index == length) { + if (wrapAround) { + meth = null; + goto l1; + } + wrapAround = 1; + index = SelectorStart; + } + } + meth = null; + l1: /* end lookupMethodFor:InDictionary: */; + if (!(meth == null)) { + return meth; + } + currentClass = longAt((currentClass + BaseHeaderSize) + (SuperclassIndex << (shiftForWord()))); + } + return null; +} + + /* make a Point xValue@yValue. We know both will be integers so no value nor root checking is needed */ Modified: branches/Cog/nsspursrc/vm/cogit.c =================================================================== --- branches/Cog/nsspursrc/vm/cogit.c 2014-12-05 23:14:12 UTC (rev 3160) +++ branches/Cog/nsspursrc/vm/cogit.c 2014-12-06 03:12:21 UTC (rev 3161) @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CCodeGenerator VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 from - StackToRegisterMappingCogit VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + StackToRegisterMappingCogit VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -861,9 +861,9 @@ static sqInt numCharacterBits(void); static sqInt numSmallIntegerBits(void); static sqInt numSmallIntegerTagBits(void); +static sqInt validInlineCacheTag(usqInt classIndexOrTagPattern) NoDbgRegParms; static sqInt allYoungObjectsAgeInFullGC(void); static sqInt cacheTagIsMarked(sqInt cacheTag) NoDbgRegParms; -static sqInt checkValidInlineCacheTag(sqInt classIndexOrTagPattern) NoDbgRegParms; static sqInt checkValidOopReference(sqInt anOop) NoDbgRegParms; static sqInt couldBeObject(sqInt literal) NoDbgRegParms; static sqInt createsClosuresInline(void); @@ -8924,7 +8924,7 @@ } } else { - if (!(asserta(checkValidInlineCacheTag(cacheTag1)))) { + if (!(asserta(validInlineCacheTag(cacheTag1)))) { return 5; } } @@ -8936,7 +8936,7 @@ } } else { - if (!(asserta(checkValidInlineCacheTag(cacheTag1)))) { + if (!(asserta(validInlineCacheTag(cacheTag1)))) { return 7; } } @@ -9026,7 +9026,7 @@ /* linked non-super send, cacheTag is a cacheTag */ - if (!(checkValidInlineCacheTag(selectorOrCacheTag))) { + if (!(validInlineCacheTag(selectorOrCacheTag))) { print("cache tag leak in CM "); printHex(((sqInt)cogMethod)); print(" @ "); @@ -9324,7 +9324,7 @@ sqInt size; sqInt target; - compilationBreakpointisMNUCase((cPIC->selector), lengthOf((cPIC->selector)), isMNUCase); + compilationBreakpointisMNUCase((cPIC->selector), numBytesOf((cPIC->selector)), isMNUCase); allocateOpcodesbytecodes(5, 0); assert(!(inlineCacheTagIsYoung(caseNTag))); assert((caseNMethod != null) @@ -9459,7 +9459,7 @@ if (isYoung(selector)) { return 0; } - compilationBreakpointisMNUCase(selector, lengthOf(selector), 1); + compilationBreakpointisMNUCase(selector, numBytesOf(selector), 1); assert(endCPICCase0 != null); startAddress = allocate(closedPICSize); if (startAddress == 0) { @@ -9497,7 +9497,7 @@ sqInt mapSize; sqInt startAddress; - compilationBreakpointisMNUCase(selector, lengthOf(selector), 0); + compilationBreakpointisMNUCase(selector, numBytesOf(selector), 0); startAddress = allocate(openPICSize); if (startAddress == 0) { return ((CogMethod *) InsufficientCodeSpace); @@ -9537,7 +9537,7 @@ if (isYoung(selector)) { return ((CogMethod *) YoungSelectorInPIC); } - compilationBreakpointisMNUCase(selector, lengthOf(selector), isMNUCase); + compilationBreakpointisMNUCase(selector, numBytesOf(selector), isMNUCase); startAddress = allocate(closedPICSize); if (startAddress == 0) { return ((CogMethod *) InsufficientCodeSpace); @@ -9894,6 +9894,7 @@ void *targetEntry; assert(case1Method != null); + compilationBreakpointisMNUCase((cPIC->selector), numBytesOf((cPIC->selector)), isMNUCase); compilePICProlog(numArgs); assert(!(inlineCacheTagIsYoung(case1Tag))); if ((!isMNUCase) @@ -9987,6 +9988,7 @@ AbstractInstruction *jumpNext; sqInt jumpTarget; + compilationBreakpointisMNUCase((cPIC->selector), numBytesOf((cPIC->selector)), 1); compilePICProlog(numArgs); jumpNext = compileCPICEntry(); /* begin MoveCw:R: */ @@ -13910,7 +13912,7 @@ void setSelectorOfto(CogMethod *cogMethod, sqInt aSelectorOop) { - compilationBreakpointisMNUCase(aSelectorOop, lengthOf(aSelectorOop), 0); + compilationBreakpointisMNUCase(aSelectorOop, numBytesOf(aSelectorOop), 0); assert(((cogMethod->cmType)) == CMMethod); (cogMethod->selector = aSelectorOop); if (isYoung(aSelectorOop)) { @@ -17387,7 +17389,17 @@ return 1; } + +/* The two valid tag patterns are 0 (Character) and 1 (SmallInteger) */ + static sqInt +validInlineCacheTag(usqInt classIndexOrTagPattern) +{ + return (classIndexOrTagPattern <= 1) + || ((classAtIndex(classIndexOrTagPattern)) != null); +} + +static sqInt allYoungObjectsAgeInFullGC(void) { return 0; @@ -17406,13 +17418,6 @@ } static sqInt -checkValidInlineCacheTag(sqInt classIndexOrTagPattern) -{ - return (classIndexOrTagPattern <= (tagMask())) - || ((classAtIndex(classIndexOrTagPattern)) != null); -} - -static sqInt checkValidOopReference(sqInt anOop) { return (isImmediate(anOop)) Modified: branches/Cog/nsspursrc/vm/cogit.h =================================================================== --- branches/Cog/nsspursrc/vm/cogit.h 2014-12-05 23:14:12 UTC (rev 3160) +++ branches/Cog/nsspursrc/vm/cogit.h 2014-12-06 03:12:21 UTC (rev 3161) @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CCodeGenerator VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 */ Modified: branches/Cog/nsspursrc/vm/cointerp.c =================================================================== --- branches/Cog/nsspursrc/vm/cointerp.c 2014-12-05 23:14:12 UTC (rev 3160) +++ branches/Cog/nsspursrc/vm/cointerp.c 2014-12-06 03:12:21 UTC (rev 3161) @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 from - CoInterpreter VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CoInterpreter VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1330,6 +1330,7 @@ static sqInt lookupInMethodCacheSelclassTag(sqInt selector, sqInt classTag) NoDbgRegParms; static sqInt lookupMethodInClass(sqInt class) NoDbgRegParms; static sqInt lookupMethodNoMNUEtcInClass(sqInt class) NoDbgRegParms; +sqInt lookupSelectorinClass(sqInt selector, sqInt class); sqInt makePointwithxValueyValue(sqInt xValue, sqInt yValue); static void mapInterpreterOops(void); static sqInt markAndTraceStackPages(sqInt fullGCFlag) NoDbgRegParms; @@ -2346,7 +2347,7 @@ /*540*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /*560*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0,-1,-1 }; -const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.968"; +const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.969"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; volatile int sendTrace; @@ -67361,6 +67362,123 @@ } +/* Lookup selector in class. Answer the method or nil. This is a debugging + routine. */ + +sqInt +lookupSelectorinClass(sqInt selector, sqInt class) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + sqInt currentClass; + sqInt dictionary; + sqInt hash; + sqInt index; + usqInt length; + sqInt mask; + sqInt meth; + sqInt methodArray; + sqInt nextSelector; + usqInt numSlots; + sqInt objOop; + sqInt objOop1; + sqInt objOop11; + sqInt objOop2; + sqInt wrapAround; + + currentClass = class; + while (currentClass != GIV(nilObj)) { + /* begin followObjField:ofObject: */ + objOop = longAt((currentClass + BaseHeaderSize) + (MethodDictionaryIndex << (shiftForWord()))); + assert(isNonImmediate(objOop)); + if (((longAt(objOop)) & (0x3FFFFF - 8)) == 0) { + objOop = fixFollowedFieldofObjectwithInitialValue(MethodDictionaryIndex, currentClass, objOop); + } + dictionary = objOop; + if (dictionary == GIV(nilObj)) { + return null; + } + /* begin lookupMethodFor:InDictionary: */ + /* begin numSlotsOf: */ + flag("endianness"); + assert((classIndexOf(dictionary)) > (isForwardedObjectClassIndexPun())); + numSlots = byteAt(dictionary + 7); + length = (numSlots == 0xFF + ? longAt(dictionary - BaseHeaderSize) + : numSlots); + mask = (length - SelectorStart) - 1; + + /* It is assumed that there are some nils in this dictionary, and search will + stop when one is encountered. However, if there are no nils, then wrapAround + will be detected the second time the loop gets to the end of the table. */ + + index = SelectorStart + (mask & (((selector & 3) != 0 + ? ((selector & 1) + ? (selector >> 1) + : ((usqInt) (((usqInt)selector))) >> 2) + : (/* begin hashBitsOf: */ + (hash = (long32At(selector + 4)) & 0x3FFFFF), + (hash == 0 + ? ((hash = (newObjectHash()) & 0x3FFFFF), + /* begin setHashBitsOf:to: */ + flag("endianness"), + assert(((hash >= 0) && (hash <= (identityHashHalfWordMask())))), + long32Atput(selector + 4, ((((long32At(selector + 4)) | 0x3FFFFF) - 0x3FFFFF)) + hash)) + : 0), + hash)))); + wrapAround = 0; + while (1) { + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + if (nextSelector == GIV(nilObj)) { + meth = null; + goto l1; + } + if (((nextSelector & 3) == 0) + && (((longAt(nextSelector)) & 0x3FFFFF) == 8)) { + nextSelector = fixFollowedFieldofObjectwithInitialValue(index + SelectorStart, dictionary, nextSelector); + } + if (nextSelector == selector) { + /* begin followObjField:ofObject: */ + objOop2 = longAt((dictionary + BaseHeaderSize) + (MethodArrayIndex << (shiftForWord()))); + assert(isNonImmediate(objOop2)); + if (((longAt(objOop2)) & (0x3FFFFF - 8)) == 0) { + objOop2 = fixFollowedFieldofObjectwithInitialValue(MethodArrayIndex, dictionary, objOop2); + } + methodArray = objOop2; + /* begin followField:ofObject: */ + objOop11 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); + if (((objOop11 & 3) == 0) + && (((longAt(objOop11)) & 0x3FFFFF) == 8)) { + objOop11 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop11); + } + meth = objOop11; + goto l1; + } + index += 1; + if (index == length) { + if (wrapAround) { + meth = null; + goto l1; + } + wrapAround = 1; + index = SelectorStart; + } + } + meth = null; + l1: /* end lookupMethodFor:InDictionary: */; + if (!(meth == null)) { + return meth; + } + /* begin followField:ofObject: */ + objOop1 = longAt((currentClass + BaseHeaderSize) + (SuperclassIndex << (shiftForWord()))); + if (((objOop1 & 3) == 0) + && (((longAt(objOop1)) & 0x3FFFFF) == 8)) { + objOop1 = fixFollowedFieldofObjectwithInitialValue(SuperclassIndex, currentClass, objOop1); + } + currentClass = objOop1; + } + return null; +} + + /* make a Point xValue@yValue. We know both will be integers so no value nor root checking is needed */ Modified: branches/Cog/nsspursrc/vm/cointerp.h =================================================================== --- branches/Cog/nsspursrc/vm/cointerp.h 2014-12-05 23:14:12 UTC (rev 3160) +++ branches/Cog/nsspursrc/vm/cointerp.h 2014-12-06 03:12:21 UTC (rev 3161) @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 */ @@ -282,6 +282,7 @@ sqInt literalofMethod(sqInt offset, sqInt methodPointer); void longPrintOop(sqInt oop); sqInt longStoreBytecodeForHeader(sqInt methodHeader); +sqInt lookupSelectorinClass(sqInt selector, sqInt class); sqInt methodClassAssociationOf(sqInt methodPointer); sqInt methodClassOf(sqInt methodPointer); sqInt methodPrimitiveIndex(void); Modified: branches/Cog/nsspursrc/vm/gcc3x-cointerp.c =================================================================== --- branches/Cog/nsspursrc/vm/gcc3x-cointerp.c 2014-12-05 23:14:12 UTC (rev 3160) +++ branches/Cog/nsspursrc/vm/gcc3x-cointerp.c 2014-12-06 03:12:21 UTC (rev 3161) @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 from - CoInterpreter VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CoInterpreter VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1333,6 +1333,7 @@ static sqInt lookupInMethodCacheSelclassTag(sqInt selector, sqInt classTag) NoDbgRegParms; static sqInt lookupMethodInClass(sqInt class) NoDbgRegParms; static sqInt lookupMethodNoMNUEtcInClass(sqInt class) NoDbgRegParms; +sqInt lookupSelectorinClass(sqInt selector, sqInt class); sqInt makePointwithxValueyValue(sqInt xValue, sqInt yValue); static void mapInterpreterOops(void); static sqInt markAndTraceStackPages(sqInt fullGCFlag) NoDbgRegParms; @@ -2349,7 +2350,7 @@ /*540*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /*560*/ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0,-1,-1 }; -const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.968"; +const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreterPrimitives_VMMaker.oscog-eem.969"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; volatile int sendTrace; @@ -67370,6 +67371,123 @@ } +/* Lookup selector in class. Answer the method or nil. This is a debugging + routine. */ + +sqInt +lookupSelectorinClass(sqInt selector, sqInt class) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + sqInt currentClass; + sqInt dictionary; + sqInt hash; + sqInt index; + usqInt length; + sqInt mask; + sqInt meth; + sqInt methodArray; + sqInt nextSelector; + usqInt numSlots; + sqInt objOop; + sqInt objOop1; + sqInt objOop11; + sqInt objOop2; + sqInt wrapAround; + + currentClass = class; + while (currentClass != GIV(nilObj)) { + /* begin followObjField:ofObject: */ + objOop = longAt((currentClass + BaseHeaderSize) + (MethodDictionaryIndex << (shiftForWord()))); + assert(isNonImmediate(objOop)); + if (((longAt(objOop)) & (0x3FFFFF - 8)) == 0) { + objOop = fixFollowedFieldofObjectwithInitialValue(MethodDictionaryIndex, currentClass, objOop); + } + dictionary = objOop; + if (dictionary == GIV(nilObj)) { + return null; + } + /* begin lookupMethodFor:InDictionary: */ + /* begin numSlotsOf: */ + flag("endianness"); + assert((classIndexOf(dictionary)) > (isForwardedObjectClassIndexPun())); + numSlots = byteAt(dictionary + 7); + length = (numSlots == 0xFF + ? longAt(dictionary - BaseHeaderSize) + : numSlots); + mask = (length - SelectorStart) - 1; + + /* It is assumed that there are some nils in this dictionary, and search will + stop when one is encountered. However, if there are no nils, then wrapAround + will be detected the second time the loop gets to the end of the table. */ + + index = SelectorStart + (mask & (((selector & 3) != 0 + ? ((selector & 1) + ? (selector >> 1) + : ((usqInt) (((usqInt)selector))) >> 2) + : (/* begin hashBitsOf: */ + (hash = (long32At(selector + 4)) & 0x3FFFFF), + (hash == 0 + ? ((hash = (newObjectHash()) & 0x3FFFFF), + /* begin setHashBitsOf:to: */ + flag("endianness"), + assert(((hash >= 0) && (hash <= (identityHashHalfWordMask())))), + long32Atput(selector + 4, ((((long32At(selector + 4)) | 0x3FFFFF) - 0x3FFFFF)) + hash)) + : 0), + hash)))); + wrapAround = 0; + while (1) { + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + if (nextSelector == GIV(nilObj)) { + meth = null; + goto l1; + } + if (((nextSelector & 3) == 0) + && (((longAt(nextSelector)) & 0x3FFFFF) == 8)) { + nextSelector = fixFollowedFieldofObjectwithInitialValue(index + SelectorStart, dictionary, nextSelector); + } + if (nextSelector == selector) { + /* begin followObjField:ofObject: */ + objOop2 = longAt((dictionary + BaseHeaderSize) + (MethodArrayIndex << (shiftForWord()))); + assert(isNonImmediate(objOop2)); + if (((longAt(objOop2)) & (0x3FFFFF - 8)) == 0) { + objOop2 = fixFollowedFieldofObjectwithInitialValue(MethodArrayIndex, dictionary, objOop2); + } + methodArray = objOop2; + /* begin followField:ofObject: */ + objOop11 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); + if (((objOop11 & 3) == 0) + && (((longAt(objOop11)) & 0x3FFFFF) == 8)) { + objOop11 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop11); + } + meth = objOop11; + goto l1; + } + index += 1; + if (index == length) { + if (wrapAround) { + meth = null; + goto l1; + } + wrapAround = 1; + index = SelectorStart; + } + } + meth = null; + l1: /* end lookupMethodFor:InDictionary: */; + if (!(meth == null)) { + return meth; + } + /* begin followField:ofObject: */ + objOop1 = longAt((currentClass + BaseHeaderSize) + (SuperclassIndex << (shiftForWord()))); + if (((objOop1 & 3) == 0) + && (((longAt(objOop1)) & 0x3FFFFF) == 8)) { + objOop1 = fixFollowedFieldofObjectwithInitialValue(SuperclassIndex, currentClass, objOop1); + } + currentClass = objOop1; + } + return null; +} + + /* make a Point xValue@yValue. We know both will be integers so no value nor root checking is needed */ Modified: branches/Cog/nsspurstacksrc/vm/gcc3x-interp.c =================================================================== --- branches/Cog/nsspurstacksrc/vm/gcc3x-interp.c 2014-12-05 23:14:12 UTC (rev 3160) +++ branches/Cog/nsspurstacksrc/vm/gcc3x-interp.c 2014-12-06 03:12:21 UTC (rev 3161) @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.966 uuid: 46dd10c6-dc03-444c-bfa2-0f0b279c9b06 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 from - StackInterpreter VMMaker.oscog-eem.966 uuid: 46dd10c6-dc03-444c-bfa2-0f0b279c9b06 + StackInterpreter VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 */ -static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.966 uuid: 46dd10c6-dc03-444c-bfa2-0f0b279c9b06 " __DATE__ ; +static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1101,6 +1101,7 @@ static sqInt lookupInMethodCacheSelclassTag(sqInt selector, sqInt classTag) NoDbgRegParms; static sqInt lookupMethodInClass(sqInt class) NoDbgRegParms; static sqInt lookupMethodNoMNUEtcInClass(sqInt class) NoDbgRegParms; +sqInt lookupSelectorinClass(sqInt selector, sqInt class); static StackPage * makeBaseFrameFor(sqInt aContext) NoDbgRegParms; sqInt makePointwithxValueyValue(sqInt xValue, sqInt yValue); static void mapInterpreterOops(void); @@ -2096,7 +2097,7 @@ /* 574 */ (void (*)(void))0, /* 575 */ (void (*)(void))0, 0 }; -const char *interpreterVersion = "Newspeak Virtual Machine StackInterpreterPrimitives_VMMaker.oscog-eem.966"; +const char *interpreterVersion = "Newspeak Virtual Machine StackInterpreterPrimitives_VMMaker.oscog-eem.969"; volatile int sendTrace; sqInt suppressHeartbeatFlag; @@ -54225,6 +54226,123 @@ } +/* Lookup selector in class. Answer the method or nil. This is a debugging + routine. */ + +sqInt +lookupSelectorinClass(sqInt selector, sqInt class) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + sqInt currentClass; + sqInt dictionary; + sqInt hash; + sqInt index; + usqInt length; + sqInt mask; + sqInt meth; + sqInt methodArray; + sqInt nextSelector; + usqInt numSlots; + sqInt objOop; + sqInt objOop1; + sqInt objOop11; + sqInt objOop2; + sqInt wrapAround; + + currentClass = class; + while (currentClass != GIV(nilObj)) { + /* begin followObjField:ofObject: */ + objOop = longAt((currentClass + BaseHeaderSize) + (MethodDictionaryIndex << (shiftForWord()))); + assert(isNonImmediate(objOop)); + if (((longAt(objOop)) & (0x3FFFFF - 8)) == 0) { + objOop = fixFollowedFieldofObjectwithInitialValue(MethodDictionaryIndex, currentClass, objOop); + } + dictionary = objOop; + if (dictionary == GIV(nilObj)) { + return null; + } + /* begin lookupMethodFor:InDictionary: */ + /* begin numSlotsOf: */ + flag("endianness"); + assert((classIndexOf(dictionary)) > (isForwardedObjectClassIndexPun())); + numSlots = byteAt(dictionary + 7); + length = (numSlots == 0xFF + ? longAt(dictionary - BaseHeaderSize) + : numSlots); + mask = (length - SelectorStart) - 1; + + /* It is assumed that there are some nils in this dictionary, and search will + stop when one is encountered. However, if there are no nils, then wrapAround + will be detected the second time the loop gets to the end of the table. */ + + index = SelectorStart + (mask & (((selector & 3) != 0 + ? ((selector & 1) + ? (selector >> 1) + : ((usqInt) (((usqInt)selector))) >> 2) + : (/* begin hashBitsOf: */ + (hash = (long32At(selector + 4)) & 0x3FFFFF), + (hash == 0 + ? ((hash = (newObjectHash()) & 0x3FFFFF), + /* begin setHashBitsOf:to: */ + flag("endianness"), + assert(((hash >= 0) && (hash <= (identityHashHalfWordMask())))), + long32Atput(selector + 4, ((((long32At(selector + 4)) | 0x3FFFFF) - 0x3FFFFF)) + hash)) + : 0), + hash)))); + wrapAround = 0; + while (1) { + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + if (nextSelector == GIV(nilObj)) { + meth = null; + goto l1; + } + if (((nextSelector & 3) == 0) + && (((longAt(nextSelector)) & 0x3FFFFF) == 8)) { + nextSelector = fixFollowedFieldofObjectwithInitialValue(index + SelectorStart, dictionary, nextSelector); + } + if (nextSelector == selector) { + /* begin followObjField:ofObject: */ + objOop2 = longAt((dictionary + BaseHeaderSize) + (MethodArrayIndex << (shiftForWord()))); + assert(isNonImmediate(objOop2)); + if (((longAt(objOop2)) & (0x3FFFFF - 8)) == 0) { + objOop2 = fixFollowedFieldofObjectwithInitialValue(MethodArrayIndex, dictionary, objOop2); + } + methodArray = objOop2; + /* begin followField:ofObject: */ + objOop11 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); + if (((objOop11 & 3) == 0) + && (((longAt(objOop11)) & 0x3FFFFF) == 8)) { + objOop11 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop11); + } + meth = objOop11; + goto l1; + } + index += 1; + if (index == length) { + if (wrapAround) { + meth = null; + goto l1; + } + wrapAround = 1; + index = SelectorStart; + } + } + meth = null; + l1: /* end lookupMethodFor:InDictionary: */; + if (!(meth == null)) { + return meth; + } + /* begin followField:ofObject: */ + objOop1 = longAt((currentClass + BaseHeaderSize) + (SuperclassIndex << (shiftForWord()))); + if (((objOop1 & 3) == 0) + && (((longAt(objOop1)) & 0x3FFFFF) == 8)) { + objOop1 = fixFollowedFieldofObjectwithInitialValue(SuperclassIndex, currentClass, objOop1); + } + currentClass = objOop1; + } + return null; +} + + /* <Integer> */ /* Marry aContext with the base frame of a new stack page. Build the base frame to reflect the context's state. Answer the new page. */ Modified: branches/Cog/nsspurstacksrc/vm/interp.c =================================================================== --- branches/Cog/nsspurstacksrc/vm/interp.c 2014-12-05 23:14:12 UTC (rev 3160) +++ branches/Cog/nsspurstacksrc/vm/interp.c 2014-12-06 03:12:21 UTC (rev 3161) @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.966 uuid: 46dd10c6-dc03-444c-bfa2-0f0b279c9b06 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 from - StackInterpreter VMMaker.oscog-eem.966 uuid: 46dd10c6-dc03-444c-bfa2-0f0b279c9b06 + StackInterpreter VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 */ -static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.966 uuid: 46dd10c6-dc03-444c-bfa2-0f0b279c9b06 " __DATE__ ; +static char __buildInfo[] = "StackInterpreter VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1098,6 +1098,7 @@ static sqInt lookupInMethodCacheSelclassTag(sqInt selector, sqInt classTag) NoDbgRegParms; static sqInt lookupMethodInClass(sqInt class) NoDbgRegParms; static sqInt lookupMethodNoMNUEtcInClass(sqInt class) NoDbgRegParms; +sqInt lookupSelectorinClass(sqInt selector, sqInt class); static StackPage * makeBaseFrameFor(sqInt aContext) NoDbgRegParms; sqInt makePointwithxValueyValue(sqInt xValue, sqInt yValue); static void mapInterpreterOops(void); @@ -2093,7 +2094,7 @@ /* 574 */ (void (*)(void))0, /* 575 */ (void (*)(void))0, 0 }; -const char *interpreterVersion = "Newspeak Virtual Machine StackInterpreterPrimitives_VMMaker.oscog-eem.966"; +const char *interpreterVersion = "Newspeak Virtual Machine StackInterpreterPrimitives_VMMaker.oscog-eem.969"; volatile int sendTrace; sqInt suppressHeartbeatFlag; @@ -54216,6 +54217,123 @@ } +/* Lookup selector in class. Answer the method or nil. This is a debugging + routine. */ + +sqInt +lookupSelectorinClass(sqInt selector, sqInt class) +{ DECL_MAYBE_SQ_GLOBAL_STRUCT + sqInt currentClass; + sqInt dictionary; + sqInt hash; + sqInt index; + usqInt length; + sqInt mask; + sqInt meth; + sqInt methodArray; + sqInt nextSelector; + usqInt numSlots; + sqInt objOop; + sqInt objOop1; + sqInt objOop11; + sqInt objOop2; + sqInt wrapAround; + + currentClass = class; + while (currentClass != GIV(nilObj)) { + /* begin followObjField:ofObject: */ + objOop = longAt((currentClass + BaseHeaderSize) + (MethodDictionaryIndex << (shiftForWord()))); + assert(isNonImmediate(objOop)); + if (((longAt(objOop)) & (0x3FFFFF - 8)) == 0) { + objOop = fixFollowedFieldofObjectwithInitialValue(MethodDictionaryIndex, currentClass, objOop); + } + dictionary = objOop; + if (dictionary == GIV(nilObj)) { + return null; + } + /* begin lookupMethodFor:InDictionary: */ + /* begin numSlotsOf: */ + flag("endianness"); + assert((classIndexOf(dictionary)) > (isForwardedObjectClassIndexPun())); + numSlots = byteAt(dictionary + 7); + length = (numSlots == 0xFF + ? longAt(dictionary - BaseHeaderSize) + : numSlots); + mask = (length - SelectorStart) - 1; + + /* It is assumed that there are some nils in this dictionary, and search will + stop when one is encountered. However, if there are no nils, then wrapAround + will be detected the second time the loop gets to the end of the table. */ + + index = SelectorStart + (mask & (((selector & 3) != 0 + ? ((selector & 1) + ? (selector >> 1) + : ((usqInt) (((usqInt)selector))) >> 2) + : (/* begin hashBitsOf: */ + (hash = (long32At(selector + 4)) & 0x3FFFFF), + (hash == 0 + ? ((hash = (newObjectHash()) & 0x3FFFFF), + /* begin setHashBitsOf:to: */ + flag("endianness"), + assert(((hash >= 0) && (hash <= (identityHashHalfWordMask())))), + long32Atput(selector + 4, ((((long32At(selector + 4)) | 0x3FFFFF) - 0x3FFFFF)) + hash)) + : 0), + hash)))); + wrapAround = 0; + while (1) { + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + if (nextSelector == GIV(nilObj)) { + meth = null; + goto l1; + } + if (((nextSelector & 3) == 0) + && (((longAt(nextSelector)) & 0x3FFFFF) == 8)) { + nextSelector = fixFollowedFieldofObjectwithInitialValue(index + SelectorStart, dictionary, nextSelector); + } + if (nextSelector == selector) { + /* begin followObjField:ofObject: */ + objOop2 = longAt((dictionary + BaseHeaderSize) + (MethodArrayIndex << (shiftForWord()))); + assert(isNonImmediate(objOop2)); + if (((longAt(objOop2)) & (0x3FFFFF - 8)) == 0) { + objOop2 = fixFollowedFieldofObjectwithInitialValue(MethodArrayIndex, dictionary, objOop2); + } + methodArray = objOop2; + /* begin followField:ofObject: */ + objOop11 = longAt((methodArray + BaseHeaderSize) + ((index - SelectorStart) << (shiftForWord()))); + if (((objOop11 & 3) == 0) + && (((longAt(objOop11)) & 0x3FFFFF) == 8)) { + objOop11 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop11); + } + meth = objOop11; + goto l1; + } + index += 1; + if (index == length) { + if (wrapAround) { + meth = null; + goto l1; + } + wrapAround = 1; + index = SelectorStart; + } + } + meth = null; + l1: /* end lookupMethodFor:InDictionary: */; + if (!(meth == null)) { + return meth; + } + /* begin followField:ofObject: */ + objOop1 = longAt((currentClass + BaseHeaderSize) + (SuperclassIndex << (shiftForWord()))); + if (((objOop1 & 3) == 0) + && (((longAt(objOop1)) & 0x3FFFFF) == 8)) { + objOop1 = fixFollowedFieldofObjectwithInitialValue(SuperclassIndex, currentClass, objOop1); + } + currentClass = objOop1; + } + return null; +} + + /* <Integer> */ /* Marry aContext with the base frame of a new stack page. Build the base frame to reflect the context's state. Answer the new page. */ Property changes on: branches/Cog/platforms/Cross/vm/sqSCCSVersion.h ___________________________________________________________________ Modified: checkindate - Fri Dec 5 15:14:03 PST 2014 + Fri Dec 5 19:10:59 PST 2014 Modified: branches/Cog/sistasrc/vm/cogit.c =================================================================== --- branches/Cog/sistasrc/vm/cogit.c 2014-12-05 23:14:12 UTC (rev 3160) +++ branches/Cog/sistasrc/vm/cogit.c 2014-12-06 03:12:21 UTC (rev 3161) @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + CCodeGenerator VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 from - SistaStackToRegisterMappingCogit VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 + SistaStackToRegisterMappingCogit VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 */ -static char __buildInfo[] = "SistaStackToRegisterMappingCogit VMMaker.oscog-eem.968 uuid: ddef3ea8-2ea4-4fe4-98ac-de4698b42ab8 " __DATE__ ; +static char __buildInfo[] = "SistaStackToRegisterMappingCogit VMMaker.oscog-eem.969 uuid: cdd723c1-bec0-42d5-970f-354702984955 " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -833,7 +833,6 @@ static sqInt branchIfInstanceOfBehaviorsbranches(sqInt arrayObj, AbstractInstruction **branches) NoDbgRegParms; static sqInt branchIfInstanceOfBehaviorbranches(sqInt classObj, AbstractInstruction **branches) NoDbgRegParms; static sqInt cacheTagIsMarked(sqInt cacheTag) NoDbgRegParms; -static sqInt checkValidInlineCacheTag(sqInt cacheTag) NoDbgRegParms; static sqInt checkValidOopReference(sqInt anOop) NoDbgRegParms; static sqInt classForInlineCacheTag(sqInt inlineCacheTag) NoDbgRegParms; static sqInt compactClassFieldMask(void); @@ -889,6 +888,7 @@ static sqInt shouldAnnotateObjectReference(sqInt anOop) NoDbgRegParms; static sqInt slotOffsetOfInstVarIndex(sqInt index) NoDbgRegParms; static sqInt smallIntegerIsOnlyImmediateType(void); +static sqInt validInlineCacheTag(sqInt cacheTag) NoDbgRegParms; static CogSimStackEntry * ensureSpilledAtfrom(CogSimStackEntry * self_in_ensureSpilledAtfrom, sqInt baseOffset, sqInt baseRegister) NoDbgRegParms; static CogSimStackEntry * mergeAtfrom(CogSimStackEntry * self_in_mergeAtfrom, sqInt baseOffset, sqInt baseRegister) NoDbgRegParms; static CogSimStackEntry * popToReg(CogSimStackEntry * self_in_popToReg, sqInt reg) NoDbgRegParms; @@ -8839,7 +8839,7 @@ } } else { - if (!(asserta(checkValidInlineCacheTag(cacheTag1)))) { + if (!(asserta(validInlineCacheTag(cacheTag1)))) { return 5; } } @@ -8851,7 +8851,7 @@ } } else { - if (!(asserta(checkValidInlineCacheTag(cacheTag1)))) { + if (!(asserta(validInlineCacheTag(cacheTag1)))) { return 7; } } @@ -8927,7 +8927,7 @@ /* linked non-super send, cacheTag is a cacheTag */ - if (!(checkValidInlineCacheTag(selectorOrCacheTag))) { + if (!(validInlineCacheTag(selectorOrCacheTag))) { print("cache tag leak in CM "); printHex(((sqInt)cogMethod)); print(" @ "); @@ -9288,7 +9288,7 @@ sqInt size; sqInt target; - compilationBreakpointisMNUCase((cPIC->selector), lengthOf((cPIC->selector)), isMNUCase); + compilationBreakpointisMNUCase((cPIC->selector), numBytesOf((cPIC->selector)), isMNUCase); allocateOpcodesbytecodes(5, 0); assert(!(inlineCacheTagIsYoung(caseNTag))); assert((caseNMethod != null) @@ -9423,7 +9423,7 @@ if (isYoung(selector)) { return 0; } - compilationBreakpointisMNUCase(selector, lengthOf(selector), 1); + compilationBreakpointisMNUCase(selector, numBytesOf(selector), 1); assert(endCPICCase0 != null); startAddress = allocate(closedPICSize); if (startAddress == 0) { @@ -9461,7 +9461,7 @@ sqInt mapSize; sqInt startAddress; - compilationBreakpointisMNUCase(selector, lengthOf(selector), 0); + compilationBreakpointisMNUCase(selector, numBytesOf(selector), 0); startAddress = allocate(openPICSize); if (startAddress == 0) { return ((CogMethod *) InsufficientCodeSpace); @@ -9501,7 +9501,7 @@ if (isYoung(selector)) { return ((CogMethod *) YoungSelectorInPIC); } @@ Diff output truncated at 50000 characters. @@ |
Free forum by Nabble | Edit this page |