| 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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 } | 516 } |
| 517 | 517 |
| 518 | 518 |
| 519 // Generate code for entering a JS function with the interpreter. | 519 // Generate code for entering a JS function with the interpreter. |
| 520 // On entry to the function the receiver and arguments have been pushed on the | 520 // On entry to the function the receiver and arguments have been pushed on the |
| 521 // stack left to right. The actual argument count matches the formal parameter | 521 // stack left to right. The actual argument count matches the formal parameter |
| 522 // count expected by the function. | 522 // count expected by the function. |
| 523 // | 523 // |
| 524 // The live registers are: | 524 // The live registers are: |
| 525 // o edi: the JS function object being called | 525 // o edi: the JS function object being called |
| 526 // o edx: the new target |
| 526 // o esi: our context | 527 // o esi: our context |
| 527 // o ebp: the caller's frame pointer | 528 // o ebp: the caller's frame pointer |
| 528 // o esp: stack pointer (pointing to return address) | 529 // o esp: stack pointer (pointing to return address) |
| 529 // | 530 // |
| 530 // The function builds a JS frame. Please see JavaScriptFrameConstants in | 531 // The function builds a JS frame. Please see JavaScriptFrameConstants in |
| 531 // frames-ia32.h for its layout. | 532 // frames-ia32.h for its layout. |
| 532 // TODO(rmcilroy): We will need to include the current bytecode pointer in the | 533 // TODO(rmcilroy): We will need to include the current bytecode pointer in the |
| 533 // frame. | 534 // frame. |
| 534 void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { | 535 void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { |
| 535 // Open a frame scope to indicate that there is a frame on the stack. The | 536 // Open a frame scope to indicate that there is a frame on the stack. The |
| 536 // MANUAL indicates that the scope shouldn't actually generate code to set up | 537 // MANUAL indicates that the scope shouldn't actually generate code to set up |
| 537 // the frame (that is done below). | 538 // the frame (that is done below). |
| 538 FrameScope frame_scope(masm, StackFrame::MANUAL); | 539 FrameScope frame_scope(masm, StackFrame::MANUAL); |
| 539 __ push(ebp); // Caller's frame pointer. | 540 __ push(ebp); // Caller's frame pointer. |
| 540 __ mov(ebp, esp); | 541 __ mov(ebp, esp); |
| 541 __ push(esi); // Callee's context. | 542 __ push(esi); // Callee's context. |
| 542 __ push(edi); // Callee's JS function. | 543 __ push(edi); // Callee's JS function. |
| 544 __ push(edx); // Callee's new target. |
| 543 | 545 |
| 544 // Get the bytecode array from the function object and load the pointer to the | 546 // Get the bytecode array from the function object and load the pointer to the |
| 545 // first entry into edi (InterpreterBytecodeRegister). | 547 // first entry into edi (InterpreterBytecodeRegister). |
| 546 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 548 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 547 __ mov(kInterpreterBytecodeArrayRegister, | 549 __ mov(kInterpreterBytecodeArrayRegister, |
| 548 FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset)); | 550 FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset)); |
| 549 | 551 |
| 550 if (FLAG_debug_code) { | 552 if (FLAG_debug_code) { |
| 551 // Check function data field is actually a BytecodeArray object. | 553 // Check function data field is actually a BytecodeArray object. |
| 552 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); | 554 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 __ push(kInterpreterBytecodeArrayRegister); | 605 __ push(kInterpreterBytecodeArrayRegister); |
| 604 __ CallRuntime(Runtime::kStackGuard, 0); | 606 __ CallRuntime(Runtime::kStackGuard, 0); |
| 605 __ pop(kInterpreterBytecodeArrayRegister); | 607 __ pop(kInterpreterBytecodeArrayRegister); |
| 606 __ bind(&ok); | 608 __ bind(&ok); |
| 607 } | 609 } |
| 608 | 610 |
| 609 // Load accumulator, register file, bytecode offset, dispatch table into | 611 // Load accumulator, register file, bytecode offset, dispatch table into |
| 610 // registers. | 612 // registers. |
| 611 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); | 613 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); |
| 612 __ mov(kInterpreterRegisterFileRegister, ebp); | 614 __ mov(kInterpreterRegisterFileRegister, ebp); |
| 613 __ sub( | 615 __ sub(kInterpreterRegisterFileRegister, |
| 614 kInterpreterRegisterFileRegister, | 616 Immediate(2 * kPointerSize + |
| 615 Immediate(kPointerSize + StandardFrameConstants::kFixedFrameSizeFromFp)); | 617 StandardFrameConstants::kFixedFrameSizeFromFp)); |
| 616 __ mov(kInterpreterBytecodeOffsetRegister, | 618 __ mov(kInterpreterBytecodeOffsetRegister, |
| 617 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag)); | 619 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag)); |
| 618 // Since the dispatch table root might be set after builtins are generated, | 620 // Since the dispatch table root might be set after builtins are generated, |
| 619 // load directly from the roots table. | 621 // load directly from the roots table. |
| 620 __ LoadRoot(ebx, Heap::kInterpreterTableRootIndex); | 622 __ LoadRoot(ebx, Heap::kInterpreterTableRootIndex); |
| 621 __ add(ebx, Immediate(FixedArray::kHeaderSize - kHeapObjectTag)); | 623 __ add(ebx, Immediate(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 622 | 624 |
| 623 // Push context as a stack located parameter to the bytecode handler. | 625 // Push context as a stack located parameter to the bytecode handler. |
| 624 DCHECK_EQ(-1, kInterpreterDispatchTableSpillSlot); | 626 DCHECK_EQ(-1, kInterpreterDispatchTableSpillSlot); |
| 625 __ push(ebx); | 627 __ push(ebx); |
| (...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1858 | 1860 |
| 1859 __ bind(&ok); | 1861 __ bind(&ok); |
| 1860 __ ret(0); | 1862 __ ret(0); |
| 1861 } | 1863 } |
| 1862 | 1864 |
| 1863 #undef __ | 1865 #undef __ |
| 1864 } // namespace internal | 1866 } // namespace internal |
| 1865 } // namespace v8 | 1867 } // namespace v8 |
| 1866 | 1868 |
| 1867 #endif // V8_TARGET_ARCH_IA32 | 1869 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |