Skip to content
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

Pullrequest/vmmaker #305

Closed
wants to merge 3,302 commits into from
Closed

Conversation

eliotmiranda
Copy link
Contributor

Initial pull request to include VMMaker source in opensmalltalk-vm repo.

Things that still need to be done before we can move to this version:

  • provide access to the Smalltalk part of the repo (Tonel format) from Squeak.
  • plugin source still needs to be included.

David T. Lewis and others added 30 commits November 8, 2018 10:28
…ss for both Spur and V3. Add testBit17AsTestFor64BitImages to document this.

The changes in ImageFormat-dtl.20 for format numbers 68019 and 68021 were missing test support, add it here.
Make sure the accessor depths of optional primitives are emitted as conditionals.
…Old code would allocate if num indexable slots was 0, but would zero-fill. New code has the fixed old code ifdef'ed out and always fails. We can make the old code work for Squeak if required, but since no one's noticed DirectoryEntry crashing the system this shouldn't be an issue. If peopel feel strongly about the ugly old code simply delete it.

Fix Slang so that e.g. cppIf: (PharoVM or: [true]) ifTrue: aBlock => aBlock
…ferentiate the closedPICs from the openPICs in the profiling report
… to display the differenciation open/closedPICs

* remove unused method (VMFileSystem, which has been replaced)

To do :
* In the textual report, the display of the number of samples and the cumulated percentages tends to get messy (non aligned) for no reason. I'll try to fix it later
Fix the crash for 2009 nthRoot: 100000 due to digitDivLarge:with:negative: failing to check if allocations fail.  The example produces 600k byet long integers and so provokes plenty of allocation failures.

In addition mark some support methods as <inline: #always> to eliminate their unnecessary uninlined versions.
The OmterpreterProxy/sqVirtualMachine.h API (e.g. in the ThreadedFFIPlugin) expects instantiateClass:indexableSize: to work with 0 indexable size for fixed classes.  So remove the cppIf:... from the Spur implementation.

ObjectMemory:
Eliminate the header2 variable in a few routines.  It is always the same as classPointer.

General:
If ioScreenSize answers a zero screen extent (as is the case for headless images) then on snapshot write the sawvedWindowSize rather thna the zero extent.  This should fix the experience people have with Pharo of saving headless images that then come up with a zero sized window when started headful.
…again, if ioScreenSize answers a zero screen extent (as is the case for headless images) then on snapshot write the sawvedWindowSize rather thna the zero extent. This should fix the experience people have with Pharo of saving headless images that then come up with a zero sized window when started headful.
* add some comments
Simplify cleverSwapHeaders:and:copyHashFlag: via xor.
Fix the type of currentAllocatedBytes given the Slang changes below.

Slang:
Fix a regression caused by the Slang fixes in VMMaker.oscog-eem.2243.
Since inferTypesForImplicitlyTypedVariablesIn: no longer sets the types of locals as it goes along (which was incorrect) we can no longer default the types of untyped variables to sqInt for the purposes of returnTypeForSend:in:ifNil:.  To allow returnTypeForSend:in:ifNil: to answer nil for arithmetic on untyped expressions typeForArithmetic:in: uses TParseNode>>typeOrNilFrom:in: instead of CCodeGenerator>>typeFor:in: to avoid the defaulting.  returnTypeForSend:in:ifNil: has been refactored to use the more direct TParseNode>>typeFrom:in: instead of CCodeGenerator>>typeFor:in: for clarity.
Teh regression caused Slang to fail to infer the types of remembered1/2 & hash1/2 in cleverSwapHeaders:and:copyHashFlag:.  The new code correctly infers the types of remembered & hashBits as sqLong.

SoundPlugin:
Eliminate a couple of warnings by using 0 instead of NULL.
Allow plugins to use sends to access struct members.
To this end replace all sends of TSendNode>>isStructSendIn: with CCodeGenerator>>isStructSend:.

Plugins wanting to use this facility must override InterpreterPlugin>>#isStructType: to answer true for types denoting structs.

There's probably more work to be done (e.g. to TSendNode>>structTargetKindIn: which sends to VMStructType directly).  Biut this is enough for the FileAttributesPlugin.
…rings were made to share code between different part of the GC, but no new things). I tried to simulate the whole VM and generate a VM and it works, but only Travis can confirm us everything's ok.

