Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.1085.mcz
==================== Summary ====================
Name: Kernel-eem.1085
Author: eem
Time: 3 April 2017, 4:53:09.025064 pm
UUID: 0ed0802d-4a76-4345-a33a-ff400094a7d9
Ancestors: Kernel-eem.1084
Get the fix for the EToys ScriptEncoder right.
=============== Diff against Kernel-eem.1084 ===============
Item was changed:
----- Method: CompiledCode class>>headerFlagForEncoder: (in category 'method encoding') -----
headerFlagForEncoder: anEncoder
anEncoder class == PrimaryBytecodeSetEncoderClass ifTrue:
[^0].
anEncoder class == SecondaryBytecodeSetEncoderClass ifTrue:
[^SmallInteger minVal].
"This allows subclasses for compiler variants such as the ScriptEncoder in EToys
to continue to function."
(anEncoder class inheritsFrom: PrimaryBytecodeSetEncoderClass) ifTrue:
+ [^0].
- [^self headerFlagForEncoder: PrimaryBytecodeSetEncoderClass].
(anEncoder class inheritsFrom: SecondaryBytecodeSetEncoderClass) ifTrue:
+ [^SmallInteger minVal].
- [^self headerFlagForEncoder: SecondaryBytecodeSetEncoderClass].
self error: 'The encoder is not one of the two installed bytecode sets'!
Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.1084.mcz
==================== Summary ====================
Name: Kernel-eem.1084
Author: eem
Time: 3 April 2017, 4:45:38.181168 pm
UUID: 131f851c-368d-42aa-b28b-5a07ae8cb7f6
Ancestors: Kernel-eem.1083
Oops, the changes reported in Compiler-eem.339 are here, to whit:
Fix a restriction in BytecodeEncoder>>computeMethodHeaderForNumArgs:numTemps:numLits:primitive: that caused EToys to have to implement an unnecessary override.
Fix the literal limit in that same method. The max number of literals is 32767 now that we reserve bit 15 for the "do not jit-compile with counters' bit in Sista VMs.
=============== Diff against Kernel-eem.1083 ===============
Item was changed:
----- Method: CompiledCode class>>headerFlagForEncoder: (in category 'method encoding') -----
headerFlagForEncoder: anEncoder
anEncoder class == PrimaryBytecodeSetEncoderClass ifTrue:
[^0].
anEncoder class == SecondaryBytecodeSetEncoderClass ifTrue:
[^SmallInteger minVal].
+ "This allows subclasses for compiler variants such as the ScriptEncoder in EToys
+ to continue to function."
+ (anEncoder class inheritsFrom: PrimaryBytecodeSetEncoderClass) ifTrue:
+ [^self headerFlagForEncoder: PrimaryBytecodeSetEncoderClass].
+ (anEncoder class inheritsFrom: SecondaryBytecodeSetEncoderClass) ifTrue:
+ [^self headerFlagForEncoder: SecondaryBytecodeSetEncoderClass].
self error: 'The encoder is not one of the two installed bytecode sets'!
Eliot Miranda uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-eem.339.mcz
==================== Summary ====================
Name: Compiler-eem.339
Author: eem
Time: 3 April 2017, 4:41:32.232382 pm
UUID: fc3a8d3e-45e0-4d89-adde-ae01ce361263
Ancestors: Compiler-eem.338
Have the Parser obey the bytecode set preference in CompiledCode preferredBytecodeSetEncoderClass. Fix a restriction in BytecodeEncoder>>computeMethodHeaderForNumArgs:numTemps:numLits:primitive: that caused EToys to have to implement an unnecessary override.
Fix the literal limit in that same method. The max number of literals is 32767 now that we reserve bit 15 for the "do not jit-compile with counters' bit in Sista VMs.
=============== Diff against Compiler-eem.338 ===============
Item was changed:
----- Method: BytecodeEncoder>>computeMethodHeaderForNumArgs:numTemps:numLits:primitive: (in category 'method generation') -----
computeMethodHeaderForNumArgs: numArgs numTemps: numTemps numLits: numLits primitive: primitiveIndex
numArgs > 15 ifTrue:
[^self error: 'Cannot compile -- too many arguments'].
numTemps > 63 ifTrue:
[^self error: 'Cannot compile -- too many temporary variables'].
+ numLits > 32767 ifTrue:
- numLits > 65535 ifTrue:
[^self error: 'Cannot compile -- too many literals'].
^(CompiledMethod headerFlagForEncoder: self)
+ (numArgs bitShift: 24)
+ (numTemps bitShift: 18)
"+ (largeBit bitShift: 17)" "largeBit gets filled in later"
+ (primitiveIndex > 0 ifTrue: [1 bitShift: 16] ifFalse: [0])
+ "+ (optimizedBit bitShift: 15)" "Sista marker may get filled in later"
+ numLits!
Item was changed:
----- Method: Parser>>encoder (in category 'public access') -----
encoder
^encoder ifNil:
+ [encoder := CompiledMethod preferredBytecodeSetEncoderClass new]!
- [encoder := EncoderForV3PlusClosures new]!
Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.1083.mcz
==================== Summary ====================
Name: Kernel-eem.1083
Author: eem
Time: 3 April 2017, 4:27:59.818532 pm
UUID: 68311a56-626f-485c-a805-9922c04ed7e4
Ancestors: Kernel-eem.1082
Add a class variable for setting and holding the preferred bytecode set to use, along with a preference that uses the new code in PreferenceBrowser-eem.80.
=============== Diff against Kernel-eem.1082 ===============
Item was changed:
ByteArray variableByteSubclass: #CompiledCode
instanceVariableNames: ''
+ classVariableNames: 'LargeFrame PreferredBytecodeSetEncoderClass PrimaryBytecodeSetEncoderClass SecondaryBytecodeSetEncoderClass SmallFrame'
- classVariableNames: 'LargeFrame PrimaryBytecodeSetEncoderClass SecondaryBytecodeSetEncoderClass SmallFrame'
poolDictionaries: ''
category: 'Kernel-Methods'!
!CompiledCode commentStamp: 'eem 3/23/2017 14:33' prior: 0!
CompiledCode instances are methods suitable for execution by the virtual machine. Instances of CompiledCode and its subclasses are the only objects in the system that have both indexable pointer fields and indexable 8-bit integer fields. The first part of a CompiledCode object is pointers, the second part is bytes. CompiledCode inherits from ByteArray to avoid duplicating some of ByteArray's methods, not because a CompiledCode is-a ByteArray.
Instance variables: *indexed* (no named inst vars)
Class variables:
SmallFrame - the number of stack slots in a small frame Context
LargeFrame - the number of stack slots in a large frame Context
PrimaryBytecodeSetEncoderClass - the encoder class that defines the primary instruction set
SecondaryBytecodeSetEncoderClass - the encoder class that defines the secondary instruction set
The current format of a CompiledCode object is as follows:
header (4 or 8 bytes, SmallInteger)
literals (4 or 8 bytes each, Object, see "The last literal..." below)
bytecodes (variable, bytes)
trailer (variable, bytes)
The header is a SmallInteger (which in the 32-bit system has 31 bits, and in the 64-bit system, 61 bits) in the following format:
(index 0) 15 bits: number of literals (#numLiterals)
(index 15) 1 bit: jit without counters - reserved for methods that have been optimized by Sista
(index 16) 1 bit: has primitive
(index 17) 1 bit: whether a large frame size is needed (#frameSize => either SmallFrame or LargeFrame)
(index 18) 6 bits: number of temporary variables (#numTemps)
(index 24) 4 bits: number of arguments to the method (#numArgs)
(index 28) 2 bits: reserved for an access modifier (00-unused, 01-private, 10-protected, 11-public), although accessors for bit 29 exist (see #flag).
sign bit: 1 bit: selects the instruction set, >= 0 Primary, < 0 Secondary (#signFlag)
If the method has a primitive then the first bytecode of the method must be a callPrimitive: bytecode that encodes the primitive index. This bytecode can encode a primitive index from 0 to 65535.
The trailer is an encoding of an instance of CompiledMethodTrailer. It is typically used to encode the index into the source files array of the method's source, but may be used to encode other values, e.g. tempNames, source as a string, etc. See the class CompiledMethodTrailer.
While there are disadvantages to this "flat" representation (it is impossible to add named instance variables to CompiledCode or its subclasses, but it is possible indirectly; see AdditionalMethodState) it is effective for interpreters. It means that both bytecodes and literals can be fetched directly from a single method object, and that only one object, the method, must be saved and restored on activation and return. A more natural representation, in which there are searate instance variables for the bytecode, and (conveniently) the literals, requires either much more work on activation and return setting up references to the literals and bytecodes, or slower access to bytecodes and literals, indirecting on each access.
The last literal of a CompiledCode object is reserved for special use by the kernel and/or the virtual machine. In CompiledMethod instances it must either be the methodClassAssociation, used to implement super sends, or nil, if the method is anonymous. In CompiledBlock it is to be used for a reference to the enclosing method or block object.
By convention, the penultimate literal is reserved for special use by the kernel. CompiledMethod instances it must either be the method selector, or an instance of AdditionalMethodState which holds the selector and any pragmas or properties in the method. In CompiledBlock it is reserved for use for an AdditionalMethodState.
Note that super sends in CompiledBlock instances do not use a methodClass association, but expect a directed supersend bytecode, in which the method class (the subclass of the class in which to start the lookup) is a literal. Logically when we switch to a bytecode set that supports the directed super send bytecode, and discard the old super send bytecodes, we can use the last literal to store the selector or the enclosing method/block or an AdditionalMethodState, and the AdditionalMethodState can hold the selector and/or the enclosing method/block.!
Item was added:
+ ----- Method: CompiledCode class>>preferredBytecodeSetEncoderClass (in category 'preferences') -----
+ preferredBytecodeSetEncoderClass
+ <preference: 'Preferred bytecode set encoder class'
+ category: 'Compiler'
+ description: 'The system supports up to two bytecode sets; select the preferred one to use here. See CompiledCode class variables PrimaryBytecodeSetEncoderClass and SecondaryBytecodeSetEncoderClass.'
+ type: #Class>
+ ^PreferredBytecodeSetEncoderClass ifNil: [PrimaryBytecodeSetEncoderClass]!
Item was added:
+ ----- Method: CompiledCode class>>preferredBytecodeSetEncoderClass: (in category 'preferences') -----
+ preferredBytecodeSetEncoderClass: aClass
+ "Set the class that determines the bytecoce set used to compile methods with."
+ self assert: (aClass includesBehavior: BytecodeEncoder).
+ PreferredBytecodeSetEncoderClass := aClass!