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 kInterpreterBytecodeArrayRegister. |
559 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 559 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
560 | |
561 Label load_debug_bytecode_array, bytecode_array_loaded; | 560 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 |
| 568 // Check function data field is actually a BytecodeArray object. |
| 569 Label bytecode_array_not_present; |
| 570 __ CompareRoot(kInterpreterBytecodeArrayRegister, |
| 571 Heap::kUndefinedValueRootIndex); |
| 572 __ j(equal, &bytecode_array_not_present); |
569 if (FLAG_debug_code) { | 573 if (FLAG_debug_code) { |
570 // Check function data field is actually a BytecodeArray object. | |
571 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); | 574 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); |
572 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, | 575 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, |
573 eax); | 576 eax); |
574 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); | 577 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); |
575 } | 578 } |
576 | 579 |
577 // Push bytecode array. | 580 // Push bytecode array. |
578 __ push(kInterpreterBytecodeArrayRegister); | 581 __ push(kInterpreterBytecodeArrayRegister); |
579 // Push zero for bytecode array offset. | 582 // Push zero for bytecode array offset. |
580 __ push(Immediate(0)); | 583 __ push(Immediate(0)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 // Even though the first bytecode handler was called, we will never return. | 634 // Even though the first bytecode handler was called, we will never return. |
632 __ Abort(kUnexpectedReturnFromBytecodeHandler); | 635 __ Abort(kUnexpectedReturnFromBytecodeHandler); |
633 | 636 |
634 // Load debug copy of the bytecode array. | 637 // Load debug copy of the bytecode array. |
635 __ bind(&load_debug_bytecode_array); | 638 __ bind(&load_debug_bytecode_array); |
636 Register debug_info = kInterpreterBytecodeArrayRegister; | 639 Register debug_info = kInterpreterBytecodeArrayRegister; |
637 __ mov(debug_info, FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset)); | 640 __ mov(debug_info, FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset)); |
638 __ mov(kInterpreterBytecodeArrayRegister, | 641 __ mov(kInterpreterBytecodeArrayRegister, |
639 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex)); | 642 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex)); |
640 __ jmp(&bytecode_array_loaded); | 643 __ jmp(&bytecode_array_loaded); |
| 644 |
| 645 // If the bytecode array is no longer present, then the underlying function |
| 646 // has been switched to a different kind of code and we heal the closure by |
| 647 // switching the code entry field over to the new code object as well. |
| 648 __ bind(&bytecode_array_not_present); |
| 649 __ pop(edx); // Callee's new target. |
| 650 __ pop(edi); // Callee's JS function. |
| 651 __ pop(esi); // Callee's context. |
| 652 __ leave(); // Leave the frame so we can tail call. |
| 653 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 654 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kCodeOffset)); |
| 655 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize)); |
| 656 __ mov(FieldOperand(edi, JSFunction::kCodeEntryOffset), ecx); |
| 657 __ RecordWriteCodeEntryField(edi, ecx, ebx); |
| 658 __ jmp(ecx); |
641 } | 659 } |
642 | 660 |
643 | 661 |
644 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { | 662 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { |
645 // The return value is in accumulator, which is already in eax. | 663 // The return value is in accumulator, which is already in eax. |
646 | 664 |
647 // Leave the frame (also dropping the register file). | 665 // Leave the frame (also dropping the register file). |
648 __ leave(); | 666 __ leave(); |
649 | 667 |
650 // Drop receiver + arguments and return. | 668 // 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. | 2874 // And "return" to the OSR entry point of the function. |
2857 __ ret(0); | 2875 __ ret(0); |
2858 } | 2876 } |
2859 | 2877 |
2860 | 2878 |
2861 #undef __ | 2879 #undef __ |
2862 } // namespace internal | 2880 } // namespace internal |
2863 } // namespace v8 | 2881 } // namespace v8 |
2864 | 2882 |
2865 #endif // V8_TARGET_ARCH_IA32 | 2883 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |