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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 } | 266 } |
267 | 267 |
268 | 268 |
269 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { | 269 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { |
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)))); |
rmcilroy
2015/08/27 08:37:16
nit - could you add a test for the new m.LoadConte
| |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 | 280 |
281 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { | 281 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { |
282 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 282 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
283 InterpreterAssemblerForTest m(this, bytecode); | 283 InterpreterAssemblerForTest m(this, bytecode); |
284 Node* object = m.IntPtrConstant(0xdeadbeef); | 284 Node* object = m.IntPtrConstant(0xdeadbeef); |
285 int offset = 16; | 285 int offset = 16; |
286 Node* load_field = m.LoadObjectField(object, offset); | 286 Node* load_field = m.LoadObjectField(object, offset); |
287 EXPECT_THAT(load_field, | 287 EXPECT_THAT(load_field, |
288 m.IsLoad(kMachAnyTagged, object, | 288 m.IsLoad(kMachAnyTagged, object, |
289 IsIntPtrConstant(offset - kHeapObjectTag))); | 289 IsIntPtrConstant(offset - kHeapObjectTag))); |
290 } | 290 } |
291 } | 291 } |
292 | 292 |
293 | 293 |
294 TARGET_TEST_F(InterpreterAssemblerTest, CallJSBuiltin) { | 294 TARGET_TEST_F(InterpreterAssemblerTest, CallJSBuiltin) { |
295 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 295 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
296 InterpreterAssemblerForTest m(this, bytecode); | 296 InterpreterAssemblerForTest m(this, bytecode); |
297 Node* receiver = m.IntPtrConstant(1234); | 297 Node* receiver = m.IntPtrConstant(1234); |
298 Node* call_js_builtin_0 = m.CallJSBuiltin(Builtins::SUB, receiver); | 298 Node* call_js_builtin_0 = |
299 m.CallJSBuiltin(Context::SUB_BUILTIN_INDEX, receiver); | |
299 | 300 |
300 Matcher<Node*> load_globals_matcher = m.IsLoad( | 301 Matcher<Node*> load_globals_matcher = m.IsLoad( |
301 kMachAnyTagged, IsParameter(Linkage::kInterpreterContextParameter), | 302 kMachAnyTagged, IsParameter(Linkage::kInterpreterContextParameter), |
302 IsIntPtrConstant(Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 303 IsIntPtrConstant(Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
303 Matcher<Node*> load_builtins_matcher = m.IsLoad( | 304 Matcher<Node*> load_native_context_matcher = m.IsLoad( |
304 kMachAnyTagged, load_globals_matcher, | 305 kMachAnyTagged, load_globals_matcher, |
305 IsIntPtrConstant(GlobalObject::kBuiltinsOffset - kHeapObjectTag)); | 306 IsIntPtrConstant(GlobalObject::kNativeContextOffset - kHeapObjectTag)); |
306 Matcher<Node*> function_matcher = | 307 Matcher<Node*> function_matcher = m.IsLoad( |
307 m.IsLoad(kMachAnyTagged, load_builtins_matcher, | 308 kMachAnyTagged, load_native_context_matcher, |
308 IsIntPtrConstant( | 309 IsIntPtrConstant(Context::SlotOffset(Context::SUB_BUILTIN_INDEX))); |
309 JSBuiltinsObject::OffsetOfFunctionWithId(Builtins::SUB) - | |
310 kHeapObjectTag)); | |
311 Matcher<Node*> context_matcher = | 310 Matcher<Node*> context_matcher = |
312 m.IsLoad(kMachAnyTagged, function_matcher, | 311 m.IsLoad(kMachAnyTagged, function_matcher, |
313 IsIntPtrConstant(JSFunction::kContextOffset - kHeapObjectTag)); | 312 IsIntPtrConstant(JSFunction::kContextOffset - kHeapObjectTag)); |
314 EXPECT_THAT(call_js_builtin_0, | 313 EXPECT_THAT(call_js_builtin_0, |
315 IsCall(_, function_matcher, receiver, context_matcher, | 314 IsCall(_, function_matcher, receiver, context_matcher, |
316 m.graph()->start(), m.graph()->start())); | 315 m.graph()->start(), m.graph()->start())); |
317 | 316 |
318 Node* arg1 = m.Int32Constant(0xabcd); | 317 Node* arg1 = m.Int32Constant(0xabcd); |
319 Node* call_js_builtin_1 = m.CallJSBuiltin(Builtins::SUB, receiver, arg1); | 318 Node* call_js_builtin_1 = |
319 m.CallJSBuiltin(Context::SUB_BUILTIN_INDEX, receiver, arg1); | |
320 EXPECT_THAT(call_js_builtin_1, | 320 EXPECT_THAT(call_js_builtin_1, |
321 IsCall(_, function_matcher, receiver, arg1, context_matcher, | 321 IsCall(_, function_matcher, receiver, arg1, context_matcher, |
322 m.graph()->start(), m.graph()->start())); | 322 m.graph()->start(), m.graph()->start())); |
323 } | 323 } |
324 } | 324 } |
325 | 325 |
326 } // namespace compiler | 326 } // namespace compiler |
327 } // namespace internal | 327 } // namespace internal |
328 } // namespace v8 | 328 } // namespace v8 |
OLD | NEW |