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

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

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

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

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

Name: VMMaker.oscog-eem.187
Author: eem
Time: 18 July 2012, 5:34:45.179 pm
UUID: c8ef3fdf-8bac-484b-95c4-7234902bc88f
Ancestors: VMMaker.oscog-eem.186

Allow the opts dictionary to select the CogAbstractCompiler class.
Use cCode:inSmalltalk: to collapse the integerObjectOf: &
isIntegerValue: implementations down to a few.

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

Item was changed:
  ----- Method: CogAbstractInstruction class>>instVarNamesAndTypesForTranslationDo: (in category 'translation') -----
  instVarNamesAndTypesForTranslationDo: aBinaryBlock
  "enumerate aBinaryBlock with the names and C type strings for the inst vars to include in an AbstractInstruction struct."
  "CogIA32Compiler printTypedefOn: Transcript"
  "CogARMCompiler printTypedefOn: Transcript"
+ | machineCodeBytes |
+ machineCodeBytes := self ==  CogAbstractInstruction
+ ifTrue: [0]
+ ifFalse: [Cogit cogCompilerClass basicNew machineCodeBytes].
  self filteredInstVarNames do:
  [:ivn|
  ivn ~= 'bcpc' ifTrue:
  [aBinaryBlock
  value: ivn
  value: (ivn caseOf: {
  ['address'] -> ['unsigned long'].
+ ['machineCode'] -> [{'unsigned char'. '[', machineCodeBytes printString, ']'}].
- ['machineCode'] -> [{'unsigned char'. '[', self basicNew machineCodeBytes printString, ']'}].
  ['operands'] -> [#('unsigned long' '[3]')].
  ['dependent'] -> ['struct _AbstractInstruction *']}
  otherwise:
  [#char])]]!

Item was changed:
  ----- Method: CogVMSimulator class>>chooseAndInitCogitClassWithOpts: (in category 'instance creation') -----
  chooseAndInitCogitClassWithOpts: opts
+ | classOrSymbol |
+ classOrSymbol := opts at: #Cogit ifAbsent: [Cogit chooseCogitClass].
+ classOrSymbol isSymbol ifTrue:
+ [classOrSymbol := Smalltalk classNamed: classOrSymbol].
+ (CoInterpreter classPool at: #CogitClass put: (classOrSymbol)) initializeWithOptions: opts!
- (CoInterpreter classPool
- at: #CogitClass
- put: Cogit chooseCogitClass)
- initializeWithOptions: opts!

Item was removed:
- ----- Method: CogVMSimulator>>integerObjectOf: (in category 'memory access') -----
- integerObjectOf: value
- "The simulator works with strictly positive bit patterns"
- value < 0
- ifTrue: [^ ((16r80000000 + value) << 1) + 1]
- ifFalse: [^ (value << 1) + 1]!

Item was removed:
- ----- Method: CogVMSimulator>>isIntegerValue: (in category 'interpreter shell') -----
- isIntegerValue: valueWord
- ^ valueWord >= 16r-40000000 and: [valueWord <= 16r3FFFFFFF]!

Item was added:
+ ----- Method: Cogit class>>cogCompilerClass (in category 'accessing') -----
+ cogCompilerClass
+ "Answer the concrete subclass of CogAbstractCompiler in current use."
+ ^ProcessorClass basicNew abstractInstructionCompilerClass!

Item was removed:
- ----- Method: InterpreterSimulator>>integerObjectOf: (in category 'memory access') -----
- integerObjectOf: value
- "The simulator works with strictly positive bit patterns"
- value < 0
- ifTrue: [^ ((16r80000000 + value) << 1) + 1]
- ifFalse: [^ (value << 1) + 1]!

Item was removed:
- ----- Method: InterpreterSimulator>>isIntegerValue: (in category 'interpreter shell') -----
- isIntegerValue: valueWord
- ^ valueWord >= 16r-40000000 and: [valueWord <= 16r3FFFFFFF]!

Item was removed:
- ----- Method: NewCoObjectMemorySimulator>>integerObjectOf: (in category 'memory access') -----
- integerObjectOf: value
- "The simulator works with strictly positive bit patterns"
- ^((value < 0
- ifTrue: [16r80000000 + value]
- ifFalse: [value])
- bitShift: 1) + 1!

Item was removed:
- ----- Method: NewCoObjectMemorySimulator>>isIntegerValue: (in category 'interpreter shell') -----
- isIntegerValue: valueWord
- ^ valueWord >= 16r-40000000 and: [valueWord <= 16r3FFFFFFF]!

Item was removed:
- ----- Method: NewObjectMemorySimulator>>integerObjectOf: (in category 'memory access') -----
- integerObjectOf: value
- "The simulator works with strictly positive bit patterns"
- ^((value < 0
- ifTrue: [16r80000000 + value]
- ifFalse: [value])
- bitShift: 1) + 1!

Item was removed:
- ----- Method: NewObjectMemorySimulator>>isIntegerValue: (in category 'interpreter shell') -----
- isIntegerValue: valueWord
- ^ valueWord >= 16r-40000000 and: [valueWord <= 16r3FFFFFFF]!

Item was removed:
- ----- Method: NewspeakInterpreterSimulator>>integerObjectOf: (in category 'memory access') -----
- integerObjectOf: value
- "The simulator works with strictly positive bit patterns"
- value < 0
- ifTrue: [^ ((16r80000000 + value) << 1) + 1]
- ifFalse: [^ (value << 1) + 1]!

Item was removed:
- ----- Method: NewspeakInterpreterSimulator>>isIntegerValue: (in category 'interpreter shell') -----
- isIntegerValue: valueWord
- ^ valueWord >= 16r-40000000 and: [valueWord <= 16r3FFFFFFF]!

Item was changed:
  ----- Method: ObjectMemory>>integerObjectOf: (in category 'interpreter access') -----
  integerObjectOf: value
+ "Convert the integer value, assumed to be in SmallInteger range, into a tagged SmallInteger object.
+ In C, use a shift and an add to set the tag bit.
+ In Smalltalk we have to work harder because thesimulator works with strictly positive bit patterns."
 
+ ^self
+ cCode: [(value << 1) + 1]
+ inSmalltalk: [value >= 0
+ ifTrue: [(value << 1) + 1]
+ ifFalse: [((16r80000000 + value) << 1) + 1]]!
- ^(value << 1) + 1!

Item was changed:
  ----- Method: ObjectMemory>>isIntegerValue: (in category 'interpreter access') -----
  isIntegerValue: intValue
+ "Answer if the given value can be represented as a Smalltalk integer value.
+ In C, use a shift and XOR to set the sign bit if and only if the top two bits of the given
+ value are the same, then test the sign bit. Note that the top two bits are equal for
+ exactly those integers in the range that can be represented in 31-bits or 63-bits."
- "Return true if the given value can be represented as a Smalltalk integer value."
- "Use a shift and XOR to set the sign bit if and only if the top two bits of the given value are the same, then test the sign bit. Note that the top two bits are equal for exactly those integers in the range that can be represented in 31-bits or 63-bits."
 
+ ^self
+ cCode: [(intValue bitXor: (intValue << 1)) >= 0]
+ inSmalltalk: [intValue >= 16r-40000000 and: [intValue <= 16r3FFFFFFF]]!
- ^ (intValue bitXor: (intValue << 1)) >= 0!

Item was removed:
- ----- Method: StackInterpreterSimulator>>integerObjectOf: (in category 'memory access') -----
- integerObjectOf: value
- "The simulator works with strictly positive bit patterns"
- value < 0
- ifTrue: [^ ((16r80000000 + value) << 1) + 1]
- ifFalse: [^ (value << 1) + 1]!

Item was removed:
- ----- Method: StackInterpreterSimulator>>isIntegerValue: (in category 'interpreter shell') -----
- isIntegerValue: valueWord
- ^ valueWord >= 16r-40000000 and: [valueWord <= 16r3FFFFFFF]!

Item was removed:
- ----- Method: StackInterpreterSimulator>>moveFramesIn:through:toPage: (in category 'debugging traps') -----
- moveFramesIn: thePage through: frameAbove toPage: newPage
- "| thisPage |
- (self checkIsStillMarriedContext: 22189568 currentFP: framePointer) ifTrue:
- [thisPage := stackPages stackPageFor: (self frameOfMarriedContext: 22189568).
- (thePage == thisPage or: [newPage == thisPage]) ifTrue:
- [self halt]]."
- ^super moveFramesIn: thePage through: frameAbove toPage: newPage!

Item was changed:
  ----- Method: TMethod>>statementsListsForInlining (in category 'inlining') -----
  statementsListsForInlining
  "Answer a collection of statement list nodes that are candidates for inlining.
  Currently, we cannot inline into the argument blocks of and: and or: messages.
+ We do not want to inline code strings within cCode:inSmalltalk: blocks (those with a
+ proper block for the cCode: argument are inlined in MessageNode>>asTranslatorNodeIn:).
+ We do not want to inline code within assert: sends (because we want the assert to read nicely)."
- We do not want to inline code within cCode:inSmalltalk: blocks.
- We do not want to inline code within assert: sends"
 
  | stmtLists |
  stmtLists := OrderedCollection new: 10.
  parseTree
  nodesDo:
  [ :node |
  node isStmtList ifTrue: [ stmtLists add: node ]]
  unless:
  [ :node |
  node isSend and: [#(cCode:inSmalltalk: assert:) includes: node selector]].
  parseTree nodesDo:
  [ :node |
  node isSend ifTrue:
  [node selector = #cCode:inSmalltalk: ifTrue:
  [node nodesDo:
  [:inStNode| stmtLists remove: inStNode ifAbsent: []]].
  node selector = #cppIf:ifTrue:ifFalse: ifTrue:
  [node args first nodesDo:
  [:inCondNode| stmtLists remove: inCondNode ifAbsent: []]].
  ((node selector = #and:) or: [node selector = #or:]) ifTrue:
  "Note: the PP 2.3 compiler produces two arg nodes for these selectors"
  [stmtLists remove: node args first ifAbsent: [].
  stmtLists remove: node args last ifAbsent: []].
  (#( #ifTrue: #ifFalse: #ifTrue:ifFalse: #ifFalse:ifTrue:
  #ifNil: #ifNotNil: #ifNil:ifNotNil: #ifNotNil:ifNil: ) includes: node selector) ifTrue:
  [stmtLists remove: node receiver ifAbsent: []].
  (#(whileTrue whileTrue: whilefalse whileFalse:) includes: node selector) ifTrue:
  "Allow inlining if it is a [...] whileTrue/whileFalse.
  This is identified by having more than one statement in the
  receiver block in which case the C code wouldn't work anyways"
  [node receiver statements size = 1 ifTrue:
  [stmtLists remove: node receiver ifAbsent: []]].
  (node selector = #to:do:) ifTrue:
  [stmtLists remove: node receiver ifAbsent: [].
  stmtLists remove: node args first ifAbsent: []].
  (node selector = #to:by:do:) ifTrue:
  [stmtLists remove: node receiver ifAbsent: [].
  stmtLists remove: node args first ifAbsent: [].
  stmtLists remove: node args second ifAbsent: []]].
  node isCaseStmt ifTrue: "don't inline cases"
  [node cases do: [: case | stmtLists remove: case ifAbsent: []]]].
  ^stmtLists!