Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2745.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.2745
Author: eem
Time: 25 April 2020, 6:53:02.146876 pm
UUID: 8a9b863d-7a2a-49f7-8856-61b563e34732
Ancestors: VMMaker.oscog-eem.2744
Simulation: Simplify handleCallOrJumpSimulationTrap:; it has no business knowing whether a control transfer was initiated by a jump or a call. What matters is what the target choses to do (this after pairing with Boris; thanks). Consequently simplify simulateEnilopmart:numArgs:. Move the primitives not to be checked for a consistent stack on success to their own collection, as a micro-optimisation yes, but more importantly to name them.
Fix a few sends of splObj: and one of integerObjectOf: which should be to objectMemory.
=============== Diff against VMMaker.oscog-eem.2744 ===============
Item was changed:
----- Method: CoInterpreter>>sendInvokeCallback:Stack:Registers:Jmpbuf: (in category 'callback support') -----
sendInvokeCallback: thunkPtr Stack: stackPtr Registers: regsPtr Jmpbuf: jmpBufPtr
"Override to log and check stack alignment. Since this is an implicit send we need to
log it explicitly. The return side is done via a primitive so that gets logged normally."
cogit assertCStackWellAligned.
cogit recordPrimTrace ifTrue:
+ [self fastLogPrim: (objectMemory splObj: SelectorInvokeCallback)].
- [self fastLogPrim: (self splObj: SelectorInvokeCallback)].
^super sendInvokeCallback: thunkPtr Stack: stackPtr Registers: regsPtr Jmpbuf: jmpBufPtr!
Item was changed:
----- Method: CoInterpreter>>sendInvokeCallbackContext: (in category 'callback support') -----
sendInvokeCallbackContext: vmCallbackContext
"Override to log and check stack alignment. Since this is an implicit send we need to
log it explicitly. The return side is done via a primitive so that gets logged normally."
cogit assertCStackWellAligned.
cogit recordPrimTrace ifTrue:
+ [self fastLogPrim: (objectMemory splObj: SelectorInvokeCallback)].
- [self fastLogPrim: (self splObj: SelectorInvokeCallback)].
^super sendInvokeCallbackContext: vmCallbackContext!
Item was changed:
CoInterpreterMT subclass: #CogVMSimulator
instanceVariableNames: 'parent enableCog byteCount lastPollCount lastExtPC sendCount lookupCount printSends traceOn myBitBlt displayForm fakeForm imageName pluginList mappedPluginEntries quitBlock transcript displayView eventTransformer printFrameAtEachStep printBytecodeAtEachStep systemAttributes uniqueIndices uniqueIndex breakCount atEachStepBlock startMicroseconds lastYieldMicroseconds externalSemaphoreSignalRequests externalSemaphoreSignalResponses extSemTabSize debugStackDepthDictionary performFilters eventQueue effectiveCogCodeSize expectedSends expecting'
+ classVariableNames: 'ByteCountsPerMicrosecond ExpectedSends NLRFailures NLRSuccesses StackAlteringPrimitives'
- classVariableNames: 'ByteCountsPerMicrosecond ExpectedSends NLRFailures NLRSuccesses'
poolDictionaries: ''
category: 'VMMaker-JITSimulation'!
!CogVMSimulator commentStamp: 'eem 9/3/2013 11:16' prior: 0!
This class defines basic memory access and primitive simulation so that the CoInterpreter can run simulated in the Squeak environment. It also defines a number of handy object viewing methods to facilitate pawing around in the object memory. Remember that you can test the Cogit using its class-side in-image compilation facilities.
To see the thing actually run, you could (after backing up this image and changes), execute
(CogVMSimulator new openOn: Smalltalk imageName) test
and be patient both to wait for things to happen, and to accept various things that may go wrong depending on how large or unusual your image may be. We usually do this with a small and simple benchmark image.
Here's an example to launch the simulator in a window. The bottom-right window has a menu packed with useful stuff:
(CogVMSimulator newWithOptions: #(Cogit StackToRegisterMappingCogit))
desiredNumStackPages: 8;
openOn: '/Users/eliot/Cog/startreader.image';
openAsMorph;
run
Here's a hairier example that I (Eliot) actually use in daily development with some of the breakpoint facilities commented out.
| cos proc opts |
CoInterpreter initializeWithOptions: (opts := Dictionary newFromPairs: #(Cogit StackToRegisterMappingCogit)).
CogVMSimulator chooseAndInitCogitClassWithOpts: opts.
cos := CogVMSimulator new.
"cos initializeThreadSupport." "to test the multi-threaded VM"
cos desiredNumStackPages: 8. "to set the size of the stack zone"
"cos desiredCogCodeSize: 8 * 1024 * 1024." "to set the size of the Cogit's code zone"
cos openOn: '/Users/eliot/Squeak/Squeak4.4/trunk44.image'. "choose your favourite image"
"cos setBreakSelector: 'r:degrees:'." "set a breakpoint at a specific selector"
proc := cos cogit processor.
"cos cogit sendTrace: 7." "turn on tracing"
"set a complex breakpoint at a specific point in machine code"
"cos cogit singleStep: true; breakPC: 16r56af; breakBlock: [:cg| cos framePointer > 16r101F3C and: [(cos longAt: cos framePointer - 4) = 16r2479A and: [(cos longAt: 16r101F30) = (cos longAt: 16r101F3C) or: [(cos longAt: 16r101F2C) = (cos longAt: 16r101F3C)]]]]; sendTrace: 1".
"[cos cogit compilationTrace: -1] on: MessageNotUnderstood do: [:ex|]." "turn on compilation tracing in the StackToRegisterMappingCogit"
"cos cogit setBreakMethod: 16rB38880."
cos
openAsMorph;
"toggleTranscript;" "toggleTranscript will send output to the Transcript instead of the morph's rather small window"
halt;
run!
Item was added:
+ ----- Method: CogVMSimulator class>>initialize (in category 'class initialization') -----
+ initialize
+ "These are primtiives that alter the state of the stack. They are here simply for assert checking.
+ After invocation the Cogit should not check for the expected stack delta when these primitives
+ succeed, because the stack will usually have been modified."
+ StackAlteringPrimitives := #( primitiveClosureValue primitiveClosureValueWithArgs primitiveClosureValueNoContextSwitch
+ primitiveEnterCriticalSection primitiveExitCriticalSection
+ primitiveFullClosureValue primitiveFullClosureValueWithArgs primitiveFullClosureValueNoContextSwitch
+ primitiveSignal primitiveWait primitiveResume primitiveSuspend primitiveYield
+ primitiveExecuteMethodArgsArray primitiveExecuteMethod
+ primitivePerform primitivePerformWithArgs primitivePerformInSuperclass
+ primitiveTerminateTo primitiveStoreStackp primitiveDoPrimitiveWithArgs) asIdentitySet!
Item was added:
+ ----- Method: CogVMSimulator class>>stackAlteringPrimitives (in category 'accessing') -----
+ stackAlteringPrimitives
+ ^StackAlteringPrimitives!
Item was changed:
----- Method: Cogit>>handleCallOrJumpSimulationTrap: (in category 'simulation only') -----
handleCallOrJumpSimulationTrap: aProcessorSimulationTrap
<doNotGenerate>
+ | evaluable function memory result savedFramePointer savedStackPointer savedArgumentCount retpc |
- | evaluable function memory result savedFramePointer savedStackPointer savedArgumentCount leaf retpc |
evaluable := simulatedTrampolines
at: aProcessorSimulationTrap address
ifAbsent: [self errorProcessingSimulationTrap: aProcessorSimulationTrap
in: simulatedTrampolines].
function := evaluable isBlock
ifTrue: ['aBlock; probably some plugin primitive']
ifFalse:
[evaluable receiver == backEnd ifTrue:
[^self handleABICallOrJumpSimulationTrap: aProcessorSimulationTrap evaluable: evaluable].
evaluable selector].
function ~~ #ceBaseFrameReturn: ifTrue:
[coInterpreter assertValidExternalStackPointers].
(backEnd wantsNearAddressFor: function) ifTrue:
[^self perform: function with: aProcessorSimulationTrap].
memory := coInterpreter memory.
+ processor
+ simulateCallOf: aProcessorSimulationTrap address
+ nextpc: aProcessorSimulationTrap nextpc
+ memory: memory.
+ retpc := processor retpcIn: memory.
+ self recordInstruction: {'(simulated call of '. aProcessorSimulationTrap address. '/'. function. ')'}.
- aProcessorSimulationTrap type == #call
- ifTrue:
- [(leaf := coInterpreter mcprims includes: function)
- ifTrue:
- [processor
- simulateLeafCallOf: aProcessorSimulationTrap address
- nextpc: aProcessorSimulationTrap nextpc
- memory: memory.
- retpc := processor leafRetpcIn: memory]
- ifFalse:
- [processor
- simulateCallOf: aProcessorSimulationTrap address
- nextpc: aProcessorSimulationTrap nextpc
- memory: memory.
- retpc := processor retpcIn: memory].
- self recordInstruction: {'(simulated call of '. aProcessorSimulationTrap address. '/'. function. ')'}]
- ifFalse:
- [leaf := false.
- processor
- simulateJumpCallOf: aProcessorSimulationTrap address
- memory: memory.
- retpc := processor retpcIn: memory. "sideways call; the primitive has pushed a return address."
- self recordInstruction: {'(simulated jump to '. aProcessorSimulationTrap address. '/'. function. ')'}].
function == #interpret ifTrue: "i.e. we're here via ceInvokeInterpret and should discard all state back to enterSmalltalkExecutiveImplementation"
[coInterpreter reenterInterpreter].
savedFramePointer := coInterpreter framePointer.
savedStackPointer := coInterpreter stackPointer.
savedArgumentCount := coInterpreter argumentCount.
result := ["self halt: evaluable selector."
clickConfirm ifTrue:
[(self confirm: 'skip run-time call?') ifFalse:
[clickConfirm := false. self halt]].
evaluable valueWithArguments: (processor
postCallArgumentsNumArgs: evaluable numArgs
in: memory)]
on: ReenterMachineCode
+ do: [:ex| ex return: #continueNoReturn].
- do: [:ex| ex return: ex returnValue].
coInterpreter assertValidExternalStackPointers.
"Verify the stack layout assumption compileInterpreterPrimitive: makes, provided we've
not called something that has built a frame, such as closure value or evaluate method, or
switched frames, such as primitiveSignal, primitiveWait, primitiveResume, primitiveSuspend et al."
(function beginsWith: 'primitive') ifTrue:
[coInterpreter primFailCode = 0
+ ifTrue: [(CogVMSimulator stackAlteringPrimitives includes: function) ifFalse:
- ifTrue: [(#( primitiveClosureValue primitiveClosureValueWithArgs primitiveClosureValueNoContextSwitch
- primitiveFullClosureValue primitiveFullClosureValueWithArgs primitiveFullClosureValueNoContextSwitch
- primitiveSignal primitiveWait primitiveResume primitiveSuspend primitiveYield
- primitiveExecuteMethodArgsArray primitiveExecuteMethod
- primitivePerform primitivePerformWithArgs primitivePerformInSuperclass
- primitiveTerminateTo primitiveStoreStackp primitiveDoPrimitiveWithArgs)
- includes: function) ifFalse:
["This is a rare case (e.g. in Scorch where a married context's sender is set to nil on trapTrpped and hence the stack layout is altered."
(function == #primitiveSlotAtPut and: [objectMemory isContext: (coInterpreter frameReceiver: coInterpreter framePointer)]) ifFalse:
[self assert: savedFramePointer = coInterpreter framePointer.
self assert: savedStackPointer + (savedArgumentCount * objectMemory wordSize)
= coInterpreter stackPointer]]]
ifFalse:
[self assert: savedFramePointer = coInterpreter framePointer.
self assert: savedStackPointer = coInterpreter stackPointer]].
result ~~ #continueNoReturn ifTrue:
[self recordInstruction: {'(simulated return to '. processor retpcIn: memory. ')'}.
+ processor simulateReturnIn: memory.
- leaf
- ifTrue: [processor simulateLeafReturnIn: memory]
- ifFalse: [processor simulateReturnIn: memory].
self assert: processor pc = retpc.
processor smashCallerSavedRegistersWithValuesFrom: 16r80000000 by: objectMemory wordSize in: memory].
self assert: (result isInteger "an oop result"
or: [result == coInterpreter
or: [result == objectMemory
+ or: [result == nil
+ or: [result == #continueNoReturn]]]]).
- or: [#(nil continue continueNoReturn) includes: result]]]).
processor cResultRegister: (result
+ ifNil: [0]
+ ifNotNil: [result isInteger
+ ifTrue: [result]
+ ifFalse: [16rF00BA222]])!
- ifNil: [0]
- ifNotNil: [result isInteger
- ifTrue: [result]
- ifFalse: [16rF00BA222]])
-
- "coInterpreter cr.
- processor sp + 32 to: processor sp - 32 by: -4 do:
- [:sp|
- sp = processor sp
- ifTrue: [coInterpreter print: 'sp->'; tab]
- ifFalse: [coInterpreter printHex: sp].
- coInterpreter tab; printHex: (coInterpreter longAt: sp); cr]"!
Item was changed:
----- Method: Cogit>>simulateEnilopmart:numArgs: (in category 'simulation only') -----
simulateEnilopmart: enilopmartAddress numArgs: n
<doNotGenerate>
"Enter Cog code, popping the class reg and receiver from the stack
and then returning to the address beneath them.
In the actual VM the enilopmart is a function pointer and so senders
of this method end up calling the enilopmart to enter machine code.
In simulation we either need to start simulating execution (if we're in
the interpreter) or return to the simulation (if we're in the run-time
called from machine code. We should also smash the register state
since, being an abnormal entry, no saved registers will be restored."
self assert: (coInterpreter isOnRumpCStack: processor sp).
self assert: (n = 0 or: [(coInterpreter stackValue: n) between: guardPageSize and: methodZone freeStart - 1]).
(printInstructions or: [printRegisters]) ifTrue:
[coInterpreter printExternalHeadFrame].
processor
smashRegistersWithValuesFrom: 16r80000000 by: objectMemory wordSize;
simulateLeafCallOf: enilopmartAddress
nextpc: 16rBADF00D
memory: coInterpreter memory.
"If we're already simulating in the context of machine code then
this will take us back to handleCallSimulationTrap:. Otherwise
start executing machine code in the simulator."
+ ReenterMachineCode new signal.
- (ReenterMachineCode new returnValue: #continueNoReturn) signal.
self simulateCogCodeAt: enilopmartAddress.
"We should either longjmp back to the interpreter or
stay in machine code so control should not reach here."
self assert: false!
Item was changed:
----- Method: StackInterpreter>>cannotAssign:to:withIndex: (in category 'stack bytecodes') -----
cannotAssign: resultObj to: targetObj withIndex: index
<option: #IMMUTABILITY>
<inline: true> "because of use of normalSend..."
self internalPush: targetObj.
self internalPush: resultObj.
+ self internalPush: (objectMemory integerObjectOf: index + 1).
+ messageSelector := objectMemory splObj: SelectorAttemptToAssign.
- self internalPush: (self integerObjectOf: index + 1).
- messageSelector := self splObj: SelectorAttemptToAssign.
argumentCount := 2.
^ self normalSend!
Item was changed:
----- Method: StackInterpreter>>sendInvokeCallback:Stack:Registers:Jmpbuf: (in category 'callback support') -----
sendInvokeCallback: thunkPtr Stack: stackPtr Registers: regsPtr Jmpbuf: jmpBufPtr
"Send the 4 argument callback message invokeCallback:stack:registers:jmpbuf:
to Alien class with the supplied args. The arguments are raw C addresses
and are converted to integer objects on the way."
<export: true>
| classTag |
+ classTag := self fetchClassTagOfNonImm: (objectMemory splObj: ClassAlien).
- classTag := self fetchClassTagOfNonImm: (self splObj: ClassAlien).
messageSelector := self splObj: SelectorInvokeCallback.
argumentCount := 4.
(self lookupInMethodCacheSel: messageSelector classTag: classTag) ifFalse:
[(self lookupOrdinaryNoMNUEtcInClass: (objectMemory classForClassTag: classTag)) ~= 0 ifTrue:
[^false]].
((self argumentCountOf: newMethod) = 4
and: [primitiveFunctionPointer = 0]) ifFalse:
[^false].
self push: (self splObj: ClassAlien). "receiver"
self push: (self positiveMachineIntegerFor: thunkPtr).
self push: (self positiveMachineIntegerFor: stackPtr).
self push: (self positiveMachineIntegerFor: regsPtr).
self push: (self positiveMachineIntegerFor: jmpBufPtr).
self ifAppropriateCompileToNativeCode: newMethod selector: messageSelector.
self justActivateNewMethod: false. "either interpreted or machine code"
(self isMachineCodeFrame: framePointer) ifFalse:
[self maybeFlagMethodAsInterpreted: newMethod].
self checkForStackOverflow.
self enterSmalltalkExecutiveFromCallback.
"not reached"
^true!
Ah Ah, but then I see a debugger with stack setupWindowProc...
Error Case not found PointerFFICallbackThunk...
So I suggest to amend line 2263 of sqWin32Window.c (#if 1) recompile, debug newspeak, then return to regular VM.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/151#issuecomment-6…
If I remove the guard at line 2263 and recompile the VM, I see the newspeak window appear...
So it looks like an essential call to `ShowWindow` is missing or failed (via FFI???).
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/151#issuecomment-6…
The UI does not open, neither on 32bits nor 64bits VM, so this is probably not related to X64 ABI.
I put a break in ioShowDisplay with gdb and the VM is going there (via primitiveShowDisplayRect).
It is painting a region of a bitmap.
But since the window is not visible (hidden?) nothing seems to happen...
I'm not a specialist of windows UI, but there must be some obvious GUI call missing...
There should be a `ShowWindow(stWindow,SW_SHOW)` or something like that.
There is one in `ioForceDisplayUpdate()` but only `#if !NewspeakVM`.
It is suggested that Newspeak has to explicitely emit such request...
See https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/36270b33202975eee7ad…
I have checked the history of platforms/win32 around may/june 2016, not much happened there...
https://github.com/OpenSmalltalk/opensmalltalk-vm/commits/Cog?after=36270b3…
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/151#issuecomment-6…
Solaris fixes
You can view, comment on, or merge this pull request online at:
https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/490
-- Commit Summary --
* Solaris fixes. Add build.sunos32x86
* Add build.sunosamd64 for 64bit on Solaris
* Add Solaris IPS manifest.
* Change docdir from /usr/doc to /usr/share/doc. Set version to 5.3.1
* Update IPS manifest for version 5.3.1. Include doc/LICENSE.gz file.
* Compilation SunPro sqUnixITimerHeartbeat
* Use FASYNC on __sun__ instead of FIOASYNC
* Put back VM_VERSION to 5.0
* IPS manifest used for squeak5(a)5.3.1
* Define MIX / MAX so that vm-sound-pulse.so loads.
* make vm-sound-pulse the default
* Compile on Solaris with --disable-dynamicopenssl
* Compile on Solaris with --disable-dynamicopenssl
* Include opensslv to define OPENSSL_VERSION_NUMBER
* Remove -g debug flag for 32bit build
* Rename build.sunosamd64 to build.sunos64x64
* Make vm-sound-pulse first plugin in Solaris case.
* Set INSTALLDIR to sqcogspursunosht/usr for Solaris
* Set INSTALLDIR to sqcogspursunos for itimer build
* Add IPS package build info to 32bit build.
* Fix INSTALLDIR doc
* Set INSTALLDIR to sqcogspur64sunos[ht] in 64 solaris
* Remove --libdir option
* Refer to HowToBuild in 64bit instead of duplicating everything.
* Add script to build IPS package
* Set ac_cv_cflags_warn_all="-v" instead of ""
* Copy 'ckformat' into Solaris IPS package so that VM32 can be used for 6521 image and VM64 can be used for 68021 images
* Add ckformat program to IPS manifest
* Merge pull request #1 from OpenSmalltalk/Cog
* Add reminder in HowToBuild on running scripts/updateSCCSVersions
* Change __SUNPRO_C to __sun so compile also works with GCC
* Replace __SUNPRO_C by __sun so that compile also works with GCC for Solaris
* Change __SUNPRO_C to __sun for succesful build with gcc 7.3 and gcc 9.2
* Build Squeak Stack Spur in addition to Cog Spur on Solaris
* set INSTALLDIR to sqstkspursunosht/usr
* Merge pull request #2 from OpenSmalltalk/Cog
* Merge Solaris changes into SunOS branch
* Remove ac_cv_cflags_warn_all from mvm files for gcc build
* Add -g option for gcc build
* Update IPS package for 5.0.4
* Add build version 5.0-202004221445-sunos
-- File Changes --
M build.linux64x64/squeak.cog.spur/build.itimerheartbeat/mvm (4)
A build.sunos32x86/HowToBuild (34)
A build.sunos32x86/squeak.cog.spur/build/mvm (38)
A build.sunos32x86/squeak.cog.spur/plugins.ext (16)
A build.sunos32x86/squeak.cog.spur/plugins.int (38)
A build.sunos32x86/squeak.stack.spur/build/mvm (38)
A build.sunos32x86/squeak.stack.spur/plugins.ext (13)
A build.sunos32x86/squeak.stack.spur/plugins.int (38)
A build.sunos64x64/HowToBuild (157)
A build.sunos64x64/squeak.cog.spur/build.itimerheartbeat/mvm (31)
A build.sunos64x64/squeak.cog.spur/build/mvm (38)
A build.sunos64x64/squeak.cog.spur/make-ips-pkg.sh (91)
A build.sunos64x64/squeak.cog.spur/plugins.ext (16)
A build.sunos64x64/squeak.cog.spur/plugins.int (38)
A build.sunos64x64/squeak.cog.spur/squeak.ips (75)
A build.sunos64x64/squeak.cog.spur/squeak5.p5m (133)
A build.sunos64x64/squeak.cog.spur/squeak5.p5m.mog (4)
A build.sunos64x64/squeak.stack.spur/build/mvm (30)
A build.sunos64x64/squeak.stack.spur/plugins.ext (13)
A build.sunos64x64/squeak.stack.spur/plugins.int (38)
M platforms/Cross/plugins/IA32ABI/ia32abicc.c (4)
M platforms/Cross/plugins/IA32ABI/x64sysvabicc.c (2)
M platforms/Cross/vm/sqAtomicOps.h (7)
M platforms/Cross/vm/sqMemoryFence.h (2)
M platforms/unix/config/make.cfg.in (2)
M platforms/unix/plugins/SqueakSSL/openssl_overlay.h (5)
M platforms/unix/plugins/SqueakSSL/sqUnixOpenSSL.inc (9)
M platforms/unix/vm-sound-pulse/sqUnixSoundPulseAudio.c (7)
M platforms/unix/vm/aio.c (1)
M platforms/unix/vm/include_ucontext.h (4)
M platforms/unix/vm/sqUnixExternalPrims.c (8)
M platforms/unix/vm/sqUnixHeartbeat.c (4)
M platforms/unix/vm/sqUnixITimerHeartbeat.c (4)
M platforms/unix/vm/sqUnixMain.c (10)
M scripts/checkSCCSversion (2)
-- Patch Links --
https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/490.patchhttps://github.com/OpenSmalltalk/opensmalltalk-vm/pull/490.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/490
This should be resolved in latest VM (including the one distributed with Squeak 5.3).
Report problems if persisting after the upgrade.
I close this issue
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/49#issuecomment-61…