The Trunk: Compiler.spur-eem.301.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Compiler.spur-eem.301.mcz

commits-2
Eliot Miranda uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler.spur-eem.301.mcz

==================== Summary ====================

Name: Compiler.spur-eem.301
Author: eem
Time: 19 June 2015, 12:42:21.36 pm
UUID: 36fb91f1-929c-4d36-ba0b-49983331a34b
Ancestors: Compiler-eem.301, Compiler.spur-eem.300

Compiler-eem.301 patched for Spur by SpurBootstrapMonticelloPackagePatcher Cog-eem.269

Fix pc range highlighting when at the #+ in the
increment at the end of an optimized to:[by:]do:
loop.

=============== Diff against Compiler-eem.301 ===============

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 > 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])
+ + numLits!
- "Compute the compiled method header that encodes the arguments
- in the receiver's header format (see CompiledMehtod's class comment)."
- self subclassResponsibility!

Item was removed:
- ----- Method: EncoderForV3>>computeMethodHeaderForNumArgs:numTemps:numLits:primitive: (in category 'method generation') -----
- computeMethodHeaderForNumArgs: numArgs numTemps: numTemps numLits: numLits primitive: primitiveIndex
- | primBits |
- numTemps > 63 ifTrue:
- [^self error: 'Cannot compile -- too many temporary variables'].
- numLits > 255 ifTrue:
- [^self error: 'Cannot compile -- too many literals'].
- primBits := primitiveIndex <= 16r1FF
- ifTrue: [primitiveIndex]
- ifFalse: "For now the high bit of primitive no. is in the 29th bit of header"
- [primitiveIndex > 16r3FF ifTrue: [self error: 'prim num too large'].
- (primitiveIndex bitAnd: 16r1FF) + ((primitiveIndex bitAnd: 16r200) bitShift: 19)].
- ^(numArgs bitShift: 24)
- + (numTemps bitShift: 18)
- "+ (largeBit bitShift: 17)" "largeBit gets filled in later"
- + (numLits bitShift: 9)
- + primBits!

Item was changed:
  ----- Method: EncoderForV3PlusClosures class>>bytecodeSize: (in category 'instruction stream support') -----
  bytecodeSize: bytecode
  "Answer the number of bytes in the bytecode."
  bytecode <= 125 ifTrue:
  [^1].
  bytecode >= 176 ifTrue:
  [^1].
  bytecode >= 160 ifTrue: "long jumps"
  [^2].
  bytecode >= 144 ifTrue: "short jumps"
  [^1].
  "extensions"
  bytecode >= 128 ifTrue:
