Skip to content

Add code only zone #985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: gsoc-code-cache
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions smalltalksrc/VMMaker/CoInterpreter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ CoInterpreter >> addNewMethodToCache: classObj [

{ #category : 'image save/restore' }
CoInterpreter >> allocateMemoryForImage: f withHeader: header [
<feature: #codeOnlyZone>

<var: #f type: #sqImageFile>
<var: #header type: #SpurImageHeaderStruct>
Expand All @@ -615,12 +616,18 @@ CoInterpreter >> allocateMemoryForImage: f withHeader: header [
cogCodeSize := cogCodeSize min: cogit maxCogCodeSize.

objectMemory getMemoryMap initialCodeZoneSize: cogCodeSize.
objectMemory getMemoryMap initialCodeOnlyZoneSize: cogCodeSize. "SH: code only zone"
super allocateMemoryForImage: f withHeader: header.
self beforeCodeZoneInitialization.

cogit
initializeCodeZoneFrom: objectMemory getMemoryMap codeZoneStart
upTo: objectMemory getMemoryMap codeZoneEnd
upTo: objectMemory getMemoryMap codeZoneEnd.

"SH: code only zone"
cogit
initializeCodeOnlyZoneFrom: objectMemory getMemoryMap codeOnlyZoneStart
upTo: objectMemory getMemoryMap codeOnlyZoneEnd.
]

{ #category : 'trampoline support' }
Expand Down Expand Up @@ -789,20 +796,19 @@ CoInterpreter >> attemptToSwitchToMachineCode: bcpc [
<inline: false>
<var: #cogMethod type: #'CogMethod *'>
(self methodHasCogMethod: method)
ifTrue:[cogMethod := self cogMethodOf: method.
pc := self convertToMachineCodeFrame: cogMethod bcpc: bcpc.
self assertValidMachineCodeFrame: pc.
self push: pc.
self push: objectMemory nilObject.
self callEnilopmart: #ceEnterCogCodePopReceiverReg]
ifFalse: [
(self iframeIsBlockActivation: framePointer)
ifTrue: [ "Compiled block / full closure"
cls := self frameStackedReceiver: framePointer numArgs: (self frameNumArgs: framePointer).
cogit cogFullBlockMethod: method numCopied: (objectMemory numPointerSlotsOf: cls) - FullClosureFirstCopiedValueIndex]
ifFalse: [ "Compiled method"
cogit cog: method selector: objectMemory nilObject ] ].
(self methodHasCogMethod: method) ifTrue:
[cogMethod := self cogMethodOf: method.
pc := self convertToMachineCodeFrame: cogMethod bcpc: bcpc.
self assertValidMachineCodeFrame: pc.
self push: pc.
self push: objectMemory nilObject.
self callEnilopmart: #ceEnterCogCodePopReceiverReg]
cogit cog: method selector: objectMemory nilObject ] ]
]

{ #category : 'return bytecodes' }
Expand Down
103 changes: 0 additions & 103 deletions smalltalksrc/VMMaker/CoInterpreterPrimitives.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -151,109 +151,6 @@ CoInterpreterPrimitives >> primitiveFunctionPointerAddress [
inSmalltalk: [cogit simulatedReadWriteVariableAddress: #primitiveFunctionPointer in: self]
]

{ #category : 'system control primitives' }
CoInterpreterPrimitives >> primitiveGetVMParameter: index [
"See primitiveVMParameter method comment.
Return an OOP if success.
Return nil if no argument is available for the index"
index caseOf: {
[1] -> [^self positiveMachineIntegerFor: objectMemory oldSpaceSize].
[2] -> [^objectMemory integerObjectOf: objectMemory newSpaceSize].
[3] -> [^self positiveMachineIntegerFor: objectMemory totalMemorySize].
[6] -> [^objectMemory integerObjectOf: objectMemory tenuringThreshold].
[7] -> [^objectMemory integerObjectOf: objectMemory statFullGCs].
[8] -> [^objectMemory integerObjectOf: objectMemory statFullGCUsecs + 500 // 1000].
[9] -> [^objectMemory integerObjectOf: objectMemory statScavenges].
[10] -> [^objectMemory integerObjectOf: objectMemory statScavengeGCUsecs + 500 // 1000].
[11] -> [^objectMemory integerObjectOf: objectMemory statTenures].
[12] -> [^ConstZero]. "Was JITTER VM info"
[13] -> [^ConstZero]. "Was JITTER VM info"
[14] -> [^ConstZero]. "Was JITTER VM info"
[15] -> [^ConstZero]. "Was JITTER VM info"
[16] -> [^self positive64BitIntegerFor: statIdleUsecs].
[17] -> [^(SistaVM and: [self isCog])
ifTrue: [objectMemory floatObjectOf: self getCogCodeZoneThreshold]
ifFalse: [ConstZero]].
[18] -> [^objectMemory integerObjectOf: objectMemory statCompactionUsecs + 500 // 1000].
[19] -> [^objectMemory integerObjectOf: objectMemory scavengeThresholdAsExtent].
[20] -> [^objectMemory positive64BitIntegerFor: self ioUTCStartMicroseconds].
[21] -> [^objectMemory integerObjectOf: objectMemory rootTableCount].
[22] -> [^objectMemory integerObjectOf: objectMemory statRootTableOverflows].
[23] -> [^objectMemory integerObjectOf: extraVMMemory].
[24] -> [^objectMemory integerObjectOf: objectMemory shrinkThreshold].
[25] -> [^objectMemory integerObjectOf: objectMemory growHeadroom].
[26] -> [^objectMemory integerObjectOf: self ioHeartbeatMilliseconds].
[27] -> [^objectMemory integerObjectOf: objectMemory statMarkCount].
[28] -> [^objectMemory integerObjectOf: objectMemory statSweepCount].
[29] -> [^objectMemory integerObjectOf: objectMemory statMkFwdCount].
[30] -> [^objectMemory integerObjectOf: objectMemory statCompMoveCount].
[31] -> [^objectMemory integerObjectOf: objectMemory statGrowMemory].
[32] -> [^objectMemory integerObjectOf: objectMemory statShrinkMemory].
[33] -> [^objectMemory integerObjectOf: objectMemory statRootTableCount].
[34] -> [^objectMemory positive64BitIntegerFor: objectMemory currentAllocatedBytes].
[35] -> [^objectMemory integerObjectOf: objectMemory statSurvivorCount].
[36] -> [^objectMemory integerObjectOf: (self microsecondsToMilliseconds: objectMemory statGCEndUsecs)].
[37] -> [^objectMemory integerObjectOf: objectMemory statSpecialMarkCount].
[38] -> [^objectMemory integerObjectOf: objectMemory statIGCDeltaUsecs + 500 // 1000].
[39] -> [^ConstZero]. "free"
[40] -> [^objectMemory integerObjectOf: objectMemory wordSize].
[41] -> [^objectMemory integerObjectOf: self imageFormatVersion].
[42] -> [^objectMemory integerObjectOf: numStackPages].
[43] -> [^objectMemory integerObjectOf: desiredNumStackPages].
[44] -> [^objectMemory integerObjectOf: objectMemory edenBytes].
[45] -> [^objectMemory integerObjectOf: desiredEdenBytes].
[46] -> [^self getCogCodeSize].
[47] -> [^self getDesiredCogCodeSize].
[48] -> [^self getCogVMFlags].
[49] -> [^objectMemory integerObjectOf: self ioGetMaxExtSemTableSize].
[52] -> [^objectMemory integerObjectOf: objectMemory rootTableCapacity].
[53] -> [^objectMemory integerObjectOf: objectMemory numSegments].
[54] -> [^objectMemory integerObjectOf: objectMemory freeSize].
[55] -> [^objectMemory floatObjectOf: objectMemory getHeapGrowthToSizeGCRatio].
[56] -> [^self positive64BitIntegerFor: statProcessSwitch].
[57] -> [^ConstZero "free"].
[58] -> [^self positive64BitIntegerFor: statForceInterruptCheck].
[59] -> [^self positive64BitIntegerFor: statCheckForEvents].
[60] -> [^self positive64BitIntegerFor: statStackOverflow].
[61] -> [^self positive64BitIntegerFor: statStackPageDivorce].
[62] -> [^self getCodeCompactionCount].
[63] -> [^self getCodeCompactionMSecs].
[64] -> [^self getCogMethodCount].
[65] -> [^self getCogVMFeatureFlags].
[66] -> [^objectMemory integerObjectOf: self stackPageByteSize].
[67] -> [^objectMemory integerObjectOf: objectMemory maxOldSpaceSize].
[68] -> [^objectMemory floatObjectOf: stackPages statAverageLivePagesWhenMapping].
[69] -> [^objectMemory integerObjectOf: stackPages statMaxPageCountWhenMapping].
[70] -> [^objectMemory integerObjectOf: (self cCode: 'VM_PROXY_MAJOR' inSmalltalk: [self class vmProxyMajorVersion])].
[71] -> [^objectMemory integerObjectOf: (self cCode: 'VM_PROXY_MINOR' inSmalltalk: [self class vmProxyMinorVersion])].
[72] -> [^objectMemory integerObjectOf: objectMemory statMarkUsecs + 500 // 1000].
[73] -> [^objectMemory integerObjectOf: objectMemory statSweepUsecs + 500 // 1000].
[74] -> [^objectMemory integerObjectOf: objectMemory statMaxAllocSegmentTime + 500 // 1000].
[75] -> [^self getMethodCompilationCount].
[76] -> [^self getMethodCompilationMSecs].
[77] -> [^self getBlockCompilationCount].
[78] -> [^self getBlockCompilationMSecs].
[79] -> [^objectMemory integerObjectOf: self getImageVersion ].
[80] -> [^objectMemory integerObjectOf:
objectMemory getFromOldSpaceRememberedSet rememberedSetSize].
[81] -> [^objectMemory integerObjectOf:
objectMemory getFromOldSpaceRememberedSet rememberedSetLimit].
[82] -> [^objectMemory integerObjectOf:
objectMemory getFromPermToOldSpaceRememberedSet rememberedSetSize].
[83] -> [^objectMemory integerObjectOf:
objectMemory getFromPermToOldSpaceRememberedSet rememberedSetLimit].
[84] -> [^objectMemory integerObjectOf:
objectMemory getFromPermToNewSpaceRememberedSet rememberedSetSize].
[85] -> [^objectMemory integerObjectOf:
objectMemory getFromPermToNewSpaceRememberedSet rememberedSetLimit].
[86] -> [^objectMemory getAvoidSearchingSegmentsWithPinnedObjects ifTrue: [ objectMemory trueObject ] ifFalse: [objectMemory falseObject]].
[87] -> [^objectMemory integerObjectOf: cogit getStatTotalHeaderSize ].
[88] -> [^objectMemory integerObjectOf: cogit getStatTotalCodeSize ].
[89] -> [^objectMemory integerObjectOf: cogit getStatTotalMapSize ].
}
otherwise: [^nil]
]

{ #category : 'process primitives' }
CoInterpreterPrimitives >> primitiveLongRunningPrimitiveSemaphore [
"Primitive. Install the semaphore to be used for collecting long-running primitives,
Expand Down
11 changes: 10 additions & 1 deletion smalltalksrc/VMMaker/CogMethod.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ Class {
'picUsage',
'methodObject',
'methodHeader',
'selector'
'selector',
'codeSize'
],
#pools : [
'CogMethodConstants',
Expand Down Expand Up @@ -260,6 +261,14 @@ CogMethod >> cmUsesPenultimateLit: anObject [
^cmUsesPenultimateLit := anObject
]

{ #category : 'accessing' }
CogMethod >> codeSize: anInteger [
<feature: #codeOnlyZone>
"Set the value of the size of the code only zone"

^codeSize := anInteger
]

{ #category : 'testing' }
CogMethod >> containsAddress: anAddress [
"is anAddress within my bounds; not a test of addresses referred to within instructions in the method"
Expand Down
11 changes: 10 additions & 1 deletion smalltalksrc/VMMaker/CogMethodSurrogate.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Class {
'address',
'memory',
'baseHeaderSize',
'cogit'
'cogit',
'codeSize'
],
#pools : [
'CogMethodConstants',
Expand Down Expand Up @@ -137,6 +138,14 @@ CogMethodSurrogate >> cmIsFullBlock [
^ self cpicHasMNUCaseOrCMIsFullBlock
]

{ #category : 'accessing' }
CogMethodSurrogate >> codeSize: anInteger [
<feature: #codeOnlyZone>
"Set the value of the size of the code only zone"

^codeSize := anInteger
]

{ #category : 'testing' }
CogMethodSurrogate >> containsAddress: anAddress [
^address <= anAddress asUnsignedInteger
Expand Down
20 changes: 18 additions & 2 deletions smalltalksrc/VMMaker/CogMethodZone.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ Class {
'objectRepresentation',
'cogit',
'objectMemory',
'percentageToEnsureRelease'
'percentageToEnsureRelease',
'cozFreeStart'
],
#pools : [
'CogMethodConstants',
Expand Down Expand Up @@ -299,6 +300,20 @@ CogMethodZone >> compactionInProgress [
^compactionInProgress
]

{ #category : 'accessing' }
CogMethodZone >> cozFreeStart [
<feature: #codeOnlyZone>
"Next available address of the code only zone"
^cozFreeStart
]

{ #category : 'accessing' }
CogMethodZone >> cozFreeStart: anInteger [
<feature: #codeOnlyZone>
"Next available address of the code only zone"
cozFreeStart := anInteger.
]

{ #category : 'allocating' }
CogMethodZone >> effectiveLimit [
<inline: true>
Expand Down Expand Up @@ -620,7 +635,8 @@ CogMethodZone >> printCogMethods [
coInterpreter print: 'CMMethod '; printNum: nm; print: ' CMClosedPIC '; printNum: nc; print: ' CMOpenPIC '; printNum: no; print: ' CMFree '; printNum: nf.
nu > 0 ifTrue:
[coInterpreter print: ' UNKNOWN '; printNum: nu].
coInterpreter print: ' total '; printNum: nm+nc+no+nf+nu; cr
coInterpreter print: ' total '; printNum: nm+nc+no+nf+nu; cr.
coInterpreter print: 'Total code size '; printNum: cogit getStatTotalCodeSize; print: ' Total map size '; printNum: cogit getStatTotalMapSize; print: ' Total header size '; printNum: cogit getStatTotalHeaderSize; cr
]

{ #category : 'printing' }
Expand Down
Loading