Skip to content

Commit

Permalink
Moving allocation of the stackPages to the memory map
Browse files Browse the repository at this point in the history
  • Loading branch information
tesonep committed Apr 4, 2022
1 parent 1c194ce commit 0d044fd
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 20 deletions.
12 changes: 5 additions & 7 deletions smalltalksrc/VMMaker/StackInterpreter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7560,13 +7560,11 @@ StackInterpreter >> initStackPages [
stackPageBytes := self stackPageByteSize.
stackPagesBytes := self computeStackZoneSize.

theStackMemory := self
cCode: [ self alloca: stackPagesBytes ]
inSmalltalk: [
stackPages
initializeWithByteSize: stackPagesBytes
for: self ].
self cCode: [ self me: theStackMemory ms: 0 et: stackPagesBytes ].
theStackMemory := stackPages
initializeWithByteSize: stackPagesBytes
inMemoryMap: objectMemory getMemoryMap
for: self.

stackPages
initializeStack: theStackMemory
numSlots: stackPagesBytes / objectMemory wordSize
Expand Down
38 changes: 37 additions & 1 deletion smalltalksrc/VMMaker/VMMemoryMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Class {
'oldSpaceMask',
'initialCodeZoneSize',
'codeZoneStart',
'codeZoneEnd'
'codeZoneEnd',
'stackPagesStart',
'stackPagesEnd'
],
#category : #'VMMaker-Memory'
}
Expand Down Expand Up @@ -141,6 +143,16 @@ VMMemoryMap >> allocatePermObjectsSpace [
self permSpaceEnd: self permSpaceStart + permSpaceSize
]

{ #category : #allocating }
VMMemoryMap >> allocateStackPages: initialStackSize [

self stackPagesStart: (self allocateMemory: initialStackSize BaseAddress: memoryMapConfiguration stackPagesInitialAddress).

self stackPagesStart ifNil: [ self insufficientMemoryAvailableError ].

self stackPagesEnd: self stackPagesStart + initialStackSize.
]

{ #category : #accessing }
VMMemoryMap >> allocationReserve [
^ allocationReserve
Expand Down Expand Up @@ -363,6 +375,30 @@ VMMemoryMap >> setOldSpaceEnd: anInteger [

]

{ #category : #accessing }
VMMemoryMap >> stackPagesEnd [

^ stackPagesEnd
]

{ #category : #accessing }
VMMemoryMap >> stackPagesEnd: anObject [

stackPagesEnd := anObject
]

{ #category : #accessing }
VMMemoryMap >> stackPagesStart [

^ stackPagesStart
]

{ #category : #accessing }
VMMemoryMap >> stackPagesStart: anObject [

stackPagesStart := anObject
]

{ #category : #accessing }
VMMemoryMap >> startOfObjectMemory [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ VMMemoryMapConfigurationFor32Bits >> permSpaceInitialAddress [
^ 16r80000000 "(2048 MB)"
]

{ #category : #'initial addresses' }
VMMemoryMapConfigurationFor32Bits >> stackPagesInitialAddress [

^ 16r0F000000 "(240 MB)"
]

{ #category : #accessing }
VMMemoryMapConfigurationFor32Bits >> wordSize [
<doNotGenerate>
Expand Down
30 changes: 19 additions & 11 deletions smalltalksrc/VMMaker/VMStackPages.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,26 @@ VMStackPages >> initializeStack: theStackPages numSlots: stackSlots pageSize: sl
]

{ #category : #initialization }
VMStackPages >> initializeWithByteSize: byteSize "<Integer>" for: anInterpreter [ "<CoInterpreter>" "^<Array of: <Integer>"
"Initialize the stackPages memory for simulation. To keep access monitoring
in one place we defer to the coInterpreter for accessing memory. Answer the
base address of th ememory."
<doNotGenerate>
coInterpreter := anInterpreter.
objectMemory := coInterpreter objectMemory.

minStackAddress := objectMemory memoryManager allocate: byteSize.
maxStackAddress := minStackAddress + byteSize.
VMStackPages >> initializeWithByteSize: byteSize inMemoryMap: aMemoryMap for: anInterpreter [

<inline: true>

| stackAddress |

aMemoryMap allocateStackPages: byteSize.
stackAddress := aMemoryMap stackPagesStart.

self
cCode: []
inSmalltalk: [
coInterpreter := anInterpreter.
objectMemory := coInterpreter objectMemory.
minStackAddress := stackAddress.
maxStackAddress := minStackAddress + byteSize.
].


^ minStackAddress
^ stackAddress
]

{ #category : #'page access' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ VMSimulatedEnvironmentBuilder >> doBuild [
memoryManager wordSize: wordSize.

interpreter memoryManager: memoryManager.
objectMemory memoryManager: memoryManager.
objectMemory createMemoryMap.

objectMemory memoryManager: memoryManager.
objectMemory coInterpreter: interpreter.

objectMemory
Expand Down

0 comments on commit 0d044fd

Please sign in to comment.