OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 // Open a frame scope to indicate that there is a frame on the stack. The | 515 // Open a frame scope to indicate that there is a frame on the stack. The |
516 // MANUAL indicates that the scope shouldn't actually generate code to set up | 516 // MANUAL indicates that the scope shouldn't actually generate code to set up |
517 // the frame (that is done below). | 517 // the frame (that is done below). |
518 FrameScope frame_scope(masm, StackFrame::MANUAL); | 518 FrameScope frame_scope(masm, StackFrame::MANUAL); |
519 __ push(ebp); // Caller's frame pointer. | 519 __ push(ebp); // Caller's frame pointer. |
520 __ mov(ebp, esp); | 520 __ mov(ebp, esp); |
521 __ push(esi); // Callee's context. | 521 __ push(esi); // Callee's context. |
522 __ push(edi); // Callee's JS function. | 522 __ push(edi); // Callee's JS function. |
523 __ push(edx); // Callee's new target. | 523 __ push(edx); // Callee's new target. |
524 | 524 |
| 525 // Push zero for bytecode array offset. |
| 526 __ push(Immediate(0)); |
| 527 |
525 // Get the bytecode array from the function object and load the pointer to the | 528 // Get the bytecode array from the function object and load the pointer to the |
526 // first entry into edi (InterpreterBytecodeRegister). | 529 // first entry into edi (InterpreterBytecodeRegister). |
527 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 530 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
528 __ mov(kInterpreterBytecodeArrayRegister, | 531 __ mov(kInterpreterBytecodeArrayRegister, |
529 FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset)); | 532 FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset)); |
530 | 533 |
531 if (FLAG_debug_code) { | 534 if (FLAG_debug_code) { |
532 // Check function data field is actually a BytecodeArray object. | 535 // Check function data field is actually a BytecodeArray object. |
533 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); | 536 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); |
534 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, | 537 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 __ push(kInterpreterBytecodeArrayRegister); | 587 __ push(kInterpreterBytecodeArrayRegister); |
585 __ CallRuntime(Runtime::kStackGuard, 0); | 588 __ CallRuntime(Runtime::kStackGuard, 0); |
586 __ pop(kInterpreterBytecodeArrayRegister); | 589 __ pop(kInterpreterBytecodeArrayRegister); |
587 __ bind(&ok); | 590 __ bind(&ok); |
588 } | 591 } |
589 | 592 |
590 // Load accumulator, register file, bytecode offset, dispatch table into | 593 // Load accumulator, register file, bytecode offset, dispatch table into |
591 // registers. | 594 // registers. |
592 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); | 595 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); |
593 __ mov(kInterpreterRegisterFileRegister, ebp); | 596 __ mov(kInterpreterRegisterFileRegister, ebp); |
594 __ sub(kInterpreterRegisterFileRegister, | 597 __ add(kInterpreterRegisterFileRegister, |
595 Immediate(2 * kPointerSize + | 598 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp)); |
596 StandardFrameConstants::kFixedFrameSizeFromFp)); | |
597 __ mov(kInterpreterBytecodeOffsetRegister, | 599 __ mov(kInterpreterBytecodeOffsetRegister, |
598 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag)); | 600 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag)); |
599 // Since the dispatch table root might be set after builtins are generated, | 601 // Since the dispatch table root might be set after builtins are generated, |
600 // load directly from the roots table. | 602 // load directly from the roots table. |
601 __ LoadRoot(ebx, Heap::kInterpreterTableRootIndex); | 603 __ LoadRoot(ebx, Heap::kInterpreterTableRootIndex); |
602 __ add(ebx, Immediate(FixedArray::kHeaderSize - kHeapObjectTag)); | 604 __ add(ebx, Immediate(FixedArray::kHeaderSize - kHeapObjectTag)); |
603 | 605 |
604 // Push context as a stack located parameter to the bytecode handler. | 606 // Push context as a stack located parameter to the bytecode handler. |
605 DCHECK_EQ(-1, kInterpreterDispatchTableSpillSlot); | 607 DCHECK_EQ(-1, kInterpreterDispatchTableSpillSlot); |
606 __ push(ebx); | 608 __ push(ebx); |
607 | 609 |
608 // Dispatch to the first bytecode handler for the function. | 610 // Dispatch to the first bytecode handler for the function. |
609 __ movzx_b(eax, Operand(kInterpreterBytecodeArrayRegister, | 611 __ movzx_b(eax, Operand(kInterpreterBytecodeArrayRegister, |
610 kInterpreterBytecodeOffsetRegister, times_1, 0)); | 612 kInterpreterBytecodeOffsetRegister, times_1, 0)); |
611 __ mov(ebx, Operand(ebx, eax, times_pointer_size, 0)); | 613 __ mov(ebx, Operand(ebx, eax, times_pointer_size, 0)); |
612 // Restore undefined_value in accumulator (eax) | 614 // Restore undefined_value in accumulator (eax) |
613 // TODO(rmcilroy): Remove this once we move the dispatch table back into a | 615 // TODO(rmcilroy): Remove this once we move the dispatch table back into a |
614 // register. | 616 // register. |
615 __ mov(eax, Immediate(masm->isolate()->factory()->undefined_value())); | 617 __ mov(eax, Immediate(masm->isolate()->factory()->undefined_value())); |
616 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging | 618 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging |
617 // and header removal. | 619 // and header removal. |
618 __ add(ebx, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 620 __ add(ebx, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
619 __ call(ebx); | 621 __ call(ebx); |
| 622 __ nop(); // Ensure that return address still counts as interpreter entry |
| 623 // trampoline. |
620 } | 624 } |
621 | 625 |
622 | 626 |
623 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { | 627 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { |
624 // TODO(rmcilroy): List of things not currently dealt with here but done in | 628 // TODO(rmcilroy): List of things not currently dealt with here but done in |
625 // fullcodegen's EmitReturnSequence. | 629 // fullcodegen's EmitReturnSequence. |
626 // - Supporting FLAG_trace for Runtime::TraceExit. | 630 // - Supporting FLAG_trace for Runtime::TraceExit. |
627 // - Support profiler (specifically decrementing profiling_counter | 631 // - Support profiler (specifically decrementing profiling_counter |
628 // appropriately and calling out to HandleInterrupts if necessary). | 632 // appropriately and calling out to HandleInterrupts if necessary). |
629 | 633 |
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1976 | 1980 |
1977 __ bind(&ok); | 1981 __ bind(&ok); |
1978 __ ret(0); | 1982 __ ret(0); |
1979 } | 1983 } |
1980 | 1984 |
1981 #undef __ | 1985 #undef __ |
1982 } // namespace internal | 1986 } // namespace internal |
1983 } // namespace v8 | 1987 } // namespace v8 |
1984 | 1988 |
1985 #endif // V8_TARGET_ARCH_X87 | 1989 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |