[Vm-dev] VM Maker: VMMaker.oscog-eem.998.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Dec 23 17:33:45 UTC 2014
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.998.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.998
Author: eem
Time: 23 December 2014, 9:31:13.819 am
UUID: 20a6acb3-9a01-4219-b650-8966301ffe11
Ancestors: VMMaker.oscog-eem.997
Fix printStackReferencesTo: for CoInterpreter.
Similarly collapse printFrame: into StackInterpreter
only. Declare as #undeclared CoInterpreter-specific
indices in StackInterpreter.
=============== Diff against VMMaker.oscog-eem.997 ===============
Item was removed:
- ----- Method: CoInterpreter>>printFrame: (in category 'debug printing') -----
- printFrame: theFP
- | thePage theSP |
- <inline: false>
- <var: #theFP type: #'char *'>
- <var: #thePage type: #'StackPage *'>
- <var: #theSP type: #'char *'>
- theFP = framePointer
- ifTrue: [theSP := stackPointer]
- ifFalse:
- [thePage := stackPages stackPageFor: theFP.
- (stackPages isFree: thePage) ifTrue:
- [self printHexPtr: theFP; print: ' is on a free page?!!'; cr.
- ^nil].
- (thePage ~= stackPage
- and: [theFP = thePage headFP])
- ifTrue: [theSP := thePage headSP]
- ifFalse:
- [theSP := self findSPOrNilOf: theFP
- on: thePage
- startingFrom: ((thePage = stackPage
- and: [framePointer
- between: thePage realStackLimit
- and: thePage baseAddress])
- ifTrue: [framePointer]
- ifFalse: [thePage headFP])]].
- theSP isNil ifTrue:
- [self print: 'could not find sp; using bogus value'; cr.
- theSP := theFP + ((self isMachineCodeFrame: theFP)
- ifTrue: [FoxMFReceiver]
- ifFalse: [FoxIFReceiver])].
- self printFrame: theFP WithSP: theSP!
Item was changed:
----- Method: StackInterpreter class>>initializeFrameIndices (in category 'initialization') -----
initializeFrameIndices
"Format of a stack frame. Word-sized indices relative to the frame pointer.
Terminology
Frames are either single (have no context) or married (have a context).
Contexts are either single (exist on the heap), married (have a context) or widowed (had a frame that has exited).
Stacks grow down:
receiver for method activations/closure for block activations
arg0
...
argN
caller's method ip/base frame's sender context
fp-> saved fp
method
frame flags
context (uninitialized)
receiver
first temp
...
sp-> Nth temp
frame flags holds the number of arguments (since argument temporaries are above the frame)
the flag for a block activation
and the flag indicating if the context field is valid (whether the frame is married).
The first frame in a stack page is the baseFrame and is marked as such by a null saved fp,
in which case the saved method ip is actually the context (possibly hybrid) beneath the base frame"
| fxCallerSavedIP fxSavedFP fxMethod fxFrameFlags fxThisContext fxReceiver |
fxCallerSavedIP := 1.
fxSavedFP := 0.
fxMethod := -1.
fxFrameFlags := -2. "Can find numArgs, needed for fast temp access. args are above fxCallerSavedIP.
+ Can find ``is block'' bit
+ Can find ``has context'' bit"
- Can find ``is block'' bit
- Can find ``has context'' bit"
fxThisContext := -3.
fxReceiver := -4.
FrameSlots := fxCallerSavedIP - fxReceiver + 1.
FoxCallerSavedIP := fxCallerSavedIP * BytesPerWord.
"In base frames the caller saved ip field holds the caller context."
FoxCallerContext := FoxCallerSavedIP.
FoxSavedFP := fxSavedFP * BytesPerWord.
FoxMethod := fxMethod * BytesPerWord.
FoxFrameFlags := fxFrameFlags * BytesPerWord.
FoxThisContext := fxThisContext * BytesPerWord.
+ FoxReceiver := fxReceiver * BytesPerWord.
+
+ "Mark the CoInterpreter-specific offsets as #undeclared to
+ avoid including them accidentally in StackInterpreter code."
+ IFrameSlots := #undeclared.
+ MFrameSlots := #undeclared.
+ FoxIFrameFlags := #undeclared.
+ FoxIFSavedIP := #undeclared.
+ FoxIFReceiver := #undeclared.
+ FoxMFReceiver := #undeclared!
- FoxReceiver := fxReceiver * BytesPerWord!
Item was changed:
----- Method: StackInterpreter>>printFrame: (in category 'debug printing') -----
printFrame: theFP
| thePage theSP |
<inline: false>
<var: #theFP type: #'char *'>
<var: #thePage type: #'StackPage *'>
<var: #theSP type: #'char *'>
theFP = framePointer
ifTrue: [theSP := stackPointer]
ifFalse:
[thePage := stackPages stackPageFor: theFP.
(stackPages isFree: thePage) ifTrue:
[self printHexPtr: theFP; print: ' is on a free page?!!'; cr.
^nil].
+ (thePage ~= stackPage
+ and: [theFP = thePage headFP])
+ ifTrue: [theSP := thePage headSP]
+ ifFalse:
+ [theSP := self findSPOrNilOf: theFP
+ on: thePage
+ startingFrom: ((thePage = stackPage
+ and: [framePointer
+ between: thePage realStackLimit
+ and: thePage baseAddress])
+ ifTrue: [framePointer]
+ ifFalse: [thePage headFP])]].
+ theSP ifNil:
- theSP := self findSPOrNilOf: theFP
- on: thePage
- startingFrom: ((thePage = stackPage
- and: [framePointer < thePage headFP])
- ifTrue: [framePointer]
- ifFalse: [thePage headFP])].
- theSP isNil ifTrue:
[self print: 'could not find sp; using bogus value'; cr.
+ theSP := self frameReceiverOffset: theFP].
- theSP := theFP + FoxReceiver].
self printFrame: theFP WithSP: theSP!
Item was changed:
----- Method: StackInterpreter>>printStackReferencesTo: (in category 'object memory support') -----
printStackReferencesTo: oop
<api>
<var: #thePage type: #'StackPage *'>
<var: #theSP type: #'char *'>
<var: #theFP type: #'char *'>
<var: #callerFP type: #'char *'>
0 to: numStackPages - 1 do:
[:i| | thePage theSP theFP callerFP |
thePage := stackPages stackPageAt: i.
thePage isFree ifFalse:
[theSP := thePage headSP.
+ theFP := thePage headFP.
- theFP := thePage headFP.
"Skip the instruction pointer on top of stack of inactive pages."
thePage = stackPage ifFalse:
[theSP := theSP + objectMemory wordSize].
+ [[theSP <= (self frameReceiverOffset: theFP)] whileTrue:
- [[theSP <= (theFP + FoxReceiver)] whileTrue:
[oop = (stackPages longAt: theSP) ifTrue:
[self print: 'FP: '; printHexnp: theFP; print: ' @ '; printHexnp: theSP; cr].
theSP := theSP + objectMemory wordSize].
+ (self frameHasContext: theFP) ifTrue:
- (self frameHasContext: theFP) ifTrue:
[oop = (self frameContext: theFP) ifTrue:
[self print: 'FP: '; printHexnp: theFP; print: ' CTXT'; cr]].
+ oop = (self frameMethod: theFP) ifTrue:
- oop = (self frameMethod: theFP) ifTrue:
[self print: 'FP: '; printHexnp: theFP; print: ' MTHD'; cr].
+ (callerFP := self frameCallerFP: theFP) ~= 0]
+ whileTrue:
+ [theSP := (theFP + FoxCallerSavedIP) + objectMemory wordSize.
+ theFP := callerFP].
+ theSP := theFP + FoxCallerSavedIP. "a.k.a. FoxCallerContext"
- (callerFP := self frameCallerFP: theFP) ~= 0] whileTrue:
- [theSP := (theFP + FoxCallerSavedIP) + objectMemory wordSize.
- theFP := callerFP].
- theSP := theFP + FoxCallerContext. "a.k.a. FoxCallerSavedIP"
[theSP <= thePage baseAddress] whileTrue:
[oop = (stackPages longAt: theSP) ifTrue:
[self print: 'FP: '; printHexnp: theFP; print: ' @ '; printHexnp: theSP; cr].
theSP := theSP + objectMemory wordSize]]]!
More information about the Vm-dev
mailing list