Revision: 2775 Author: eliot Date: 2013-08-20 18:28:22 -0700 (Tue, 20 Aug 2013) Log Message: ----------- CogVM source as per VMMaker.oscog-eem.329 Set the inBlock variable in scanBlock and scanMethod. Change the argument to the needsFrameFunction to be the stack delta. Change genSpecialSelectorClass's needsFrameFunction to needsFrameIfStackGreaterThanOne: which better handles e.g. TextColor>>dominates: other ^self class == other class than needsFrameIfFollowsSend:. Modified Paths: -------------- branches/Cog/nscogsrc/vm/cogit.c branches/Cog/nscogsrc/vm/cogit.h branches/Cog/nscogsrc/vm/cogmethod.h branches/Cog/src/vm/cogit.c branches/Cog/src/vm/cogit.h branches/Cog/src/vm/cogmethod.h Property Changed: ---------------- branches/Cog/platforms/Cross/vm/sqSCCSVersion.h Modified: branches/Cog/nscogsrc/vm/cogit.c =================================================================== --- branches/Cog/nscogsrc/vm/cogit.c 2013-08-20 01:18:13 UTC (rev 2774) +++ branches/Cog/nscogsrc/vm/cogit.c 2013-08-21 01:28:22 UTC (rev 2775) @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.328 uuid: d9a4d11d-3a72-437e-b617-92de227ffdde + CCodeGenerator VMMaker.oscog-eem.329 uuid: 5bf1ecce-8cdb-48fd-bc66-b41b4cff2efe from - StackToRegisterMappingCogit VMMaker.oscog-eem.328 uuid: d9a4d11d-3a72-437e-b617-92de227ffdde + StackToRegisterMappingCogit VMMaker.oscog-eem.329 uuid: 5bf1ecce-8cdb-48fd-bc66-b41b4cff2efe */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.328 uuid: d9a4d11d-3a72-437e-b617-92de227ffdde " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.329 uuid: 5bf1ecce-8cdb-48fd-bc66-b41b4cff2efe " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -918,10 +918,10 @@ sqInt mnuOffset(void); static sqInt modRMRO(AbstractInstruction * self_in_modRMRO, sqInt mod, sqInt regMode, sqInt regOpcode); static AbstractInstruction * gNegateR(sqInt reg); -static sqInt needsFrameIfFollowsSend(sqInt isInBlock); -static sqInt needsFrameIfInBlock(sqInt isInBlock); -static sqInt needsFrameIfMod16GENumArgs(sqInt isInBlock); -static sqInt needsFrameNever(sqInt isInBlock); +static sqInt needsFrameIfInBlock(sqInt stackDelta); +static sqInt needsFrameIfMod16GENumArgs(sqInt stackDelta); +static sqInt needsFrameIfStackGreaterThanOne(sqInt stackDelta); +static sqInt needsFrameNever(sqInt stackDelta); static sqInt noAssertMethodClassAssociationOf(sqInt methodPointer); static sqInt noCogMethodsMaximallyMarked(void); static void nopsFromto(AbstractInstruction * self_in_nopsFromto, sqInt startAddr, sqInt endAddr); @@ -1355,8 +1355,8 @@ { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, - { genSpecialSelectorEqualsEquals, 0, needsFrameIfFollowsSend, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, - { genSpecialSelectorClass, 0, needsFrameIfFollowsSend, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, + { genSpecialSelectorEqualsEquals, 0, needsFrameNever, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, + { genSpecialSelectorClass, 0, needsFrameIfStackGreaterThanOne, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, @@ -1515,8 +1515,8 @@ { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, - { genSpecialSelectorEqualsEquals, 0, needsFrameIfFollowsSend, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, - { genSpecialSelectorClass, 0, needsFrameIfFollowsSend, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, + { genSpecialSelectorEqualsEquals, 0, needsFrameNever, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, + { genSpecialSelectorClass, 0, needsFrameIfStackGreaterThanOne, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, @@ -16106,42 +16106,38 @@ return genoperand(NegateR, reg); } - -/* As of August 2013, the code generator can't deal with spills in frameless - methods (the - issue is to do with the stack offset to get at an argument, which is - changed when there's a spill). - The only context in a spill is needed in a frameless method that I can - think of is sends - following sends as in e.g. TextColor>>#dominates: other ^other class == - self class. - Only need to check for the frameless sends since all other sends will - force a frame. - */ - static sqInt -needsFrameIfFollowsSend(sqInt isInBlock) +needsFrameIfInBlock(sqInt stackDelta) { - assert((prevBCDescriptor != null) - && (((prevBCDescriptor->needsFrameFunction)) != null)); - return (((prevBCDescriptor->generator)) == genSpecialSelectorEqualsEquals) - || (((prevBCDescriptor->generator)) == genSpecialSelectorClass); + return inBlock; } static sqInt -needsFrameIfInBlock(sqInt isInBlock) +needsFrameIfMod16GENumArgs(sqInt stackDelta) { - return inBlock; + return (byte0 % 16) >= methodOrBlockNumArgs; } + +/* As of August 2013, the code generator can't deal with spills in frameless + methods (the + issue is to do with the stack offset to get at an argument, which is + changed when there's a spill). + In e.g. TextColor>>#dominates: other ^other class == self class the second + send of class + needs also rto allocate a register that the first one used, but the first + one's register can't be + spilled. So avoid this by only allowing class to be sent if the stack + contains a single element. */ + static sqInt -needsFrameIfMod16GENumArgs(sqInt isInBlock) +needsFrameIfStackGreaterThanOne(sqInt stackDelta) { - return (byte0 % 16) >= methodOrBlockNumArgs; + return stackDelta > 1; } static sqInt -needsFrameNever(sqInt isInBlock) +needsFrameNever(sqInt stackDelta) { return 0; } @@ -17478,30 +17474,30 @@ { BytecodeDescriptor *descriptor; sqInt end; + sqInt framelessStackDelta; sqInt (* const isPushNilFunction)(struct _BytecodeDescriptor *,sqInt,sqInt,sqInt) = v3or4IsPushNil; sqInt nExts; sqInt pc; sqInt pushingNils; - sqInt stackDelta; needsFrame = 0; prevBCDescriptor = null; methodOrBlockNumArgs = (blockStart->numArgs); - nExts = 0; + inBlock = 1; pc = (blockStart->startpc); end = ((blockStart->startpc)) + ((blockStart->span)); - stackDelta = 0; + framelessStackDelta = (nExts = 0); pushingNils = 1; while (pc < end) { byte0 = (fetchByteofObject(pc, methodObj)) + bytecodeSetOffset; descriptor = generatorAt(byte0); if (!needsFrame) { if ((((descriptor->needsFrameFunction)) == null) - || (((descriptor->needsFrameFunction))(1))) { + || (((descriptor->needsFrameFunction))(framelessStackDelta))) { needsFrame = 1; } else { - stackDelta += (descriptor->stackDelta); + framelessStackDelta += (descriptor->stackDelta); } } if (pushingNils @@ -17528,9 +17524,9 @@ prevBCDescriptor = descriptor; } if (!needsFrame) { - assert((stackDelta >= 0) - && (((blockStart->numInitialNils)) >= stackDelta)); - (blockStart->numInitialNils = ((blockStart->numInitialNils)) - stackDelta); + assert((framelessStackDelta >= 0) + && (((blockStart->numInitialNils)) >= framelessStackDelta)); + (blockStart->numInitialNils = ((blockStart->numInitialNils)) - framelessStackDelta); } } @@ -17560,7 +17556,7 @@ } -/* Scan the method to determine +/* Scan the method (and all embedded blocks) to determine - what the last bytecode is; extra bytes at the end of a method are used to encode things like source pointers or temp names - if the method needs a frame or not @@ -17573,6 +17569,7 @@ { BytecodeDescriptor *descriptor; sqInt distance; + sqInt framelessStackDelta; sqInt latestContinuation; sqInt nExts; sqInt numBlocks; @@ -17580,14 +17577,14 @@ sqInt targetPC; needsFrame = 0; + inBlock = 0; prevBCDescriptor = null; if ((primitiveIndex > 0) && (isQuickPrimitiveIndex(primitiveIndex))) { return 0; } - numBlocks = 0; pc = (latestContinuation = initialPC); - nExts = 0; + numBlocks = (framelessStackDelta = (nExts = 0)); while (pc <= endPC) { byte0 = (fetchByteofObject(pc, methodObj)) + bytecodeSetOffset; descriptor = generatorAt(byte0); @@ -17595,10 +17592,14 @@ && (pc >= latestContinuation)) { endPC = pc; } - if ((!needsFrame) - && ((((descriptor->needsFrameFunction)) == null) - || (((descriptor->needsFrameFunction))(0)))) { - needsFrame = 1; + if (!needsFrame) { + if ((((descriptor->needsFrameFunction)) == null) + || (((descriptor->needsFrameFunction))(framelessStackDelta))) { + needsFrame = 1; + } + else { + framelessStackDelta += (descriptor->stackDelta); + } } if (isBranch(descriptor)) { distance = ((descriptor->spanFunction))(descriptor, pc, nExts, methodObj); Modified: branches/Cog/nscogsrc/vm/cogit.h =================================================================== --- branches/Cog/nscogsrc/vm/cogit.h 2013-08-20 01:18:13 UTC (rev 2774) +++ branches/Cog/nscogsrc/vm/cogit.h 2013-08-21 01:28:22 UTC (rev 2775) @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.328 uuid: d9a4d11d-3a72-437e-b617-92de227ffdde + CCodeGenerator VMMaker.oscog-eem.329 uuid: 5bf1ecce-8cdb-48fd-bc66-b41b4cff2efe */ Modified: branches/Cog/nscogsrc/vm/cogmethod.h =================================================================== --- branches/Cog/nscogsrc/vm/cogmethod.h 2013-08-20 01:18:13 UTC (rev 2774) +++ branches/Cog/nscogsrc/vm/cogmethod.h 2013-08-21 01:28:22 UTC (rev 2775) @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.328 uuid: d9a4d11d-3a72-437e-b617-92de227ffdde + CCodeGenerator VMMaker.oscog-eem.329 uuid: 5bf1ecce-8cdb-48fd-bc66-b41b4cff2efe */ typedef struct { Property changes on: branches/Cog/platforms/Cross/vm/sqSCCSVersion.h ___________________________________________________________________ Modified: checkindate - Sat Aug 17 14:48:34 PDT 2013 + Tue Aug 20 18:27:27 PDT 2013 Modified: branches/Cog/src/vm/cogit.c =================================================================== --- branches/Cog/src/vm/cogit.c 2013-08-20 01:18:13 UTC (rev 2774) +++ branches/Cog/src/vm/cogit.c 2013-08-21 01:28:22 UTC (rev 2775) @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.328 uuid: d9a4d11d-3a72-437e-b617-92de227ffdde + CCodeGenerator VMMaker.oscog-eem.329 uuid: 5bf1ecce-8cdb-48fd-bc66-b41b4cff2efe from - StackToRegisterMappingCogit VMMaker.oscog-eem.328 uuid: d9a4d11d-3a72-437e-b617-92de227ffdde + StackToRegisterMappingCogit VMMaker.oscog-eem.329 uuid: 5bf1ecce-8cdb-48fd-bc66-b41b4cff2efe */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.328 uuid: d9a4d11d-3a72-437e-b617-92de227ffdde " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.329 uuid: 5bf1ecce-8cdb-48fd-bc66-b41b4cff2efe " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -873,10 +873,10 @@ sqInt mnuOffset(void); static sqInt modRMRO(AbstractInstruction * self_in_modRMRO, sqInt mod, sqInt regMode, sqInt regOpcode); static AbstractInstruction * gNegateR(sqInt reg); -static sqInt needsFrameIfFollowsSend(sqInt isInBlock); -static sqInt needsFrameIfInBlock(sqInt isInBlock); -static sqInt needsFrameIfMod16GENumArgs(sqInt isInBlock); -static sqInt needsFrameNever(sqInt isInBlock); +static sqInt needsFrameIfInBlock(sqInt stackDelta); +static sqInt needsFrameIfMod16GENumArgs(sqInt stackDelta); +static sqInt needsFrameIfStackGreaterThanOne(sqInt stackDelta); +static sqInt needsFrameNever(sqInt stackDelta); static sqInt noAssertMethodClassAssociationOf(sqInt methodPointer); static sqInt noCogMethodsMaximallyMarked(void); static void nopsFromto(AbstractInstruction * self_in_nopsFromto, sqInt startAddr, sqInt endAddr); @@ -1298,8 +1298,8 @@ { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, - { genSpecialSelectorEqualsEquals, 0, needsFrameIfFollowsSend, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, - { genSpecialSelectorClass, 0, needsFrameIfFollowsSend, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, + { genSpecialSelectorEqualsEquals, 0, needsFrameNever, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, + { genSpecialSelectorClass, 0, needsFrameIfStackGreaterThanOne, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, { genSpecialSelectorSend, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, @@ -14756,42 +14756,38 @@ return genoperand(NegateR, reg); } - -/* As of August 2013, the code generator can't deal with spills in frameless - methods (the - issue is to do with the stack offset to get at an argument, which is - changed when there's a spill). - The only context in a spill is needed in a frameless method that I can - think of is sends - following sends as in e.g. TextColor>>#dominates: other ^other class == - self class. - Only need to check for the frameless sends since all other sends will - force a frame. - */ - static sqInt -needsFrameIfFollowsSend(sqInt isInBlock) +needsFrameIfInBlock(sqInt stackDelta) { - assert((prevBCDescriptor != null) - && (((prevBCDescriptor->needsFrameFunction)) != null)); - return (((prevBCDescriptor->generator)) == genSpecialSelectorEqualsEquals) - || (((prevBCDescriptor->generator)) == genSpecialSelectorClass); + return inBlock; } static sqInt -needsFrameIfInBlock(sqInt isInBlock) +needsFrameIfMod16GENumArgs(sqInt stackDelta) { - return inBlock; + return (byte0 % 16) >= methodOrBlockNumArgs; } + +/* As of August 2013, the code generator can't deal with spills in frameless + methods (the + issue is to do with the stack offset to get at an argument, which is + changed when there's a spill). + In e.g. TextColor>>#dominates: other ^other class == self class the second + send of class + needs also rto allocate a register that the first one used, but the first + one's register can't be + spilled. So avoid this by only allowing class to be sent if the stack + contains a single element. */ + static sqInt -needsFrameIfMod16GENumArgs(sqInt isInBlock) +needsFrameIfStackGreaterThanOne(sqInt stackDelta) { - return (byte0 % 16) >= methodOrBlockNumArgs; + return stackDelta > 1; } static sqInt -needsFrameNever(sqInt isInBlock) +needsFrameNever(sqInt stackDelta) { return 0; } @@ -16018,30 +16014,30 @@ { BytecodeDescriptor *descriptor; sqInt end; + sqInt framelessStackDelta; sqInt (* const isPushNilFunction)(struct _BytecodeDescriptor *,sqInt,sqInt,sqInt) = v3IsPushNil; sqInt nExts; sqInt pc; sqInt pushingNils; - sqInt stackDelta; needsFrame = 0; prevBCDescriptor = null; methodOrBlockNumArgs = (blockStart->numArgs); - nExts = 0; + inBlock = 1; pc = (blockStart->startpc); end = ((blockStart->startpc)) + ((blockStart->span)); - stackDelta = 0; + framelessStackDelta = (nExts = 0); pushingNils = 1; while (pc < end) { byte0 = (fetchByteofObject(pc, methodObj)) + bytecodeSetOffset; descriptor = generatorAt(byte0); if (!needsFrame) { if ((((descriptor->needsFrameFunction)) == null) - || (((descriptor->needsFrameFunction))(1))) { + || (((descriptor->needsFrameFunction))(framelessStackDelta))) { needsFrame = 1; } else { - stackDelta += (descriptor->stackDelta); + framelessStackDelta += (descriptor->stackDelta); } } if (pushingNils @@ -16068,9 +16064,9 @@ prevBCDescriptor = descriptor; } if (!needsFrame) { - assert((stackDelta >= 0) - && (((blockStart->numInitialNils)) >= stackDelta)); - (blockStart->numInitialNils = ((blockStart->numInitialNils)) - stackDelta); + assert((framelessStackDelta >= 0) + && (((blockStart->numInitialNils)) >= framelessStackDelta)); + (blockStart->numInitialNils = ((blockStart->numInitialNils)) - framelessStackDelta); } } @@ -16100,7 +16096,7 @@ } -/* Scan the method to determine +/* Scan the method (and all embedded blocks) to determine - what the last bytecode is; extra bytes at the end of a method are used to encode things like source pointers or temp names - if the method needs a frame or not @@ -16113,6 +16109,7 @@ { BytecodeDescriptor *descriptor; sqInt distance; + sqInt framelessStackDelta; sqInt latestContinuation; sqInt nExts; sqInt numBlocks; @@ -16120,14 +16117,14 @@ sqInt targetPC; needsFrame = 0; + inBlock = 0; prevBCDescriptor = null; if ((primitiveIndex > 0) && (isQuickPrimitiveIndex(primitiveIndex))) { return 0; } - numBlocks = 0; pc = (latestContinuation = initialPC); - nExts = 0; + numBlocks = (framelessStackDelta = (nExts = 0)); while (pc <= endPC) { byte0 = (fetchByteofObject(pc, methodObj)) + bytecodeSetOffset; descriptor = generatorAt(byte0); @@ -16135,10 +16132,14 @@ && (pc >= latestContinuation)) { endPC = pc; } - if ((!needsFrame) - && ((((descriptor->needsFrameFunction)) == null) - || (((descriptor->needsFrameFunction))(0)))) { - needsFrame = 1; + if (!needsFrame) { + if ((((descriptor->needsFrameFunction)) == null) + || (((descriptor->needsFrameFunction))(framelessStackDelta))) { + needsFrame = 1; + } + else { + framelessStackDelta += (descriptor->stackDelta); + } } if (isBranch(descriptor)) { distance = ((descriptor->spanFunction))(descriptor, pc, nExts, methodObj); Modified: branches/Cog/src/vm/cogit.h =================================================================== --- branches/Cog/src/vm/cogit.h 2013-08-20 01:18:13 UTC (rev 2774) +++ branches/Cog/src/vm/cogit.h 2013-08-21 01:28:22 UTC (rev 2775) @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.328 uuid: d9a4d11d-3a72-437e-b617-92de227ffdde + CCodeGenerator VMMaker.oscog-eem.329 uuid: 5bf1ecce-8cdb-48fd-bc66-b41b4cff2efe */ Modified: branches/Cog/src/vm/cogmethod.h =================================================================== --- branches/Cog/src/vm/cogmethod.h 2013-08-20 01:18:13 UTC (rev 2774) +++ branches/Cog/src/vm/cogmethod.h 2013-08-21 01:28:22 UTC (rev 2775) @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.328 uuid: d9a4d11d-3a72-437e-b617-92de227ffdde + CCodeGenerator VMMaker.oscog-eem.329 uuid: 5bf1ecce-8cdb-48fd-bc66-b41b4cff2efe */ typedef struct { |
Free forum by Nabble | Edit this page |