-
Notifications
You must be signed in to change notification settings - Fork 65
/
VMPrimitiveCallingTest.class.st
97 lines (76 loc) · 2.87 KB
/
VMPrimitiveCallingTest.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Class {
#name : #VMPrimitiveCallingTest,
#superclass : #VMInterpreterTests,
#category : #'VMMakerTests-InterpreterTests'
}
{ #category : #tests }
VMPrimitiveCallingTest >> testPrimitiveFailingDoesNotSetErrorCodeInOtherTemp [
"The method has two temporaries. The first one is the error code, the second one is a user defined temp."
| method |
method := methodBuilder newMethod
bytecodes:
#[ "call primitive" 16rF8 16rB8 16r00
"store into temp 0" 16rF5 16r00 ];
numberOfTemporaries: 2;
isPrimitive: true;
buildMethod.
stackBuilder addNewFrame; buildStack.
interpreter newMethod: method.
interpreter primFailCode: -1.
interpreter activateNewMethod.
self assert: (interpreter temporary: 1 in: interpreter framePointer) equals: memory nilObject
]
{ #category : #tests }
VMPrimitiveCallingTest >> testPrimitiveFailingDoesNotSkipSecondBytecodeIfNotLongStore [
"The method has two temporaries. The first one is the error code, the second one is a user defined temp."
| method |
method := methodBuilder newMethod
bytecodes:
#[ "call primitive" 16rF8 16rB8 16r00
"not store into temp 0" 16rF4 ];
numberOfTemporaries: 2;
isPrimitive: true;
buildMethod.
stackBuilder addNewFrame; buildStack.
interpreter newMethod: method.
interpreter primFailCode: -1.
interpreter activateNewMethod.
self assert: interpreter fetchByte equals: 16rF4
]
{ #category : #tests }
VMPrimitiveCallingTest >> testPrimitiveFailingSetsErrorCodeInCorrectTemp [
"The method has two temporaries. The first one is the error code, the second one is a user defined temp."
| method |
method := methodBuilder newMethod
bytecodes:
#[ "call primitive" 16rF8 16rB8 16r00
"store into temp 0" 16rF5 16r00 ];
numberOfTemporaries: 2;
isPrimitive: true;
buildMethod.
stackBuilder addNewFrame; buildStack.
interpreter newMethod: method.
interpreter primFailCode: -1.
interpreter activateNewMethod.
self assert: (interpreter temporary: 0 in: interpreter framePointer) equals: (memory integerObjectOf: -1)
]
{ #category : #tests }
VMPrimitiveCallingTest >> testPrimitiveFailingSetsErrorCodeInCorrectTempWithInternalActivation [
"The method has two temporaries. The first one is the error code, the second one is a user defined temp."
| method |
method := methodBuilder newMethod
bytecodes:
#[ "call primitive" 16rF8 16rB8 16r00
"store into temp 0" 16rF5 16r00 ];
numberOfTemporaries: 2;
isPrimitive: true;
buildMethod.
stackBuilder addNewFrame; addNewFrame; buildStack.
interpreter newMethod: method.
interpreter primFailCode: -1.
"Move the frame pointer to its caller but keep the correct one in the local FP".
interpreter framePointer: (interpreter frameCallerFP: interpreter framePointer).
interpreter activateNewMethod.
"Then externalize and assert"
self assert: (interpreter temporary: 0 in: interpreter framePointer) equals: (memory integerObjectOf: -1)
]