OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "test/cctest/compiler/function-tester.h" | 7 #include "test/cctest/compiler/function-tester.h" |
8 | 8 |
9 using namespace v8::internal; | 9 using namespace v8::internal; |
10 using namespace v8::internal::compiler; | 10 using namespace v8::internal::compiler; |
11 uint32_t flags = CompilationInfo::kInliningEnabled; | 11 uint32_t flags = CompilationInfo::kInliningEnabled; |
12 | 12 |
13 | 13 |
14 TEST(CallFunction) { | 14 TEST(CallFunction) { |
15 FLAG_turbo_deoptimization = true; | |
16 FunctionTester T("(function(a,b) { return %_CallFunction(a, 1, 2, 3, b); })", | 15 FunctionTester T("(function(a,b) { return %_CallFunction(a, 1, 2, 3, b); })", |
17 flags); | 16 flags); |
18 CompileRun("function f(a,b,c) { return a + b + c + this.d; }"); | 17 CompileRun("function f(a,b,c) { return a + b + c + this.d; }"); |
19 | 18 |
20 T.CheckCall(T.Val(129), T.NewObject("({d:123})"), T.NewObject("f")); | 19 T.CheckCall(T.Val(129), T.NewObject("({d:123})"), T.NewObject("f")); |
21 T.CheckCall(T.Val("6x"), T.NewObject("({d:'x'})"), T.NewObject("f")); | 20 T.CheckCall(T.Val("6x"), T.NewObject("({d:'x'})"), T.NewObject("f")); |
22 } | 21 } |
23 | 22 |
24 | 23 |
25 TEST(ClassOf) { | 24 TEST(ClassOf) { |
26 FLAG_turbo_deoptimization = true; | |
27 FunctionTester T("(function(a) { return %_ClassOf(a); })", flags); | 25 FunctionTester T("(function(a) { return %_ClassOf(a); })", flags); |
28 | 26 |
29 T.CheckCall(T.Val("Function"), T.NewObject("(function() {})")); | 27 T.CheckCall(T.Val("Function"), T.NewObject("(function() {})")); |
30 T.CheckCall(T.Val("Array"), T.NewObject("([1])")); | 28 T.CheckCall(T.Val("Array"), T.NewObject("([1])")); |
31 T.CheckCall(T.Val("Object"), T.NewObject("({})")); | 29 T.CheckCall(T.Val("Object"), T.NewObject("({})")); |
32 T.CheckCall(T.Val("RegExp"), T.NewObject("(/x/)")); | 30 T.CheckCall(T.Val("RegExp"), T.NewObject("(/x/)")); |
33 T.CheckCall(T.null(), T.undefined()); | 31 T.CheckCall(T.null(), T.undefined()); |
34 T.CheckCall(T.null(), T.null()); | 32 T.CheckCall(T.null(), T.null()); |
35 T.CheckCall(T.null(), T.Val("x")); | 33 T.CheckCall(T.null(), T.Val("x")); |
36 T.CheckCall(T.null(), T.Val(1)); | 34 T.CheckCall(T.null(), T.Val(1)); |
37 } | 35 } |
38 | 36 |
39 | 37 |
40 TEST(HeapObjectGetMap) { | 38 TEST(HeapObjectGetMap) { |
41 FLAG_turbo_deoptimization = true; | |
42 FunctionTester T("(function(a) { return %_HeapObjectGetMap(a); })", flags); | 39 FunctionTester T("(function(a) { return %_HeapObjectGetMap(a); })", flags); |
43 | 40 |
44 Factory* factory = T.main_isolate()->factory(); | 41 Factory* factory = T.main_isolate()->factory(); |
45 T.CheckCall(factory->null_map(), T.null()); | 42 T.CheckCall(factory->null_map(), T.null()); |
46 T.CheckCall(factory->undefined_map(), T.undefined()); | 43 T.CheckCall(factory->undefined_map(), T.undefined()); |
47 T.CheckCall(factory->heap_number_map(), T.Val(3.1415)); | 44 T.CheckCall(factory->heap_number_map(), T.Val(3.1415)); |
48 T.CheckCall(factory->symbol_map(), factory->NewSymbol()); | 45 T.CheckCall(factory->symbol_map(), factory->NewSymbol()); |
49 } | 46 } |
50 | 47 |
51 | 48 |
52 #define COUNTER_NAME "hurz" | 49 #define COUNTER_NAME "hurz" |
53 | 50 |
54 static int* LookupCounter(const char* name) { | 51 static int* LookupCounter(const char* name) { |
55 static int counter = 1234; | 52 static int counter = 1234; |
56 return strcmp(name, COUNTER_NAME) == 0 ? &counter : nullptr; | 53 return strcmp(name, COUNTER_NAME) == 0 ? &counter : nullptr; |
57 } | 54 } |
58 | 55 |
59 | 56 |
60 TEST(IncrementStatsCounter) { | 57 TEST(IncrementStatsCounter) { |
61 FLAG_turbo_deoptimization = true; | |
62 FLAG_native_code_counters = true; | 58 FLAG_native_code_counters = true; |
63 reinterpret_cast<v8::Isolate*>(CcTest::InitIsolateOnce()) | 59 reinterpret_cast<v8::Isolate*>(CcTest::InitIsolateOnce()) |
64 ->SetCounterFunction(LookupCounter); | 60 ->SetCounterFunction(LookupCounter); |
65 FunctionTester T( | 61 FunctionTester T( |
66 "(function() { %_IncrementStatsCounter('" COUNTER_NAME "'); })", flags); | 62 "(function() { %_IncrementStatsCounter('" COUNTER_NAME "'); })", flags); |
67 StatsCounter counter(T.main_isolate(), COUNTER_NAME); | 63 StatsCounter counter(T.main_isolate(), COUNTER_NAME); |
68 if (!counter.Enabled()) return; | 64 if (!counter.Enabled()) return; |
69 | 65 |
70 int old_value = *counter.GetInternalPointer(); | 66 int old_value = *counter.GetInternalPointer(); |
71 T.CheckCall(T.undefined()); | 67 T.CheckCall(T.undefined()); |
72 CHECK_EQ(old_value + 1, *counter.GetInternalPointer()); | 68 CHECK_EQ(old_value + 1, *counter.GetInternalPointer()); |
73 } | 69 } |
74 | 70 |
75 #undef COUNTER_NAME | 71 #undef COUNTER_NAME |
76 | 72 |
77 | 73 |
78 TEST(IsArray) { | 74 TEST(IsArray) { |
79 FLAG_turbo_deoptimization = true; | |
80 FunctionTester T("(function(a) { return %_IsArray(a); })", flags); | 75 FunctionTester T("(function(a) { return %_IsArray(a); })", flags); |
81 | 76 |
82 T.CheckFalse(T.NewObject("(function() {})")); | 77 T.CheckFalse(T.NewObject("(function() {})")); |
83 T.CheckTrue(T.NewObject("([1])")); | 78 T.CheckTrue(T.NewObject("([1])")); |
84 T.CheckFalse(T.NewObject("({})")); | 79 T.CheckFalse(T.NewObject("({})")); |
85 T.CheckFalse(T.NewObject("(/x/)")); | 80 T.CheckFalse(T.NewObject("(/x/)")); |
86 T.CheckFalse(T.undefined()); | 81 T.CheckFalse(T.undefined()); |
87 T.CheckFalse(T.null()); | 82 T.CheckFalse(T.null()); |
88 T.CheckFalse(T.Val("x")); | 83 T.CheckFalse(T.Val("x")); |
89 T.CheckFalse(T.Val(1)); | 84 T.CheckFalse(T.Val(1)); |
90 } | 85 } |
91 | 86 |
92 | 87 |
93 TEST(IsFunction) { | 88 TEST(IsFunction) { |
94 FLAG_turbo_deoptimization = true; | |
95 FunctionTester T("(function(a) { return %_IsFunction(a); })", flags); | 89 FunctionTester T("(function(a) { return %_IsFunction(a); })", flags); |
96 | 90 |
97 T.CheckTrue(T.NewObject("(function() {})")); | 91 T.CheckTrue(T.NewObject("(function() {})")); |
98 T.CheckFalse(T.NewObject("([1])")); | 92 T.CheckFalse(T.NewObject("([1])")); |
99 T.CheckFalse(T.NewObject("({})")); | 93 T.CheckFalse(T.NewObject("({})")); |
100 T.CheckFalse(T.NewObject("(/x/)")); | 94 T.CheckFalse(T.NewObject("(/x/)")); |
101 T.CheckFalse(T.undefined()); | 95 T.CheckFalse(T.undefined()); |
102 T.CheckFalse(T.null()); | 96 T.CheckFalse(T.null()); |
103 T.CheckFalse(T.Val("x")); | 97 T.CheckFalse(T.Val("x")); |
104 T.CheckFalse(T.Val(1)); | 98 T.CheckFalse(T.Val(1)); |
105 } | 99 } |
106 | 100 |
107 | 101 |
108 TEST(IsMinusZero) { | 102 TEST(IsMinusZero) { |
109 FLAG_turbo_deoptimization = true; | |
110 FunctionTester T("(function(a) { return %_IsMinusZero(a); })", flags); | 103 FunctionTester T("(function(a) { return %_IsMinusZero(a); })", flags); |
111 | 104 |
112 T.CheckFalse(T.Val(1)); | 105 T.CheckFalse(T.Val(1)); |
113 T.CheckFalse(T.Val(1.1)); | 106 T.CheckFalse(T.Val(1.1)); |
114 T.CheckTrue(T.Val(-0.0)); | 107 T.CheckTrue(T.Val(-0.0)); |
115 T.CheckFalse(T.Val(-2)); | 108 T.CheckFalse(T.Val(-2)); |
116 T.CheckFalse(T.Val(-2.3)); | 109 T.CheckFalse(T.Val(-2.3)); |
117 T.CheckFalse(T.undefined()); | 110 T.CheckFalse(T.undefined()); |
118 } | 111 } |
119 | 112 |
120 | 113 |
121 TEST(IsNonNegativeSmi) { | 114 TEST(IsNonNegativeSmi) { |
122 FLAG_turbo_deoptimization = true; | |
123 FunctionTester T("(function(a) { return %_IsNonNegativeSmi(a); })", flags); | 115 FunctionTester T("(function(a) { return %_IsNonNegativeSmi(a); })", flags); |
124 | 116 |
125 T.CheckTrue(T.Val(1)); | 117 T.CheckTrue(T.Val(1)); |
126 T.CheckFalse(T.Val(1.1)); | 118 T.CheckFalse(T.Val(1.1)); |
127 T.CheckFalse(T.Val(-0.0)); | 119 T.CheckFalse(T.Val(-0.0)); |
128 T.CheckFalse(T.Val(-2)); | 120 T.CheckFalse(T.Val(-2)); |
129 T.CheckFalse(T.Val(-2.3)); | 121 T.CheckFalse(T.Val(-2.3)); |
130 T.CheckFalse(T.undefined()); | 122 T.CheckFalse(T.undefined()); |
131 } | 123 } |
132 | 124 |
133 | 125 |
134 TEST(IsObject) { | 126 TEST(IsObject) { |
135 FLAG_turbo_deoptimization = true; | |
136 FunctionTester T("(function(a) { return %_IsObject(a); })", flags); | 127 FunctionTester T("(function(a) { return %_IsObject(a); })", flags); |
137 | 128 |
138 T.CheckFalse(T.NewObject("(function() {})")); | 129 T.CheckFalse(T.NewObject("(function() {})")); |
139 T.CheckTrue(T.NewObject("([1])")); | 130 T.CheckTrue(T.NewObject("([1])")); |
140 T.CheckTrue(T.NewObject("({})")); | 131 T.CheckTrue(T.NewObject("({})")); |
141 T.CheckTrue(T.NewObject("(/x/)")); | 132 T.CheckTrue(T.NewObject("(/x/)")); |
142 T.CheckFalse(T.undefined()); | 133 T.CheckFalse(T.undefined()); |
143 T.CheckTrue(T.null()); | 134 T.CheckTrue(T.null()); |
144 T.CheckFalse(T.Val("x")); | 135 T.CheckFalse(T.Val("x")); |
145 T.CheckFalse(T.Val(1)); | 136 T.CheckFalse(T.Val(1)); |
146 } | 137 } |
147 | 138 |
148 | 139 |
149 TEST(IsRegExp) { | 140 TEST(IsRegExp) { |
150 FLAG_turbo_deoptimization = true; | |
151 FunctionTester T("(function(a) { return %_IsRegExp(a); })", flags); | 141 FunctionTester T("(function(a) { return %_IsRegExp(a); })", flags); |
152 | 142 |
153 T.CheckFalse(T.NewObject("(function() {})")); | 143 T.CheckFalse(T.NewObject("(function() {})")); |
154 T.CheckFalse(T.NewObject("([1])")); | 144 T.CheckFalse(T.NewObject("([1])")); |
155 T.CheckFalse(T.NewObject("({})")); | 145 T.CheckFalse(T.NewObject("({})")); |
156 T.CheckTrue(T.NewObject("(/x/)")); | 146 T.CheckTrue(T.NewObject("(/x/)")); |
157 T.CheckFalse(T.undefined()); | 147 T.CheckFalse(T.undefined()); |
158 T.CheckFalse(T.null()); | 148 T.CheckFalse(T.null()); |
159 T.CheckFalse(T.Val("x")); | 149 T.CheckFalse(T.Val("x")); |
160 T.CheckFalse(T.Val(1)); | 150 T.CheckFalse(T.Val(1)); |
161 } | 151 } |
162 | 152 |
163 | 153 |
164 TEST(IsSmi) { | 154 TEST(IsSmi) { |
165 FLAG_turbo_deoptimization = true; | |
166 FunctionTester T("(function(a) { return %_IsSmi(a); })", flags); | 155 FunctionTester T("(function(a) { return %_IsSmi(a); })", flags); |
167 | 156 |
168 T.CheckTrue(T.Val(1)); | 157 T.CheckTrue(T.Val(1)); |
169 T.CheckFalse(T.Val(1.1)); | 158 T.CheckFalse(T.Val(1.1)); |
170 T.CheckFalse(T.Val(-0.0)); | 159 T.CheckFalse(T.Val(-0.0)); |
171 T.CheckTrue(T.Val(-2)); | 160 T.CheckTrue(T.Val(-2)); |
172 T.CheckFalse(T.Val(-2.3)); | 161 T.CheckFalse(T.Val(-2.3)); |
173 T.CheckFalse(T.undefined()); | 162 T.CheckFalse(T.undefined()); |
174 } | 163 } |
175 | 164 |
176 | 165 |
177 TEST(MapGetInstanceType) { | 166 TEST(MapGetInstanceType) { |
178 FLAG_turbo_deoptimization = true; | |
179 FunctionTester T( | 167 FunctionTester T( |
180 "(function(a) { return %_MapGetInstanceType(%_HeapObjectGetMap(a)); })", | 168 "(function(a) { return %_MapGetInstanceType(%_HeapObjectGetMap(a)); })", |
181 flags); | 169 flags); |
182 | 170 |
183 Factory* factory = T.main_isolate()->factory(); | 171 Factory* factory = T.main_isolate()->factory(); |
184 T.CheckCall(T.Val(ODDBALL_TYPE), T.null()); | 172 T.CheckCall(T.Val(ODDBALL_TYPE), T.null()); |
185 T.CheckCall(T.Val(ODDBALL_TYPE), T.undefined()); | 173 T.CheckCall(T.Val(ODDBALL_TYPE), T.undefined()); |
186 T.CheckCall(T.Val(HEAP_NUMBER_TYPE), T.Val(3.1415)); | 174 T.CheckCall(T.Val(HEAP_NUMBER_TYPE), T.Val(3.1415)); |
187 T.CheckCall(T.Val(SYMBOL_TYPE), factory->NewSymbol()); | 175 T.CheckCall(T.Val(SYMBOL_TYPE), factory->NewSymbol()); |
188 } | 176 } |
189 | 177 |
190 | 178 |
191 TEST(ObjectEquals) { | 179 TEST(ObjectEquals) { |
192 FLAG_turbo_deoptimization = true; | |
193 FunctionTester T("(function(a,b) { return %_ObjectEquals(a,b); })", flags); | 180 FunctionTester T("(function(a,b) { return %_ObjectEquals(a,b); })", flags); |
194 CompileRun("var o = {}"); | 181 CompileRun("var o = {}"); |
195 | 182 |
196 T.CheckTrue(T.NewObject("(o)"), T.NewObject("(o)")); | 183 T.CheckTrue(T.NewObject("(o)"), T.NewObject("(o)")); |
197 T.CheckTrue(T.Val("internal"), T.Val("internal")); | 184 T.CheckTrue(T.Val("internal"), T.Val("internal")); |
198 T.CheckTrue(T.true_value(), T.true_value()); | 185 T.CheckTrue(T.true_value(), T.true_value()); |
199 T.CheckFalse(T.true_value(), T.false_value()); | 186 T.CheckFalse(T.true_value(), T.false_value()); |
200 T.CheckFalse(T.NewObject("({})"), T.NewObject("({})")); | 187 T.CheckFalse(T.NewObject("({})"), T.NewObject("({})")); |
201 T.CheckFalse(T.Val("a"), T.Val("b")); | 188 T.CheckFalse(T.Val("a"), T.Val("b")); |
202 } | 189 } |
203 | 190 |
204 | 191 |
205 TEST(OneByteSeqStringGetChar) { | 192 TEST(OneByteSeqStringGetChar) { |
206 FLAG_turbo_deoptimization = true; | |
207 FunctionTester T("(function(a,b) { return %_OneByteSeqStringGetChar(a,b); })", | 193 FunctionTester T("(function(a,b) { return %_OneByteSeqStringGetChar(a,b); })", |
208 flags); | 194 flags); |
209 | 195 |
210 Handle<SeqOneByteString> string = | 196 Handle<SeqOneByteString> string = |
211 T.main_isolate()->factory()->NewRawOneByteString(3).ToHandleChecked(); | 197 T.main_isolate()->factory()->NewRawOneByteString(3).ToHandleChecked(); |
212 string->SeqOneByteStringSet(0, 'b'); | 198 string->SeqOneByteStringSet(0, 'b'); |
213 string->SeqOneByteStringSet(1, 'a'); | 199 string->SeqOneByteStringSet(1, 'a'); |
214 string->SeqOneByteStringSet(2, 'r'); | 200 string->SeqOneByteStringSet(2, 'r'); |
215 T.CheckCall(T.Val('b'), string, T.Val(0.0)); | 201 T.CheckCall(T.Val('b'), string, T.Val(0.0)); |
216 T.CheckCall(T.Val('a'), string, T.Val(1)); | 202 T.CheckCall(T.Val('a'), string, T.Val(1)); |
217 T.CheckCall(T.Val('r'), string, T.Val(2)); | 203 T.CheckCall(T.Val('r'), string, T.Val(2)); |
218 } | 204 } |
219 | 205 |
220 | 206 |
221 TEST(OneByteSeqStringSetChar) { | 207 TEST(OneByteSeqStringSetChar) { |
222 FLAG_turbo_deoptimization = true; | |
223 FunctionTester T("(function(a,b) { %_OneByteSeqStringSetChar(a,88,b); })", | 208 FunctionTester T("(function(a,b) { %_OneByteSeqStringSetChar(a,88,b); })", |
224 flags); | 209 flags); |
225 | 210 |
226 Handle<SeqOneByteString> string = | 211 Handle<SeqOneByteString> string = |
227 T.main_isolate()->factory()->NewRawOneByteString(3).ToHandleChecked(); | 212 T.main_isolate()->factory()->NewRawOneByteString(3).ToHandleChecked(); |
228 string->SeqOneByteStringSet(0, 'b'); | 213 string->SeqOneByteStringSet(0, 'b'); |
229 string->SeqOneByteStringSet(1, 'a'); | 214 string->SeqOneByteStringSet(1, 'a'); |
230 string->SeqOneByteStringSet(2, 'r'); | 215 string->SeqOneByteStringSet(2, 'r'); |
231 T.Call(T.Val(1), string); | 216 T.Call(T.Val(1), string); |
232 CHECK_EQ('b', string->SeqOneByteStringGet(0)); | 217 CHECK_EQ('b', string->SeqOneByteStringGet(0)); |
233 CHECK_EQ('X', string->SeqOneByteStringGet(1)); | 218 CHECK_EQ('X', string->SeqOneByteStringGet(1)); |
234 CHECK_EQ('r', string->SeqOneByteStringGet(2)); | 219 CHECK_EQ('r', string->SeqOneByteStringGet(2)); |
235 } | 220 } |
236 | 221 |
237 | 222 |
238 TEST(NewConsString) { | 223 TEST(NewConsString) { |
239 FLAG_turbo_deoptimization = true; | |
240 FunctionTester T( | 224 FunctionTester T( |
241 "(function() { " | 225 "(function() { " |
242 " return %_NewConsString(14, true, 'abcdefghi', 'jklmn');" | 226 " return %_NewConsString(14, true, 'abcdefghi', 'jklmn');" |
243 " })", | 227 " })", |
244 flags); | 228 flags); |
245 | 229 |
246 T.CheckCall(T.Val("abcdefghijklmn")); | 230 T.CheckCall(T.Val("abcdefghijklmn")); |
247 } | 231 } |
248 | 232 |
249 | 233 |
250 TEST(SetValueOf) { | 234 TEST(SetValueOf) { |
251 FLAG_turbo_deoptimization = true; | |
252 FunctionTester T("(function(a,b) { return %_SetValueOf(a,b); })", flags); | 235 FunctionTester T("(function(a,b) { return %_SetValueOf(a,b); })", flags); |
253 | 236 |
254 T.CheckCall(T.Val("a"), T.NewObject("(new String)"), T.Val("a")); | 237 T.CheckCall(T.Val("a"), T.NewObject("(new String)"), T.Val("a")); |
255 T.CheckCall(T.Val(123), T.NewObject("(new Number)"), T.Val(123)); | 238 T.CheckCall(T.Val(123), T.NewObject("(new Number)"), T.Val(123)); |
256 T.CheckCall(T.Val("x"), T.undefined(), T.Val("x")); | 239 T.CheckCall(T.Val("x"), T.undefined(), T.Val("x")); |
257 } | 240 } |
258 | 241 |
259 | 242 |
260 TEST(StringAdd) { | 243 TEST(StringAdd) { |
261 FLAG_turbo_deoptimization = true; | |
262 FunctionTester T("(function(a,b) { return %_StringAdd(a,b); })", flags); | 244 FunctionTester T("(function(a,b) { return %_StringAdd(a,b); })", flags); |
263 | 245 |
264 T.CheckCall(T.Val("aaabbb"), T.Val("aaa"), T.Val("bbb")); | 246 T.CheckCall(T.Val("aaabbb"), T.Val("aaa"), T.Val("bbb")); |
265 T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val("")); | 247 T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val("")); |
266 T.CheckCall(T.Val("bbb"), T.Val(""), T.Val("bbb")); | 248 T.CheckCall(T.Val("bbb"), T.Val(""), T.Val("bbb")); |
267 } | 249 } |
268 | 250 |
269 | 251 |
270 TEST(StringCharAt) { | 252 TEST(StringCharAt) { |
271 FLAG_turbo_deoptimization = true; | |
272 FunctionTester T("(function(a,b) { return %_StringCharAt(a,b); })", flags); | 253 FunctionTester T("(function(a,b) { return %_StringCharAt(a,b); })", flags); |
273 | 254 |
274 T.CheckCall(T.Val("e"), T.Val("huge fan!"), T.Val(3)); | 255 T.CheckCall(T.Val("e"), T.Val("huge fan!"), T.Val(3)); |
275 T.CheckCall(T.Val("f"), T.Val("\xE2\x9D\x8A fan!"), T.Val(2)); | 256 T.CheckCall(T.Val("f"), T.Val("\xE2\x9D\x8A fan!"), T.Val(2)); |
276 T.CheckCall(T.Val(""), T.Val("not a fan!"), T.Val(23)); | 257 T.CheckCall(T.Val(""), T.Val("not a fan!"), T.Val(23)); |
277 } | 258 } |
278 | 259 |
279 | 260 |
280 TEST(StringCharCodeAt) { | 261 TEST(StringCharCodeAt) { |
281 FLAG_turbo_deoptimization = true; | |
282 FunctionTester T("(function(a,b) { return %_StringCharCodeAt(a,b); })", | 262 FunctionTester T("(function(a,b) { return %_StringCharCodeAt(a,b); })", |
283 flags); | 263 flags); |
284 | 264 |
285 T.CheckCall(T.Val('e'), T.Val("huge fan!"), T.Val(3)); | 265 T.CheckCall(T.Val('e'), T.Val("huge fan!"), T.Val(3)); |
286 T.CheckCall(T.Val('f'), T.Val("\xE2\x9D\x8A fan!"), T.Val(2)); | 266 T.CheckCall(T.Val('f'), T.Val("\xE2\x9D\x8A fan!"), T.Val(2)); |
287 T.CheckCall(T.nan(), T.Val("not a fan!"), T.Val(23)); | 267 T.CheckCall(T.nan(), T.Val("not a fan!"), T.Val(23)); |
288 } | 268 } |
289 | 269 |
290 | 270 |
291 TEST(StringCharFromCode) { | 271 TEST(StringCharFromCode) { |
292 FLAG_turbo_deoptimization = true; | |
293 FunctionTester T("(function(a) { return %_StringCharFromCode(a); })", flags); | 272 FunctionTester T("(function(a) { return %_StringCharFromCode(a); })", flags); |
294 | 273 |
295 T.CheckCall(T.Val("a"), T.Val(97)); | 274 T.CheckCall(T.Val("a"), T.Val(97)); |
296 T.CheckCall(T.Val("\xE2\x9D\x8A"), T.Val(0x274A)); | 275 T.CheckCall(T.Val("\xE2\x9D\x8A"), T.Val(0x274A)); |
297 T.CheckCall(T.Val(""), T.undefined()); | 276 T.CheckCall(T.Val(""), T.undefined()); |
298 } | 277 } |
299 | 278 |
300 | 279 |
301 TEST(StringCompare) { | 280 TEST(StringCompare) { |
302 FLAG_turbo_deoptimization = true; | |
303 FunctionTester T("(function(a,b) { return %_StringCompare(a,b); })", flags); | 281 FunctionTester T("(function(a,b) { return %_StringCompare(a,b); })", flags); |
304 | 282 |
305 T.CheckCall(T.Val(-1), T.Val("aaa"), T.Val("bbb")); | 283 T.CheckCall(T.Val(-1), T.Val("aaa"), T.Val("bbb")); |
306 T.CheckCall(T.Val(0.0), T.Val("bbb"), T.Val("bbb")); | 284 T.CheckCall(T.Val(0.0), T.Val("bbb"), T.Val("bbb")); |
307 T.CheckCall(T.Val(+1), T.Val("ccc"), T.Val("bbb")); | 285 T.CheckCall(T.Val(+1), T.Val("ccc"), T.Val("bbb")); |
308 } | 286 } |
309 | 287 |
310 | 288 |
311 TEST(SubString) { | 289 TEST(SubString) { |
312 FLAG_turbo_deoptimization = true; | |
313 FunctionTester T("(function(a,b) { return %_SubString(a,b,b+3); })", flags); | 290 FunctionTester T("(function(a,b) { return %_SubString(a,b,b+3); })", flags); |
314 | 291 |
315 T.CheckCall(T.Val("aaa"), T.Val("aaabbb"), T.Val(0.0)); | 292 T.CheckCall(T.Val("aaa"), T.Val("aaabbb"), T.Val(0.0)); |
316 T.CheckCall(T.Val("abb"), T.Val("aaabbb"), T.Val(2)); | 293 T.CheckCall(T.Val("abb"), T.Val("aaabbb"), T.Val(2)); |
317 T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val(0.0)); | 294 T.CheckCall(T.Val("aaa"), T.Val("aaa"), T.Val(0.0)); |
318 } | 295 } |
319 | 296 |
320 | 297 |
321 TEST(TwoByteSeqStringGetChar) { | 298 TEST(TwoByteSeqStringGetChar) { |
322 FLAG_turbo_deoptimization = true; | |
323 FunctionTester T("(function(a,b) { return %_TwoByteSeqStringGetChar(a,b); })", | 299 FunctionTester T("(function(a,b) { return %_TwoByteSeqStringGetChar(a,b); })", |
324 flags); | 300 flags); |
325 | 301 |
326 Handle<SeqTwoByteString> string = | 302 Handle<SeqTwoByteString> string = |
327 T.main_isolate()->factory()->NewRawTwoByteString(3).ToHandleChecked(); | 303 T.main_isolate()->factory()->NewRawTwoByteString(3).ToHandleChecked(); |
328 string->SeqTwoByteStringSet(0, 'b'); | 304 string->SeqTwoByteStringSet(0, 'b'); |
329 string->SeqTwoByteStringSet(1, 'a'); | 305 string->SeqTwoByteStringSet(1, 'a'); |
330 string->SeqTwoByteStringSet(2, 'r'); | 306 string->SeqTwoByteStringSet(2, 'r'); |
331 T.CheckCall(T.Val('b'), string, T.Val(0.0)); | 307 T.CheckCall(T.Val('b'), string, T.Val(0.0)); |
332 T.CheckCall(T.Val('a'), string, T.Val(1)); | 308 T.CheckCall(T.Val('a'), string, T.Val(1)); |
333 T.CheckCall(T.Val('r'), string, T.Val(2)); | 309 T.CheckCall(T.Val('r'), string, T.Val(2)); |
334 } | 310 } |
335 | 311 |
336 | 312 |
337 TEST(TwoByteSeqStringSetChar) { | 313 TEST(TwoByteSeqStringSetChar) { |
338 FLAG_turbo_deoptimization = true; | |
339 FunctionTester T("(function(a,b) { %_TwoByteSeqStringSetChar(a,88,b); })", | 314 FunctionTester T("(function(a,b) { %_TwoByteSeqStringSetChar(a,88,b); })", |
340 flags); | 315 flags); |
341 | 316 |
342 Handle<SeqTwoByteString> string = | 317 Handle<SeqTwoByteString> string = |
343 T.main_isolate()->factory()->NewRawTwoByteString(3).ToHandleChecked(); | 318 T.main_isolate()->factory()->NewRawTwoByteString(3).ToHandleChecked(); |
344 string->SeqTwoByteStringSet(0, 'b'); | 319 string->SeqTwoByteStringSet(0, 'b'); |
345 string->SeqTwoByteStringSet(1, 'a'); | 320 string->SeqTwoByteStringSet(1, 'a'); |
346 string->SeqTwoByteStringSet(2, 'r'); | 321 string->SeqTwoByteStringSet(2, 'r'); |
347 T.Call(T.Val(1), string); | 322 T.Call(T.Val(1), string); |
348 CHECK_EQ('b', string->SeqTwoByteStringGet(0)); | 323 CHECK_EQ('b', string->SeqTwoByteStringGet(0)); |
349 CHECK_EQ('X', string->SeqTwoByteStringGet(1)); | 324 CHECK_EQ('X', string->SeqTwoByteStringGet(1)); |
350 CHECK_EQ('r', string->SeqTwoByteStringGet(2)); | 325 CHECK_EQ('r', string->SeqTwoByteStringGet(2)); |
351 } | 326 } |
352 | 327 |
353 | 328 |
354 TEST(ValueOf) { | 329 TEST(ValueOf) { |
355 FLAG_turbo_deoptimization = true; | |
356 FunctionTester T("(function(a) { return %_ValueOf(a); })", flags); | 330 FunctionTester T("(function(a) { return %_ValueOf(a); })", flags); |
357 | 331 |
358 T.CheckCall(T.Val("a"), T.Val("a")); | 332 T.CheckCall(T.Val("a"), T.Val("a")); |
359 T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); | 333 T.CheckCall(T.Val("b"), T.NewObject("(new String('b'))")); |
360 T.CheckCall(T.Val(123), T.Val(123)); | 334 T.CheckCall(T.Val(123), T.Val(123)); |
361 T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); | 335 T.CheckCall(T.Val(456), T.NewObject("(new Number(456))")); |
362 } | 336 } |
OLD | NEW |