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

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

Issue 1402943002: [Interpreter] Support for operator new. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: One more test. Created 5 years, 2 months 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
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 #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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 4 * kPointerSize, 910 4 * kPointerSize,
911 3, 911 3,
912 30, 912 30,
913 { 913 {
914 B(Ldar), R(helper.kLastParamIndex - 1), // 914 B(Ldar), R(helper.kLastParamIndex - 1), //
915 B(Star), R(1), // 915 B(Star), R(1), //
916 B(LdaConstant), U8(0), // 916 B(LdaConstant), U8(0), //
917 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // 917 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), //
918 B(Star), R(0), // 918 B(Star), R(0), //
919 B(Ldar), R(helper.kLastParamIndex), // 919 B(Ldar), R(helper.kLastParamIndex), //
920 B(Star), R(2), // 920 B(Star), R(3), //
921 B(Ldar), R(helper.kLastParamIndex), // 921 B(Ldar), R(helper.kLastParamIndex), //
922 B(Add), R(2), // 922 B(Add), R(3), //
923 B(Star), R(2), // 923 B(Star), R(2), //
924 B(Ldar), R(helper.kLastParamIndex), // 924 B(Ldar), R(helper.kLastParamIndex), //
925 B(Star), R(3), // 925 B(Star), R(3), //
926 B(Call), R(0), R(1), U8(2), // 926 B(Call), R(0), R(1), U8(2), //
927 B(Return) // 927 B(Return), //
928 }, 928 },
929 1, 929 1,
930 {"func"}}}; 930 {"func"}}};
931 for (size_t i = 0; i < arraysize(snippets); i++) { 931 for (size_t i = 0; i < arraysize(snippets); i++) {
932 Handle<BytecodeArray> bytecode_array = 932 Handle<BytecodeArray> bytecode_array =
933 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); 933 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName);
934 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 934 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
935 } 935 }
936 } 936 }
937 937
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 2505 InstanceType::SHARED_FUNCTION_INFO_TYPE}},
2506 }; 2506 };
2507 2507
2508 for (size_t i = 0; i < arraysize(snippets); i++) { 2508 for (size_t i = 0; i < arraysize(snippets); i++) {
2509 Handle<BytecodeArray> bytecode_array = 2509 Handle<BytecodeArray> bytecode_array =
2510 helper.MakeTopLevelBytecode(snippets[i].code_snippet); 2510 helper.MakeTopLevelBytecode(snippets[i].code_snippet);
2511 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2511 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2512 } 2512 }
2513 } 2513 }
2514 2514
2515
2516 TEST(CallNew) {
2517 InitializedHandleScope handle_scope;
2518 BytecodeGeneratorHelper helper;
2519
2520 ExpectedSnippet<InstanceType> snippets[] = {
2521 {"function bar() { this.value = 0; }\n"
2522 "function f() { return new bar(); }\n"
2523 "f()",
2524 kPointerSize,
2525 1,
2526 9,
2527 {
2528 B(LdaGlobal), _, //
2529 B(Star), R(0), //
2530 B(New), R(0), R(0), U8(0), //
2531 B(Return), //
2532 },
2533 0},
2534 {"function bar(x) { this.value = 18; this.x = x;}\n"
2535 "function f() { return new bar(3); }\n"
2536 "f()",
2537 2 * kPointerSize,
2538 1,
2539 13,
2540 {
2541 B(LdaGlobal), _, //
2542 B(Star), R(0), //
2543 B(LdaSmi8), U8(3), //
2544 B(Star), R(1), //
2545 B(New), R(0), R(1), U8(1), //
2546 B(Return), //
2547 },
2548 0},
2549 {"function bar(w, x, y, z) {\n"
2550 " this.value = 18;\n"
2551 " this.x = x;\n"
2552 " this.y = y;\n"
2553 " this.z = z;\n"
2554 "}\n"
2555 "function f() { return new bar(3, 4, 5); }\n"
2556 "f()",
2557 4 * kPointerSize,
2558 1,
2559 21,
2560 {
2561 B(LdaGlobal), _, //
2562 B(Star), R(0), //
2563 B(LdaSmi8), U8(3), //
2564 B(Star), R(1), //
2565 B(LdaSmi8), U8(4), //
2566 B(Star), R(2), //
2567 B(LdaSmi8), U8(5), //
2568 B(Star), R(3), //
2569 B(New), R(0), R(1), U8(3), //
2570 B(Return), //
2571 },
2572 0}};
2573
2574 for (size_t i = 0; i < arraysize(snippets); i++) {
2575 Handle<BytecodeArray> bytecode_array =
2576 helper.MakeBytecode(snippets[i].code_snippet, "f");
2577 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
2578 }
2579 }
2580
2515 } // namespace interpreter 2581 } // namespace interpreter
2516 } // namespace internal 2582 } // namespace internal
2517 } // namespace v8 2583 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698