This is the first commit for the work done in the direction of a low pause GC. The work is split in two, an "engineering" part which consists in incremental marking derived from Dijkstra tri-color, and a "research" part which consists in selective compaction of the heap reusing forwarding objects.

This commit introduces SpurCompactor, an abstract class over the available compactors (Pig, Planning and the experimental ones). The full GC work is divided in Spur in two phases, the marking phase (incremental or not) and the compaction phase (Pig, planning or the experimental ones). 

The new compactor I want to build (SpurSelectiveCompactor) is a sweep algorithm which also compacts part of the heap. I started to do it in 2 steps. First I added SpurSweeper, a compactor which does not compact (if the programmer choose SpurSweeper as the compaction phase, the fullGC is a mark-sweep algorithm). Second I added SpurSelectiveCompactor, which reuses SpurSweeper to sweep the heap. We note that as these new compactors are not compacting the full heap, they should not be used for snapshots, hence snapshots use another compactor (currently SpurPlanningCompactor instead).
…fullGC to a mark-sweep algorithm when enabled.

Still need to check:
- SpurSweeper for snapshot
- Compilation to C (where I may need help since spurSweeper needs to call another comapctor for snapshots)
…d a VM with SpurSweeper and it worked just fine, handling many GCs.

I need to talk with Eliot about how to use another ompactor for snapshots. Once done, I can start working on the SelectiveCompactor.
…hie how to write code in the JIT, so we did that together). We implemented only the quick paths for byte objects and array-like objects.

Can't wait to see people like Levente benching these things again. Aside from the copying loops, I am pretty sure the machine code generated can be improved - but we see the 2x perf boost on copies of less than 10 elements, which is the main case I wanted to speed up.
…ough memory in old space. Allocates an extra memory segment in that case. This is very uncommon.

 
Please check the thread: "[Vm-dev] VM crash with message 'could not grow remembered set' " to reproduce the problem.
…>log:with:* for API. See Slang changes below for support.

Use the logging facility to log scavenges. Each scavenge produces output such as

scavenge 31 eden bytes: 0x2cfaf00/47165184 past bytes: 0x17c618/1558040
	remembered set: 73 redzone: 98304 size: 131072
	tenure below 0x0/0 by age
	survivor bytes: 0x17dd90/1564048 remembered objects: 73 tenured: 0

Slang:
Add the notion of a varargs selector (currently anything ending in printf:, such as f:printf:).  Transform sends of such selectors with a brace of arguments into a varargs call (i.e. include all the arguments in the brace).

When inlining, if the method being inlined is of the form
	guard ifTrue: [...]
and the argument assignments are side-effect free,
and the guard does not refer to the arguments,
push the argument assignments past the guard into the block so that they too are guarded.
…teStream.

Slang: Now that scavengeLog is typed isFunctionalIn: must accept FILE * as an acceptable return type of a functional method.
Revise scavenger logging to collect data during the scavenge and log it to the file after the scavenge, hence including an accurate elapsed time.

Consequently nuke the log: methods in VMClass; they arent needed, which neatly avoids the issue of multiple classes needing to define logStream.

Slang:
Output the printf format string using the LP64/LLP64 convention in sqMemoryAccess.h
…on routines in 64-bits would cause 64-but sources to be generated. This caused the recent misgeneration of src/vm/cogit.c.

Do not inherit from VMMaker.oscog-eem.2279 which msidiagnosed the problem.

Slang: Back out of the inlining optimization used in the logging methods that are now unused.  Better format a method.
unskew is a signed bitShift and must remain signed.
Strength reduce the loop split for combinationRule = 3 so that less tests are done in the inner loop and so trhat when combinstionRule = 3 mergeFn is never used.  Use an explicit type declaration for unskew instead of trickier relying on type inference.  Eliminate bogus use of #== for numeric comparison.
akgrant and others added 18 commits November 8, 2018 10:45
Add VMClass>>asByteArray:size:.

Modify:

- FilePluginSimulator>>fileOpenName:size:write:secure:
- FilePluginSimulator>>fileOpenNewName:size:secure:

