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

Side by Side Diff: test/unittests/compiler/interpreter-assembler-unittest.cc

Issue 1245133002: [interpreter] Add Interpreter{Entry,Exit}Trampoline builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@oth_bytecode_array
Patch Set: Adding MIPS based on https://codereview.chromium.org/1257953002/ Created 5 years, 4 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/builtins-x64.cc ('k') | test/unittests/compiler/node-test-utils.h » ('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 "test/unittests/compiler/interpreter-assembler-unittest.h" 5 #include "test/unittests/compiler/interpreter-assembler-unittest.h"
6 6
7 #include "src/compiler/graph.h" 7 #include "src/compiler/graph.h"
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "src/unique.h"
9 #include "test/unittests/compiler/compiler-test-utils.h" 10 #include "test/unittests/compiler/compiler-test-utils.h"
10 #include "test/unittests/compiler/node-test-utils.h" 11 #include "test/unittests/compiler/node-test-utils.h"
11 12
12 namespace v8 { 13 namespace v8 {
13 namespace internal { 14 namespace internal {
14 namespace compiler { 15 namespace compiler {
15 16
16 const interpreter::Bytecode kBytecodes[] = { 17 const interpreter::Bytecode kBytecodes[] = {
17 #define DEFINE_BYTECODE(Name, _) interpreter::Bytecode::k##Name, 18 #define DEFINE_BYTECODE(Name, _) interpreter::Bytecode::k##Name,
18 BYTECODE_LIST(DEFINE_BYTECODE) 19 BYTECODE_LIST(DEFINE_BYTECODE)
(...skipping 26 matching lines...) Expand all
45 } 46 }
46 47
47 48
48 Matcher<Node*> IsIntPtrAdd(const Matcher<Node*>& lhs_matcher, 49 Matcher<Node*> IsIntPtrAdd(const Matcher<Node*>& lhs_matcher,
49 const Matcher<Node*>& rhs_matcher) { 50 const Matcher<Node*>& rhs_matcher) {
50 return kPointerSize == 8 ? IsInt64Add(lhs_matcher, rhs_matcher) 51 return kPointerSize == 8 ? IsInt64Add(lhs_matcher, rhs_matcher)
51 : IsInt32Add(lhs_matcher, rhs_matcher); 52 : IsInt32Add(lhs_matcher, rhs_matcher);
52 } 53 }
53 54
54 55
56 Matcher<Node*> IsIntPtrSub(const Matcher<Node*>& lhs_matcher,
57 const Matcher<Node*>& rhs_matcher) {
58 return kPointerSize == 8 ? IsInt64Sub(lhs_matcher, rhs_matcher)
59 : IsInt32Sub(lhs_matcher, rhs_matcher);
60 }
61
62
63 Matcher<Node*> IsWordShl(const Matcher<Node*>& lhs_matcher,
64 const Matcher<Node*>& rhs_matcher) {
65 return kPointerSize == 8 ? IsWord64Shl(lhs_matcher, rhs_matcher)
66 : IsWord32Shl(lhs_matcher, rhs_matcher);
67 }
68
69
55 TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) { 70 TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) {
56 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 71 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
57 InterpreterAssemblerForTest m(this, bytecode); 72 InterpreterAssemblerForTest m(this, bytecode);
58 m.Dispatch(); 73 m.Dispatch();
59 Graph* graph = m.GetCompletedGraph(); 74 Graph* graph = m.GetCompletedGraph();
60 75
61 Node* end = graph->end(); 76 Node* end = graph->end();
62 EXPECT_EQ(1, end->InputCount()); 77 EXPECT_EQ(1, end->InputCount());
63 Node* tail_call_node = end->InputAt(0); 78 Node* tail_call_node = end->InputAt(0);
64 79
(...skipping 14 matching lines...) Expand all
79 tail_call_node, 94 tail_call_node,
80 IsTailCall(m.call_descriptor(), code_target_matcher, 95 IsTailCall(m.call_descriptor(), code_target_matcher,
81 next_bytecode_offset_matcher, 96 next_bytecode_offset_matcher,
82 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), 97 IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
83 IsParameter(Linkage::kInterpreterDispatchTableParameter), 98 IsParameter(Linkage::kInterpreterDispatchTableParameter),
84 graph->start(), graph->start())); 99 graph->start(), graph->start()));
85 } 100 }
86 } 101 }
87 102
88 103
104 TARGET_TEST_F(InterpreterAssemblerTest, Return) {
105 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
106 InterpreterAssemblerForTest m(this, bytecode);
107 m.Return();
108 Graph* graph = m.GetCompletedGraph();
109
110 Node* end = graph->end();
111 EXPECT_EQ(1, end->InputCount());
112 Node* tail_call_node = end->InputAt(0);
113
114 EXPECT_EQ(CallDescriptor::kInterpreterDispatch,
115 m.call_descriptor()->kind());
116 Matcher<Unique<HeapObject>> exit_trampoline(
117 Unique<HeapObject>::CreateImmovable(
118 isolate()->builtins()->InterpreterExitTrampoline()));
119 EXPECT_THAT(
120 tail_call_node,
121 IsTailCall(m.call_descriptor(), IsHeapConstant(exit_trampoline),
122 IsParameter(Linkage::kInterpreterBytecodeOffsetParameter),
123 IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
124 IsParameter(Linkage::kInterpreterDispatchTableParameter),
125 graph->start(), graph->start()));
126 }
127 }
128
129
89 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeArg) { 130 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeArg) {
90 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 131 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
91 InterpreterAssemblerForTest m(this, bytecode); 132 InterpreterAssemblerForTest m(this, bytecode);
92 int number_of_args = interpreter::Bytecodes::NumberOfArguments(bytecode); 133 int number_of_args = interpreter::Bytecodes::NumberOfArguments(bytecode);
93 for (int i = 0; i < number_of_args; i++) { 134 for (int i = 0; i < number_of_args; i++) {
94 Node* load_arg_node = m.BytecodeArg(i); 135 Node* load_arg_node = m.BytecodeArg(i);
95 EXPECT_THAT( 136 EXPECT_THAT(
96 load_arg_node, 137 load_arg_node,
97 m.IsLoad( 138 m.IsLoad(
98 kMachUint8, 139 kMachUint8,
(...skipping 21 matching lines...) Expand all
120 161
121 162
122 TARGET_TEST_F(InterpreterAssemblerTest, LoadRegister) { 163 TARGET_TEST_F(InterpreterAssemblerTest, LoadRegister) {
123 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 164 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
124 InterpreterAssemblerForTest m(this, bytecode); 165 InterpreterAssemblerForTest m(this, bytecode);
125 Node* reg_index_node = m.Int32Constant(44); 166 Node* reg_index_node = m.Int32Constant(44);
126 Node* load_reg_node = m.LoadRegister(reg_index_node); 167 Node* load_reg_node = m.LoadRegister(reg_index_node);
127 EXPECT_THAT( 168 EXPECT_THAT(
128 load_reg_node, 169 load_reg_node,
129 m.IsLoad(kMachPtr, IsLoadFramePointer(), 170 m.IsLoad(kMachPtr, IsLoadFramePointer(),
130 IsInt32Sub(IsInt32Constant(m.kFirstRegisterOffsetFromFp), 171 IsIntPtrSub(IsInt32Constant(m.kFirstRegisterOffsetFromFp),
131 IsWord32Shl(reg_index_node, 172 IsWordShl(reg_index_node,
132 IsInt32Constant(kPointerSizeLog2))))); 173 IsInt32Constant(kPointerSizeLog2)))));
133 } 174 }
134 } 175 }
135 176
136 177
137 TARGET_TEST_F(InterpreterAssemblerTest, StoreRegisterFixed) { 178 TARGET_TEST_F(InterpreterAssemblerTest, StoreRegisterFixed) {
138 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 179 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
139 InterpreterAssemblerForTest m(this, bytecode); 180 InterpreterAssemblerForTest m(this, bytecode);
140 Node* store_value = m.Int32Constant(0xdeadbeef); 181 Node* store_value = m.Int32Constant(0xdeadbeef);
141 for (int i = 0; i < m.kMaxRegisterIndex; i++) { 182 for (int i = 0; i < m.kMaxRegisterIndex; i++) {
142 Node* store_reg_node = m.StoreRegister(store_value, i); 183 Node* store_reg_node = m.StoreRegister(store_value, i);
(...skipping 11 matching lines...) Expand all
154 TARGET_TEST_F(InterpreterAssemblerTest, StoreRegister) { 195 TARGET_TEST_F(InterpreterAssemblerTest, StoreRegister) {
155 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 196 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
156 InterpreterAssemblerForTest m(this, bytecode); 197 InterpreterAssemblerForTest m(this, bytecode);
157 Node* store_value = m.Int32Constant(0xdeadbeef); 198 Node* store_value = m.Int32Constant(0xdeadbeef);
158 Node* reg_index_node = m.Int32Constant(44); 199 Node* reg_index_node = m.Int32Constant(44);
159 Node* store_reg_node = m.StoreRegister(store_value, reg_index_node); 200 Node* store_reg_node = m.StoreRegister(store_value, reg_index_node);
160 EXPECT_THAT( 201 EXPECT_THAT(
161 store_reg_node, 202 store_reg_node,
162 m.IsStore(StoreRepresentation(kMachPtr, kNoWriteBarrier), 203 m.IsStore(StoreRepresentation(kMachPtr, kNoWriteBarrier),
163 IsLoadFramePointer(), 204 IsLoadFramePointer(),
164 IsInt32Sub(IsInt32Constant(m.kFirstRegisterOffsetFromFp), 205 IsIntPtrSub(IsInt32Constant(m.kFirstRegisterOffsetFromFp),
165 IsWord32Shl(reg_index_node, 206 IsWordShl(reg_index_node,
166 IsInt32Constant(kPointerSizeLog2))), 207 IsInt32Constant(kPointerSizeLog2))),
167 store_value)); 208 store_value));
168 } 209 }
169 } 210 }
170 211
171 } // namespace compiler 212 } // namespace compiler
172 } // namespace internal 213 } // namespace internal
173 } // namespace v8 214 } // namespace v8
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698