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/unique.h" | 9 #include "src/unique.h" |
10 #include "test/unittests/compiler/compiler-test-utils.h" | 10 #include "test/unittests/compiler/compiler-test-utils.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 270 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
271 InterpreterAssemblerForTest m(this, bytecode); | 271 InterpreterAssemblerForTest m(this, bytecode); |
272 Node* load_context = m.LoadContextSlot(22); | 272 Node* load_context = m.LoadContextSlot(22); |
273 EXPECT_THAT(load_context, | 273 EXPECT_THAT(load_context, |
274 m.IsLoad(kMachAnyTagged, | 274 m.IsLoad(kMachAnyTagged, |
275 IsParameter(Linkage::kInterpreterContextParameter), | 275 IsParameter(Linkage::kInterpreterContextParameter), |
276 IsIntPtrConstant(Context::SlotOffset(22)))); | 276 IsIntPtrConstant(Context::SlotOffset(22)))); |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
| 280 |
| 281 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { |
| 282 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 283 InterpreterAssemblerForTest m(this, bytecode); |
| 284 Node* object = m.IntPtrConstant(0xdeadbeef); |
| 285 int offset = 16; |
| 286 Node* load_field = m.LoadObjectField(object, offset); |
| 287 EXPECT_THAT(load_field, |
| 288 m.IsLoad(kMachAnyTagged, object, |
| 289 IsIntPtrConstant(offset - kHeapObjectTag))); |
| 290 } |
| 291 } |
| 292 |
| 293 |
| 294 TARGET_TEST_F(InterpreterAssemblerTest, CallJSBuiltin) { |
| 295 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 296 InterpreterAssemblerForTest m(this, bytecode); |
| 297 Node* receiver = m.IntPtrConstant(1234); |
| 298 Node* call_js_builtin_0 = m.CallJSBuiltin(Builtins::SUB, receiver); |
| 299 |
| 300 Matcher<Node*> load_globals_matcher = m.IsLoad( |
| 301 kMachAnyTagged, IsParameter(Linkage::kInterpreterContextParameter), |
| 302 IsIntPtrConstant(Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
| 303 Matcher<Node*> load_builtins_matcher = m.IsLoad( |
| 304 kMachAnyTagged, load_globals_matcher, |
| 305 IsIntPtrConstant(GlobalObject::kBuiltinsOffset - kHeapObjectTag)); |
| 306 Matcher<Node*> function_matcher = |
| 307 m.IsLoad(kMachAnyTagged, load_builtins_matcher, |
| 308 IsIntPtrConstant( |
| 309 JSBuiltinsObject::OffsetOfFunctionWithId(Builtins::SUB) - |
| 310 kHeapObjectTag)); |
| 311 Matcher<Node*> context_matcher = |
| 312 m.IsLoad(kMachAnyTagged, function_matcher, |
| 313 IsIntPtrConstant(JSFunction::kContextOffset - kHeapObjectTag)); |
| 314 EXPECT_THAT(call_js_builtin_0, |
| 315 IsCall(_, function_matcher, receiver, context_matcher, |
| 316 m.graph()->start(), m.graph()->start())); |
| 317 |
| 318 Node* arg1 = m.Int32Constant(0xabcd); |
| 319 Node* call_js_builtin_1 = m.CallJSBuiltin(Builtins::SUB, receiver, arg1); |
| 320 EXPECT_THAT(call_js_builtin_1, |
| 321 IsCall(_, function_matcher, receiver, arg1, context_matcher, |
| 322 m.graph()->start(), m.graph()->start())); |
| 323 } |
| 324 } |
| 325 |
280 } // namespace compiler | 326 } // namespace compiler |
281 } // namespace internal | 327 } // namespace internal |
282 } // namespace v8 | 328 } // namespace v8 |
OLD | NEW |