VM Maker: VMMaker.oscog-eem.2031.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

VM Maker: VMMaker.oscog-eem.2031.mcz

commits-2
 
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2031.mcz

==================== Summary ====================

Name: VMMaker.oscog-eem.2031
Author: eem
Time: 7 December 2016, 6:35:42.344995 pm
UUID: 8ca33ad6-6017-412f-8c48-83024848049f
Ancestors: VMMaker.oscog-eem.2030

registerAllocatingCogit:
Implement mustBeBoolean processing, mapping machine code frame to interpreted frame.

=============== Diff against VMMaker.oscog-eem.2030 ===============

Item was changed:
  ----- Method: CoInterpreter>>ceSendMustBeBooleanTo:interpretingAtDelta: (in category 'trampolines') -----
+ ceSendMustBeBooleanTo: aNonBooleanObject interpretingAtDelta: jumpSize
- ceSendMustBeBooleanTo: anObject interpretingAtDelta: jumpSize
  "For RegisterAllocatingCogit we want the address following a conditional branch not to be reachable, so we
+ don't have to generate code to reload registers.  Instead simply convert to an interpreter frame,
+ backup the pc to the branch, reenter the interpreter and hence retry the mustBeBoolean send therein."
- don't have to generate code to reload registers.  Instead simply convert to an interpreter frame."
  <api>
+ | cogMethod methodObj methodHeader startBcpc |
+ <var: 'cogMethod' type: #'CogBlockMethod *'>
+ self assert: (objectMemory addressCouldBeOop: aNonBooleanObject).
+ cogMethod := self mframeCogMethod: framePointer.
+ ((self mframeIsBlockActivation: framePointer)
+ and: [cogMethod cmIsFullBlock not])
+ ifTrue:
+ [methodHeader := cogMethod cmHomeMethod methodHeader.
+ methodObj := cogMethod cmHomeMethod methodObject.
+ startBcpc := cogMethod startpc]
+ ifFalse:
+ [methodHeader := (self cCoerceSimple: cogMethod to: #'CogMethod *') methodHeader.
+ methodObj := (self cCoerceSimple: cogMethod to: #'CogMethod *') methodObject.
+ startBcpc := self startPCOfMethod: methodObj].
+
+ "Map the machine code instructionPointer to the interpreter instructionPointer of the branch."
- self flag: 'A nice way to implement this is to
- - provide an additional argument that is the size of the branch (have trampolines for 1 & 2 byte jumps).
-  Note that there is no need to back up before any extensions since the branch will not be taken.
- ceSendMustBeBooleanTo: anObject interpretingAtDelta: jumpSize
- - map the frame to an interpreter frame
- - push anObject
- - back up the pc to position the interpreter at the jump
- - enter the interpreter, hence reexecuting the mustBeBoolean'.
- self shouldBeImplemented.
  instructionPointer := self popStack.
+ instructionPointer := cogit bytecodePCFor: instructionPointer startBcpc: startBcpc in: cogMethod.
+ instructionPointer := methodObj + objectMemory baseHeaderSize + instructionPointer - jumpSize - 1. "pre-decrement"
+
+ "Make space for the two extra fields in an interpreter frame"
+ stackPointer to: framePointer + FoxMFReceiver by: objectMemory wordSize do:
+ [:p| | oop |
+ oop := objectMemory longAt: p.
+ objectMemory
+ longAt: p - objectMemory wordSize - objectMemory wordSize
+ put: (objectMemory longAt: p)].
+ stackPointer := stackPointer - objectMemory wordSize - objectMemory wordSize.
+ self push: aNonBooleanObject.
+ "Fill in the fields"
+ objectMemory
+ longAt: framePointer + FoxIFrameFlags
+ put: (self
+ encodeFrameFieldHasContext: (self mframeHasContext: framePointer)
+ isBlock: (self mframeIsBlockActivation: framePointer)
+ numArgs: cogMethod cmNumArgs);
+ longAt: framePointer + FoxIFSavedIP
+ put: 0;
+ longAt: framePointer + FoxMethod
+ put: methodObj.
+
+ "and now reenter the interpreter..."
+ self setMethod: methodObj methodHeader: methodHeader.
+ self siglong: reenterInterpreter jmp: ReturnToInterpreter.!
- self push: anObject.
- self push: instructionPointer.
- ^self
- ceSendAbort: (objectMemory splObj: SelectorMustBeBoolean)
- to: anObject
- numArgs: 0!