Skip to content

Commit aba9cd3

Browse files
committed
Round up the result of sbrk (used for the hint to the initial mmap for Spur) to
a page boundary.
1 parent b8d838c commit aba9cd3

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

image/Slang Test Workspace.text

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"Here are some doits to get Slang to generate a single method to the transcript"[Transcript show: [| sel vmm s cg | sel := #scavenge:. vmm := (VMMaker forPlatform: 'Cross') interpreterClass: StackInterpreter; options: #(ObjectMemory Spur64BitCoMemoryManager). cg := [vmm buildCodeGeneratorForInterpreter] on: Notification do: [:ex| ex tag == #getVMMaker ifTrue: [ex resume: vmm] ifFalse: [ex pass]]. "to break at inlining decisions or type inferrence uncomment the following. If src & dest are different selectors, breaks on inlining. If src & dest are the same selector, breaks on type inference in sel." "cg breakSrcInlineSelector: sel; breakDestInlineSelector: sel; breakOnInline: false". cg vmClass preGenerationHook: cg. cg inferTypesForImplicitlyTypedVariablesAndMethods. cg retainMethods: { sel }. cg prepareMethods. ((sel beginsWith: 'bytecode') or: [sel endsWith: 'Bytecode']) ifTrue: [cg doBasicInlining: true] ifFalse: [cg doInlining: true]. s := ReadWriteStream on: String new. (cg methodNamed: sel) halt; emitCCodeOn: s generator: cg. s contents] value].[Transcript show: [| sel vmm s cg | sel := #primitiveVoidVMStateForMethod. vmm := (VMMaker forPlatform: 'Cross') interpreterClass: CoInterpreter"MT"; options: {#Cogit. Cogit chooseCogitClass name}. cg := [vmm buildCodeGeneratorForInterpreter] on: Notification do: [:ex| ex tag == #getVMMaker ifTrue: [ex resume: vmm] ifFalse: [ex pass]]. cg vmClass preGenerationHook: cg. cg inferTypesForImplicitlyTypedVariablesAndMethods. cg retainMethods: { sel }. cg prepareMethods. ((sel beginsWith: 'bytecode') or: [sel endsWith: 'Bytecode']) ifTrue: [cg doBasicInlining: true] ifFalse: [cg doInlining: true]. s := ReadWriteStream on: String new. (cg methodNamed: sel) halt; emitCCodeOn: s generator: cg. s contents] value].[Transcript show: [| sel s vmm cg | sel := #compileEntry. vmm := VMMaker forPlatform: 'Cross'. cg := [vmm interpreterClass: CoInterpreter; options: {#Cogit. Cogit chooseCogitClass name}; buildCodeGeneratorForCogit] on: Notification do: [:ex| ex tag == #getVMMaker ifTrue: [ex resume: vmm] ifFalse: [ex pass]]. cg vmClass preGenerationHook: cg. cg inferTypesForImplicitlyTypedVariablesAndMethods. cg retainMethods: { #compactCogCompiledCode. sel }. cg prepareMethods. cg doInlining: cg vmClass doInlining. s := ReadWriteStream on: String new. (cg methodNamed: sel) halt; emitCCodeOn: s generator: cg. s contents] value].[Transcript show: [| tm s vmm cg | vmm := VMMaker forPlatform: 'Cross'. cg := [vmm interpreterClass: StackInterpreter; buildCodeGeneratorForInterpreter] on: Notification do: [:ex| ex tag == #getVMMaker ifTrue: [ex resume: vmm] ifFalse: [ex pass]]. cg vmClass preGenerationHook: cg. tm := (StackInterpreter compile: 'foo self cppIf: ''ARBITRARY'' ifTrue: [self cCode: ''arbi''] ifFalse: [self cCode: ''trary'']. self cppIf: (self cCode: ''ARBITRARY'') ifTrue: [self cCode: ''arbi''] ifFalse: [self cCode: ''trary'']' classified: nil notifying: nil trailer: CompiledMethodTrailer empty ifFail: []) node asTranslationMethodOfClass: cg translationMethodClass. cg addMethod: tm. cg inferTypesForImplicitlyTypedVariablesAndMethods. cg retainMethods: { #foo }. cg prepareMethods. cg doInlining: true. s := ReadWriteStream on: String new. (cg methodNamed: #foo) halt; emitCCodeOn: s generator: cg. s contents] value].[Transcript show: [| plugin sel s vmm cg | plugin := ThreadedARMFFIPlugin. sel := #primitiveCallout. vmm := VMMaker forPlatform: 'Cross'. cg := [plugin buildCodeGenerator] on: Notification do: [:ex| ex tag == #getVMMaker ifTrue: [ex resume: vmm] ifFalse: [ex pass]]. cg breakSrcInlineSelector: #cdigitMontgomery:len:times:len:modulo:len:mInvModB:into:; breakDestInlineSelector: sel; breakOnInline: "false"true. cg inferTypesForImplicitlyTypedVariablesAndMethods. cg retainMethods: { sel }. cg prepareMethods. cg doInlining: true. s := ReadWriteStream on: String new. (cg anyMethodNamed: sel) removeUnusedTempsAndNilIfRequiredIn: cg; halt; emitCCodeOn: s generator: cg. s contents] value].[Transcript show: [| plugin s cg | plugin := FileCopyPlugin"UnixOSProcessPlugin". cg := plugin buildCodeGenerator. cg inferTypesForImplicitlyTypedVariablesAndMethods. plugin pruneUnusedInterpreterPluginMethodsIn: cg. s := ReadWriteStream on: String new. cg emitCCodeOn: s doInlining: true doAssertions: false. s contents] value].[| cg |cg := BitBltSimulation buildCodeGeneratorUpTo: BitBltSimulation.cg inferTypesForImplicitlyTypedVariablesAndMethods].
1+
"Here are some doits to get Slang to generate a single method to the transcript"[Transcript show: [| sel vmm s cg | sel := #scavenge:. vmm := (VMMaker forPlatform: 'Cross') interpreterClass: StackInterpreter; options: #(ObjectMemory Spur64BitCoMemoryManager). cg := [vmm buildCodeGeneratorForInterpreter] on: Notification do: [:ex| ex tag == #getVMMaker ifTrue: [ex resume: vmm] ifFalse: [ex pass]]. "to break at inlining decisions or type inferrence uncomment the following. If src & dest are different selectors, breaks on inlining. If src & dest are the same selector, breaks on type inference in sel." "cg breakSrcInlineSelector: sel; breakDestInlineSelector: sel; breakOnInline: false". cg vmClass preGenerationHook: cg. cg inferTypesForImplicitlyTypedVariablesAndMethods. cg retainMethods: { sel }. cg prepareMethods. ((sel beginsWith: 'bytecode') or: [sel endsWith: 'Bytecode']) ifTrue: [cg doBasicInlining: true] ifFalse: [cg doInlining: true]. s := ReadWriteStream on: String new. (cg methodNamed: sel) halt; emitCCodeOn: s generator: cg. s contents] value].[Transcript show: [| sel vmm s cg | sel := #initializeThreadState"populate:from:to:". vmm := (VMMaker forPlatform: 'Cross') interpreterClass: CoInterpreterMT; options: {ObjectMemory. Spur64BitCoMemoryManager. #Cogit. Cogit chooseCogitClass name}. cg := [vmm buildCodeGeneratorForInterpreter] on: Notification do: [:ex| ex tag == #getVMMaker ifTrue: [ex resume: vmm] ifFalse: [ex pass]]. cg vmClass preGenerationHook: cg. cg inferTypesForImplicitlyTypedVariablesAndMethods. cg retainMethods: { sel }. cg prepareMethods. ((sel beginsWith: 'bytecode') or: [sel endsWith: 'Bytecode']) ifTrue: [cg doBasicInlining: true] ifFalse: [cg doInlining: true]. s := ReadWriteStream on: String new. (cg methodNamed: sel) halt; emitCCodeOn: s generator: cg. s contents] value].[Transcript show: [| sel s vmm cg | sel := #compileEntry. vmm := VMMaker forPlatform: 'Cross'. cg := [vmm interpreterClass: CoInterpreter; options: {#Cogit. Cogit chooseCogitClass name}; buildCodeGeneratorForCogit] on: Notification do: [:ex| ex tag == #getVMMaker ifTrue: [ex resume: vmm] ifFalse: [ex pass]]. cg vmClass preGenerationHook: cg. cg inferTypesForImplicitlyTypedVariablesAndMethods. cg retainMethods: { #compactCogCompiledCode. sel }. cg prepareMethods. cg doInlining: cg vmClass doInlining. s := ReadWriteStream on: String new. (cg methodNamed: sel) halt; emitCCodeOn: s generator: cg. s contents] value].[Transcript show: [| tm s vmm cg | vmm := VMMaker forPlatform: 'Cross'. cg := [vmm interpreterClass: StackInterpreter; buildCodeGeneratorForInterpreter] on: Notification do: [:ex| ex tag == #getVMMaker ifTrue: [ex resume: vmm] ifFalse: [ex pass]]. cg vmClass preGenerationHook: cg. tm := (StackInterpreter compile: 'foo self cppIf: ''ARBITRARY'' ifTrue: [self cCode: ''arbi''] ifFalse: [self cCode: ''trary'']. self cppIf: (self cCode: ''ARBITRARY'') ifTrue: [self cCode: ''arbi''] ifFalse: [self cCode: ''trary'']' classified: nil notifying: nil trailer: CompiledMethodTrailer empty ifFail: []) node asTranslationMethodOfClass: cg translationMethodClass. cg addMethod: tm. cg inferTypesForImplicitlyTypedVariablesAndMethods. cg retainMethods: { #foo }. cg prepareMethods. cg doInlining: true. s := ReadWriteStream on: String new. (cg methodNamed: #foo) halt; emitCCodeOn: s generator: cg. s contents] value].[Transcript show: [| plugin sel s vmm cg | plugin := ThreadedARMFFIPlugin. sel := #primitiveCallout. vmm := VMMaker forPlatform: 'Cross'. cg := [plugin buildCodeGenerator] on: Notification do: [:ex| ex tag == #getVMMaker ifTrue: [ex resume: vmm] ifFalse: [ex pass]]. cg breakSrcInlineSelector: #cdigitMontgomery:len:times:len:modulo:len:mInvModB:into:; breakDestInlineSelector: sel; breakOnInline: "false"true. cg inferTypesForImplicitlyTypedVariablesAndMethods. cg retainMethods: { sel }. cg prepareMethods. cg doInlining: true. s := ReadWriteStream on: String new. (cg anyMethodNamed: sel) removeUnusedTempsAndNilIfRequiredIn: cg; halt; emitCCodeOn: s generator: cg. s contents] value].[Transcript show: [| plugin s cg | plugin := FileCopyPlugin"UnixOSProcessPlugin". cg := plugin buildCodeGenerator. cg inferTypesForImplicitlyTypedVariablesAndMethods. plugin pruneUnusedInterpreterPluginMethodsIn: cg. s := ReadWriteStream on: String new. cg emitCCodeOn: s doInlining: true doAssertions: false. s contents] value].[| cg |cg := BitBltSimulation buildCodeGeneratorUpTo: BitBltSimulation.cg inferTypesForImplicitlyTypedVariablesAndMethods].

platforms/unix/vm/sqUnixSpurMemory.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ int mmapErrno = 0;
106106
static int min(int x, int y) { return (x < y) ? x : y; }
107107
static int max(int x, int y) { return (x > y) ? x : y; }
108108

109+
// a hint of the lowest possible address for mmap
110+
#define lowestPageAlignedAddressForMMap() \
111+
(assert(pageSize), (void *)roundUpToPage((usqInt)sbrk(0)))
112+
109113
/* Answer the address of minHeapSize rounded up to page size bytes of memory. */
110114

111115
#if COGVM
@@ -127,7 +131,7 @@ sqAllocateMemory(usqInt minHeapSize, usqInt desiredHeapSize)
127131
pageSize = getpagesize();
128132
pageMask = ~(pageSize - 1);
129133

130-
hint = sbrk(0);
134+
hint = lowestPageAlignedAddressForMMap();
131135
#else
132136
assert(pageSize != 0 && pageMask != 0);
133137
hint = endOfJITZone;
@@ -275,12 +279,14 @@ sqMakeMemoryExecutableFromToCodeToDataDelta(usqInt startAddr,
275279
void *
276280
allocateJITMemory(usqInt *desiredSize)
277281
{
278-
void *hint = sbrk(0); // a hint of the lowest possible address for mmap
282+
void *hint; // a hint of the lowest possible address for mmap
279283
void *result;
280284

281285
pageSize = getpagesize();
282286
pageMask = ~(pageSize - 1);
283287

288+
hint = lowestPageAlignedAddressForMMap();
289+
284290
#if !defined(MAP_JIT)
285291
# define MAP_JIT 0
286292
#endif

0 commit comments

Comments
 (0)