VM Maker: VMMaker.oscog-eem.2071.mcz

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

VM Maker: VMMaker.oscog-eem.2071.mcz

commits-2
 
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2071.mcz

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

Name: VMMaker.oscog-eem.2071
Author: eem
Time: 4 January 2017, 5:40:04.754725 pm
UUID: f96e66a4-24c6-4c44-925c-116a07bf1d27
Ancestors: VMMaker.oscog-eem.2070

Slang:
To make code more readable when implementing SpurPlanningCompactor, markedBitShift was made a macro.  That caused Slang to generate a bogus versuon of nullHeaderForMachineCodeMethod because it could no longer infer the type of the shift operand for the marked bit, and so generated 1UL << 55 instead of 1ULL << 55.  Consequently nullHeaderForMachineCodeMethod answered 0 (!!).

Add TParseNode>>constantNumbericValueIfAtAllPossibleOrNilIn: that provides a vaue for defines and methods answerinf constants as well as explicit constants and use it in generateShiftLeft:on:indent:, hence fixing nullHeaderForMachineCodeMethod.

=============== Diff against VMMaker.oscog-eem.2070 ===============

Item was changed:
  ----- Method: CCodeGenerator>>generateShiftLeft:on:indent: (in category 'C translation') -----
  generateShiftLeft: msgNode on: aStream indent: level
  "Generate a C bitShift.  If we can determine the result
  would overflow the word size, cast to a long integer."
  | rcvr arg castToLong type mustCastBackToSign mustCastToUnsigned canSuffixTheConstant typeIsUnsigned |
  rcvr := msgNode receiver.
  arg := msgNode args first.
  castToLong := false.
