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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 // Open a frame scope to indicate that there is a frame on the stack. The | 547 // Open a frame scope to indicate that there is a frame on the stack. The |
548 // MANUAL indicates that the scope shouldn't actually generate code to set up | 548 // MANUAL indicates that the scope shouldn't actually generate code to set up |
549 // the frame (that is done below). | 549 // the frame (that is done below). |
550 FrameScope frame_scope(masm, StackFrame::MANUAL); | 550 FrameScope frame_scope(masm, StackFrame::MANUAL); |
551 __ push(ebp); // Caller's frame pointer. | 551 __ push(ebp); // Caller's frame pointer. |
552 __ mov(ebp, esp); | 552 __ mov(ebp, esp); |
553 __ push(esi); // Callee's context. | 553 __ push(esi); // Callee's context. |
554 __ push(edi); // Callee's JS function. | 554 __ push(edi); // Callee's JS function. |
555 __ push(edx); // Callee's new target. | 555 __ push(edx); // Callee's new target. |
556 | 556 |
557 // Get the bytecode array from the function object and load the pointer to the | 557 // Get the bytecode array from the function object (or from the DebugInfo if |
558 // first entry into edi (InterpreterBytecodeRegister). | 558 // it is present) and load it into edi (InterpreterBytecodeArrayRegister). |
559 Label load_debug_bytecode_array, bytecode_array_loaded; | |
559 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 560 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
560 | |
561 Label load_debug_bytecode_array, bytecode_array_loaded; | |
562 __ cmp(FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset), | 561 __ cmp(FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset), |
563 Immediate(DebugInfo::uninitialized())); | 562 Immediate(DebugInfo::uninitialized())); |
564 __ j(not_equal, &load_debug_bytecode_array); | 563 __ j(not_equal, &load_debug_bytecode_array); |
565 __ mov(kInterpreterBytecodeArrayRegister, | 564 __ mov(kInterpreterBytecodeArrayRegister, |
566 FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset)); | 565 FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset)); |
567 __ bind(&bytecode_array_loaded); | 566 __ bind(&bytecode_array_loaded); |
568 | 567 |
569 if (FLAG_debug_code) { | 568 // Check function data field is actually a BytecodeArray object. |
570 // Check function data field is actually a BytecodeArray object. | 569 Label bytecode_array_not_present; |
571 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); | 570 __ JumpIfSmi(kInterpreterBytecodeArrayRegister, &bytecode_array_not_present); |
rmcilroy
2016/04/21 15:16:02
Maybe you could just compare with undefined to che
Michael Starzinger
2016/04/21 15:43:08
Done. Good point.
| |
572 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, | 571 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, eax); |
573 eax); | 572 __ j(not_equal, &bytecode_array_not_present); |
574 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); | |
575 } | |
576 | 573 |
577 // Push bytecode array. | 574 // Push bytecode array. |
578 __ push(kInterpreterBytecodeArrayRegister); | 575 __ push(kInterpreterBytecodeArrayRegister); |
579 // Push zero for bytecode array offset. | 576 // Push zero for bytecode array offset. |
580 __ push(Immediate(0)); | 577 __ push(Immediate(0)); |
581 | 578 |
582 // Allocate the local and temporary register file on the stack. | 579 // Allocate the local and temporary register file on the stack. |
583 { | 580 { |
584 // Load frame size from the BytecodeArray object. | 581 // Load frame size from the BytecodeArray object. |
585 __ mov(ebx, FieldOperand(kInterpreterBytecodeArrayRegister, | 582 __ mov(ebx, FieldOperand(kInterpreterBytecodeArrayRegister, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
631 // Even though the first bytecode handler was called, we will never return. | 628 // Even though the first bytecode handler was called, we will never return. |
632 __ Abort(kUnexpectedReturnFromBytecodeHandler); | 629 __ Abort(kUnexpectedReturnFromBytecodeHandler); |
633 | 630 |
634 // Load debug copy of the bytecode array. | 631 // Load debug copy of the bytecode array. |
635 __ bind(&load_debug_bytecode_array); | 632 __ bind(&load_debug_bytecode_array); |
636 Register debug_info = kInterpreterBytecodeArrayRegister; | 633 Register debug_info = kInterpreterBytecodeArrayRegister; |
637 __ mov(debug_info, FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset)); | 634 __ mov(debug_info, FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset)); |
638 __ mov(kInterpreterBytecodeArrayRegister, | 635 __ mov(kInterpreterBytecodeArrayRegister, |
639 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex)); | 636 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex)); |
640 __ jmp(&bytecode_array_loaded); | 637 __ jmp(&bytecode_array_loaded); |
638 | |
639 // If the bytecode array is no longer present, then the underlying function | |
640 // has been switched to a different kind of code and we heal the closure by | |
641 // switching the code entry field over to the new code object as well. | |
642 __ bind(&bytecode_array_not_present); | |
643 __ pop(edx); // Callee's new target. | |
644 __ pop(edi); // Callee's JS function. | |
645 __ pop(esi); // Callee's context. | |
646 __ leave(); // Leave the frame so we can tail call. | |
647 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | |
648 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kCodeOffset)); | |
649 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize)); | |
650 __ mov(FieldOperand(edi, JSFunction::kCodeEntryOffset), ecx); | |
651 __ RecordWriteCodeEntryField(edi, ecx, ebx); | |
652 __ jmp(ecx); | |
641 } | 653 } |
642 | 654 |
643 | 655 |
644 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { | 656 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { |
645 // The return value is in accumulator, which is already in eax. | 657 // The return value is in accumulator, which is already in eax. |
646 | 658 |
647 // Leave the frame (also dropping the register file). | 659 // Leave the frame (also dropping the register file). |
648 __ leave(); | 660 __ leave(); |
649 | 661 |
650 // Drop receiver + arguments and return. | 662 // Drop receiver + arguments and return. |
(...skipping 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2856 // And "return" to the OSR entry point of the function. | 2868 // And "return" to the OSR entry point of the function. |
2857 __ ret(0); | 2869 __ ret(0); |
2858 } | 2870 } |
2859 | 2871 |
2860 | 2872 |
2861 #undef __ | 2873 #undef __ |
2862 } // namespace internal | 2874 } // namespace internal |
2863 } // namespace v8 | 2875 } // namespace v8 |
2864 | 2876 |
2865 #endif // V8_TARGET_ARCH_IA32 | 2877 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |