VM Maker: VMMaker.oscog-nice.2559.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-nice.2559.mcz

Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:

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

Name: VMMaker.oscog-nice.2559
Author: nice
Time: 10 September 2019, 11:41:28.433927 pm
UUID: d975a6c4-5d70-5741-898a-20867bdd9af3
Ancestors: VMMaker.oscog-eem.2558

Fix awfull VM crash when testing
[48 = $0] bench.

genJumpImmediate: is not generating a single instruction but two (Compare + Jump).
So we cannot use it as a jumpTarget (or we skip the Compare instruction!)

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

Item was changed:
  ----- Method: CogObjectRepresentationFor64BitSpur>>genSmallIntegerComparison:orDoubleComparison:invert: (in category 'primitive generators') -----
  genSmallIntegerComparison: jumpOpcode orDoubleComparison: jumpFPOpcodeGenerator invert: invertComparison
  "Stack looks like
  return address"
  | jumpCond r compareIntFloat jumpAmbiguous jumpNotBoxedFloat jumpNotFloatAtAll jumpNotSmallFloat jumpTrue returnTrue |
  <var: #jumpFPOpcodeGenerator declareC: 'AbstractInstruction * NoDbgRegParms (*jumpFPOpcodeGenerator)(void *)'>
  <var: #jumpNonInt type: #'AbstractInstruction *'>
  <var: #jumpCond type: #'AbstractInstruction *'>
  <var: #jumpTrue type: #'AbstractInstruction *'>
  <var: #returnTrue type: #'AbstractInstruction *'>
  <var: #jumpAmbiguous type: #'AbstractInstruction *'>
  <var: #jumpNotBoxedFloat type: #'AbstractInstruction *'>
  <var: #jumpNotSmallFloat type: #'AbstractInstruction *'>
  <var: #jumpNotFloatAtAll type: #'AbstractInstruction *'>
  <var: #compareIntFloat type: #'AbstractInstruction *'>
  r := self genSmallIntegerComparison: jumpOpcode.
  r < 0 ifTrue:
  self cppIf: #DPFPReg0 defined ifTrue:
  "Fall through on non-SmallInteger argument.  Argument may be a Float : let us check or fail"
  "check for Small Float argument"
  jumpNotSmallFloat := self genJumpNotSmallFloat: Arg0Reg.
  self genGetSmallFloatValueOf: Arg0Reg scratch: TempReg into: DPFPReg1.
  "Case of (int compare: float). Test for ambiguity, that is when (double) intRcvr == floatArg"
  compareIntFloat := cogit Label.
  self genConvertSmallIntegerToIntegerInReg: ReceiverResultReg.
  cogit ConvertR: ReceiverResultReg Rd: DPFPReg0.
  cogit CmpRd: DPFPReg0 Rd: DPFPReg1.
  jumpAmbiguous := cogit perform: #JumpFPEqual: with: 0.
  "Case of non ambiguity, use compareFloat((double) intRcvr,floatArg)"
  invertComparison "May need to invert for NaNs"
  ifTrue: [cogit CmpRd: DPFPReg0 Rd: DPFPReg1]
  ifFalse: [cogit CmpRd: DPFPReg1 Rd: DPFPReg0].
  jumpCond := cogit perform: jumpFPOpcodeGenerator with: 0. "FP jumps are a little weird"
  cogit genMoveFalseR: ReceiverResultReg.
  cogit genPrimReturn.
  jumpCond jmpTarget: (returnTrue := cogit genMoveTrueR: ReceiverResultReg).
  cogit genPrimReturn.
  "Case of ambiguity, use compareInt(intRcvr , (int64) floatArg)"
  jumpAmbiguous jmpTarget: (cogit ConvertRd: DPFPReg1 R: Arg0Reg).
  cogit CmpR: Arg0Reg R: ReceiverResultReg. "N.B. FLAGS := RRReg - Arg0Reg"
  jumpTrue := cogit genConditionalBranch: jumpOpcode operand: 0.
  cogit genMoveFalseR: ReceiverResultReg.
  cogit genPrimReturn.
  jumpTrue jmpTarget: returnTrue.
  "not a Small Float, check for Boxed Float argument"
+ jumpNotSmallFloat jmpTarget:cogit Label.
+ jumpNotFloatAtAll := self genJumpImmediate: Arg0Reg.
- jumpNotSmallFloat jmpTarget: (jumpNotFloatAtAll := self genJumpImmediate: Arg0Reg).
  self genGetCompactClassIndexNonImmOf: Arg0Reg into: SendNumArgsReg.
  self genCmpClassFloatCompactIndexR: SendNumArgsReg.
  jumpNotBoxedFloat := cogit JumpNonZero: 0.
  "It was a Boxed Float, so convert the receiver to double and perform the (int compare: float) operation"
  self genGetDoubleValueOf: Arg0Reg into: DPFPReg1.
  cogit Jump: compareIntFloat.
  "not a Float, just let the primitive fall thru failure"
  jumpNotBoxedFloat jmpTarget: (jumpNotFloatAtAll jmpTarget: cogit Label)].