Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1422443006: [Intepreter] Don't throw reference errors for globals in typeof. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // TODO(rmcilroy): Remove this define after this flag is turned on globally 5 // TODO(rmcilroy): Remove this define after this flag is turned on globally
6 #define V8_IMMINENT_DEPRECATION_WARNINGS 6 #define V8_IMMINENT_DEPRECATION_WARNINGS
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/compiler.h" 10 #include "src/compiler.h"
(...skipping 2438 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 B(LdaSmi8), U8(1), // 2449 B(LdaSmi8), U8(1), //
2450 B(Sub), R(2), // 2450 B(Sub), R(2), //
2451 B(LdaUndefined), // 2451 B(LdaUndefined), //
2452 B(Star), R(1), // 2452 B(Star), R(1), //
2453 B(Ldar), R(1), // 2453 B(Ldar), R(1), //
2454 B(Return), // 2454 B(Return), //
2455 }, 2455 },
2456 1, 2456 1,
2457 {1234}}, 2457 {1234}},
2458 {"var x = 13;" 2458 {"var x = 13;"
2459 "return typeof(x);",
2460 kPointerSize,
2461 1,
2462 8,
2463 {
2464 B(LdaSmi8), U8(13), //
2465 B(Star), R(0), // TODO(oth): Ldar R(X) following Star R(X)
2466 B(Ldar), R(0), // could be culled in bytecode array builder.
2467 B(TypeOf), //
2468 B(Return), //
2469 },
2470 0},
2471 {"var x = 13;"
2472 "return ~x;", 2459 "return ~x;",
2473 1 * kPointerSize, 2460 1 * kPointerSize,
2474 1, 2461 1,
2475 9, 2462 9,
2476 { 2463 {
2477 B(LdaSmi8), U8(13), // 2464 B(LdaSmi8), U8(13), //
2478 B(Star), R(0), // 2465 B(Star), R(0), //
2479 B(LdaSmi8), U8(-1), // 2466 B(LdaSmi8), U8(-1), //
2480 B(BitwiseXor), R(0), // 2467 B(BitwiseXor), R(0), //
2481 B(Return), // 2468 B(Return), //
(...skipping 27 matching lines...) Expand all
2509 0}}; 2496 0}};
2510 2497
2511 for (size_t i = 0; i < arraysize(snippets); i++) { 2498 for (size_t i = 0; i < arraysize(snippets); i++) {
2512 Handle<BytecodeArray> bytecode_array = 2499 Handle<BytecodeArray> bytecode_array =
2513 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 2500 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2514 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2501 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2515 } 2502 }
2516 } 2503 }
2517 2504
2518 2505
2506 TEST(Typeof) {
2507 InitializedHandleScope handle_scope;
2508 BytecodeGeneratorHelper helper;
2509 Zone zone;
2510
2511 FeedbackVectorSpec feedback_spec(&zone);
2512 FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot();
2513
2514 Handle<i::TypeFeedbackVector> vector =
2515 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
2516
2517 ExpectedSnippet<const char*> snippets[] = {
2518 {"function f() {\n"
2519 " var x = 13;\n"
2520 " return typeof(x);\n"
2521 "}; f();",
2522 kPointerSize,
2523 1,
2524 8,
2525 {
2526 B(LdaSmi8), U8(13), //
2527 B(Star), R(0), // TODO(oth): Ldar R(X) following Star R(X)
2528 B(Ldar), R(0), // could be culled in bytecode array builder.
2529 B(TypeOf), //
2530 B(Return), //
2531 }},
2532 {"var x = 13;\n"
2533 "function f() {\n"
2534 " return typeof(x);\n"
2535 "}; f();",
2536 0,
2537 1,
2538 5,
2539 {
2540 B(LdaGlobalInsideTypeofSloppy), U8(0), //
2541 U8(vector->GetIndex(slot)), //
2542 B(TypeOf), //
2543 B(Return), //
2544 },
2545 1,
2546 {"x"}},
2547 {"var x = 13;\n"
2548 "function f() {\n"
2549 " 'use strict';\n"
2550 " return typeof(x);\n"
2551 "}; f();",
2552 0,
2553 1,
2554 5,
2555 {
2556 B(LdaGlobalInsideTypeofStrict), U8(0), //
2557 U8(vector->GetIndex(slot)), //
2558 B(TypeOf), //
2559 B(Return), //
2560 },
2561 1,
2562 {"x"}},
2563 };
2564
2565 for (size_t i = 0; i < arraysize(snippets); i++) {
2566 Handle<BytecodeArray> bytecode_array =
2567 helper.MakeBytecodeForFunction(snippets[i].code_snippet);
2568 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2569 }
2570 }
2571
2572
2519 TEST(Delete) { 2573 TEST(Delete) {
2520 InitializedHandleScope handle_scope; 2574 InitializedHandleScope handle_scope;
2521 BytecodeGeneratorHelper helper; 2575 BytecodeGeneratorHelper helper;
2522 2576
2523 int deep_elements_flags = 2577 int deep_elements_flags =
2524 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos; 2578 ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos;
2525 int closure = Register::function_closure().index(); 2579 int closure = Register::function_closure().index();
2526 int first_context_slot = Context::MIN_CONTEXT_SLOTS; 2580 int first_context_slot = Context::MIN_CONTEXT_SLOTS;
2527 2581
2528 ExpectedSnippet<InstanceType> snippets[] = { 2582 ExpectedSnippet<InstanceType> snippets[] = {
(...skipping 2542 matching lines...) Expand 10 before | Expand all | Expand 10 after
5071 for (size_t i = 0; i < arraysize(snippets); i++) { 5125 for (size_t i = 0; i < arraysize(snippets); i++) {
5072 Handle<BytecodeArray> bytecode_array = 5126 Handle<BytecodeArray> bytecode_array =
5073 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 5127 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
5074 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 5128 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
5075 } 5129 }
5076 } 5130 }
5077 5131
5078 } // namespace interpreter 5132 } // namespace interpreter
5079 } // namespace internal 5133 } // namespace internal
5080 } // namespace v8 5134 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698