to utf8Decode the paths supplied by the in-simulation image.  This is required otherwise the simulation, which uses the same code, will attempt to reencode the string with utf8, corrupting the file name.
Fix a bug in FloatArrayPlugin>>primitiveDivFloatArray; the old code a) didn't check for -0.0 and b) didn't simulate.  Eliminate several unnecessary stackObjectValue:'s in Matrix2x3Plugin; isWords: checkxs for immediates anyway.  Fix several comments in FloatArrayPlugin primitives.

Simulator:
Fix simulation of the FloatArrayPlugin & Matrix2x3Plugin. Key is to implement cCoerce:to: in InterpreterPlugin to correctly coerce CArrays (as in self cCoerce: (interpreterProxy firstIndexableField: matrix) to: #'float *'), and to have CFloatArray>>at:put: convert floats via asIEEE[32|64]BitWord.  Also fix coercion of CFloatArray back to CArray.  Add Matrix2x3PluginSimulator to check primitiveComposeMatrix simulates correctly (there appear to be no tests; FloatArrayPluygin has a test suite).

Improve the performance of some of the C library simulations slightly and simplify where possible (basicAt:[put:] on strings fetch/store integers).
BalloonEngine & simulation.  Clean up primitiveInitializeBuffer.  Make some initial fixes to BalloonArray (the simulation of the engine's work buffer).  I have other fish to fry right now but this is a stab in the right direction.
Fix a regression in VMMaker.oscog-eem.2467.

Slang: special case coercing a Float literal to #float, emitting it as N.Mf
Fix a regression in memcpy:_:_: in VMMaker.oscog-eem.2467.  Make malloc: simuulate a la alloca:.
…m for VMClass>>malloc:.

Ronie, if I've broken Lowcode simulation I apologise, and want to work on fixing it (perhaps with you?) but I have no test cases.
- #isCArray is true if the receiver provides the interface.
- FilePluginSimulator>>sqFileDeleteName:Size: handles UTF8 character names
-- TODO: Method to be renamed.
- Add InterpreterPlugin>>memcpy:_:_: to delegate to the interpreter proxy
- Remove SpurMemoryManager>>memcpy:_:_: this looks like it was created before VMClass>>memcpy:_:_:, but doesn't handle different argument types.
- Add InterpreterPlugin>>memmove:_:_: to delegate to the interpreter proxy.
- InterpreterPrimitives>>getenv: handle CArrayAccessor.
- InterpreterPrimitives>>primitiveGetenv remove #cCode:inSmalltalk:.
- Add VMClass>>asByteArray: to handle UTF8 strings (which shouldn't be a String)
- VMClass>>memcpy:_:_: handle different parameter types
- VMClass>>strlen: handle CArray(Accessor)s
- VMClass>>strncpy:_:_: handle CArrayAccessors
This allows LocalTimeZone>>primOffset to succeed, setting the same timezone within the simulated image to the value of the simulator timezone.
Make directory names in VMMaker work on FileSystem as well as FileDirectory; a first step to being able to generate sources on Pharo.  Eliminate the obsolete machinesDirName.  Remove unnecessary overrides of shouldBeTranslated (the default is ^true).  Make baseTypeForType: answer e.g. 'int *' for the type 'int*', to comnform to the style I use in coerceTo:sim: and Slang type inferrence.

Simulator:
Fix a bug in strlen: with CArrays.

Restore SpurMemoryManager>>memmove:_:_: for performance but implement it better, adapting to whether memory is a DoubleWordArray or a WordArray.

Revise instantiating plugin simulators.  Remove all the hierarchy searching hacks in tryLoadNewPlugin:pluginEntries: & loadNewPlugin: and nuke newFor:, replacing this with simulatorForInterpreterInterface:.  Add a test, StackInterpreterSimulatorTests>>testPluginSimulators, to check that plugin simulators are instantiated as expected.  Consequently implement some unimplemented coercions in SmartSyntaxPluginSimulator, and fix its doesNotUnderstand: method to not cut back plugin arguments twice (in plugins that mix smart syntax and traditional style).

No longer answer nil from SmartSyntaxInterpreterPlugin class>>simulatorClass, making the defailt to simulate, rather than not.  Make initial attempts at simulating the BalloonEnginePlugin (B2DPlugin) using the rewrite engine to automatically generate overrides for methods that use 32-bit arithmetic.

Simplify simulation of the LocalePlugin; LocalePluginSimulator is not needed.

Move evaluateIfFailed: up to InterpreterPlugin; it is generally useful.

Fix simulation of primitiveCompareColors
Fix primDigitCompare for SmallIntegers.  The old code compared the values of the receiver and argument, not their magnitudes, if both were SmallIntegers.

Simplify the FilePlugin. removing an unnecessary indirection around dir_Delimitor, and eliminating an unnecessary cCode:inSmalltalk:.

Simulator:
Fix a regression with FilePlugin loading due to the simplifications to simulated plugin loading introduced in VMMaker.oscog-eem.2476.  mappedPluginEntries must be extended, not assigned to.

Disable simulation for ClipboardExtendedPlugin.  This would be a good exercise for someone who wanted to try writing a plugin simulation themselves, hint, hint.
Fix slip in primitiveDirectoryDelimitor.
Eliminate cCode:inSmalltalk:'s from the B3DAcceleratorPlugin
Provide simulation stubs for the B3DAcceleratorPlugin C api.

Slang:
Provide some clean up of pointer types in TMethods and type extraction, ensuring there's a space before any trailing *'s.
Fix a bug passing floats on the stack on X64.  The original code passed stacked floats as doubles.
Mark ffiPush*Float:in: as <inline: #always> since they are inined and this eliminates unused functions.
Add some commentary to stack alignment methods to aid locating associated defines.
@nicolas-cellier-aka-nice
Copy link
Contributor

Hi Eliot, great work!
It seems that history graph is flatten though.
This generates strange diffs for parallel branches.
Also a (Tonel?) bug flips compound category from Symbol to String et vice et versa, which generates spurious diffs...
Which tool did you use for the mc->git conversion?

@georgeganea
Copy link

Hi Nicolas,
We used https://github.com/peteruhnak/git-migration.
We selected the packages
#('Balloon-Engine-Pools' 'BytecodeSets.spur' 'VMMaker' 'VMMaker.oscog' 'Cog' 'CogTools' 'ImageFormat' 'VMMakerCompatibilityForPharo6' 'Android-Base' 'CMakeVMMaker' 'CMakeVMMakerSqueak' 'CogAttic' 'CogBenchmarks' 'CogCompatibility' 'CogTools-Listener' 'ImageFormat' 'MemoryAccess' 'Qwaq-VMProfiling' 'SlangBrowser' 'VMM-touch-temp' 'VMMakerCompatibilityForPharo6' 'VMMakerExtras' 'VMMakerJS'), and the migration tool just creates a long line of commits.

@georgeganea
Copy link

Could you please post an example for "strange diffs for parallel branches" and also for the "compound category from Symbol to String et vice et versa"?

@nicolas-cellier-aka-nice
Copy link
Contributor

Example of String/Symbol mess: find the real changes in:

4accb9e

Example of parallel branches mess:

This commit is a merge of VMMaker.oscog-nice.2109 and VMMaker.oscog-eem.2109, and thus should have 2 parents instead of one:
d5fae5a

Its parent is VMMaker.oscog-nice.2109
af7947f

and its parent has been marked incorrectly as VMMaker.oscog-eem.2109
a97aba9

We thus see diffs between two different branches VMMaker.oscog-nice.2109 and VMMaker.oscog-eem.2109 which is completely irrelevant...

Also, it would be good to append the name of original Monticello package (and why not URL) at the end of the commit message for easing diagnostics!

@nicolas-cellier-aka-nice
Copy link
Contributor

parallel branch problems is now peteruhnak/git-migration#18

@georgeganea
Copy link

parallel branch problems is now peteruhnak/git-migration#18

Very cool!

@georgeganea
Copy link

I did pharo-vcs/tonel#63.

@georgeganea georgeganea deleted the pullrequest/vmmaker branch November 20, 2018 15:38
@krono
Copy link
Member

krono commented Sep 10, 2020

This looks a bit outdated, no?

tesonep pushed a commit to tesonep/opensmalltalk-vm that referenced this pull request Sep 2, 2021
…tNode

Added tests and translation on Labelled Comment nodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants