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 "src/compiler/interpreter-assembler.h" | 5 #include "src/compiler/interpreter-assembler.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 return raw_assembler_->Load(kMachAnyTagged, constant_pool, entry_offset); | 284 return raw_assembler_->Load(kMachAnyTagged, constant_pool, entry_offset); |
285 } | 285 } |
286 | 286 |
287 | 287 |
288 Node* InterpreterAssembler::LoadObjectField(Node* object, int offset) { | 288 Node* InterpreterAssembler::LoadObjectField(Node* object, int offset) { |
289 return raw_assembler_->Load(kMachAnyTagged, object, | 289 return raw_assembler_->Load(kMachAnyTagged, object, |
290 IntPtrConstant(offset - kHeapObjectTag)); | 290 IntPtrConstant(offset - kHeapObjectTag)); |
291 } | 291 } |
292 | 292 |
293 | 293 |
294 Node* InterpreterAssembler::LoadContextSlot(Node* context, int slot_index) { | 294 Node* InterpreterAssembler::LoadContextSlot(Node* context, Node* slot_index) { |
295 return raw_assembler_->Load(kMachAnyTagged, context, | 295 Node* offset = |
296 IntPtrConstant(Context::SlotOffset(slot_index))); | 296 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), |
| 297 Int32Constant(Context::kHeaderSize - kHeapObjectTag)); |
| 298 return raw_assembler_->Load(kMachAnyTagged, context, offset); |
297 } | 299 } |
298 | 300 |
299 | 301 |
300 Node* InterpreterAssembler::LoadContextSlot(int slot_index) { | |
301 return LoadContextSlot(ContextTaggedPointer(), slot_index); | |
302 } | |
303 | |
304 | |
305 Node* InterpreterAssembler::LoadTypeFeedbackVector() { | 302 Node* InterpreterAssembler::LoadTypeFeedbackVector() { |
306 Node* function = raw_assembler_->Load( | 303 Node* function = raw_assembler_->Load( |
307 kMachAnyTagged, RegisterFileRawPointer(), | 304 kMachAnyTagged, RegisterFileRawPointer(), |
308 IntPtrConstant(InterpreterFrameConstants::kFunctionFromRegisterPointer)); | 305 IntPtrConstant(InterpreterFrameConstants::kFunctionFromRegisterPointer)); |
309 Node* shared_info = | 306 Node* shared_info = |
310 LoadObjectField(function, JSFunction::kSharedFunctionInfoOffset); | 307 LoadObjectField(function, JSFunction::kSharedFunctionInfoOffset); |
311 Node* vector = | 308 Node* vector = |
312 LoadObjectField(shared_info, SharedFunctionInfo::kFeedbackVectorOffset); | 309 LoadObjectField(shared_info, SharedFunctionInfo::kFeedbackVectorOffset); |
313 return vector; | 310 return vector; |
314 } | 311 } |
315 | 312 |
316 | 313 |
317 Node* InterpreterAssembler::CallN(CallDescriptor* descriptor, | 314 Node* InterpreterAssembler::CallN(CallDescriptor* descriptor, Node* code_target, |
318 Node* code_target, | |
319 Node** args) { | 315 Node** args) { |
320 Node* stack_pointer_before_call = nullptr; | 316 Node* stack_pointer_before_call = nullptr; |
321 if (FLAG_debug_code) { | 317 if (FLAG_debug_code) { |
322 stack_pointer_before_call = raw_assembler_->LoadStackPointer(); | 318 stack_pointer_before_call = raw_assembler_->LoadStackPointer(); |
323 } | 319 } |
324 Node* return_val = raw_assembler_->CallN(descriptor, code_target, args); | 320 Node* return_val = raw_assembler_->CallN(descriptor, code_target, args); |
325 if (FLAG_debug_code) { | 321 if (FLAG_debug_code) { |
326 Node* stack_pointer_after_call = raw_assembler_->LoadStackPointer(); | 322 Node* stack_pointer_after_call = raw_assembler_->LoadStackPointer(); |
327 AbortIfWordNotEqual(stack_pointer_before_call, stack_pointer_after_call, | 323 AbortIfWordNotEqual(stack_pointer_before_call, stack_pointer_after_call, |
328 kUnexpectedStackPointer); | 324 kUnexpectedStackPointer); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 BytecodeArrayTaggedPointer(), | 497 BytecodeArrayTaggedPointer(), |
502 DispatchTableRawPointer(), | 498 DispatchTableRawPointer(), |
503 ContextTaggedPointer() }; | 499 ContextTaggedPointer() }; |
504 Node* tail_call = | 500 Node* tail_call = |
505 raw_assembler_->TailCallN(call_descriptor(), target_code_object, args); | 501 raw_assembler_->TailCallN(call_descriptor(), target_code_object, args); |
506 // This should always be the end node. | 502 // This should always be the end node. |
507 AddEndInput(tail_call); | 503 AddEndInput(tail_call); |
508 } | 504 } |
509 | 505 |
510 | 506 |
511 void InterpreterAssembler::AbortIfWordNotEqual( | 507 void InterpreterAssembler::AbortIfWordNotEqual(Node* lhs, Node* rhs, |
512 Node* lhs, Node* rhs, BailoutReason bailout_reason) { | 508 BailoutReason bailout_reason) { |
513 RawMachineAssembler::Label match, no_match; | 509 RawMachineAssembler::Label match, no_match; |
514 Node* condition = raw_assembler_->WordEqual(lhs, rhs); | 510 Node* condition = raw_assembler_->WordEqual(lhs, rhs); |
515 raw_assembler_->Branch(condition, &match, &no_match); | 511 raw_assembler_->Branch(condition, &match, &no_match); |
516 raw_assembler_->Bind(&no_match); | 512 raw_assembler_->Bind(&no_match); |
517 Node* abort_id = SmiTag(Int32Constant(bailout_reason)); | 513 Node* abort_id = SmiTag(Int32Constant(bailout_reason)); |
518 CallRuntime(Runtime::kAbort, abort_id); | 514 CallRuntime(Runtime::kAbort, abort_id); |
519 Return(); | 515 Return(); |
520 raw_assembler_->Bind(&match); | 516 raw_assembler_->Bind(&match); |
521 } | 517 } |
522 | 518 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 return raw_assembler_->schedule(); | 562 return raw_assembler_->schedule(); |
567 } | 563 } |
568 | 564 |
569 | 565 |
570 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } | 566 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } |
571 | 567 |
572 | 568 |
573 } // namespace compiler | 569 } // namespace compiler |
574 } // namespace internal | 570 } // namespace internal |
575 } // namespace v8 | 571 } // namespace v8 |
OLD | NEW |