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

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: Fix missing receiver slot. 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
« no previous file with comments | « src/x64/interface-descriptors-x64.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 #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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 4 * kPointerSize, 1008 4 * kPointerSize,
1009 3, 1009 3,
1010 30, 1010 30,
1011 { 1011 {
1012 B(Ldar), R(helper.kLastParamIndex - 1), // 1012 B(Ldar), R(helper.kLastParamIndex - 1), //
1013 B(Star), R(1), // 1013 B(Star), R(1), //
1014 B(LdaConstant), U8(0), // 1014 B(LdaConstant), U8(0), //
1015 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), // 1015 B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), //
1016 B(Star), R(0), // 1016 B(Star), R(0), //
1017 B(Ldar), R(helper.kLastParamIndex), // 1017 B(Ldar), R(helper.kLastParamIndex), //
1018 B(Star), R(2), // 1018 B(Star), R(3), //
1019 B(Ldar), R(helper.kLastParamIndex), // 1019 B(Ldar), R(helper.kLastParamIndex), //
1020 B(Add), R(2), // 1020 B(Add), R(3), //
1021 B(Star), R(2), // 1021 B(Star), R(2), //
1022 B(Ldar), R(helper.kLastParamIndex), // 1022 B(Ldar), R(helper.kLastParamIndex), //
1023 B(Star), R(3), // 1023 B(Star), R(3), //
1024 B(Call), R(0), R(1), U8(2), // 1024 B(Call), R(0), R(1), U8(2), //
1025 B(Return) // 1025 B(Return), //
1026 }, 1026 },
1027 1, 1027 1,
1028 {"func"}}}; 1028 {"func"}}};
1029 for (size_t i = 0; i < arraysize(snippets); i++) { 1029 for (size_t i = 0; i < arraysize(snippets); i++) {
1030 Handle<BytecodeArray> bytecode_array = 1030 Handle<BytecodeArray> bytecode_array =
1031 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); 1031 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName);
1032 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1032 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1033 } 1033 }
1034 } 1034 }
1035 1035
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
2663 0}, 2663 0},
2664 }; 2664 };
2665 2665
2666 for (size_t i = 0; i < arraysize(snippets); i++) { 2666 for (size_t i = 0; i < arraysize(snippets); i++) {
2667 Handle<BytecodeArray> bytecode_array = 2667 Handle<BytecodeArray> bytecode_array =
2668 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 2668 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2669 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2669 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2670 } 2670 }
2671 } 2671 }
2672 2672
2673
2674 TEST(CallNew) {
2675 InitializedHandleScope handle_scope;
2676 BytecodeGeneratorHelper helper;
2677
2678 ExpectedSnippet<InstanceType> snippets[] = {
2679 {"function bar() { this.value = 0; }\n"
2680 "function f() { return new bar(); }\n"
2681 "f()",
2682 kPointerSize,
2683 1,
2684 9,
2685 {
2686 B(LdaGlobal), _, //
2687 B(Star), R(0), //
2688 B(New), R(0), R(0), U8(0), //
2689 B(Return), //
2690 },
2691 0},
2692 {"function bar(x) { this.value = 18; this.x = x;}\n"
2693 "function f() { return new bar(3); }\n"
2694 "f()",
2695 2 * kPointerSize,
2696 1,
2697 13,
2698 {
2699 B(LdaGlobal), _, //
2700 B(Star), R(0), //
2701 B(LdaSmi8), U8(3), //
2702 B(Star), R(1), //
2703 B(New), R(0), R(1), U8(1), //
2704 B(Return), //
2705 },
2706 0},
2707 {"function bar(w, x, y, z) {\n"
2708 " this.value = 18;\n"
2709 " this.x = x;\n"
2710 " this.y = y;\n"
2711 " this.z = z;\n"
2712 "}\n"
2713 "function f() { return new bar(3, 4, 5); }\n"
2714 "f()",
2715 4 * kPointerSize,
2716 1,
2717 21,
2718 {
2719 B(LdaGlobal), _, //
2720 B(Star), R(0), //
2721 B(LdaSmi8), U8(3), //
2722 B(Star), R(1), //
2723 B(LdaSmi8), U8(4), //
2724 B(Star), R(2), //
2725 B(LdaSmi8), U8(5), //
2726 B(Star), R(3), //
2727 B(New), R(0), R(1), U8(3), //
2728 B(Return), //
2729 },
2730 0}};
2731
2732 for (size_t i = 0; i < arraysize(snippets); i++) {
2733 Handle<BytecodeArray> bytecode_array =
2734 helper.MakeBytecode(snippets[i].code_snippet, "f");
2735 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
2736 }
2737 }
2738
2673 } // namespace interpreter 2739 } // namespace interpreter
2674 } // namespace internal 2740 } // namespace internal
2675 } // namespace v8 2741 } // namespace v8
OLDNEW
« no previous file with comments | « src/x64/interface-descriptors-x64.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698