-
Notifications
You must be signed in to change notification settings - Fork 65
/
VMJittedBoxFloatPrimitivesTest.class.st
60 lines (43 loc) · 1.54 KB
/
VMJittedBoxFloatPrimitivesTest.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Class {
#name : #VMJittedBoxFloatPrimitivesTest,
#superclass : #VMJittedPrimitivesTest,
#pools : [
'CogAbstractRegisters',
'CogRTLOpcodes'
],
#category : #'VMMakerTests-JitTests'
}
{ #category : #tests }
VMJittedBoxFloatPrimitivesTest >> setUp [
super setUp.
"If we are in Intel 32bits, we need to check if we have SSE instruction set"
isa = #IA32 ifTrue: [
cogit ceCheckFeaturesFunction: (self
compileTrampoline: [
cogit MoveCq: 1 << 26 R: TempReg.
cogit RetN: 0 ]
named: 'ceCheckFeatures') ]
]
{ #category : #tests }
VMJittedBoxFloatPrimitivesTest >> testAsFloat [
cogit receiverTags: memory smallIntegerTag.
cogInitialAddress := self compile: [ cogit objectRepresentation genPrimitiveAsFloat ].
self executePrimitiveWithReceiver: (self memory integerObjectOf: 27).
self
assert: (memory floatValueOf: machineSimulator receiverRegisterValue)
equals: 27.0
]
{ #category : #tests }
VMJittedBoxFloatPrimitivesTest >> testAsFloatWhenThereIsNotSpaceFailsPrimitive [
| stop |
"We can only generate BoxedFloat from an SmallInteger in 32bits"
wordSize ~= 4 ifTrue: [ ^ self skip ].
cogit receiverTags: memory smallIntegerTag.
memory freeStart: memory scavengeThreshold.
cogInitialAddress := self compile: [
cogit objectRepresentation genPrimitiveAsFloat.
stop := cogit Stop ].
self prepareStackForSendReceiver: (self memory integerObjectOf: 27) arguments: #().
self runFrom: cogInitialAddress until: stop address.
self assert: machineSimulator instructionPointerRegisterValue equals: stop address
]