From ba1cc46d7efd42269f08d9674b97afe84e6866f1 Mon Sep 17 00:00:00 2001 From: briantrice Date: Fri, 5 Feb 2010 14:27:46 -0800 Subject: [PATCH] Removed instructionInfo entirely, replacing the remaining usage with instancesSetting:to: call/data. --- src/mobius/compiler.slate | 107 ++++++++++++++-------------------------------- 1 file changed, 32 insertions(+), 75 deletions(-) diff --git a/src/mobius/compiler.slate b/src/mobius/compiler.slate index 58d84d5..3020636 100644 --- a/src/mobius/compiler.slate +++ b/src/mobius/compiler.slate @@ -49,6 +49,7 @@ VM ensureNamespace: #SSACode. VM SSACode define: #Instruction &parents: {Cloneable} &slots: { #code. + #selector. #name. #argNames -> {}. #offsettingArgIndices -> {}. @@ -72,94 +73,50 @@ i@(VM SSACode Instruction traits) instancesSetting: slotNames to: values each argNames do: [| :argName | (arityNames includes: argName) ifTrue: [""]]. + VM SSACode addImmutableSlot: each selector valued: each code. i ByCode at: each code put: each]. ] ]. -VM SSACode Instruction instancesSetting: #(code name argNames offsettingArgIndices) to: { - {0. 'Direct Send'. {'register of result'. 'selector'. 'arity' ". args..."}. {2}}. - "{1. 'Indirect Send'. {'register of result'. 'selector'. 'arity'. args...}. {2}}." - "{2. 'Allocate Registers'. 3. {}}." - {3. 'Load Literal'. {'register of result'. 'index of literal'}}. - "{4. 'Store Literal'. {'index of literal'. 'register of source'}}." - {5. 'Send with Optionals'. {'register of result'. 'register of selector'. 'arity'. 'register of optionals array' ". args..."}. {2}}. - {7. 'New Closure'. {'register of result'. 'block'}}. - {8. 'New Array With'. {'register of result'. 'size' ". args..."}. {1}}. - {9. 'Resend'. {'register of result'. 'lexical offset'}}. - {10. 'Return From'. {'register of result'. 'lexical offset'}}. - {11. 'Load Environment'. {'register of result'}}. - {12. 'Load Variable'. {'register of result'}}. - {13. 'Store Variable'. {'register of result'}}. - {14. 'Load Free Variable'. {'register of result'. 'lexical offset'. 'index of variable'}}. - {15. 'Store Free Variable'. {'lexical offset'. 'index of variable'. 'register of source'}}. - {16. 'Is Identical To'. {'register of result'. 'register of x'. 'register of y'}}. - {17. 'Branch Keyed'. {'register of key'. 'table'}}. - {18. 'Jump To'. {'offset'}}. +VM SSACode Instruction instancesSetting: #(code selector name argNames offsettingArgIndices) to: { + {0. #directSendMessage. 'Direct Send'. {'register of result'. 'selector'. 'arity' ". args..."}. {2}}. + "{1. #indirectSendMessage. 'Indirect Send'. {'register of result'. 'selector'. 'arity'. args...}. {2}}." + "{2. #allocateRegisters. 'Allocate Registers'. 3. {}}." + {3. #loadLiteral. 'Load Literal'. {'register of result'. 'index of literal'}}. + "{4. #storeLiteral. 'Store Literal'. {'index of literal'. 'register of source'}}." + {5. #sendMessageWithOptionals. 'Send with Optionals'. {'register of result'. 'register of selector'. 'arity'. 'register of optionals array' ". args..."}. {2}}. + {7. #newClosure. 'New Closure'. {'register of result'. 'block'}}. + {8. #newArrayWith. 'New Array With'. {'register of result'. 'size' ". args..."}. {1}}. + {9. #resendMessage. 'Resend'. {'register of result'. 'lexical offset'}}. + {10. #returnFrom. 'Return From'. {'register of result'. 'lexical offset'}}. + {11. #loadEnvironment. 'Load Environment'. {'register of result'}}. + {12. #loadVariable. 'Load Variable'. {'register of result'}}. + {13. #storeVariable. 'Store Variable'. {'register of result'}}. + {14. #loadFreeVariable. 'Load Free Variable'. {'register of result'. 'lexical offset'. 'index of variable'}}. + {15. #storeFreeVariable. 'Store Free Variable'. {'lexical offset'. 'index of variable'. 'register of source'}}. + {16. #isIdenticalTo. 'Is Identical To'. {'register of result'. 'register of x'. 'register of y'}}. + {17. #branchKeyed. 'Branch Keyed'. {'register of key'. 'table'}}. + {18. #jumpTo. 'Jump To'. {'offset'}}. "Used like SSA phi / branch merges:" - {19. 'Move Register'. {'register of source'. 'register of result'}}. - {20. 'Branch If True'. {'register of condition'. 'branch offset'}}. - {21. 'Branch If False'. {'register of condition'. 'branch offset'}}. + {19. #moveRegister. 'Move Register'. {'register of source'. 'register of result'}}. + {20. #branchIfTrue. 'Branch If True'. {'register of condition'. 'branch offset'}}. + {21. #branchIfFalse. 'Branch If False'. {'register of condition'. 'branch offset'}}. "Marks the end of a block:" - {22. 'Return Register'. {'register of value'}}. + {22. #returnRegister. 'Return Register'. {'register of value'}}. "Marks the end of a block:" - {23. 'Return Value'. {'value to return'}}. + {23. #returnValue. 'Return Value'. {'value to return'}}. "I'm not sure what this does yet..used in bootstrap:" - {24. 'Resume'. {}}. - {25. 'Primitive Do'. {'number of primitive'. 'arity'. 'register of result' ". args..."}. {1}}. - {26. 'Direct Apply To'. {'method'. 'arity'. 'register of result' ". args..."}. {1}}. - {27. 'Is Nil'. {'register of result'. 'register of x'}}. + {24. #resume. 'Resume'. {}}. + {25. #primitiveDo. 'Primitive Do'. {'number of primitive'. 'arity'. 'register of result' ". args..."}. {1}}. + {26. #directApplyTo. 'Direct Apply To'. {'method'. 'arity'. 'register of result' ". args..."}. {1}}. + {27. #isNilOp. 'Is Nil'. {'register of result'. 'register of x'}}. "these check the arguments to see if their maps match the ones in the map array" "if they match, we fall through to the next instruction which is the primitive (no code) or inlined function" "it also needs to set up the input varibles" - {28. 'Inline Primitive Check Jump'. {'register of result'. 'map array'. 'prim number(in-opcode not a register)'. 'arity'. 'jump offset' ". args..."}. {3}}. - {29. 'Inline Method Check Jump'. {'map array'. 'arity'. 'jump offset' ". args..."}. {1}}. + {28. #inlinePrimitiveCheckJump. 'Inline Primitive Check Jump'. {'register of result'. 'map array'. 'prim number(in-opcode not a register)'. 'arity'. 'jump offset' ". args..."}. {3}}. + {29. #inlineMethodCheckJump. 'Inline Method Check Jump'. {'map array'. 'arity'. 'jump offset' ". args..."}. {1}}. }. -VM SSACode addImmutableSlot: #instructionInfo valued: -{ "the result or destination is usually the first argument" -" the first item in the argument list is the number of arguments. numbers after that tell which items in the argument -list to use to increment the whole count" - 0 -> (#directSendMessage -> {3. 2}). "result register, selector, arity, parameters..." - "1 -> (#indirectSendMessage -> {3. 2})." "result register, selector register, arity, parameters...." - - "2 -> (#allocateRegisters -> {1})." "this should be in the function definition now" - 3 -> (#loadLiteral -> {2}). "dest register, literal" - "4 -> (#storeLiteral -> {2})." "dest literal index, src register" - - 5 -> (#sendMessageWithOptionals -> {4. 2}). "result register, selector register, arity, optsArrayRegister, parameters...." - - 7 -> (#newClosure -> {2}). "register, block" - 8 -> (#newArrayWith -> {2. 1}). "result register, size, parameters..." - 9 -> (#resendMessage -> {2}). "result register, lexical offset" - 10 -> (#returnFrom -> {2}). "result register, lexical offset" - 11 -> (#loadEnvironment -> {1}). "result register" - 12 -> (#loadVariable -> {1}). "dest register / var index" - 13 -> (#storeVariable -> {1}). "var index / src register" - 14 -> (#loadFreeVariable -> {3}). "dest register, lexical offset, free var index" - 15 -> (#storeFreeVariable -> {3}). "lexical offset, var index, src register" - - 16 -> (#isIdenticalTo -> {3}). "result register, x register, y register" - 17 -> (#branchKeyed -> {2}). "key to switch on register, table" - 18 -> (#jumpTo -> {1}). "offset" - 19 -> (#moveRegister -> {2}). "dest reg, src reg. (used like SSA phi / branch merges)" - 20 -> (#branchIfTrue -> {2}). "condition register, branch offset" - 21 -> (#branchIfFalse -> {2}). "condition register, branch offset" - 22 -> (#returnRegister -> {1}). "mark the end of a block" - 23 -> (#returnValue -> {1}). "mark the end of a block" - 24 -> (#resume -> {0}). "I'm not sure what this does yet..used in bootstrap" - 25 -> (#primitiveDo -> {3. 1}). "call a primitive directly, bypassing method lookup: primNum, primArgCount, resultReg, args..." - 26 -> (#directApplyTo -> {3. 1}). "call a method/closure directly, bypassing array creation: method, argCount, resultReg, args..." - 27 -> (#isNilOp -> {2}). "is identical to but doesn't need the nil argument" - - "these check the arguments to see if their maps match the ones in the map array" - "if they match, we fall through to the next instruction which is the primitive (no code) or inlined function" - "it also needs to set up the input varibles" - 28 -> (#inlinePrimitiveCheckJump -> {5. 3}). "result reg, map array, prim number(in-opcode not a register), arity, jump offset, parameters..." - 29 -> (#inlineMethodCheckJump -> {3. 1}). "map array, arity, jump offset, parameters..." -}. - -VM SSACode instructionInfo do: [| :sym | VM SSACode addImmutableSlot: sym value key valued: sym key]. - VM define: #SSACompiler &parents: {Cloneable} &slots: {#contexts -> Stack new}. -- 2.11.4.GIT