| 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-array-iterator.h" | 8 #include "src/interpreter/bytecode-array-iterator.h" |
| 9 #include "src/interpreter/bytecode-generator.h" | 9 #include "src/interpreter/bytecode-generator.h" |
| 10 #include "src/interpreter/interpreter.h" | 10 #include "src/interpreter/interpreter.h" |
| (...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2206 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2206 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2207 } | 2207 } |
| 2208 } | 2208 } |
| 2209 | 2209 |
| 2210 | 2210 |
| 2211 TEST(BreakableBlocks) { | 2211 TEST(BreakableBlocks) { |
| 2212 InitializedHandleScope handle_scope; | 2212 InitializedHandleScope handle_scope; |
| 2213 BytecodeGeneratorHelper helper; | 2213 BytecodeGeneratorHelper helper; |
| 2214 | 2214 |
| 2215 int closure = Register::function_closure().index(); | 2215 int closure = Register::function_closure().index(); |
| 2216 int context = Register::function_context().index(); | 2216 int context = Register::current_context().index(); |
| 2217 | 2217 |
| 2218 ExpectedSnippet<InstanceType> snippets[] = { | 2218 ExpectedSnippet<InstanceType> snippets[] = { |
| 2219 {"var x = 0;\n" | 2219 {"var x = 0;\n" |
| 2220 "label: {\n" | 2220 "label: {\n" |
| 2221 " x = x + 1;\n" | 2221 " x = x + 1;\n" |
| 2222 " break label;\n" | 2222 " break label;\n" |
| 2223 " x = x + 1;\n" | 2223 " x = x + 1;\n" |
| 2224 "}\n" | 2224 "}\n" |
| 2225 "return x;", | 2225 "return x;", |
| 2226 2 * kPointerSize, | 2226 2 * kPointerSize, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2302 1, | 2302 1, |
| 2303 39, | 2303 39, |
| 2304 { | 2304 { |
| 2305 B(LdaConstant), U8(0), // | 2305 B(LdaConstant), U8(0), // |
| 2306 B(Star), R(3), // | 2306 B(Star), R(3), // |
| 2307 B(Ldar), R(closure), // | 2307 B(Ldar), R(closure), // |
| 2308 B(Star), R(4), // | 2308 B(Star), R(4), // |
| 2309 B(CallRuntime), U16(Runtime::kPushBlockContext), R(3), U8(2), // | 2309 B(CallRuntime), U16(Runtime::kPushBlockContext), R(3), U8(2), // |
| 2310 B(PushContext), R(2), // | 2310 B(PushContext), R(2), // |
| 2311 B(LdaTheHole), // | 2311 B(LdaTheHole), // |
| 2312 B(StaContextSlot), R(2), U8(4), // | 2312 B(StaContextSlot), R(context), U8(4), // |
| 2313 B(CreateClosure), U8(1), U8(0), // | 2313 B(CreateClosure), U8(1), U8(0), // |
| 2314 B(Star), R(0), // | 2314 B(Star), R(0), // |
| 2315 B(LdaSmi8), U8(10), // | 2315 B(LdaSmi8), U8(10), // |
| 2316 B(StaContextSlot), R(2), U8(4), // | 2316 B(StaContextSlot), R(context), U8(4), // |
| 2317 B(Ldar), R(0), // | 2317 B(Ldar), R(0), // |
| 2318 B(Star), R(1), // | 2318 B(Star), R(1), // |
| 2319 B(Jump), U8(2), // | 2319 B(Jump), U8(2), // |
| 2320 B(PopContext), R(context), // | 2320 B(PopContext), R(2), // |
| 2321 B(LdaUndefined), // | 2321 B(LdaUndefined), // |
| 2322 B(Return), // | 2322 B(Return), // |
| 2323 }, | 2323 }, |
| 2324 2, | 2324 2, |
| 2325 {InstanceType::FIXED_ARRAY_TYPE, | 2325 {InstanceType::FIXED_ARRAY_TYPE, |
| 2326 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2326 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2327 {"let x = 1;\n" | 2327 {"let x = 1;\n" |
| 2328 "outer: {\n" | 2328 "outer: {\n" |
| 2329 " inner: {\n" | 2329 " inner: {\n" |
| 2330 " let y = 2;\n" | 2330 " let y = 2;\n" |
| 2331 " function f() { return x + y; }\n" | 2331 " function f() { return x + y; }\n" |
| 2332 " if (y) break outer;\n" | 2332 " if (y) break outer;\n" |
| 2333 " y = 3;\n" | 2333 " y = 3;\n" |
| 2334 " }\n" | 2334 " }\n" |
| 2335 "}\n" | 2335 "}\n" |
| 2336 "x = 4;", | 2336 "x = 4;", |
| 2337 6 * kPointerSize, | 2337 6 * kPointerSize, |
| 2338 1, | 2338 1, |
| 2339 72, | 2339 72, |
| 2340 { | 2340 { |
| 2341 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 2341 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 2342 U8(1), // | 2342 U8(1), // |
| 2343 B(PushContext), R(2), // | 2343 B(PushContext), R(2), // |
| 2344 B(LdaTheHole), // | 2344 B(LdaTheHole), // |
| 2345 B(StaContextSlot), R(2), U8(4), // | 2345 B(StaContextSlot), R(context), U8(4), // |
| 2346 B(LdaSmi8), U8(1), // | 2346 B(LdaSmi8), U8(1), // |
| 2347 B(StaContextSlot), R(2), U8(4), // | 2347 B(StaContextSlot), R(context), U8(4), // |
| 2348 B(LdaConstant), U8(0), // | 2348 B(LdaConstant), U8(0), // |
| 2349 B(Star), R(4), // | 2349 B(Star), R(4), // |
| 2350 B(Ldar), R(closure), // | 2350 B(Ldar), R(closure), // |
| 2351 B(Star), R(5), // | 2351 B(Star), R(5), // |
| 2352 B(CallRuntime), U16(Runtime::kPushBlockContext), R(4), U8(2), // | 2352 B(CallRuntime), U16(Runtime::kPushBlockContext), R(4), U8(2), // |
| 2353 B(PushContext), R(3), // | 2353 B(PushContext), R(3), // |
| 2354 B(LdaTheHole), // | 2354 B(LdaTheHole), // |
| 2355 B(StaContextSlot), R(3), U8(4), // | 2355 B(StaContextSlot), R(context), U8(4), // |
| 2356 B(CreateClosure), U8(1), U8(0), // | 2356 B(CreateClosure), U8(1), U8(0), // |
| 2357 B(Star), R(0), // | 2357 B(Star), R(0), // |
| 2358 B(LdaSmi8), U8(2), // | 2358 B(LdaSmi8), U8(2), // |
| 2359 B(StaContextSlot), R(3), U8(4), // | 2359 B(StaContextSlot), R(context), U8(4), // |
| 2360 B(Ldar), R(0), // | 2360 B(Ldar), R(0), // |
| 2361 B(Star), R(1), // | 2361 B(Star), R(1), // |
| 2362 B(LdaContextSlot), R(3), U8(4), // | 2362 B(LdaContextSlot), R(context), U8(4), // |
| 2363 B(JumpIfToBooleanFalse), U8(6), // | 2363 B(JumpIfToBooleanFalse), U8(6), // |
| 2364 B(PopContext), R(2), // | 2364 B(PopContext), R(3), // |
| 2365 B(Jump), U8(9), // | 2365 B(Jump), U8(9), // |
| 2366 B(LdaSmi8), U8(3), // | 2366 B(LdaSmi8), U8(3), // |
| 2367 B(StaContextSlot), R(3), U8(4), // | 2367 B(StaContextSlot), R(context), U8(4), // |
| 2368 B(PopContext), R(2), // | 2368 B(PopContext), R(3), // |
| 2369 B(LdaSmi8), U8(4), // | 2369 B(LdaSmi8), U8(4), // |
| 2370 B(StaContextSlot), R(2), U8(4), // | 2370 B(StaContextSlot), R(context), U8(4), // |
| 2371 B(LdaUndefined), // | 2371 B(LdaUndefined), // |
| 2372 B(Return), // | 2372 B(Return), // |
| 2373 }, | 2373 }, |
| 2374 2, | 2374 2, |
| 2375 {InstanceType::FIXED_ARRAY_TYPE, | 2375 {InstanceType::FIXED_ARRAY_TYPE, |
| 2376 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 2376 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 2377 }; | 2377 }; |
| 2378 | 2378 |
| 2379 for (size_t i = 0; i < arraysize(snippets); i++) { | 2379 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2380 Handle<BytecodeArray> bytecode_array = | 2380 Handle<BytecodeArray> bytecode_array = |
| 2381 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 2381 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 2382 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 2382 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 2383 } | 2383 } |
| 2384 } | 2384 } |
| 2385 | 2385 |
| 2386 | 2386 |
| 2387 TEST(BasicLoops) { | 2387 TEST(BasicLoops) { |
| 2388 InitializedHandleScope handle_scope; | 2388 InitializedHandleScope handle_scope; |
| 2389 BytecodeGeneratorHelper helper; | 2389 BytecodeGeneratorHelper helper; |
| 2390 | 2390 |
| 2391 int closure = Register::function_closure().index(); | 2391 int closure = Register::function_closure().index(); |
| 2392 int context = Register::function_context().index(); | 2392 int context = Register::current_context().index(); |
| 2393 | 2393 |
| 2394 ExpectedSnippet<InstanceType> snippets[] = { | 2394 ExpectedSnippet<InstanceType> snippets[] = { |
| 2395 {"var x = 0;\n" | 2395 {"var x = 0;\n" |
| 2396 "while (false) { x = 99; break; continue; }\n" | 2396 "while (false) { x = 99; break; continue; }\n" |
| 2397 "return x;", | 2397 "return x;", |
| 2398 1 * kPointerSize, | 2398 1 * kPointerSize, |
| 2399 1, | 2399 1, |
| 2400 4, | 2400 4, |
| 2401 { | 2401 { |
| 2402 B(LdaZero), // | 2402 B(LdaZero), // |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3020 B(Star), R(1), // | 3020 B(Star), R(1), // |
| 3021 B(Ldar), R(1), // | 3021 B(Ldar), R(1), // |
| 3022 B(JumpIfToBooleanFalse), U8(58), // | 3022 B(JumpIfToBooleanFalse), U8(58), // |
| 3023 B(LdaConstant), U8(0), // | 3023 B(LdaConstant), U8(0), // |
| 3024 B(Star), R(4), // | 3024 B(Star), R(4), // |
| 3025 B(Ldar), R(closure), // | 3025 B(Ldar), R(closure), // |
| 3026 B(Star), R(5), // | 3026 B(Star), R(5), // |
| 3027 B(CallRuntime), U16(Runtime::kPushBlockContext), R(4), U8(2), // | 3027 B(CallRuntime), U16(Runtime::kPushBlockContext), R(4), U8(2), // |
| 3028 B(PushContext), R(3), // | 3028 B(PushContext), R(3), // |
| 3029 B(LdaTheHole), // | 3029 B(LdaTheHole), // |
| 3030 B(StaContextSlot), R(3), U8(4), // | 3030 B(StaContextSlot), R(context), U8(4), // |
| 3031 B(CreateClosure), U8(1), U8(0), // | 3031 B(CreateClosure), U8(1), U8(0), // |
| 3032 B(Star), R(0), // | 3032 B(Star), R(0), // |
| 3033 B(LdaSmi8), U8(1), // | 3033 B(LdaSmi8), U8(1), // |
| 3034 B(StaContextSlot), R(3), U8(4), // | 3034 B(StaContextSlot), R(context), U8(4), // |
| 3035 B(Ldar), R(0), // | 3035 B(Ldar), R(0), // |
| 3036 B(Star), R(2), // | 3036 B(Star), R(2), // |
| 3037 B(LdaContextSlot), R(3), U8(4), // | 3037 B(LdaContextSlot), R(context), U8(4), // |
| 3038 B(JumpIfToBooleanFalse), U8(6), // | 3038 B(JumpIfToBooleanFalse), U8(6), // |
| 3039 B(PopContext), R(context), // | 3039 B(PopContext), R(3), // |
| 3040 B(Jump), U8(-44), // | 3040 B(Jump), U8(-44), // |
| 3041 B(LdaContextSlot), R(3), U8(4), // | 3041 B(LdaContextSlot), R(context), U8(4), // |
| 3042 B(ToNumber), // | 3042 B(ToNumber), // |
| 3043 B(Star), R(4), // | 3043 B(Star), R(4), // |
| 3044 B(Inc), // | 3044 B(Inc), // |
| 3045 B(StaContextSlot), R(3), U8(4), // | 3045 B(StaContextSlot), R(context), U8(4), // |
| 3046 B(PopContext), R(context), // | 3046 B(PopContext), R(3), // |
| 3047 B(Jump), U8(-58), // | 3047 B(Jump), U8(-58), // |
| 3048 B(LdaUndefined), // | 3048 B(LdaUndefined), // |
| 3049 B(Return), // | 3049 B(Return), // |
| 3050 }, | 3050 }, |
| 3051 2, | 3051 2, |
| 3052 {InstanceType::FIXED_ARRAY_TYPE, | 3052 {InstanceType::FIXED_ARRAY_TYPE, |
| 3053 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3053 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3054 }; | 3054 }; |
| 3055 | 3055 |
| 3056 for (size_t i = 0; i < arraysize(snippets); i++) { | 3056 for (size_t i = 0; i < arraysize(snippets); i++) { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3346 } | 3346 } |
| 3347 | 3347 |
| 3348 | 3348 |
| 3349 TEST(Delete) { | 3349 TEST(Delete) { |
| 3350 InitializedHandleScope handle_scope; | 3350 InitializedHandleScope handle_scope; |
| 3351 BytecodeGeneratorHelper helper; | 3351 BytecodeGeneratorHelper helper; |
| 3352 | 3352 |
| 3353 int deep_elements_flags = | 3353 int deep_elements_flags = |
| 3354 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; | 3354 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; |
| 3355 int closure = Register::function_closure().index(); | 3355 int closure = Register::function_closure().index(); |
| 3356 int context = Register::current_context().index(); |
| 3356 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 3357 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 3357 | 3358 |
| 3358 ExpectedSnippet<InstanceType> snippets[] = { | 3359 ExpectedSnippet<InstanceType> snippets[] = { |
| 3359 {"var a = {x:13, y:14}; return delete a.x;", | 3360 {"var a = {x:13, y:14}; return delete a.x;", |
| 3360 2 * kPointerSize, | 3361 2 * kPointerSize, |
| 3361 1, | 3362 1, |
| 3362 15, | 3363 15, |
| 3363 {B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // | 3364 {B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // |
| 3364 B(Star), R(1), // | 3365 B(Star), R(1), // |
| 3365 B(Star), R(0), // | 3366 B(Star), R(0), // |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3411 "(function f1() {return a;});" | 3412 "(function f1() {return a;});" |
| 3412 "return delete a[1];", | 3413 "return delete a[1];", |
| 3413 2 * kPointerSize, | 3414 2 * kPointerSize, |
| 3414 1, | 3415 1, |
| 3415 29, | 3416 29, |
| 3416 {B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 3417 {B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 3417 R(closure), U8(1), // | 3418 R(closure), U8(1), // |
| 3418 B(PushContext), R(0), // | 3419 B(PushContext), R(0), // |
| 3419 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // | 3420 B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), // |
| 3420 B(Star), R(1), // | 3421 B(Star), R(1), // |
| 3421 B(StaContextSlot), R(0), U8(first_context_slot), // | 3422 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 3422 B(CreateClosure), U8(1), U8(0), // | 3423 B(CreateClosure), U8(1), U8(0), // |
| 3423 B(LdaContextSlot), R(0), U8(first_context_slot), // | 3424 B(LdaContextSlot), R(context), U8(first_context_slot), // |
| 3424 B(Star), R(1), // | 3425 B(Star), R(1), // |
| 3425 B(LdaSmi8), U8(1), // | 3426 B(LdaSmi8), U8(1), // |
| 3426 B(DeletePropertyStrict), R(1), // | 3427 B(DeletePropertyStrict), R(1), // |
| 3427 B(Return)}, | 3428 B(Return)}, |
| 3428 2, | 3429 2, |
| 3429 {InstanceType::FIXED_ARRAY_TYPE, | 3430 {InstanceType::FIXED_ARRAY_TYPE, |
| 3430 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 3431 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 3431 {"return delete 'test';", | 3432 {"return delete 'test';", |
| 3432 0 * kPointerSize, | 3433 0 * kPointerSize, |
| 3433 1, | 3434 1, |
| 3434 2, | 3435 2, |
| 3435 {B(LdaTrue), // | 3436 {B(LdaTrue), // |
| 3436 B(Return)}, | 3437 B(Return)}, |
| 3437 0}, | 3438 0}, |
| 3438 }; | 3439 }; |
| 3439 | 3440 |
| 3440 for (size_t i = 0; i < arraysize(snippets); i++) { | 3441 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 3441 Handle<BytecodeArray> bytecode_array = | 3442 Handle<BytecodeArray> bytecode_array = |
| 3442 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 3443 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 3443 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 3444 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 3444 } | 3445 } |
| 3445 } | 3446 } |
| 3446 | 3447 |
| 3447 | 3448 |
| 3448 TEST(GlobalDelete) { | 3449 TEST(GlobalDelete) { |
| 3449 InitializedHandleScope handle_scope; | 3450 InitializedHandleScope handle_scope; |
| 3450 BytecodeGeneratorHelper helper; | 3451 BytecodeGeneratorHelper helper; |
| 3451 Zone zone; | 3452 Zone zone; |
| 3452 | 3453 |
| 3453 int context = Register::function_context().index(); | 3454 int context = Register::current_context().index(); |
| 3454 int native_context_index = Context::NATIVE_CONTEXT_INDEX; | 3455 int native_context_index = Context::NATIVE_CONTEXT_INDEX; |
| 3455 int global_context_index = Context::EXTENSION_INDEX; | 3456 int global_context_index = Context::EXTENSION_INDEX; |
| 3456 FeedbackVectorSpec feedback_spec(&zone); | 3457 FeedbackVectorSpec feedback_spec(&zone); |
| 3457 FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot(); | 3458 FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot(); |
| 3458 | 3459 |
| 3459 Handle<i::TypeFeedbackVector> vector = | 3460 Handle<i::TypeFeedbackVector> vector = |
| 3460 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 3461 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 3461 | 3462 |
| 3462 ExpectedSnippet<InstanceType> snippets[] = { | 3463 ExpectedSnippet<InstanceType> snippets[] = { |
| 3463 {"var a = {x:13, y:14};\n function f() { return delete a.x; };\n f();", | 3464 {"var a = {x:13, y:14};\n function f() { return delete a.x; };\n f();", |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4261 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 4262 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 4262 } | 4263 } |
| 4263 } | 4264 } |
| 4264 | 4265 |
| 4265 | 4266 |
| 4266 TEST(TryCatch) { | 4267 TEST(TryCatch) { |
| 4267 InitializedHandleScope handle_scope; | 4268 InitializedHandleScope handle_scope; |
| 4268 BytecodeGeneratorHelper helper; | 4269 BytecodeGeneratorHelper helper; |
| 4269 | 4270 |
| 4270 int closure = Register::function_closure().index(); | 4271 int closure = Register::function_closure().index(); |
| 4271 int context = Register::function_context().index(); | |
| 4272 | 4272 |
| 4273 ExpectedSnippet<const char*> snippets[] = { | 4273 ExpectedSnippet<const char*> snippets[] = { |
| 4274 {"try { return 1; } catch(e) { return 2; }", | 4274 {"try { return 1; } catch(e) { return 2; }", |
| 4275 5 * kPointerSize, | 4275 5 * kPointerSize, |
| 4276 1, | 4276 1, |
| 4277 27, | 4277 27, |
| 4278 { | 4278 { |
| 4279 B(LdaSmi8), U8(1), // | 4279 B(LdaSmi8), U8(1), // |
| 4280 B(Return), // | 4280 B(Return), // |
| 4281 B(Star), R(3), // | 4281 B(Star), R(3), // |
| 4282 B(LdaConstant), U8(0), // | 4282 B(LdaConstant), U8(0), // |
| 4283 B(Star), R(2), // | 4283 B(Star), R(2), // |
| 4284 B(Ldar), R(closure), // | 4284 B(Ldar), R(closure), // |
| 4285 B(Star), R(4), // | 4285 B(Star), R(4), // |
| 4286 B(CallRuntime), U16(Runtime::kPushCatchContext), R(2), U8(3), // | 4286 B(CallRuntime), U16(Runtime::kPushCatchContext), R(2), U8(3), // |
| 4287 B(PushContext), R(0), // | 4287 B(PushContext), R(0), // |
| 4288 B(LdaSmi8), U8(2), // | 4288 B(LdaSmi8), U8(2), // |
| 4289 B(PopContext), R(context), // | 4289 B(PopContext), R(0), // |
| 4290 B(Return), // | 4290 B(Return), // |
| 4291 // TODO(mstarzinger): Potential optimization, elide next bytes. | 4291 // TODO(mstarzinger): Potential optimization, elide next bytes. |
| 4292 B(LdaUndefined), // | 4292 B(LdaUndefined), // |
| 4293 B(Return), // | 4293 B(Return), // |
| 4294 }, | 4294 }, |
| 4295 1, | 4295 1, |
| 4296 {"e"}, | 4296 {"e"}, |
| 4297 1, | 4297 1, |
| 4298 {{0, 3, 3}}}, | 4298 {{0, 3, 3}}}, |
| 4299 {"var a; try { a = 1 } catch(e1) {}; try { a = 2 } catch(e2) { a = 3 }", | 4299 {"var a; try { a = 1 } catch(e1) {}; try { a = 2 } catch(e2) { a = 3 }", |
| 4300 6 * kPointerSize, | 4300 6 * kPointerSize, |
| 4301 1, | 4301 1, |
| 4302 56, | 4302 56, |
| 4303 { | 4303 { |
| 4304 B(LdaSmi8), U8(1), // | 4304 B(LdaSmi8), U8(1), // |
| 4305 B(Star), R(0), // | 4305 B(Star), R(0), // |
| 4306 B(Jump), U8(21), // | 4306 B(Jump), U8(21), // |
| 4307 B(Star), R(4), // | 4307 B(Star), R(4), // |
| 4308 B(LdaConstant), U8(0), // | 4308 B(LdaConstant), U8(0), // |
| 4309 B(Star), R(3), // | 4309 B(Star), R(3), // |
| 4310 B(Ldar), R(closure), // | 4310 B(Ldar), R(closure), // |
| 4311 B(Star), R(5), // | 4311 B(Star), R(5), // |
| 4312 B(CallRuntime), U16(Runtime::kPushCatchContext), R(3), U8(3), // | 4312 B(CallRuntime), U16(Runtime::kPushCatchContext), R(3), U8(3), // |
| 4313 B(PushContext), R(1), // | 4313 B(PushContext), R(1), // |
| 4314 B(PopContext), R(context), // | 4314 B(PopContext), R(1), // |
| 4315 B(LdaSmi8), U8(2), // | 4315 B(LdaSmi8), U8(2), // |
| 4316 B(Star), R(0), // | 4316 B(Star), R(0), // |
| 4317 B(Jump), U8(25), // | 4317 B(Jump), U8(25), // |
| 4318 B(Star), R(4), // | 4318 B(Star), R(4), // |
| 4319 B(LdaConstant), U8(1), // | 4319 B(LdaConstant), U8(1), // |
| 4320 B(Star), R(3), // | 4320 B(Star), R(3), // |
| 4321 B(Ldar), R(closure), // | 4321 B(Ldar), R(closure), // |
| 4322 B(Star), R(5), // | 4322 B(Star), R(5), // |
| 4323 B(CallRuntime), U16(Runtime::kPushCatchContext), R(3), U8(3), // | 4323 B(CallRuntime), U16(Runtime::kPushCatchContext), R(3), U8(3), // |
| 4324 B(PushContext), R(1), // | 4324 B(PushContext), R(1), // |
| 4325 B(LdaSmi8), U8(3), // | 4325 B(LdaSmi8), U8(3), // |
| 4326 B(Star), R(0), // | 4326 B(Star), R(0), // |
| 4327 B(PopContext), R(context), // | 4327 B(PopContext), R(1), // |
| 4328 B(LdaUndefined), // | 4328 B(LdaUndefined), // |
| 4329 B(Return), // | 4329 B(Return), // |
| 4330 }, | 4330 }, |
| 4331 2, | 4331 2, |
| 4332 {"e1", "e2"}, | 4332 {"e1", "e2"}, |
| 4333 2, | 4333 2, |
| 4334 {{0, 4, 6}, {25, 29, 31}}}, | 4334 {{0, 4, 6}, {25, 29, 31}}}, |
| 4335 }; | 4335 }; |
| 4336 | 4336 |
| 4337 for (size_t i = 0; i < arraysize(snippets); i++) { | 4337 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 4338 Handle<BytecodeArray> bytecode_array = | 4338 Handle<BytecodeArray> bytecode_array = |
| 4339 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 4339 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 4340 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 4340 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 4341 } | 4341 } |
| 4342 } | 4342 } |
| 4343 | 4343 |
| 4344 | 4344 |
| 4345 TEST(TryFinally) { | 4345 TEST(TryFinally) { |
| 4346 InitializedHandleScope handle_scope; | 4346 InitializedHandleScope handle_scope; |
| 4347 BytecodeGeneratorHelper helper; | 4347 BytecodeGeneratorHelper helper; |
| 4348 | 4348 |
| 4349 int closure = Register::function_closure().index(); | 4349 int closure = Register::function_closure().index(); |
| 4350 int context = Register::function_context().index(); | |
| 4351 | 4350 |
| 4352 ExpectedSnippet<const char*> snippets[] = { | 4351 ExpectedSnippet<const char*> snippets[] = { |
| 4353 {"var a = 1; try { a = 2; } finally { a = 3; }", | 4352 {"var a = 1; try { a = 2; } finally { a = 3; }", |
| 4354 4 * kPointerSize, | 4353 4 * kPointerSize, |
| 4355 1, | 4354 1, |
| 4356 35, | 4355 35, |
| 4357 { | 4356 { |
| 4358 B(LdaSmi8), U8(1), // | 4357 B(LdaSmi8), U8(1), // |
| 4359 B(Star), R(0), // | 4358 B(Star), R(0), // |
| 4360 B(LdaSmi8), U8(2), // | 4359 B(LdaSmi8), U8(2), // |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4392 B(Jump), U8(25), // | 4391 B(Jump), U8(25), // |
| 4393 B(Star), R(7), // | 4392 B(Star), R(7), // |
| 4394 B(LdaConstant), U8(0), // | 4393 B(LdaConstant), U8(0), // |
| 4395 B(Star), R(6), // | 4394 B(Star), R(6), // |
| 4396 B(Ldar), R(closure), // | 4395 B(Ldar), R(closure), // |
| 4397 B(Star), R(8), // | 4396 B(Star), R(8), // |
| 4398 B(CallRuntime), U16(Runtime::kPushCatchContext), R(6), U8(3), // | 4397 B(CallRuntime), U16(Runtime::kPushCatchContext), R(6), U8(3), // |
| 4399 B(PushContext), R(1), // | 4398 B(PushContext), R(1), // |
| 4400 B(LdaSmi8), U8(20), // | 4399 B(LdaSmi8), U8(20), // |
| 4401 B(Star), R(0), // | 4400 B(Star), R(0), // |
| 4402 B(PopContext), R(context), // | 4401 B(PopContext), R(1), // |
| 4403 B(LdaSmi8), U8(-1), // | 4402 B(LdaSmi8), U8(-1), // |
| 4404 B(Star), R(2), // | 4403 B(Star), R(2), // |
| 4405 B(Jump), U8(7), // | 4404 B(Jump), U8(7), // |
| 4406 B(Star), R(3), // | 4405 B(Star), R(3), // |
| 4407 B(LdaZero), // | 4406 B(LdaZero), // |
| 4408 B(Star), R(2), // | 4407 B(Star), R(2), // |
| 4409 B(LdaSmi8), U8(3), // | 4408 B(LdaSmi8), U8(3), // |
| 4410 B(Star), R(0), // | 4409 B(Star), R(0), // |
| 4411 B(LdaZero), // | 4410 B(LdaZero), // |
| 4412 B(TestEqualStrict), R(2), // | 4411 B(TestEqualStrict), R(2), // |
| (...skipping 20 matching lines...) Expand all Loading... |
| 4433 B(Jump), U8(25), // | 4432 B(Jump), U8(25), // |
| 4434 B(Star), R(8), // | 4433 B(Star), R(8), // |
| 4435 B(LdaConstant), U8(0), // | 4434 B(LdaConstant), U8(0), // |
| 4436 B(Star), R(7), // | 4435 B(Star), R(7), // |
| 4437 B(Ldar), R(closure), // | 4436 B(Ldar), R(closure), // |
| 4438 B(Star), R(9), // | 4437 B(Star), R(9), // |
| 4439 B(CallRuntime), U16(Runtime::kPushCatchContext), R(7), U8(3), // | 4438 B(CallRuntime), U16(Runtime::kPushCatchContext), R(7), U8(3), // |
| 4440 B(PushContext), R(1), // | 4439 B(PushContext), R(1), // |
| 4441 B(LdaSmi8), U8(2), // | 4440 B(LdaSmi8), U8(2), // |
| 4442 B(Star), R(0), // | 4441 B(Star), R(0), // |
| 4443 B(PopContext), R(context), // | 4442 B(PopContext), R(1), // |
| 4444 B(Jump), U8(25), // | 4443 B(Jump), U8(25), // |
| 4445 B(Star), R(7), // | 4444 B(Star), R(7), // |
| 4446 B(LdaConstant), U8(0), // | 4445 B(LdaConstant), U8(0), // |
| 4447 B(Star), R(6), // | 4446 B(Star), R(6), // |
| 4448 B(Ldar), R(closure), // | 4447 B(Ldar), R(closure), // |
| 4449 B(Star), R(8), // | 4448 B(Star), R(8), // |
| 4450 B(CallRuntime), U16(Runtime::kPushCatchContext), R(6), U8(3), // | 4449 B(CallRuntime), U16(Runtime::kPushCatchContext), R(6), U8(3), // |
| 4451 B(PushContext), R(1), // | 4450 B(PushContext), R(1), // |
| 4452 B(LdaSmi8), U8(20), // | 4451 B(LdaSmi8), U8(20), // |
| 4453 B(Star), R(0), // | 4452 B(Star), R(0), // |
| 4454 B(PopContext), R(context), // | 4453 B(PopContext), R(1), // |
| 4455 B(LdaSmi8), U8(-1), // | 4454 B(LdaSmi8), U8(-1), // |
| 4456 B(Star), R(2), // | 4455 B(Star), R(2), // |
| 4457 B(Jump), U8(7), // | 4456 B(Jump), U8(7), // |
| 4458 B(Star), R(3), // | 4457 B(Star), R(3), // |
| 4459 B(LdaZero), // | 4458 B(LdaZero), // |
| 4460 B(Star), R(2), // | 4459 B(Star), R(2), // |
| 4461 B(LdaSmi8), U8(3), // | 4460 B(LdaSmi8), U8(3), // |
| 4462 B(Star), R(0), // | 4461 B(Star), R(0), // |
| 4463 B(LdaZero), // | 4462 B(LdaZero), // |
| 4464 B(TestEqualStrict), R(2), // | 4463 B(TestEqualStrict), R(2), // |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4616 BytecodeGeneratorHelper helper; | 4615 BytecodeGeneratorHelper helper; |
| 4617 Zone zone; | 4616 Zone zone; |
| 4618 | 4617 |
| 4619 FeedbackVectorSpec feedback_spec(&zone); | 4618 FeedbackVectorSpec feedback_spec(&zone); |
| 4620 FeedbackVectorSlot slot = feedback_spec.AddCallICSlot(); | 4619 FeedbackVectorSlot slot = feedback_spec.AddCallICSlot(); |
| 4621 | 4620 |
| 4622 Handle<i::TypeFeedbackVector> vector = | 4621 Handle<i::TypeFeedbackVector> vector = |
| 4623 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 4622 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 4624 | 4623 |
| 4625 int closure = Register::function_closure().index(); | 4624 int closure = Register::function_closure().index(); |
| 4626 int context = Register::function_context().index(); | 4625 int context = Register::current_context().index(); |
| 4627 int new_target = Register::new_target().index(); | 4626 int new_target = Register::new_target().index(); |
| 4628 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 4627 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 4629 | 4628 |
| 4630 // The wide check below relies on MIN_CONTEXT_SLOTS + 3 + 249 == 256, if this | 4629 // The wide check below relies on MIN_CONTEXT_SLOTS + 3 + 249 == 256, if this |
| 4631 // ever changes, the REPEAT_XXX should be changed to output the correct number | 4630 // ever changes, the REPEAT_XXX should be changed to output the correct number |
| 4632 // of unique variables to trigger the wide slot load / store. | 4631 // of unique variables to trigger the wide slot load / store. |
| 4633 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS + 3 + 249 == 256); | 4632 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS + 3 + 249 == 256); |
| 4634 int wide_slot = first_context_slot + 3; | 4633 int wide_slot = first_context_slot + 3; |
| 4635 | 4634 |
| 4636 ExpectedSnippet<InstanceType> snippets[] = { | 4635 ExpectedSnippet<InstanceType> snippets[] = { |
| 4637 {"var a; return function() { a = 1; };", | 4636 {"var a; return function() { a = 1; };", |
| 4638 1 * kPointerSize, | 4637 1 * kPointerSize, |
| 4639 1, | 4638 1, |
| 4640 11, | 4639 11, |
| 4641 { | 4640 { |
| 4642 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 4641 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 4643 R(closure), U8(1), // | 4642 R(closure), U8(1), // |
| 4644 B(PushContext), R(0), // | 4643 B(PushContext), R(0), // |
| 4645 B(CreateClosure), U8(0), U8(0), // | 4644 B(CreateClosure), U8(0), U8(0), // |
| 4646 B(Return), // | 4645 B(Return), // |
| 4647 }, | 4646 }, |
| 4648 1, | 4647 1, |
| 4649 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 4648 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 4650 {"var a = 1; return function() { a = 2; };", | 4649 {"var a = 1; return function() { a = 2; };", |
| 4651 1 * kPointerSize, | 4650 1 * kPointerSize, |
| 4652 1, | 4651 1, |
| 4653 16, | 4652 16, |
| 4654 { | 4653 { |
| 4655 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 4654 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 4656 R(closure), U8(1), // | 4655 R(closure), U8(1), // |
| 4657 B(PushContext), R(0), // | 4656 B(PushContext), R(0), // |
| 4658 B(LdaSmi8), U8(1), // | 4657 B(LdaSmi8), U8(1), // |
| 4659 B(StaContextSlot), R(0), U8(first_context_slot), // | 4658 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 4660 B(CreateClosure), U8(0), U8(0), // | 4659 B(CreateClosure), U8(0), U8(0), // |
| 4661 B(Return), // | 4660 B(Return), // |
| 4662 }, | 4661 }, |
| 4663 1, | 4662 1, |
| 4664 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 4663 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 4665 {"var a = 1; var b = 2; return function() { a = 2; b = 3 };", | 4664 {"var a = 1; var b = 2; return function() { a = 2; b = 3 };", |
| 4666 1 * kPointerSize, | 4665 1 * kPointerSize, |
| 4667 1, | 4666 1, |
| 4668 21, | 4667 21, |
| 4669 { | 4668 { |
| 4670 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 4669 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 4671 R(closure), U8(1), // | 4670 R(closure), U8(1), // |
| 4672 B(PushContext), R(0), // | 4671 B(PushContext), R(0), // |
| 4673 B(LdaSmi8), U8(1), // | 4672 B(LdaSmi8), U8(1), // |
| 4674 B(StaContextSlot), R(0), U8(first_context_slot), // | 4673 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 4675 B(LdaSmi8), U8(2), // | 4674 B(LdaSmi8), U8(2), // |
| 4676 B(StaContextSlot), R(0), U8(first_context_slot + 1), // | 4675 B(StaContextSlot), R(context), U8(first_context_slot + 1), // |
| 4677 B(CreateClosure), U8(0), U8(0), // | 4676 B(CreateClosure), U8(0), U8(0), // |
| 4678 B(Return), // | 4677 B(Return), // |
| 4679 }, | 4678 }, |
| 4680 1, | 4679 1, |
| 4681 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 4680 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 4682 {"var a; (function() { a = 2; })(); return a;", | 4681 {"var a; (function() { a = 2; })(); return a;", |
| 4683 3 * kPointerSize, | 4682 3 * kPointerSize, |
| 4684 1, | 4683 1, |
| 4685 24, | 4684 24, |
| 4686 { | 4685 { |
| 4687 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 4686 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 4688 R(closure), U8(1), // | 4687 R(closure), U8(1), // |
| 4689 B(PushContext), R(0), // | 4688 B(PushContext), R(0), // |
| 4690 B(LdaUndefined), // | 4689 B(LdaUndefined), // |
| 4691 B(Star), R(2), // | 4690 B(Star), R(2), // |
| 4692 B(CreateClosure), U8(0), U8(0), // | 4691 B(CreateClosure), U8(0), U8(0), // |
| 4693 B(Star), R(1), // | 4692 B(Star), R(1), // |
| 4694 B(Call), R(1), R(2), U8(0), U8(vector->GetIndex(slot)), // | 4693 B(Call), R(1), R(2), U8(0), U8(vector->GetIndex(slot)), // |
| 4695 B(LdaContextSlot), R(0), U8(first_context_slot), // | 4694 B(LdaContextSlot), R(context), U8(first_context_slot), // |
| 4696 B(Return), // | 4695 B(Return), // |
| 4697 }, | 4696 }, |
| 4698 1, | 4697 1, |
| 4699 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 4698 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 4700 {"'use strict'; let a = 1; { let b = 2; return function() { a + b; }; }", | 4699 {"'use strict'; let a = 1; { let b = 2; return function() { a + b; }; }", |
| 4701 4 * kPointerSize, | 4700 4 * kPointerSize, |
| 4702 1, | 4701 1, |
| 4703 46, | 4702 46, |
| 4704 { | 4703 { |
| 4705 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 4704 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 4706 R(closure), U8(1), // | 4705 R(closure), U8(1), // |
| 4707 B(PushContext), R(0), // | 4706 B(PushContext), R(0), // |
| 4708 B(LdaTheHole), // | 4707 B(LdaTheHole), // |
| 4709 B(StaContextSlot), R(0), U8(first_context_slot), // | 4708 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 4710 B(LdaSmi8), U8(1), // | 4709 B(LdaSmi8), U8(1), // |
| 4711 B(StaContextSlot), R(0), U8(first_context_slot), // | 4710 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 4712 B(LdaConstant), U8(0), // | 4711 B(LdaConstant), U8(0), // |
| 4713 B(Star), R(2), // | 4712 B(Star), R(2), // |
| 4714 B(Ldar), R(closure), // | 4713 B(Ldar), R(closure), // |
| 4715 B(Star), R(3), // | 4714 B(Star), R(3), // |
| 4716 B(CallRuntime), U16(Runtime::kPushBlockContext), R(2), U8(2), // | 4715 B(CallRuntime), U16(Runtime::kPushBlockContext), R(2), U8(2), // |
| 4717 B(PushContext), R(1), // | 4716 B(PushContext), R(1), // |
| 4718 B(LdaTheHole), // | 4717 B(LdaTheHole), // |
| 4719 B(StaContextSlot), R(1), U8(first_context_slot), // | 4718 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 4720 B(LdaSmi8), U8(2), // | 4719 B(LdaSmi8), U8(2), // |
| 4721 B(StaContextSlot), R(1), U8(first_context_slot), // | 4720 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 4722 B(CreateClosure), U8(1), U8(0), // | 4721 B(CreateClosure), U8(1), U8(0), // |
| 4723 B(PopContext), R(context), // | 4722 B(PopContext), R(0), // |
| 4724 B(Return), // | 4723 B(Return), // |
| 4725 }, | 4724 }, |
| 4726 2, | 4725 2, |
| 4727 {InstanceType::FIXED_ARRAY_TYPE, | 4726 {InstanceType::FIXED_ARRAY_TYPE, |
| 4728 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 4727 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 4729 {"'use strict';\n" | 4728 {"'use strict';\n" |
| 4730 REPEAT_249_UNIQUE_VARS() | 4729 REPEAT_249_UNIQUE_VARS() |
| 4731 "eval();" | 4730 "eval();" |
| 4732 "var b = 100;" | 4731 "var b = 100;" |
| 4733 "return b", | 4732 "return b", |
| 4734 3 * kPointerSize, | 4733 3 * kPointerSize, |
| 4735 1, | 4734 1, |
| 4736 1041, | 4735 1041, |
| 4737 { | 4736 { |
| 4738 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 4737 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 4739 U8(1), // | 4738 U8(1), // |
| 4740 B(PushContext), R(0), // | 4739 B(PushContext), R(0), // |
| 4741 B(Ldar), THIS(1), // | 4740 B(Ldar), THIS(1), // |
| 4742 B(StaContextSlot), R(0), U8(first_context_slot), // | 4741 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 4743 B(CreateUnmappedArguments), // | 4742 B(CreateUnmappedArguments), // |
| 4744 B(StaContextSlot), R(0), U8(first_context_slot + 1), // | 4743 B(StaContextSlot), R(context), U8(first_context_slot + 1), // |
| 4745 B(Ldar), R(new_target), // | 4744 B(Ldar), R(new_target), // |
| 4746 B(StaContextSlot), R(0), U8(first_context_slot + 2), // | 4745 B(StaContextSlot), R(context), U8(first_context_slot + 2), // |
| 4747 REPEAT_249(COMMA, // | 4746 REPEAT_249(COMMA, // |
| 4748 B(LdaZero), // | 4747 B(LdaZero), // |
| 4749 B(StaContextSlot), R(0), U8(wide_slot++)), // | 4748 B(StaContextSlot), R(context), U8(wide_slot++)), // |
| 4750 B(LdaUndefined), // | 4749 B(LdaUndefined), // |
| 4751 B(Star), R(2), // | 4750 B(Star), R(2), // |
| 4752 B(LdaGlobalStrict), U8(0), U8(1), // | 4751 B(LdaGlobalStrict), U8(0), U8(1), // |
| 4753 B(Star), R(1), // | 4752 B(Star), R(1), // |
| 4754 B(Call), R(1), R(2), U8(0), U8(0), // | 4753 B(Call), R(1), R(2), U8(0), U8(0), // |
| 4755 B(LdaSmi8), U8(100), // | 4754 B(LdaSmi8), U8(100), // |
| 4756 B(StaContextSlotWide), R(0), U16(256), // | 4755 B(StaContextSlotWide), R(context), U16(256), // |
| 4757 B(LdaContextSlotWide), R(0), U16(256), // | 4756 B(LdaContextSlotWide), R(context), U16(256), // |
| 4758 B(Return), // | 4757 B(Return), // |
| 4759 }, | 4758 }, |
| 4760 1, | 4759 1, |
| 4761 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, | 4760 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
| 4762 }; | 4761 }; |
| 4763 | 4762 |
| 4764 for (size_t i = 0; i < arraysize(snippets); i++) { | 4763 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 4765 Handle<BytecodeArray> bytecode_array = | 4764 Handle<BytecodeArray> bytecode_array = |
| 4766 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 4765 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| 4767 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 4766 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 4768 } | 4767 } |
| 4769 } | 4768 } |
| 4770 | 4769 |
| 4771 | 4770 |
| 4772 TEST(ContextParameters) { | 4771 TEST(ContextParameters) { |
| 4773 InitializedHandleScope handle_scope; | 4772 InitializedHandleScope handle_scope; |
| 4774 BytecodeGeneratorHelper helper; | 4773 BytecodeGeneratorHelper helper; |
| 4775 | 4774 |
| 4776 int closure = Register::function_closure().index(); | 4775 int closure = Register::function_closure().index(); |
| 4776 int context = Register::current_context().index(); |
| 4777 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 4777 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 4778 | 4778 |
| 4779 ExpectedSnippet<InstanceType> snippets[] = { | 4779 ExpectedSnippet<InstanceType> snippets[] = { |
| 4780 {"function f(arg1) { return function() { arg1 = 2; }; }", | 4780 {"function f(arg1) { return function() { arg1 = 2; }; }", |
| 4781 1 * kPointerSize, | 4781 1 * kPointerSize, |
| 4782 2, | 4782 2, |
| 4783 16, | 4783 16, |
| 4784 { | 4784 { |
| 4785 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 4785 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 4786 R(closure), U8(1), // | 4786 R(closure), U8(1), // |
| 4787 B(PushContext), R(0), // | 4787 B(PushContext), R(0), // |
| 4788 B(Ldar), R(helper.kLastParamIndex), // | 4788 B(Ldar), R(helper.kLastParamIndex), // |
| 4789 B(StaContextSlot), R(0), U8(first_context_slot), // | 4789 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 4790 B(CreateClosure), U8(0), U8(0), // | 4790 B(CreateClosure), U8(0), U8(0), // |
| 4791 B(Return), // | 4791 B(Return), // |
| 4792 }, | 4792 }, |
| 4793 1, | 4793 1, |
| 4794 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 4794 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 4795 {"function f(arg1) { var a = function() { arg1 = 2; }; return arg1; }", | 4795 {"function f(arg1) { var a = function() { arg1 = 2; }; return arg1; }", |
| 4796 2 * kPointerSize, | 4796 2 * kPointerSize, |
| 4797 2, | 4797 2, |
| 4798 21, | 4798 21, |
| 4799 { | 4799 { |
| 4800 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 4800 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 4801 R(closure), U8(1), // | 4801 R(closure), U8(1), // |
| 4802 B(PushContext), R(1), // | 4802 B(PushContext), R(1), // |
| 4803 B(Ldar), R(helper.kLastParamIndex), // | 4803 B(Ldar), R(helper.kLastParamIndex), // |
| 4804 B(StaContextSlot), R(1), U8(first_context_slot), // | 4804 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 4805 B(CreateClosure), U8(0), U8(0), // | 4805 B(CreateClosure), U8(0), U8(0), // |
| 4806 B(Star), R(0), // | 4806 B(Star), R(0), // |
| 4807 B(LdaContextSlot), R(1), U8(first_context_slot), // | 4807 B(LdaContextSlot), R(context), U8(first_context_slot), // |
| 4808 B(Return), // | 4808 B(Return), // |
| 4809 }, | 4809 }, |
| 4810 1, | 4810 1, |
| 4811 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 4811 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 4812 {"function f(a1, a2, a3, a4) { return function() { a1 = a3; }; }", | 4812 {"function f(a1, a2, a3, a4) { return function() { a1 = a3; }; }", |
| 4813 1 * kPointerSize, | 4813 1 * kPointerSize, |
| 4814 5, | 4814 5, |
| 4815 21, | 4815 21, |
| 4816 { | 4816 { |
| 4817 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 4817 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 4818 R(closure), U8(1), // | 4818 R(closure), U8(1), // |
| 4819 B(PushContext), R(0), // | 4819 B(PushContext), R(0), // |
| 4820 B(Ldar), R(helper.kLastParamIndex - 3), // | 4820 B(Ldar), R(helper.kLastParamIndex - 3), // |
| 4821 B(StaContextSlot), R(0), U8(first_context_slot + 1), // | 4821 B(StaContextSlot), R(context), U8(first_context_slot + 1), // |
| 4822 B(Ldar), R(helper.kLastParamIndex -1), // | 4822 B(Ldar), R(helper.kLastParamIndex -1), // |
| 4823 B(StaContextSlot), R(0), U8(first_context_slot), // | 4823 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 4824 B(CreateClosure), U8(0), U8(0), // | 4824 B(CreateClosure), U8(0), U8(0), // |
| 4825 B(Return), // | 4825 B(Return), // |
| 4826 }, | 4826 }, |
| 4827 1, | 4827 1, |
| 4828 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 4828 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 4829 {"function f() { var self = this; return function() { self = 2; }; }", | 4829 {"function f() { var self = this; return function() { self = 2; }; }", |
| 4830 1 * kPointerSize, | 4830 1 * kPointerSize, |
| 4831 1, | 4831 1, |
| 4832 16, | 4832 16, |
| 4833 { | 4833 { |
| 4834 B(CallRuntime), U16(Runtime::kNewFunctionContext), // | 4834 B(CallRuntime), U16(Runtime::kNewFunctionContext), // |
| 4835 R(closure), U8(1), // | 4835 R(closure), U8(1), // |
| 4836 B(PushContext), R(0), // | 4836 B(PushContext), R(0), // |
| 4837 B(Ldar), R(helper.kLastParamIndex), // | 4837 B(Ldar), R(helper.kLastParamIndex), // |
| 4838 B(StaContextSlot), R(0), U8(first_context_slot), // | 4838 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 4839 B(CreateClosure), U8(0), U8(0), // | 4839 B(CreateClosure), U8(0), U8(0), // |
| 4840 B(Return), // | 4840 B(Return), // |
| 4841 }, | 4841 }, |
| 4842 1, | 4842 1, |
| 4843 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 4843 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 4844 }; | 4844 }; |
| 4845 | 4845 |
| 4846 for (size_t i = 0; i < arraysize(snippets); i++) { | 4846 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 4847 Handle<BytecodeArray> bytecode_array = | 4847 Handle<BytecodeArray> bytecode_array = |
| 4848 helper.MakeBytecodeForFunction(snippets[i].code_snippet); | 4848 helper.MakeBytecodeForFunction(snippets[i].code_snippet); |
| 4849 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 4849 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 4850 } | 4850 } |
| 4851 } | 4851 } |
| 4852 | 4852 |
| 4853 | 4853 |
| 4854 TEST(OuterContextVariables) { | 4854 TEST(OuterContextVariables) { |
| 4855 InitializedHandleScope handle_scope; | 4855 InitializedHandleScope handle_scope; |
| 4856 BytecodeGeneratorHelper helper; | 4856 BytecodeGeneratorHelper helper; |
| 4857 | 4857 |
| 4858 int context = Register::function_context().index(); | 4858 int context = Register::current_context().index(); |
| 4859 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 4859 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 4860 | 4860 |
| 4861 ExpectedSnippet<InstanceType> snippets[] = { | 4861 ExpectedSnippet<InstanceType> snippets[] = { |
| 4862 {"function Outer() {" | 4862 {"function Outer() {" |
| 4863 " var outerVar = 1;" | 4863 " var outerVar = 1;" |
| 4864 " function Inner(innerArg) {" | 4864 " function Inner(innerArg) {" |
| 4865 " this.innerFunc = function() { return outerVar * innerArg; }" | 4865 " this.innerFunc = function() { return outerVar * innerArg; }" |
| 4866 " }" | 4866 " }" |
| 4867 " this.getInnerFunc = function() { return new Inner(1).innerFunc; }" | 4867 " this.getInnerFunc = function() { return new Inner(1).innerFunc; }" |
| 4868 "}" | 4868 "}" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4924 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot(); | 4924 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot(); |
| 4925 Handle<i::TypeFeedbackVector> vector = | 4925 Handle<i::TypeFeedbackVector> vector = |
| 4926 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 4926 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 4927 | 4927 |
| 4928 FeedbackVectorSpec store_feedback_spec(&zone); | 4928 FeedbackVectorSpec store_feedback_spec(&zone); |
| 4929 FeedbackVectorSlot store_slot = store_feedback_spec.AddStoreICSlot(); | 4929 FeedbackVectorSlot store_slot = store_feedback_spec.AddStoreICSlot(); |
| 4930 Handle<i::TypeFeedbackVector> store_vector = | 4930 Handle<i::TypeFeedbackVector> store_vector = |
| 4931 i::NewTypeFeedbackVector(helper.isolate(), &store_feedback_spec); | 4931 i::NewTypeFeedbackVector(helper.isolate(), &store_feedback_spec); |
| 4932 | 4932 |
| 4933 int closure = Register::function_closure().index(); | 4933 int closure = Register::function_closure().index(); |
| 4934 int context = Register::current_context().index(); |
| 4934 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 4935 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 4935 | 4936 |
| 4936 int object_literal_flags = | 4937 int object_literal_flags = |
| 4937 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; | 4938 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; |
| 4938 int array_literal_flags = | 4939 int array_literal_flags = |
| 4939 ArrayLiteral::kDisableMementos | ArrayLiteral::kShallowElements; | 4940 ArrayLiteral::kDisableMementos | ArrayLiteral::kShallowElements; |
| 4940 | 4941 |
| 4941 ExpectedSnippet<InstanceType> snippets[] = { | 4942 ExpectedSnippet<InstanceType> snippets[] = { |
| 4942 {"var a = 1; return ++a;", | 4943 {"var a = 1; return ++a;", |
| 4943 1 * kPointerSize, | 4944 1 * kPointerSize, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5077 InstanceType::FIXED_ARRAY_TYPE}}, | 5078 InstanceType::FIXED_ARRAY_TYPE}}, |
| 5078 {"var a = 1; var b = function() { return a }; return ++a;", | 5079 {"var a = 1; var b = function() { return a }; return ++a;", |
| 5079 2 * kPointerSize, | 5080 2 * kPointerSize, |
| 5080 1, | 5081 1, |
| 5081 26, | 5082 26, |
| 5082 { | 5083 { |
| 5083 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 5084 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 5084 U8(1), // | 5085 U8(1), // |
| 5085 B(PushContext), R(1), // | 5086 B(PushContext), R(1), // |
| 5086 B(LdaSmi8), U8(1), // | 5087 B(LdaSmi8), U8(1), // |
| 5087 B(StaContextSlot), R(1), U8(first_context_slot), // | 5088 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 5088 B(CreateClosure), U8(0), U8(0), // | 5089 B(CreateClosure), U8(0), U8(0), // |
| 5089 B(Star), R(0), // | 5090 B(Star), R(0), // |
| 5090 B(LdaContextSlot), R(1), U8(first_context_slot), // | 5091 B(LdaContextSlot), R(context), U8(first_context_slot), // |
| 5091 B(ToNumber), // | 5092 B(ToNumber), // |
| 5092 B(Inc), // | 5093 B(Inc), // |
| 5093 B(StaContextSlot), R(1), U8(first_context_slot), // | 5094 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 5094 B(Return), // | 5095 B(Return), // |
| 5095 }, | 5096 }, |
| 5096 1, | 5097 1, |
| 5097 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 5098 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 5098 {"var a = 1; var b = function() { return a }; return a--;", | 5099 {"var a = 1; var b = function() { return a }; return a--;", |
| 5099 3 * kPointerSize, | 5100 3 * kPointerSize, |
| 5100 1, | 5101 1, |
| 5101 30, | 5102 30, |
| 5102 { | 5103 { |
| 5103 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 5104 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 5104 U8(1), // | 5105 U8(1), // |
| 5105 B(PushContext), R(1), // | 5106 B(PushContext), R(1), // |
| 5106 B(LdaSmi8), U8(1), // | 5107 B(LdaSmi8), U8(1), // |
| 5107 B(StaContextSlot), R(1), U8(first_context_slot), // | 5108 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 5108 B(CreateClosure), U8(0), U8(0), // | 5109 B(CreateClosure), U8(0), U8(0), // |
| 5109 B(Star), R(0), // | 5110 B(Star), R(0), // |
| 5110 B(LdaContextSlot), R(1), U8(first_context_slot), // | 5111 B(LdaContextSlot), R(context), U8(first_context_slot), // |
| 5111 B(ToNumber), // | 5112 B(ToNumber), // |
| 5112 B(Star), R(2), // | 5113 B(Star), R(2), // |
| 5113 B(Dec), // | 5114 B(Dec), // |
| 5114 B(StaContextSlot), R(1), U8(first_context_slot), // | 5115 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 5115 B(Ldar), R(2), // | 5116 B(Ldar), R(2), // |
| 5116 B(Return), // | 5117 B(Return), // |
| 5117 }, | 5118 }, |
| 5118 1, | 5119 1, |
| 5119 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 5120 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 5120 {"var idx = 1; var a = [1, 2]; return a[idx++] = 2;", | 5121 {"var idx = 1; var a = [1, 2]; return a[idx++] = 2;", |
| 5121 4 * kPointerSize, | 5122 4 * kPointerSize, |
| 5122 1, | 5123 1, |
| 5123 27, | 5124 27, |
| 5124 { | 5125 { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5228 } | 5229 } |
| 5229 } | 5230 } |
| 5230 | 5231 |
| 5231 | 5232 |
| 5232 TEST(CompoundExpressions) { | 5233 TEST(CompoundExpressions) { |
| 5233 InitializedHandleScope handle_scope; | 5234 InitializedHandleScope handle_scope; |
| 5234 BytecodeGeneratorHelper helper; | 5235 BytecodeGeneratorHelper helper; |
| 5235 Zone zone; | 5236 Zone zone; |
| 5236 | 5237 |
| 5237 int closure = Register::function_closure().index(); | 5238 int closure = Register::function_closure().index(); |
| 5239 int context = Register::current_context().index(); |
| 5238 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 5240 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 5239 | 5241 |
| 5240 FeedbackVectorSpec feedback_spec(&zone); | 5242 FeedbackVectorSpec feedback_spec(&zone); |
| 5241 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); | 5243 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); |
| 5242 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot(); | 5244 FeedbackVectorSlot slot2 = feedback_spec.AddStoreICSlot(); |
| 5243 | 5245 |
| 5244 Handle<i::TypeFeedbackVector> vector = | 5246 Handle<i::TypeFeedbackVector> vector = |
| 5245 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 5247 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 5246 | 5248 |
| 5247 int object_literal_flags = | 5249 int object_literal_flags = |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5318 {InstanceType::FIXED_ARRAY_TYPE}}, | 5320 {InstanceType::FIXED_ARRAY_TYPE}}, |
| 5319 {"var a = 1; (function f() { return a; }); a |= 24;", | 5321 {"var a = 1; (function f() { return a; }); a |= 24;", |
| 5320 2 * kPointerSize, | 5322 2 * kPointerSize, |
| 5321 1, | 5323 1, |
| 5322 29, | 5324 29, |
| 5323 { | 5325 { |
| 5324 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 5326 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 5325 U8(1), // | 5327 U8(1), // |
| 5326 B(PushContext), R(0), // | 5328 B(PushContext), R(0), // |
| 5327 B(LdaSmi8), U8(1), // | 5329 B(LdaSmi8), U8(1), // |
| 5328 B(StaContextSlot), R(0), U8(first_context_slot), // | 5330 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 5329 B(CreateClosure), U8(0), U8(0), // | 5331 B(CreateClosure), U8(0), U8(0), // |
| 5330 B(LdaContextSlot), R(0), U8(first_context_slot), // | 5332 B(LdaContextSlot), R(context), U8(first_context_slot), // |
| 5331 B(Star), R(1), // | 5333 B(Star), R(1), // |
| 5332 B(LdaSmi8), U8(24), // | 5334 B(LdaSmi8), U8(24), // |
| 5333 B(BitwiseOr), R(1), // | 5335 B(BitwiseOr), R(1), // |
| 5334 B(StaContextSlot), R(0), U8(first_context_slot), // | 5336 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 5335 B(LdaUndefined), // | 5337 B(LdaUndefined), // |
| 5336 B(Return), // | 5338 B(Return), // |
| 5337 }, | 5339 }, |
| 5338 1, | 5340 1, |
| 5339 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, | 5341 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, |
| 5340 }; | 5342 }; |
| 5341 | 5343 |
| 5342 for (size_t i = 0; i < arraysize(snippets); i++) { | 5344 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 5343 Handle<BytecodeArray> bytecode_array = | 5345 Handle<BytecodeArray> bytecode_array = |
| 5344 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); | 5346 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5397 } | 5399 } |
| 5398 } | 5400 } |
| 5399 | 5401 |
| 5400 | 5402 |
| 5401 TEST(CreateArguments) { | 5403 TEST(CreateArguments) { |
| 5402 InitializedHandleScope handle_scope; | 5404 InitializedHandleScope handle_scope; |
| 5403 BytecodeGeneratorHelper helper; | 5405 BytecodeGeneratorHelper helper; |
| 5404 Zone zone; | 5406 Zone zone; |
| 5405 | 5407 |
| 5406 int closure = Register::function_closure().index(); | 5408 int closure = Register::function_closure().index(); |
| 5409 int context = Register::current_context().index(); |
| 5407 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 5410 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 5408 | 5411 |
| 5409 FeedbackVectorSpec feedback_spec(&zone); | 5412 FeedbackVectorSpec feedback_spec(&zone); |
| 5410 FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot(); | 5413 FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot(); |
| 5411 | 5414 |
| 5412 Handle<i::TypeFeedbackVector> vector = | 5415 Handle<i::TypeFeedbackVector> vector = |
| 5413 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 5416 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 5414 | 5417 |
| 5415 ExpectedSnippet<const char*> snippets[] = { | 5418 ExpectedSnippet<const char*> snippets[] = { |
| 5416 {"function f() { return arguments; }", | 5419 {"function f() { return arguments; }", |
| (...skipping 28 matching lines...) Expand all Loading... |
| 5445 }}, | 5448 }}, |
| 5446 {"function f(a) { return arguments[0]; }", | 5449 {"function f(a) { return arguments[0]; }", |
| 5447 3 * kPointerSize, | 5450 3 * kPointerSize, |
| 5448 2, | 5451 2, |
| 5449 22, | 5452 22, |
| 5450 { | 5453 { |
| 5451 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 5454 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 5452 U8(1), // | 5455 U8(1), // |
| 5453 B(PushContext), R(1), // | 5456 B(PushContext), R(1), // |
| 5454 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), // | 5457 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), // |
| 5455 B(StaContextSlot), R(1), U8(first_context_slot), // | 5458 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 5456 B(CreateMappedArguments), // | 5459 B(CreateMappedArguments), // |
| 5457 B(Star), R(0), // | 5460 B(Star), R(0), // |
| 5458 B(Star), R(2), // | 5461 B(Star), R(2), // |
| 5459 B(LdaZero), // | 5462 B(LdaZero), // |
| 5460 B(KeyedLoadICSloppy), R(2), U8(vector->GetIndex(slot)), // | 5463 B(KeyedLoadICSloppy), R(2), U8(vector->GetIndex(slot)), // |
| 5461 B(Return), // | 5464 B(Return), // |
| 5462 }}, | 5465 }}, |
| 5463 {"function f(a, b, c) { return arguments; }", | 5466 {"function f(a, b, c) { return arguments; }", |
| 5464 2 * kPointerSize, | 5467 2 * kPointerSize, |
| 5465 4, | 5468 4, |
| 5466 26, | 5469 26, |
| 5467 { | 5470 { |
| 5468 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 5471 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 5469 U8(1), // | 5472 U8(1), // |
| 5470 B(PushContext), R(1), // | 5473 B(PushContext), R(1), // |
| 5471 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 2), // | 5474 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 2), // |
| 5472 B(StaContextSlot), R(1), U8(first_context_slot + 2), // | 5475 B(StaContextSlot), R(context), U8(first_context_slot + 2), // |
| 5473 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 1), // | 5476 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 1), // |
| 5474 B(StaContextSlot), R(1), U8(first_context_slot + 1), // | 5477 B(StaContextSlot), R(context), U8(first_context_slot + 1), // |
| 5475 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), // | 5478 B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), // |
| 5476 B(StaContextSlot), R(1), U8(first_context_slot), // | 5479 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 5477 B(CreateMappedArguments), // | 5480 B(CreateMappedArguments), // |
| 5478 B(Star), R(0), // | 5481 B(Star), R(0), // |
| 5479 B(Return), // | 5482 B(Return), // |
| 5480 }}, | 5483 }}, |
| 5481 {"function f(a, b, c) { 'use strict'; return arguments; }", | 5484 {"function f(a, b, c) { 'use strict'; return arguments; }", |
| 5482 1 * kPointerSize, | 5485 1 * kPointerSize, |
| 5483 4, | 5486 4, |
| 5484 4, | 5487 4, |
| 5485 { | 5488 { |
| 5486 B(CreateUnmappedArguments), // | 5489 B(CreateUnmappedArguments), // |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6786 } | 6789 } |
| 6787 } | 6790 } |
| 6788 | 6791 |
| 6789 | 6792 |
| 6790 TEST(Eval) { | 6793 TEST(Eval) { |
| 6791 InitializedHandleScope handle_scope; | 6794 InitializedHandleScope handle_scope; |
| 6792 BytecodeGeneratorHelper helper; | 6795 BytecodeGeneratorHelper helper; |
| 6793 Zone zone; | 6796 Zone zone; |
| 6794 | 6797 |
| 6795 int closure = Register::function_closure().index(); | 6798 int closure = Register::function_closure().index(); |
| 6799 int context = Register::current_context().index(); |
| 6796 int new_target = Register::new_target().index(); | 6800 int new_target = Register::new_target().index(); |
| 6797 | 6801 |
| 6798 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 6802 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 6799 | 6803 |
| 6800 ExpectedSnippet<const char*> snippets[] = { | 6804 ExpectedSnippet<const char*> snippets[] = { |
| 6801 {"return eval('1;');", | 6805 {"return eval('1;');", |
| 6802 9 * kPointerSize, | 6806 9 * kPointerSize, |
| 6803 1, | 6807 1, |
| 6804 67, | 6808 67, |
| 6805 { | 6809 { |
| 6806 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 6810 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 6807 U8(1), // | 6811 U8(1), // |
| 6808 B(PushContext), R(0), // | 6812 B(PushContext), R(0), // |
| 6809 B(Ldar), THIS(1), // | 6813 B(Ldar), THIS(1), // |
| 6810 B(StaContextSlot), R(0), U8(first_context_slot), // | 6814 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 6811 B(CreateMappedArguments), // | 6815 B(CreateMappedArguments), // |
| 6812 B(StaContextSlot), R(0), U8(first_context_slot + 1), // | 6816 B(StaContextSlot), R(context), U8(first_context_slot + 1), // |
| 6813 B(Ldar), R(new_target), // | 6817 B(Ldar), R(new_target), // |
| 6814 B(StaContextSlot), R(0), U8(first_context_slot + 2), // | 6818 B(StaContextSlot), R(context), U8(first_context_slot + 2), // |
| 6815 B(Mov), R(0), R(3), // | 6819 B(Mov), R(context), R(3), // |
| 6816 B(LdaConstant), U8(0), // | 6820 B(LdaConstant), U8(0), // |
| 6817 B(Star), R(4), // | 6821 B(Star), R(4), // |
| 6818 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 6822 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // |
| 6819 R(3), U8(2), R(1), // | 6823 R(3), U8(2), R(1), // |
| 6820 B(LdaConstant), U8(1), // | 6824 B(LdaConstant), U8(1), // |
| 6821 B(Star), R(3), // | 6825 B(Star), R(3), // |
| 6822 B(Mov), R(1), R(4), // | 6826 B(Mov), R(1), R(4), // |
| 6823 B(Mov), R(3), R(5), // | 6827 B(Mov), R(3), R(5), // |
| 6824 B(Mov), R(closure), R(6), // | 6828 B(Mov), R(closure), R(6), // |
| 6825 B(LdaZero), // | 6829 B(LdaZero), // |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6842 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 6846 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 6843 } | 6847 } |
| 6844 } | 6848 } |
| 6845 | 6849 |
| 6846 | 6850 |
| 6847 TEST(LookupSlot) { | 6851 TEST(LookupSlot) { |
| 6848 InitializedHandleScope handle_scope; | 6852 InitializedHandleScope handle_scope; |
| 6849 BytecodeGeneratorHelper helper; | 6853 BytecodeGeneratorHelper helper; |
| 6850 | 6854 |
| 6851 int closure = Register::function_closure().index(); | 6855 int closure = Register::function_closure().index(); |
| 6856 int context = Register::current_context().index(); |
| 6852 int first_context_slot = Context::MIN_CONTEXT_SLOTS; | 6857 int first_context_slot = Context::MIN_CONTEXT_SLOTS; |
| 6853 int new_target = Register::new_target().index(); | 6858 int new_target = Register::new_target().index(); |
| 6854 | 6859 |
| 6855 ExpectedSnippet<const char*> snippets[] = { | 6860 ExpectedSnippet<const char*> snippets[] = { |
| 6856 {"eval('var x = 10;'); return x;", | 6861 {"eval('var x = 10;'); return x;", |
| 6857 9 * kPointerSize, | 6862 9 * kPointerSize, |
| 6858 1, | 6863 1, |
| 6859 69, | 6864 69, |
| 6860 { | 6865 { |
| 6861 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 6866 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 6862 U8(1), // | 6867 U8(1), // |
| 6863 B(PushContext), R(0), // | 6868 B(PushContext), R(0), // |
| 6864 B(Ldar), THIS(1), // | 6869 B(Ldar), THIS(1), // |
| 6865 B(StaContextSlot), R(0), U8(first_context_slot), // | 6870 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 6866 B(CreateMappedArguments), // | 6871 B(CreateMappedArguments), // |
| 6867 B(StaContextSlot), R(0), U8(first_context_slot + 1), // | 6872 B(StaContextSlot), R(context), U8(first_context_slot + 1), // |
| 6868 B(Ldar), R(new_target), // | 6873 B(Ldar), R(new_target), // |
| 6869 B(StaContextSlot), R(0), U8(first_context_slot + 2), // | 6874 B(StaContextSlot), R(context), U8(first_context_slot + 2), // |
| 6870 B(Mov), R(0), R(3), // | 6875 B(Mov), R(context), R(3), // |
| 6871 B(LdaConstant), U8(0), // | 6876 B(LdaConstant), U8(0), // |
| 6872 B(Star), R(4), // | 6877 B(Star), R(4), // |
| 6873 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 6878 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // |
| 6874 R(3), U8(2), R(1), // | 6879 R(3), U8(2), R(1), // |
| 6875 B(LdaConstant), U8(1), // | 6880 B(LdaConstant), U8(1), // |
| 6876 B(Star), R(3), // | 6881 B(Star), R(3), // |
| 6877 B(Mov), R(1), R(4), // | 6882 B(Mov), R(1), R(4), // |
| 6878 B(Mov), R(3), R(5), // | 6883 B(Mov), R(3), R(5), // |
| 6879 B(Mov), R(closure), R(6), // | 6884 B(Mov), R(closure), R(6), // |
| 6880 B(LdaZero), // | 6885 B(LdaZero), // |
| (...skipping 11 matching lines...) Expand all Loading... |
| 6892 {"eval", "var x = 10;", "x"}}, | 6897 {"eval", "var x = 10;", "x"}}, |
| 6893 {"eval('var x = 10;'); return typeof x;", | 6898 {"eval('var x = 10;'); return typeof x;", |
| 6894 9 * kPointerSize, | 6899 9 * kPointerSize, |
| 6895 1, | 6900 1, |
| 6896 70, | 6901 70, |
| 6897 { | 6902 { |
| 6898 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 6903 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 6899 U8(1), // | 6904 U8(1), // |
| 6900 B(PushContext), R(0), // | 6905 B(PushContext), R(0), // |
| 6901 B(Ldar), THIS(1), // | 6906 B(Ldar), THIS(1), // |
| 6902 B(StaContextSlot), R(0), U8(first_context_slot), // | 6907 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 6903 B(CreateMappedArguments), // | 6908 B(CreateMappedArguments), // |
| 6904 B(StaContextSlot), R(0), U8(first_context_slot + 1), // | 6909 B(StaContextSlot), R(context), U8(first_context_slot + 1), // |
| 6905 B(Ldar), R(new_target), // | 6910 B(Ldar), R(new_target), // |
| 6906 B(StaContextSlot), R(0), U8(first_context_slot + 2), // | 6911 B(StaContextSlot), R(context), U8(first_context_slot + 2), // |
| 6907 B(Mov), R(0), R(3), // | 6912 B(Mov), R(context), R(3), // |
| 6908 B(LdaConstant), U8(0), // | 6913 B(LdaConstant), U8(0), // |
| 6909 B(Star), R(4), // | 6914 B(Star), R(4), // |
| 6910 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 6915 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // |
| 6911 R(3), U8(2), R(1), // | 6916 R(3), U8(2), R(1), // |
| 6912 B(LdaConstant), U8(1), // | 6917 B(LdaConstant), U8(1), // |
| 6913 B(Star), R(3), // | 6918 B(Star), R(3), // |
| 6914 B(Mov), R(1), R(4), // | 6919 B(Mov), R(1), R(4), // |
| 6915 B(Mov), R(3), R(5), // | 6920 B(Mov), R(3), R(5), // |
| 6916 B(Mov), R(closure), R(6), // | 6921 B(Mov), R(closure), R(6), // |
| 6917 B(LdaZero), // | 6922 B(LdaZero), // |
| (...skipping 12 matching lines...) Expand all Loading... |
| 6930 {"eval", "var x = 10;", "x"}}, | 6935 {"eval", "var x = 10;", "x"}}, |
| 6931 {"x = 20; return eval('');", | 6936 {"x = 20; return eval('');", |
| 6932 9 * kPointerSize, | 6937 9 * kPointerSize, |
| 6933 1, | 6938 1, |
| 6934 71, | 6939 71, |
| 6935 { | 6940 { |
| 6936 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 6941 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 6937 U8(1), // | 6942 U8(1), // |
| 6938 B(PushContext), R(0), // | 6943 B(PushContext), R(0), // |
| 6939 B(Ldar), THIS(1), // | 6944 B(Ldar), THIS(1), // |
| 6940 B(StaContextSlot), R(0), U8(first_context_slot), // | 6945 B(StaContextSlot), R(context), U8(first_context_slot), // |
| 6941 B(CreateMappedArguments), // | 6946 B(CreateMappedArguments), // |
| 6942 B(StaContextSlot), R(0), U8(first_context_slot + 1), // | 6947 B(StaContextSlot), R(context), U8(first_context_slot + 1), // |
| 6943 B(Ldar), R(new_target), // | 6948 B(Ldar), R(new_target), // |
| 6944 B(StaContextSlot), R(0), U8(first_context_slot + 2), // | 6949 B(StaContextSlot), R(context), U8(first_context_slot + 2), // |
| 6945 B(LdaSmi8), U8(20), // | 6950 B(LdaSmi8), U8(20), // |
| 6946 B(StaLookupSlotSloppy), U8(0), // | 6951 B(StaLookupSlotSloppy), U8(0), // |
| 6947 B(Mov), R(0), R(3), // | 6952 B(Mov), R(context), R(3), // |
| 6948 B(LdaConstant), U8(1), // | 6953 B(LdaConstant), U8(1), // |
| 6949 B(Star), R(4), // | 6954 B(Star), R(4), // |
| 6950 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 6955 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // |
| 6951 R(3), U8(2), R(1), // | 6956 R(3), U8(2), R(1), // |
| 6952 B(LdaConstant), U8(2), // | 6957 B(LdaConstant), U8(2), // |
| 6953 B(Star), R(3), // | 6958 B(Star), R(3), // |
| 6954 B(Mov), R(1), R(4), // | 6959 B(Mov), R(1), R(4), // |
| 6955 B(Mov), R(3), R(5), // | 6960 B(Mov), R(3), R(5), // |
| 6956 B(Mov), R(closure), R(6), // | 6961 B(Mov), R(closure), R(6), // |
| 6957 B(LdaZero), // | 6962 B(LdaZero), // |
| (...skipping 25 matching lines...) Expand all Loading... |
| 6983 | 6988 |
| 6984 FeedbackVectorSpec feedback_spec(&zone); | 6989 FeedbackVectorSpec feedback_spec(&zone); |
| 6985 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); | 6990 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); |
| 6986 FeedbackVectorSlot slot2 = feedback_spec.AddCallICSlot(); | 6991 FeedbackVectorSlot slot2 = feedback_spec.AddCallICSlot(); |
| 6987 USE(slot1); | 6992 USE(slot1); |
| 6988 | 6993 |
| 6989 Handle<i::TypeFeedbackVector> vector = | 6994 Handle<i::TypeFeedbackVector> vector = |
| 6990 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); | 6995 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); |
| 6991 | 6996 |
| 6992 int closure = Register::function_closure().index(); | 6997 int closure = Register::function_closure().index(); |
| 6998 int context = Register::current_context().index(); |
| 6993 int new_target = Register::new_target().index(); | 6999 int new_target = Register::new_target().index(); |
| 6994 | 7000 |
| 6995 ExpectedSnippet<InstanceType> snippets[] = { | 7001 ExpectedSnippet<InstanceType> snippets[] = { |
| 6996 {"g = function(){}; eval(''); return g();", | 7002 {"g = function(){}; eval(''); return g();", |
| 6997 9 * kPointerSize, | 7003 9 * kPointerSize, |
| 6998 1, | 7004 1, |
| 6999 90, | 7005 90, |
| 7000 { | 7006 { |
| 7001 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // | 7007 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // |
| 7002 U8(1), // | 7008 U8(1), // |
| 7003 B(PushContext), R(0), // | 7009 B(PushContext), R(0), // |
| 7004 B(Ldar), THIS(1), // | 7010 B(Ldar), THIS(1), // |
| 7005 B(StaContextSlot), R(0), U8(4), // | 7011 B(StaContextSlot), R(context), U8(4), // |
| 7006 B(CreateMappedArguments), // | 7012 B(CreateMappedArguments), // |
| 7007 B(StaContextSlot), R(0), U8(5), // | 7013 B(StaContextSlot), R(context), U8(5), // |
| 7008 B(Ldar), R(new_target), // | 7014 B(Ldar), R(new_target), // |
| 7009 B(StaContextSlot), R(0), U8(6), // | 7015 B(StaContextSlot), R(context), U8(6), // |
| 7010 B(CreateClosure), U8(0), U8(0), // | 7016 B(CreateClosure), U8(0), U8(0), // |
| 7011 B(StaLookupSlotSloppy), U8(1), // | 7017 B(StaLookupSlotSloppy), U8(1), // |
| 7012 B(Mov), R(0), R(3), // | 7018 B(Mov), R(context), R(3), // |
| 7013 B(LdaConstant), U8(2), // | 7019 B(LdaConstant), U8(2), // |
| 7014 B(Star), R(4), // | 7020 B(Star), R(4), // |
| 7015 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 7021 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // |
| 7016 R(3), U8(2), R(1), // | 7022 R(3), U8(2), R(1), // |
| 7017 B(LdaConstant), U8(3), // | 7023 B(LdaConstant), U8(3), // |
| 7018 B(Star), R(3), // | 7024 B(Star), R(3), // |
| 7019 B(Mov), R(1), R(4), // | 7025 B(Mov), R(1), R(4), // |
| 7020 B(Mov), R(3), R(5), // | 7026 B(Mov), R(3), R(5), // |
| 7021 B(Mov), R(closure), R(6), // | 7027 B(Mov), R(closure), R(6), // |
| 7022 B(LdaZero), // | 7028 B(LdaZero), // |
| 7023 B(Star), R(7), // | 7029 B(Star), R(7), // |
| 7024 B(LdaSmi8), U8(10), // | 7030 B(LdaSmi8), U8(10), // |
| 7025 B(Star), R(8), // | 7031 B(Star), R(8), // |
| 7026 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // | 7032 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // |
| 7027 U8(5), // | 7033 U8(5), // |
| 7028 B(Star), R(1), // | 7034 B(Star), R(1), // |
| 7029 B(Call), R(1), R(2), U8(1), U8(0), // | 7035 B(Call), R(1), R(2), U8(1), U8(0), // |
| 7030 B(Mov), R(0), R(3), // | 7036 B(Mov), R(context), R(3), // |
| 7031 B(LdaConstant), U8(1), // | 7037 B(LdaConstant), U8(1), // |
| 7032 B(Star), R(4), // | 7038 B(Star), R(4), // |
| 7033 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // | 7039 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), // |
| 7034 R(3), U8(2), R(1), // | 7040 R(3), U8(2), R(1), // |
| 7035 B(Call), R(1), R(2), U8(0), U8(vector->GetIndex(slot2)), // | 7041 B(Call), R(1), R(2), U8(0), U8(vector->GetIndex(slot2)), // |
| 7036 B(Return), // | 7042 B(Return), // |
| 7037 }, | 7043 }, |
| 7038 4, | 7044 4, |
| 7039 {InstanceType::SHARED_FUNCTION_INFO_TYPE, | 7045 {InstanceType::SHARED_FUNCTION_INFO_TYPE, |
| 7040 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, | 7046 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7273 std::string(function_epilogue); | 7279 std::string(function_epilogue); |
| 7274 Handle<BytecodeArray> bytecode_array = | 7280 Handle<BytecodeArray> bytecode_array = |
| 7275 helper.MakeBytecode(script.c_str(), "*", "f"); | 7281 helper.MakeBytecode(script.c_str(), "*", "f"); |
| 7276 CheckBytecodeArrayEqual(snippets[i], bytecode_array); | 7282 CheckBytecodeArrayEqual(snippets[i], bytecode_array); |
| 7277 } | 7283 } |
| 7278 } | 7284 } |
| 7279 | 7285 |
| 7280 } // namespace interpreter | 7286 } // namespace interpreter |
| 7281 } // namespace internal | 7287 } // namespace internal |
| 7282 } // namespace v8 | 7288 } // namespace v8 |
| OLD | NEW |