+ [^#(2 2 2 2 3 2 2 1 1 1 2 3 3 3 3 4) at: bytecode - 127].
- [^#(2 2 2 2 3 2 2 1 1 1 2 nil 3 3 3 4) at: bytecode - 127].
  ^nil!

Item was added:
+ ----- Method: EncoderForV3PlusClosures class>>callPrimitiveCode (in category 'bytecode decoding') -----
+ callPrimitiveCode
+ "139 11101111 iiiiiiii jjjjjjjj Call Primitive #iiiiiiii + (jjjjjjjj * 256)"
+ ^139!

Item was added:
+ ----- Method: EncoderForV3PlusClosures>>genCallPrimitive: (in category 'bytecode generation') -----
+ genCallPrimitive: primitiveIndex
+ "139 11101111 iiiiiiii jjjjjjjj Call Primitive #iiiiiiii + (jjjjjjjj * 256)"
+ (primitiveIndex < 1 or: [primitiveIndex > 65535]) ifTrue:
+ [self outOfRangeError: 'primitive index' index: primitiveIndex range: 1 to: 65535].
+ stream
+ nextPut: 139;
+ nextPut: (primitiveIndex bitAnd: 255);
+ nextPut: (primitiveIndex bitShift: -8)!

Item was changed:
  ----- Method: MethodNode>>generate:using: (in category 'code generation') -----
  generate: trailer using: aCompiledMethodClass
  "The receiver is the root of a parse tree. Answer an instance of aCompiledMethodClass.
  The argument, trailer, is arbitrary but is typically either the reference to the source code
  that is stored with every CompiledMethod, or an encoding of the method's temporary names."
 
+ | primErrNode blkSize nLits locals literals stack header method |
- | primErrNode blkSize nLits literals stack method |
  self generate: trailer
  using: aCompiledMethodClass
  ifQuick:
  [:m |
  encoder noteBlockExtent: (0 to: 2) hasLocals: arguments.
  m literalAt: 2 put: encoder associationForClass;
  properties: properties.
  ^m].
  primErrNode := self primitiveErrorVariableName ifNotNil:
  [encoder fixTemp: self primitiveErrorVariableName].
+ self ensureClosureAnalysisDone.
+ encoder rootNode: self. "this is for BlockNode>>sizeCodeForClosureValue:"
- encoder supportsClosureOpcodes ifTrue:
- [self ensureClosureAnalysisDone.
- encoder rootNode: self. "this is for BlockNode>>sizeCodeForClosureValue:"].
  blkSize := (block sizeCodeForEvaluatedValue: encoder)
+ + (primitive > 0
+ ifTrue: [encoder sizeCallPrimitive: primitive]
+ ifFalse: [0])
  + (primErrNode
  ifNil: [0]
  ifNotNil:
  [primErrNode
  index: arguments size + temporaries size;
  sizeCodeForStore: encoder "The VM relies on storeIntoTemp: (129)"]).
+ locals := arguments, temporaries, (primErrNode ifNil: [#()] ifNotNil: [{primErrNode}]).
+ encoder noteBlockExtent: block blockExtent hasLocals: locals.
+ header := encoder computeMethodHeaderForNumArgs: arguments size
+ numTemps: locals size
+ numLits: (nLits := (literals := encoder allLiterals) size)
+ primitive: primitive.
+ method := trailer
+ createMethod: blkSize
+ class: aCompiledMethodClass
+ header: header.
- method := aCompiledMethodClass
- newBytes: blkSize
- trailerBytes: trailer
- nArgs: arguments size
- nTemps: (encoder supportsClosureOpcodes
- ifTrue: [| locals |
- locals := arguments,
-  temporaries,
-  (primErrNode
- ifNil: [#()]
- ifNotNil: [{primErrNode}]).
- encoder
- noteBlockExtent: block blockExtent
- hasLocals: locals.
- locals size]
- ifFalse: [encoder maxTemp])
- nStack: 0
- nLits: (nLits := (literals := encoder allLiterals) size)
- primitive: primitive.
- nLits > 255 ifTrue:
- [^self error: 'Too many literals referenced'].
  1 to: nLits do: [:lit | method literalAt: lit put: (literals at: lit)].
  encoder streamToMethod: method.
  stack := ParseStack new init.
+ primitive > 0 ifTrue:
+ [encoder genCallPrimitive: primitive.
+ primErrNode ifNotNil:
+ [primErrNode emitCodeForStore: stack encoder: encoder]].
- primErrNode ifNotNil: [primErrNode emitCodeForStore: stack encoder: encoder].
  stack position: method numTemps.
  [block emitCodeForEvaluatedValue: stack encoder: encoder]
  on: Error "If an attempt is made to write too much code the method will be asked"
  do: [:ex|  "to grow, and the grow attempt will fail in CompiledMethod class>>#new:"
  ex signalerContext sender method = (CompiledMethod class>>#new:)
  ifTrue: [^self error: 'Compiler code size discrepancy']
  ifFalse: [ex pass]].
  stack position ~= (method numTemps + 1) ifTrue:
  [^self error: 'Compiler stack discrepancy'].
  encoder methodStreamPosition ~= (method size - trailer size) ifTrue:
  [^self error: 'Compiler code size discrepancy'].
  method needsFrameSize: stack size - method numTemps.
  method properties: properties.
  ^method!