| OLD | NEW |
| 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/interface-descriptors.h" | 9 #include "src/interface-descriptors.h" |
| 10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 Node* object = m.IntPtrConstant(0xdeadbeef); | 321 Node* object = m.IntPtrConstant(0xdeadbeef); |
| 322 int offset = 16; | 322 int offset = 16; |
| 323 Node* load_field = m.LoadObjectField(object, offset); | 323 Node* load_field = m.LoadObjectField(object, offset); |
| 324 EXPECT_THAT(load_field, | 324 EXPECT_THAT(load_field, |
| 325 m.IsLoad(kMachAnyTagged, object, | 325 m.IsLoad(kMachAnyTagged, object, |
| 326 IsIntPtrConstant(offset - kHeapObjectTag))); | 326 IsIntPtrConstant(offset - kHeapObjectTag))); |
| 327 } | 327 } |
| 328 } | 328 } |
| 329 | 329 |
| 330 | 330 |
| 331 TARGET_TEST_F(InterpreterAssemblerTest, CallJSBuiltin) { | 331 TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime) { |
| 332 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 332 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 333 InterpreterAssemblerForTest m(this, bytecode); | 333 InterpreterAssemblerForTest m(this, bytecode); |
| 334 Node* receiver = m.IntPtrConstant(1234); | 334 Node* arg1 = m.Int32Constant(2); |
| 335 Node* call_js_builtin_0 = | 335 Node* arg2 = m.Int32Constant(3); |
| 336 m.CallJSBuiltin(Context::SUB_BUILTIN_INDEX, receiver); | 336 Node* call_runtime = m.CallRuntime(Runtime::kAdd, arg1, arg2); |
| 337 | 337 EXPECT_THAT(call_runtime, |
| 338 Matcher<Node*> load_globals_matcher = m.IsLoad( | 338 m.IsCall(_, _, arg1, arg2, _, IsInt32Constant(2), |
| 339 kMachAnyTagged, IsParameter(Linkage::kInterpreterContextParameter), | 339 IsParameter(Linkage::kInterpreterContextParameter))); |
| 340 IsIntPtrConstant(Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | |
| 341 Matcher<Node*> load_native_context_matcher = m.IsLoad( | |
| 342 kMachAnyTagged, load_globals_matcher, | |
| 343 IsIntPtrConstant(GlobalObject::kNativeContextOffset - kHeapObjectTag)); | |
| 344 Matcher<Node*> function_matcher = m.IsLoad( | |
| 345 kMachAnyTagged, load_native_context_matcher, | |
| 346 IsIntPtrConstant(Context::SlotOffset(Context::SUB_BUILTIN_INDEX))); | |
| 347 Matcher<Node*> context_matcher = | |
| 348 m.IsLoad(kMachAnyTagged, function_matcher, | |
| 349 IsIntPtrConstant(JSFunction::kContextOffset - kHeapObjectTag)); | |
| 350 EXPECT_THAT(call_js_builtin_0, | |
| 351 m.IsCall(_, function_matcher, receiver, context_matcher)); | |
| 352 | |
| 353 Node* arg1 = m.Int32Constant(0xabcd); | |
| 354 Node* call_js_builtin_1 = | |
| 355 m.CallJSBuiltin(Context::SUB_BUILTIN_INDEX, receiver, arg1); | |
| 356 EXPECT_THAT(call_js_builtin_1, | |
| 357 m.IsCall(_, function_matcher, receiver, arg1, context_matcher)); | |
| 358 } | 340 } |
| 359 } | 341 } |
| 360 | 342 |
| 361 | 343 |
| 362 TARGET_TEST_F(InterpreterAssemblerTest, CallIC) { | 344 TARGET_TEST_F(InterpreterAssemblerTest, CallIC) { |
| 363 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 345 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 364 InterpreterAssemblerForTest m(this, bytecode); | 346 InterpreterAssemblerForTest m(this, bytecode); |
| 365 LoadWithVectorDescriptor descriptor(isolate()); | 347 LoadWithVectorDescriptor descriptor(isolate()); |
| 366 Node* target = m.Int32Constant(1); | 348 Node* target = m.Int32Constant(1); |
| 367 Node* arg1 = m.Int32Constant(2); | 349 Node* arg1 = m.Int32Constant(2); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 394 feedback_vector, | 376 feedback_vector, |
| 395 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, | 377 m.IsLoad(kMachAnyTagged, load_shared_function_info_matcher, |
| 396 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - | 378 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - |
| 397 kHeapObjectTag))); | 379 kHeapObjectTag))); |
| 398 } | 380 } |
| 399 } | 381 } |
| 400 | 382 |
| 401 } // namespace compiler | 383 } // namespace compiler |
| 402 } // namespace internal | 384 } // namespace internal |
| 403 } // namespace v8 | 385 } // namespace v8 |
| OLD | NEW |