OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 "src/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/interpreter/bytecode-generator.h" | 8 #include "src/interpreter/bytecode-generator.h" |
9 #include "src/interpreter/interpreter.h" | 9 #include "src/interpreter/interpreter.h" |
10 #include "test/cctest/cctest.h" | 10 #include "test/cctest/cctest.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 namespace interpreter { | 14 namespace interpreter { |
15 | 15 |
16 class BytecodeGeneratorHelper { | 16 class BytecodeGeneratorHelper { |
17 public: | 17 public: |
18 const char* kFunctionName = "f"; | 18 const char* kFunctionName = "f"; |
19 | 19 |
| 20 const int kLastParamIndex = |
| 21 -InterpreterFrameConstants::kLastParamFromRegisterPointer / kPointerSize; |
| 22 |
20 BytecodeGeneratorHelper() { | 23 BytecodeGeneratorHelper() { |
21 i::FLAG_ignition = true; | 24 i::FLAG_ignition = true; |
22 i::FLAG_ignition_filter = kFunctionName; | 25 i::FLAG_ignition_filter = kFunctionName; |
23 CcTest::i_isolate()->interpreter()->Initialize(); | 26 CcTest::i_isolate()->interpreter()->Initialize(); |
24 } | 27 } |
25 | 28 |
26 | 29 |
| 30 Factory* factory() { return CcTest::i_isolate()->factory(); } |
| 31 |
| 32 |
27 Handle<BytecodeArray> MakeBytecode(const char* script, | 33 Handle<BytecodeArray> MakeBytecode(const char* script, |
28 const char* function_name) { | 34 const char* function_name) { |
29 CompileRun(script); | 35 CompileRun(script); |
30 Local<Function> function = | 36 Local<Function> function = |
31 Local<Function>::Cast(CcTest::global()->Get(v8_str(function_name))); | 37 Local<Function>::Cast(CcTest::global()->Get(v8_str(function_name))); |
32 i::Handle<i::JSFunction> js_function = v8::Utils::OpenHandle(*function); | 38 i::Handle<i::JSFunction> js_function = v8::Utils::OpenHandle(*function); |
33 return handle(js_function->shared()->bytecode_array(), CcTest::i_isolate()); | 39 return handle(js_function->shared()->bytecode_array(), CcTest::i_isolate()); |
34 } | 40 } |
35 | 41 |
36 | 42 |
37 Handle<BytecodeArray> MakeBytecodeForFunctionBody(const char* body) { | 43 Handle<BytecodeArray> MakeBytecodeForFunctionBody(const char* body) { |
38 ScopedVector<char> program(1024); | 44 ScopedVector<char> program(1024); |
39 SNPrintF(program, "function %s() { %s }\n%s();", kFunctionName, body, | 45 SNPrintF(program, "function %s() { %s }\n%s();", kFunctionName, body, |
40 kFunctionName); | 46 kFunctionName); |
41 return MakeBytecode(program.start(), kFunctionName); | 47 return MakeBytecode(program.start(), kFunctionName); |
42 } | 48 } |
43 | 49 |
44 Handle<BytecodeArray> MakeBytecodeForFunction(const char* function) { | 50 Handle<BytecodeArray> MakeBytecodeForFunction(const char* function) { |
45 ScopedVector<char> program(1024); | 51 ScopedVector<char> program(1024); |
46 SNPrintF(program, "%s\n%s();", function, kFunctionName); | 52 SNPrintF(program, "%s\n%s();", function, kFunctionName); |
47 return MakeBytecode(program.start(), kFunctionName); | 53 return MakeBytecode(program.start(), kFunctionName); |
48 } | 54 } |
49 }; | 55 }; |
50 | 56 |
51 | 57 |
52 // Structure for containing expected bytecode snippets. | 58 // Structure for containing expected bytecode snippets. |
53 template<typename T> | 59 template<typename T> |
54 struct ExpectedSnippet { | 60 struct ExpectedSnippet { |
55 const char* body; | 61 const char* code_snippet; |
56 int frame_size; | 62 int frame_size; |
57 int parameter_count; | 63 int parameter_count; |
58 int bytecode_length; | 64 int bytecode_length; |
59 const uint8_t bytecode[16]; | 65 const uint8_t bytecode[24]; |
60 int constant_count; | 66 int constant_count; |
61 T constants[16]; | 67 T constants[16]; |
62 }; | 68 }; |
63 | 69 |
64 | 70 |
65 // Helper macros for handcrafting bytecode sequences. | 71 // Helper macros for handcrafting bytecode sequences. |
66 #define B(x) static_cast<uint8_t>(Bytecode::k##x) | 72 #define B(x) static_cast<uint8_t>(Bytecode::k##x) |
67 #define U8(x) static_cast<uint8_t>((x) & 0xff) | 73 #define U8(x) static_cast<uint8_t>((x) & 0xff) |
68 #define R(x) static_cast<uint8_t>(-(x) & 0xff) | 74 #define R(x) static_cast<uint8_t>(-(x) & 0xff) |
69 | 75 |
(...skipping 10 matching lines...) Expand all Loading... |
80 {"return 0;", 0, 1, 2, {B(LdaZero), B(Return)}, 0}, | 86 {"return 0;", 0, 1, 2, {B(LdaZero), B(Return)}, 0}, |
81 {"return +1;", 0, 1, 3, {B(LdaSmi8), U8(1), B(Return)}, 0}, | 87 {"return +1;", 0, 1, 3, {B(LdaSmi8), U8(1), B(Return)}, 0}, |
82 {"return -1;", 0, 1, 3, {B(LdaSmi8), U8(-1), B(Return)}, 0}, | 88 {"return -1;", 0, 1, 3, {B(LdaSmi8), U8(-1), B(Return)}, 0}, |
83 {"return +127;", 0, 1, 3, {B(LdaSmi8), U8(127), B(Return)}, 0}, | 89 {"return +127;", 0, 1, 3, {B(LdaSmi8), U8(127), B(Return)}, 0}, |
84 {"return -128;", 0, 1, 3, {B(LdaSmi8), U8(-128), B(Return)}, 0}, | 90 {"return -128;", 0, 1, 3, {B(LdaSmi8), U8(-128), B(Return)}, 0}, |
85 }; | 91 }; |
86 | 92 |
87 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); | 93 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
88 for (size_t i = 0; i < num_snippets; i++) { | 94 for (size_t i = 0; i < num_snippets; i++) { |
89 Handle<BytecodeArray> ba = | 95 Handle<BytecodeArray> ba = |
90 helper.MakeBytecodeForFunctionBody(snippets[i].body); | 96 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
91 CHECK_EQ(ba->frame_size(), snippets[i].frame_size); | 97 CHECK_EQ(ba->frame_size(), snippets[i].frame_size); |
92 CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count); | 98 CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count); |
93 CHECK_EQ(ba->length(), snippets[i].bytecode_length); | 99 CHECK_EQ(ba->length(), snippets[i].bytecode_length); |
94 CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode, | 100 CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode, |
95 ba->length())); | 101 ba->length())); |
96 CHECK_EQ(ba->constant_pool(), CcTest::heap()->empty_fixed_array()); | 102 CHECK_EQ(ba->constant_pool(), CcTest::heap()->empty_fixed_array()); |
97 } | 103 } |
98 } | 104 } |
99 | 105 |
100 | 106 |
(...skipping 26 matching lines...) Expand all Loading... |
127 B(LdaSmi8), U8(3), // | 133 B(LdaSmi8), U8(3), // |
128 B(Add), R(1), // | 134 B(Add), R(1), // |
129 B(Return) // | 135 B(Return) // |
130 }, | 136 }, |
131 0 | 137 0 |
132 }}; | 138 }}; |
133 | 139 |
134 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); | 140 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
135 for (size_t i = 0; i < num_snippets; i++) { | 141 for (size_t i = 0; i < num_snippets; i++) { |
136 Handle<BytecodeArray> ba = | 142 Handle<BytecodeArray> ba = |
137 helper.MakeBytecodeForFunctionBody(snippets[i].body); | 143 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
138 CHECK_EQ(ba->frame_size(), snippets[i].frame_size); | 144 CHECK_EQ(ba->frame_size(), snippets[i].frame_size); |
139 CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count); | 145 CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count); |
140 CHECK_EQ(ba->length(), snippets[i].bytecode_length); | 146 CHECK_EQ(ba->length(), snippets[i].bytecode_length); |
141 CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode, | 147 CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode, |
142 ba->length())); | 148 ba->length())); |
143 CHECK_EQ(ba->constant_pool(), CcTest::heap()->empty_fixed_array()); | 149 CHECK_EQ(ba->constant_pool(), CcTest::heap()->empty_fixed_array()); |
144 } | 150 } |
145 } | 151 } |
146 | 152 |
147 | 153 |
148 TEST(Parameters) { | 154 TEST(Parameters) { |
149 InitializedHandleScope handle_scope; | 155 InitializedHandleScope handle_scope; |
150 BytecodeGeneratorHelper helper; | 156 BytecodeGeneratorHelper helper; |
151 | 157 |
152 int last_param_index = | |
153 -InterpreterFrameConstants::kLastParamFromRegisterPointer / kPointerSize; | |
154 ExpectedSnippet<void*> snippets[] = { | 158 ExpectedSnippet<void*> snippets[] = { |
155 {"function f() { return this; }", | 159 {"function f() { return this; }", |
156 0, 1, 3, {B(Ldar), R(last_param_index), B(Return)}, 0}, | 160 0, 1, 3, {B(Ldar), R(helper.kLastParamIndex), B(Return)}, 0}, |
157 {"function f(arg1) { return arg1; }", | 161 {"function f(arg1) { return arg1; }", |
158 0, 2, 3, {B(Ldar), R(last_param_index), B(Return)}, 0}, | 162 0, 2, 3, {B(Ldar), R(helper.kLastParamIndex), B(Return)}, 0}, |
159 {"function f(arg1) { return this; }", | 163 {"function f(arg1) { return this; }", |
160 0, 2, 3, {B(Ldar), R(last_param_index - 1), B(Return)}, 0}, | 164 0, 2, 3, {B(Ldar), R(helper.kLastParamIndex - 1), B(Return)}, 0}, |
161 {"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return arg4; }", | 165 {"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return arg4; }", |
162 0, 8, 3, {B(Ldar), R(last_param_index - 3), B(Return)}, 0}, | 166 0, 8, 3, {B(Ldar), R(helper.kLastParamIndex - 3), B(Return)}, 0}, |
163 {"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return this; }", | 167 {"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return this; }", |
164 0, 8, 3, {B(Ldar), R(last_param_index - 7), B(Return)}, 0} | 168 0, 8, 3, {B(Ldar), R(helper.kLastParamIndex - 7), B(Return)}, 0} |
165 }; | 169 }; |
166 | 170 |
167 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); | 171 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
168 for (size_t i = 0; i < num_snippets; i++) { | 172 for (size_t i = 0; i < num_snippets; i++) { |
169 Handle<BytecodeArray> ba = helper.MakeBytecodeForFunction(snippets[i].body); | 173 Handle<BytecodeArray> ba = |
| 174 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
170 CHECK_EQ(ba->frame_size(), snippets[i].frame_size); | 175 CHECK_EQ(ba->frame_size(), snippets[i].frame_size); |
171 CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count); | 176 CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count); |
172 CHECK_EQ(ba->length(), snippets[i].bytecode_length); | 177 CHECK_EQ(ba->length(), snippets[i].bytecode_length); |
173 CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode, | 178 CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode, |
174 ba->length())); | 179 ba->length())); |
175 CHECK_EQ(ba->constant_pool(), CcTest::heap()->empty_fixed_array()); | 180 CHECK_EQ(ba->constant_pool(), CcTest::heap()->empty_fixed_array()); |
176 } | 181 } |
177 } | 182 } |
178 | 183 |
179 | 184 |
(...skipping 25 matching lines...) Expand all Loading... |
205 B(Star), R(0), | 210 B(Star), R(0), |
206 B(LdaConstant), U8(0), | 211 B(LdaConstant), U8(0), |
207 B(Return) | 212 B(Return) |
208 }, 1, { 1234 } | 213 }, 1, { 1234 } |
209 } | 214 } |
210 }; | 215 }; |
211 | 216 |
212 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); | 217 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
213 for (size_t i = 0; i < num_snippets; i++) { | 218 for (size_t i = 0; i < num_snippets; i++) { |
214 Handle<BytecodeArray> ba = | 219 Handle<BytecodeArray> ba = |
215 helper.MakeBytecodeForFunctionBody(snippets[i].body); | 220 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
216 CHECK_EQ(ba->frame_size(), snippets[i].frame_size); | 221 CHECK_EQ(ba->frame_size(), snippets[i].frame_size); |
217 CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count); | 222 CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count); |
218 CHECK_EQ(ba->length(), snippets[i].bytecode_length); | 223 CHECK_EQ(ba->length(), snippets[i].bytecode_length); |
219 CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode, | 224 CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode, |
220 ba->length())); | 225 ba->length())); |
221 CHECK_EQ(ba->constant_pool()->length(), snippets[i].constant_count); | 226 CHECK_EQ(ba->constant_pool()->length(), snippets[i].constant_count); |
222 for (int j = 0; j < snippets[i].constant_count; j++) { | 227 for (int j = 0; j < snippets[i].constant_count; j++) { |
223 CHECK_EQ(Smi::cast(ba->constant_pool()->get(j))->value(), | 228 CHECK_EQ(Smi::cast(ba->constant_pool()->get(j))->value(), |
224 snippets[i].constants[j]); | 229 snippets[i].constants[j]); |
225 } | 230 } |
(...skipping 28 matching lines...) Expand all Loading... |
254 // TODO(rmcilroy): Currently multiple identical double literals end up | 259 // TODO(rmcilroy): Currently multiple identical double literals end up |
255 // being allocated as new HeapNumbers and so require multiple constant | 260 // being allocated as new HeapNumbers and so require multiple constant |
256 // pool entries. De-dup identical values. | 261 // pool entries. De-dup identical values. |
257 { 3.14, 3.14 } | 262 { 3.14, 3.14 } |
258 } | 263 } |
259 }; | 264 }; |
260 | 265 |
261 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); | 266 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
262 for (size_t i = 0; i < num_snippets; i++) { | 267 for (size_t i = 0; i < num_snippets; i++) { |
263 Handle<BytecodeArray> ba = | 268 Handle<BytecodeArray> ba = |
264 helper.MakeBytecodeForFunctionBody(snippets[i].body); | 269 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
265 CHECK_EQ(ba->frame_size(), snippets[i].frame_size); | 270 CHECK_EQ(ba->frame_size(), snippets[i].frame_size); |
266 CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count); | 271 CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count); |
267 CHECK_EQ(ba->length(), snippets[i].bytecode_length); | 272 CHECK_EQ(ba->length(), snippets[i].bytecode_length); |
268 CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode, | 273 CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode, |
269 ba->length())); | 274 ba->length())); |
270 CHECK_EQ(ba->constant_pool()->length(), snippets[i].constant_count); | 275 CHECK_EQ(ba->constant_pool()->length(), snippets[i].constant_count); |
271 for (int j = 0; j < snippets[i].constant_count; j++) { | 276 for (int j = 0; j < snippets[i].constant_count; j++) { |
272 CHECK_EQ(HeapNumber::cast(ba->constant_pool()->get(j))->value(), | 277 CHECK_EQ(HeapNumber::cast(ba->constant_pool()->get(j))->value(), |
273 snippets[i].constants[j]); | 278 snippets[i].constants[j]); |
274 } | 279 } |
(...skipping 26 matching lines...) Expand all Loading... |
301 B(Star), R(0), | 306 B(Star), R(0), |
302 B(LdaConstant), U8(0), | 307 B(LdaConstant), U8(0), |
303 B(Return) | 308 B(Return) |
304 }, 1, { "Same string" } | 309 }, 1, { "Same string" } |
305 } | 310 } |
306 }; | 311 }; |
307 | 312 |
308 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); | 313 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
309 for (size_t i = 0; i < num_snippets; i++) { | 314 for (size_t i = 0; i < num_snippets; i++) { |
310 Handle<BytecodeArray> ba = | 315 Handle<BytecodeArray> ba = |
311 helper.MakeBytecodeForFunctionBody(snippets[i].body); | 316 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
312 CHECK_EQ(ba->frame_size(), snippets[i].frame_size); | 317 CHECK_EQ(ba->frame_size(), snippets[i].frame_size); |
313 CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count); | 318 CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count); |
314 CHECK_EQ(ba->length(), snippets[i].bytecode_length); | 319 CHECK_EQ(ba->length(), snippets[i].bytecode_length); |
315 CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode, | 320 CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode, |
316 ba->length())); | 321 ba->length())); |
317 CHECK_EQ(ba->constant_pool()->length(), snippets[i].constant_count); | 322 CHECK_EQ(ba->constant_pool()->length(), snippets[i].constant_count); |
318 for (int j = 0; j < snippets[i].constant_count; j++) { | 323 for (int j = 0; j < snippets[i].constant_count; j++) { |
319 Handle<String> expected = | 324 Handle<String> expected = helper.factory()->NewStringFromAsciiChecked( |
320 CcTest::i_isolate()->factory()->NewStringFromAsciiChecked( | 325 snippets[i].constants[j]); |
321 snippets[i].constants[j]); | |
322 CHECK(String::cast(ba->constant_pool()->get(j))->Equals(*expected)); | 326 CHECK(String::cast(ba->constant_pool()->get(j))->Equals(*expected)); |
323 } | 327 } |
324 } | 328 } |
325 } | 329 } |
326 } | 330 } |
327 | 331 |
328 | 332 |
| 333 TEST(PropertyLoads) { |
| 334 InitializedHandleScope handle_scope; |
| 335 BytecodeGeneratorHelper helper; |
| 336 |
| 337 Code::Kind ic_kinds[] = { i::Code::LOAD_IC, i::Code::LOAD_IC }; |
| 338 FeedbackVectorSpec feedback_spec(0, 1, ic_kinds); |
| 339 Handle<i::TypeFeedbackVector> vector = |
| 340 helper.factory()->NewTypeFeedbackVector(&feedback_spec); |
| 341 |
| 342 ExpectedSnippet<const char*> snippets[] = { |
| 343 {"function f(a) { return a.name; }\nf({name : \"test\"})", |
| 344 1 * kPointerSize, 2, 10, |
| 345 { |
| 346 B(Ldar), R(helper.kLastParamIndex), |
| 347 B(Star), R(0), |
| 348 B(LdaConstant), U8(0), |
| 349 B(LoadIC), R(0), U8(vector->first_ic_slot_index()), |
| 350 B(Return) |
| 351 }, |
| 352 1, { "name" } |
| 353 }, |
| 354 {"function f(a) { return a[\"key\"]; }\nf({key : \"test\"})", |
| 355 1 * kPointerSize, 2, 10, |
| 356 { |
| 357 B(Ldar), R(helper.kLastParamIndex), |
| 358 B(Star), R(0), |
| 359 B(LdaConstant), U8(0), |
| 360 B(LoadIC), R(0), U8(vector->first_ic_slot_index()), |
| 361 B(Return) |
| 362 }, |
| 363 1, { "key" } |
| 364 }, |
| 365 {"function f(a) { return a[100]; }\nf({100 : \"test\"})", |
| 366 1 * kPointerSize, 2, 10, |
| 367 { |
| 368 B(Ldar), R(helper.kLastParamIndex), |
| 369 B(Star), R(0), |
| 370 B(LdaSmi8), U8(100), |
| 371 B(KeyedLoadIC), R(0), U8(vector->first_ic_slot_index()), |
| 372 B(Return) |
| 373 }, 0 |
| 374 }, |
| 375 {"function f(a, b) { return a[b]; }\nf({arg : \"test\"}, \"arg\")", |
| 376 1 * kPointerSize, 3, 10, |
| 377 { |
| 378 B(Ldar), R(helper.kLastParamIndex - 1), |
| 379 B(Star), R(0), |
| 380 B(Ldar), R(helper.kLastParamIndex), |
| 381 B(KeyedLoadIC), R(0), U8(vector->first_ic_slot_index()), |
| 382 B(Return) |
| 383 }, 0 |
| 384 }, |
| 385 {"function f(a) { var b = a.name; return a[-124]; }\n" |
| 386 "f({\"-124\" : \"test\", name : 123 })", |
| 387 2 * kPointerSize, 2, 21, |
| 388 { |
| 389 B(Ldar), R(helper.kLastParamIndex), |
| 390 B(Star), R(1), |
| 391 B(LdaConstant), U8(0), |
| 392 B(LoadIC), R(1), U8(vector->first_ic_slot_index()), |
| 393 B(Star), R(0), |
| 394 B(Ldar), R(helper.kLastParamIndex), |
| 395 B(Star), R(1), |
| 396 B(LdaSmi8), U8(-124), |
| 397 B(KeyedLoadIC), R(1), U8(vector->first_ic_slot_index() + 2), |
| 398 B(Return) |
| 399 }, |
| 400 1, { "name" } |
| 401 } |
| 402 }; |
| 403 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
| 404 for (size_t i = 0; i < num_snippets; i++) { |
| 405 Handle<BytecodeArray> ba = |
| 406 helper.MakeBytecode(snippets[i].code_snippet, "f"); |
| 407 CHECK_EQ(ba->frame_size(), snippets[i].frame_size); |
| 408 CHECK_EQ(ba->parameter_count(), snippets[i].parameter_count); |
| 409 CHECK_EQ(ba->length(), snippets[i].bytecode_length); |
| 410 CHECK(!memcmp(ba->GetFirstBytecodeAddress(), snippets[i].bytecode, |
| 411 ba->length())); |
| 412 CHECK_EQ(ba->constant_pool()->length(), snippets[i].constant_count); |
| 413 for (int j = 0; j < snippets[i].constant_count; j++) { |
| 414 Handle<String> expected = helper.factory()->NewStringFromAsciiChecked( |
| 415 snippets[i].constants[j]); |
| 416 CHECK(String::cast(ba->constant_pool()->get(j))->Equals(*expected)); |
| 417 } |
| 418 } |
| 419 } |
| 420 |
329 } // namespace interpreter | 421 } // namespace interpreter |
330 } // namespace internal | 422 } // namespace internal |
331 } // namespance v8 | 423 } // namespance v8 |
OLD | NEW |