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/interpreter/interpreter-assembler.h" | 5 #include "src/interpreter/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/frames.h" | 10 #include "src/frames.h" |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 void InterpreterAssembler::JumpIfWordNotEqual(Node* lhs, Node* rhs, | 435 void InterpreterAssembler::JumpIfWordNotEqual(Node* lhs, Node* rhs, |
436 Node* delta) { | 436 Node* delta) { |
437 JumpConditional(WordNotEqual(lhs, rhs), delta); | 437 JumpConditional(WordNotEqual(lhs, rhs), delta); |
438 } | 438 } |
439 | 439 |
440 void InterpreterAssembler::Dispatch() { | 440 void InterpreterAssembler::Dispatch() { |
441 DispatchTo(Advance(Bytecodes::Size(bytecode_))); | 441 DispatchTo(Advance(Bytecodes::Size(bytecode_))); |
442 } | 442 } |
443 | 443 |
444 void InterpreterAssembler::DispatchTo(Node* new_bytecode_offset) { | 444 void InterpreterAssembler::DispatchTo(Node* new_bytecode_offset) { |
445 if (FLAG_trace_ignition) { | |
446 TraceBytecode(Runtime::kInterpreterTraceBytecodeExit); | |
447 } | |
448 Node* target_bytecode = Load( | 445 Node* target_bytecode = Load( |
449 MachineType::Uint8(), BytecodeArrayTaggedPointer(), new_bytecode_offset); | 446 MachineType::Uint8(), BytecodeArrayTaggedPointer(), new_bytecode_offset); |
450 | 447 |
451 // TODO(rmcilroy): Create a code target dispatch table to avoid conversion | 448 // TODO(rmcilroy): Create a code target dispatch table to avoid conversion |
452 // from code object on every dispatch. | 449 // from code object on every dispatch. |
453 Node* target_code_object = | 450 Node* target_code_object = |
454 Load(MachineType::Pointer(), DispatchTableRawPointer(), | 451 Load(MachineType::Pointer(), DispatchTableRawPointer(), |
455 Word32Shl(target_bytecode, Int32Constant(kPointerSizeLog2))); | 452 Word32Shl(target_bytecode, Int32Constant(kPointerSizeLog2))); |
456 | 453 |
457 InterpreterDispatchDescriptor descriptor(isolate()); | 454 DispatchToBytecodeHandler(target_code_object, new_bytecode_offset); |
458 Node* args[] = {GetAccumulator(), RegisterFileRawPointer(), | |
459 new_bytecode_offset, BytecodeArrayTaggedPointer(), | |
460 DispatchTableRawPointer(), GetContext()}; | |
461 TailCall(descriptor, target_code_object, args, 0); | |
462 } | 455 } |
463 | 456 |
464 void InterpreterAssembler::InterpreterReturn() { | 457 void InterpreterAssembler::DispatchToBytecodeHandler(Node* handler, |
| 458 Node* bytecode_offset) { |
465 if (FLAG_trace_ignition) { | 459 if (FLAG_trace_ignition) { |
466 TraceBytecode(Runtime::kInterpreterTraceBytecodeExit); | 460 TraceBytecode(Runtime::kInterpreterTraceBytecodeExit); |
467 } | 461 } |
468 | 462 |
| 463 InterpreterDispatchDescriptor descriptor(isolate()); |
| 464 Node* args[] = {GetAccumulator(), RegisterFileRawPointer(), |
| 465 bytecode_offset, BytecodeArrayTaggedPointer(), |
| 466 DispatchTableRawPointer(), GetContext()}; |
| 467 TailCall(descriptor, handler, args, 0); |
| 468 } |
| 469 |
| 470 void InterpreterAssembler::InterpreterReturn() { |
469 // TODO(rmcilroy): Investigate whether it is worth supporting self | 471 // TODO(rmcilroy): Investigate whether it is worth supporting self |
470 // optimization of primitive functions like FullCodegen. | 472 // optimization of primitive functions like FullCodegen. |
471 | 473 |
472 // Update profiling count by -BytecodeOffset to simulate backedge to start of | 474 // Update profiling count by -BytecodeOffset to simulate backedge to start of |
473 // function. | 475 // function. |
474 Node* profiling_weight = | 476 Node* profiling_weight = |
475 Int32Sub(Int32Constant(kHeapObjectTag + BytecodeArray::kHeaderSize), | 477 Int32Sub(Int32Constant(kHeapObjectTag + BytecodeArray::kHeaderSize), |
476 BytecodeOffset()); | 478 BytecodeOffset()); |
477 UpdateInterruptBudget(profiling_weight); | 479 UpdateInterruptBudget(profiling_weight); |
478 | 480 |
479 InterpreterDispatchDescriptor descriptor(isolate()); | |
480 Node* exit_trampoline_code_object = | 481 Node* exit_trampoline_code_object = |
481 HeapConstant(isolate()->builtins()->InterpreterExitTrampoline()); | 482 HeapConstant(isolate()->builtins()->InterpreterExitTrampoline()); |
482 Node* args[] = {GetAccumulator(), RegisterFileRawPointer(), | 483 DispatchToBytecodeHandler(exit_trampoline_code_object); |
483 BytecodeOffset(), BytecodeArrayTaggedPointer(), | |
484 DispatchTableRawPointer(), GetContext()}; | |
485 TailCall(descriptor, exit_trampoline_code_object, args, 0); | |
486 } | 484 } |
487 | 485 |
488 void InterpreterAssembler::StackCheck() { | 486 void InterpreterAssembler::StackCheck() { |
489 CodeStubAssembler::Label end(this); | 487 CodeStubAssembler::Label end(this); |
490 CodeStubAssembler::Label ok(this); | 488 CodeStubAssembler::Label ok(this); |
491 CodeStubAssembler::Label stack_guard(this); | 489 CodeStubAssembler::Label stack_guard(this); |
492 | 490 |
493 Node* sp = LoadStackPointer(); | 491 Node* sp = LoadStackPointer(); |
494 Node* stack_limit = Load( | 492 Node* stack_limit = Load( |
495 MachineType::Pointer(), | 493 MachineType::Pointer(), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 | 537 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 |
540 return true; | 538 return true; |
541 #else | 539 #else |
542 #error "Unknown Architecture" | 540 #error "Unknown Architecture" |
543 #endif | 541 #endif |
544 } | 542 } |
545 | 543 |
546 } // namespace interpreter | 544 } // namespace interpreter |
547 } // namespace internal | 545 } // namespace internal |
548 } // namespace v8 | 546 } // namespace v8 |
OLD | NEW |