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

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

Issue 1323463005: [Interpreter] Add support for JS calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add MIPS port contributed by akos.palfi@imgtec.com Created 5 years, 3 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 "test/unittests/compiler/interpreter-assembler-unittest.h" 5 #include "test/unittests/compiler/interpreter-assembler-unittest.h"
6 6
7 #include "src/code-factory.h"
7 #include "src/compiler/graph.h" 8 #include "src/compiler/graph.h"
8 #include "src/compiler/node.h" 9 #include "src/compiler/node.h"
9 #include "src/interface-descriptors.h" 10 #include "src/interface-descriptors.h"
10 #include "src/isolate.h" 11 #include "src/isolate.h"
11 #include "test/unittests/compiler/compiler-test-utils.h" 12 #include "test/unittests/compiler/compiler-test-utils.h"
12 #include "test/unittests/compiler/node-test-utils.h" 13 #include "test/unittests/compiler/node-test-utils.h"
13 14
14 using ::testing::_; 15 using ::testing::_;
15 16
16 namespace v8 { 17 namespace v8 {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 179 }
179 } 180 }
180 181
181 182
182 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { 183 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) {
183 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 184 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
184 InterpreterAssemblerForTest m(this, bytecode); 185 InterpreterAssemblerForTest m(this, bytecode);
185 int number_of_operands = interpreter::Bytecodes::NumberOfOperands(bytecode); 186 int number_of_operands = interpreter::Bytecodes::NumberOfOperands(bytecode);
186 for (int i = 0; i < number_of_operands; i++) { 187 for (int i = 0; i < number_of_operands; i++) {
187 switch (interpreter::Bytecodes::GetOperandType(bytecode, i)) { 188 switch (interpreter::Bytecodes::GetOperandType(bytecode, i)) {
189 case interpreter::OperandType::kCount:
190 EXPECT_THAT(m.BytecodeOperandCount(i), m.IsBytecodeOperand(i));
191 break;
188 case interpreter::OperandType::kIdx: 192 case interpreter::OperandType::kIdx:
189 EXPECT_THAT(m.BytecodeOperandIdx(i), m.IsBytecodeOperand(i)); 193 EXPECT_THAT(m.BytecodeOperandIdx(i), m.IsBytecodeOperand(i));
190 break; 194 break;
191 case interpreter::OperandType::kImm8: 195 case interpreter::OperandType::kImm8:
192 EXPECT_THAT(m.BytecodeOperandImm8(i), 196 EXPECT_THAT(m.BytecodeOperandImm8(i),
193 m.IsBytecodeOperandSignExtended(i)); 197 m.IsBytecodeOperandSignExtended(i));
194 break; 198 break;
195 case interpreter::OperandType::kReg: 199 case interpreter::OperandType::kReg:
196 EXPECT_THAT(m.BytecodeOperandReg(i), 200 EXPECT_THAT(m.BytecodeOperandReg(i),
197 m.IsBytecodeOperandSignExtended(i)); 201 m.IsBytecodeOperandSignExtended(i));
(...skipping 30 matching lines...) Expand all
228 EXPECT_EQ(1, end->InputCount()); 232 EXPECT_EQ(1, end->InputCount());
229 Node* tail_call_node = end->InputAt(0); 233 Node* tail_call_node = end->InputAt(0);
230 234
231 EXPECT_THAT(tail_call_node, 235 EXPECT_THAT(tail_call_node,
232 IsTailCall(m.call_descriptor(), _, accumulator_value_2, _, _, _, 236 IsTailCall(m.call_descriptor(), _, accumulator_value_2, _, _, _,
233 _, graph->start(), graph->start())); 237 _, graph->start(), graph->start()));
234 } 238 }
235 } 239 }
236 240
237 241
242 TARGET_TEST_F(InterpreterAssemblerTest, RegisterLocation) {
243 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
244 InterpreterAssemblerForTest m(this, bytecode);
245 Node* reg_index_node = m.Int32Constant(44);
246 Node* reg_location_node = m.RegisterLocation(reg_index_node);
247 EXPECT_THAT(
248 reg_location_node,
249 IsIntPtrAdd(
250 IsParameter(Linkage::kInterpreterRegisterFileParameter),
251 IsWordShl(reg_index_node, IsInt32Constant(kPointerSizeLog2))));
252 }
253 }
254
255
238 TARGET_TEST_F(InterpreterAssemblerTest, LoadRegister) { 256 TARGET_TEST_F(InterpreterAssemblerTest, LoadRegister) {
239 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 257 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
240 InterpreterAssemblerForTest m(this, bytecode); 258 InterpreterAssemblerForTest m(this, bytecode);
241 Node* reg_index_node = m.Int32Constant(44); 259 Node* reg_index_node = m.Int32Constant(44);
242 Node* load_reg_node = m.LoadRegister(reg_index_node); 260 Node* load_reg_node = m.LoadRegister(reg_index_node);
243 EXPECT_THAT( 261 EXPECT_THAT(
244 load_reg_node, 262 load_reg_node,
245 m.IsLoad(kMachAnyTagged, 263 m.IsLoad(kMachAnyTagged,
246 IsParameter(Linkage::kInterpreterRegisterFileParameter), 264 IsParameter(Linkage::kInterpreterRegisterFileParameter),
247 IsWordShl(reg_index_node, IsInt32Constant(kPointerSizeLog2)))); 265 IsWordShl(reg_index_node, IsInt32Constant(kPointerSizeLog2))));
(...skipping 22 matching lines...) Expand all
270 InterpreterAssemblerForTest m(this, bytecode); 288 InterpreterAssemblerForTest m(this, bytecode);
271 Node* value = m.Int32Constant(44); 289 Node* value = m.Int32Constant(44);
272 EXPECT_THAT(m.SmiTag(value), 290 EXPECT_THAT(m.SmiTag(value),
273 IsWordShl(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize))); 291 IsWordShl(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize)));
274 EXPECT_THAT(m.SmiUntag(value), 292 EXPECT_THAT(m.SmiUntag(value),
275 IsWordSar(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize))); 293 IsWordSar(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize)));
276 } 294 }
277 } 295 }
278 296
279 297
298 TARGET_TEST_F(InterpreterAssemblerTest, IntPtrAdd) {
299 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
300 InterpreterAssemblerForTest m(this, bytecode);
301 Node* a = m.Int32Constant(0);
302 Node* b = m.Int32Constant(1);
303 Node* add = m.IntPtrAdd(a, b);
304 EXPECT_THAT(add, IsIntPtrAdd(a, b));
305 }
306 }
307
308
309 TARGET_TEST_F(InterpreterAssemblerTest, IntPtrSub) {
310 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
311 InterpreterAssemblerForTest m(this, bytecode);
312 Node* a = m.Int32Constant(0);
313 Node* b = m.Int32Constant(1);
314 Node* add = m.IntPtrSub(a, b);
315 EXPECT_THAT(add, IsIntPtrSub(a, b));
316 }
317 }
318
319
320 TARGET_TEST_F(InterpreterAssemblerTest, WordShl) {
321 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
322 InterpreterAssemblerForTest m(this, bytecode);
323 Node* a = m.Int32Constant(0);
324 Node* add = m.WordShl(a, 10);
325 EXPECT_THAT(add, IsWordShl(a, IsInt32Constant(10)));
326 }
327 }
328
329
280 TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { 330 TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) {
281 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 331 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
282 InterpreterAssemblerForTest m(this, bytecode); 332 InterpreterAssemblerForTest m(this, bytecode);
283 Node* index = m.Int32Constant(2); 333 Node* index = m.Int32Constant(2);
284 Node* load_constant = m.LoadConstantPoolEntry(index); 334 Node* load_constant = m.LoadConstantPoolEntry(index);
285 Matcher<Node*> constant_pool_matcher = m.IsLoad( 335 Matcher<Node*> constant_pool_matcher = m.IsLoad(
286 kMachAnyTagged, 336 kMachAnyTagged,
287 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), 337 IsParameter(Linkage::kInterpreterBytecodeArrayParameter),
288 IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - kHeapObjectTag)); 338 IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - kHeapObjectTag));
289 EXPECT_THAT( 339 EXPECT_THAT(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 Node* arg3 = m.Int32Constant(4); 401 Node* arg3 = m.Int32Constant(4);
352 Node* arg4 = m.Int32Constant(5); 402 Node* arg4 = m.Int32Constant(5);
353 Node* call_ic = m.CallIC(descriptor, target, arg1, arg2, arg3, arg4); 403 Node* call_ic = m.CallIC(descriptor, target, arg1, arg2, arg3, arg4);
354 EXPECT_THAT(call_ic, 404 EXPECT_THAT(call_ic,
355 m.IsCall(_, target, arg1, arg2, arg3, arg4, 405 m.IsCall(_, target, arg1, arg2, arg3, arg4,
356 IsParameter(Linkage::kInterpreterContextParameter))); 406 IsParameter(Linkage::kInterpreterContextParameter)));
357 } 407 }
358 } 408 }
359 409
360 410
411 TARGET_TEST_F(InterpreterAssemblerTest, CallJS) {
412 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
413 InterpreterAssemblerForTest m(this, bytecode);
414 Callable builtin = CodeFactory::PushArgsAndCall(isolate());
415 Node* function = m.Int32Constant(0);
416 Node* first_arg = m.Int32Constant(1);
417 Node* arg_count = m.Int32Constant(2);
418 Node* call_js = m.CallJS(function, first_arg, arg_count);
419 EXPECT_THAT(
420 call_js,
421 m.IsCall(_, IsHeapConstant(builtin.code()), arg_count, first_arg,
422 function, IsParameter(Linkage::kInterpreterContextParameter)));
423 }
424 }
425
426
361 TARGET_TEST_F(InterpreterAssemblerTest, LoadTypeFeedbackVector) { 427 TARGET_TEST_F(InterpreterAssemblerTest, LoadTypeFeedbackVector) {
362 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 428 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
363 InterpreterAssemblerForTest m(this, bytecode); 429 InterpreterAssemblerForTest m(this, bytecode);
364 Node* feedback_vector = m.LoadTypeFeedbackVector(); 430 Node* feedback_vector = m.LoadTypeFeedbackVector();
365 431
366 Matcher<Node*> load_function_matcher = m.IsLoad( 432 Matcher<Node*> load_function_matcher = m.IsLoad(
367 kMachAnyTagged, IsParameter(Linkage::kInterpreterRegisterFileParameter), 433 kMachAnyTagged, IsParameter(Linkage::kInterpreterRegisterFileParameter),
368 IsIntPtrConstant( 434 IsIntPtrConstant(
369 InterpreterFrameConstants::kFunctionFromRegisterPointer)); 435 InterpreterFrameConstants::kFunctionFromRegisterPointer));
370 Matcher<Node*> load_shared_function_info_matcher = 436 Matcher<Node*> load_shared_function_info_matcher =
371 m.IsLoad(kMachAnyTagged, load_function_matcher, 437 m.IsLoad(kMachAnyTagged, load_function_matcher,
372 IsIntPtrConstant(JSFunction::kSharedFunctionInfoOffset - 438 IsIntPtrConstant(JSFunction::kSharedFunctionInfoOffset -
373 kHeapObjectTag)); 439 kHeapObjectTag));
374 440
375 EXPECT_THAT( 441 EXPECT_THAT(
376 feedback_vector, 442 feedback_vector,
377 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, 443 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher,
378 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - 444 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset -
379 kHeapObjectTag))); 445 kHeapObjectTag)));
380 } 446 }
381 } 447 }
382 448
383 } // namespace compiler 449 } // namespace compiler
384 } // namespace internal 450 } // namespace internal
385 } // namespace v8 451 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-interpreter.cc ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698