+ (rcvr constantNumbericValueIfAtAllPossibleOrNilIn: self) ifNotNil:
- rcvr constantNumbericValueOrNil ifNotNil:
  [:rcvrVal |
+ (arg constantNumbericValueIfAtAllPossibleOrNilIn: self)
- arg constantNumbericValueOrNil
  ifNil: [castToLong := vmClass notNil and: [vmClass objectMemoryClass wordSize = 8]]
  ifNotNil:
  [:argVal |
  | valueBeyondInt |
  valueBeyondInt := 1 bitShift: 32. "The default type of const << N is int."
  castToLong := rcvrVal < valueBeyondInt
   and: [(rcvrVal bitShift: argVal) >= valueBeyondInt]]].
  canSuffixTheConstant := rcvr isConstant and: [rcvr name isEmpty and: [rcvr value >= 0]].
  canSuffixTheConstant
  ifTrue:
  [aStream nextPutAll: (self cLiteralForUnsignedInteger: rcvr value longlong: castToLong).
  aStream nextPutAll: ' << '.
  self emitCExpression: arg on: aStream indent: level.
  ^self].
  type := self typeFor: rcvr in: currentMethod.
  castToLong := castToLong and: [(self sizeOfIntegralCType: type) < (self sizeOfIntegralCType: #usqLong)].
  typeIsUnsigned := type first = $u.
  mustCastToUnsigned := typeIsUnsigned not
  or: [castToLong
  or: [(self sizeOfIntegralCType: type) < (self sizeOfIntegralCType: #usqInt)]].
  mustCastBackToSign := typeIsUnsigned not.
  mustCastBackToSign
  ifTrue:
  [| promotedType |
  promotedType := castToLong
  ifTrue: [#sqLong]
  ifFalse: [(self sizeOfIntegralCType: type) < (self sizeOfIntegralCType: #sqInt)
  ifTrue: [#sqInt]
  ifFalse: [type]].
  aStream nextPutAll: '(('; nextPutAll: promotedType; nextPut: $)].
  mustCastToUnsigned
  ifTrue:
  [| unsigned |
  unsigned := castToLong
  ifTrue: [#usqLong]
  ifFalse: [(self sizeOfIntegralCType: type) < (self sizeOfIntegralCType: #usqLong)
  ifTrue: [#usqInt]
  ifFalse: [self unsignedTypeForIntegralType: type]].
  aStream nextPutAll: '(('; nextPutAll: unsigned; nextPutAll: ')('].
  self emitCExpression: rcvr on: aStream indent: level.
  mustCastToUnsigned ifTrue: [aStream nextPut: $)].
  aStream nextPutAll: ' << '.
  self emitCExpression: arg on: aStream indent: level.
  mustCastToUnsigned ifTrue: [aStream nextPut: $)].
  mustCastBackToSign ifTrue: [aStream nextPut: $)].!

Item was added:
+ ----- Method: TConstantNode>>constantNumbericValueIfAtAllPossibleOrNilIn: (in category 'accessing') -----
+ constantNumbericValueIfAtAllPossibleOrNilIn: aCCodeGen
+ "This is a version of constantNumbericValueOrNil for type checking rather than code generation.
+ It aims to yield a value if at all possible.  This should /not/ be overridden in TDefineNode."
+ ^value isNumber ifTrue: [value]!

Item was changed:
+ ----- Method: TConstantNode>>constantNumbericValueOrNil (in category 'accessing') -----
- ----- Method: TConstantNode>>constantNumbericValueOrNil (in category 'testing') -----
  constantNumbericValueOrNil
 
  ^value isNumber ifTrue: [value]!

Item was changed:
+ ----- Method: TDefineNode>>constantNumbericValueOrNil (in category 'accessing') -----
- ----- Method: TDefineNode>>constantNumbericValueOrNil (in category 'testing') -----
  constantNumbericValueOrNil
  "Override so that named constants don't get elided."
  ^nil!

Item was added:
+ ----- Method: TParseNode>>constantNumbericValueIfAtAllPossibleOrNilIn: (in category 'accessing') -----
+ constantNumbericValueIfAtAllPossibleOrNilIn: aCCodeGen
+ "This is a version of constantNumbericValueOrNil for type checking rather than code generation.
+ It aims to yield a value if at all possible."
+ ^self constantNumbericValueOrNil!

Item was changed:
+ ----- Method: TParseNode>>constantNumbericValueOrNil (in category 'accessing') -----
- ----- Method: TParseNode>>constantNumbericValueOrNil (in category 'testing') -----
  constantNumbericValueOrNil
 
  ^nil!

Item was added:
+ ----- Method: TSendNode>>constantNumbericValueIfAtAllPossibleOrNilIn: (in category 'accessing') -----
+ constantNumbericValueIfAtAllPossibleOrNilIn: aCCodeGen
+ "This is a version of constantNumbericValueOrNil for type checking rather than code generation.
+ It aims to yield a value if at all possible."
+ (#(* // + - << >> bitAnd: bitOr: bitShift:) includes: selector) ifTrue:
+ [(receiver constantNumbericValueIfAtAllPossibleOrNilIn: aCCodeGen) ifNotNil:
+ [:rval|
+ (arguments first constantNumbericValueIfAtAllPossibleOrNilIn: aCCodeGen) ifNotNil:
+ [:aval|
+ ^rval perform: selector with: aval]]].
+ ^(aCCodeGen anyMethodNamed: selector) ifNotNil:
+ [:m|
+ m isReturnConstant ifTrue:
+ [m statements last expression constantNumbericValueIfAtAllPossibleOrNilIn: aCCodeGen]]!

Item was changed:
+ ----- Method: TSendNode>>constantNumbericValueOrNil (in category 'accessing') -----
- ----- Method: TSendNode>>constantNumbericValueOrNil (in category 'C code generation') -----
  constantNumbericValueOrNil
  (#(* // + -) includes: selector) ifTrue:
  [receiver constantNumbericValueOrNil ifNotNil:
  [:rval|
  arguments first constantNumbericValueOrNil ifNotNil:
  [:aval|
  ^rval perform: selector with: aval]]].
  ^nil!

Loading...