Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/x87/builtins-x87.cc

Issue 1543433002: X87: [Interpreter] Add basic deoptimization support from TurboFan to Ignition. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 __ mov(kInterpreterRegisterFileRegister, ebp); 596 __ mov(kInterpreterRegisterFileRegister, ebp);
597 __ add(kInterpreterRegisterFileRegister, 597 __ add(kInterpreterRegisterFileRegister,
598 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp)); 598 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp));
599 __ mov(kInterpreterBytecodeOffsetRegister, 599 __ mov(kInterpreterBytecodeOffsetRegister,
600 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag)); 600 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag));
601 // 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,
602 // load directly from the roots table. 602 // load directly from the roots table.
603 __ LoadRoot(ebx, Heap::kInterpreterTableRootIndex); 603 __ LoadRoot(ebx, Heap::kInterpreterTableRootIndex);
604 __ add(ebx, Immediate(FixedArray::kHeaderSize - kHeapObjectTag)); 604 __ add(ebx, Immediate(FixedArray::kHeaderSize - kHeapObjectTag));
605 605
606 // Push context as a stack located parameter to the bytecode handler. 606 // Push dispatch table as a stack located parameter to the bytecode handler.
607 DCHECK_EQ(-1, kInterpreterDispatchTableSpillSlot); 607 DCHECK_EQ(-1, kInterpreterDispatchTableSpillSlot);
608 __ push(ebx); 608 __ push(ebx);
609 609
610 // Dispatch to the first bytecode handler for the function. 610 // Dispatch to the first bytecode handler for the function.
611 __ movzx_b(eax, Operand(kInterpreterBytecodeArrayRegister, 611 __ movzx_b(eax, Operand(kInterpreterBytecodeArrayRegister,
612 kInterpreterBytecodeOffsetRegister, times_1, 0)); 612 kInterpreterBytecodeOffsetRegister, times_1, 0));
613 __ mov(ebx, Operand(ebx, eax, times_pointer_size, 0)); 613 __ mov(ebx, Operand(ebx, eax, times_pointer_size, 0));
614 // Restore undefined_value in accumulator (eax) 614 // Restore undefined_value in accumulator (eax)
615 // 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
616 // register. 616 // register.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 __ mov(eax, Operand(esp, -kPointerSize)); 726 __ mov(eax, Operand(esp, -kPointerSize));
727 727
728 // Re-push return address. 728 // Re-push return address.
729 __ Push(ecx); 729 __ Push(ecx);
730 730
731 // Call the constructor with unmodified eax, edi, ebi values. 731 // Call the constructor with unmodified eax, edi, ebi values.
732 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 732 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
733 } 733 }
734 734
735 735
736 static void Generate_InterpreterNotifyDeoptimizedHelper(
737 MacroAssembler* masm, Deoptimizer::BailoutType type) {
738 // Enter an internal frame.
739 {
740 FrameScope scope(masm, StackFrame::INTERNAL);
741 __ Push(kInterpreterAccumulatorRegister); // Save accumulator register.
742
743 // Pass the deoptimization type to the runtime system.
744 __ Push(Smi::FromInt(static_cast<int>(type)));
745
746 __ CallRuntime(Runtime::kNotifyDeoptimized, 1);
747
748 __ Pop(kInterpreterAccumulatorRegister); // Restore accumulator register.
749 // Tear down internal frame.
750 }
751
752 // Initialize register file register.
753 __ mov(kInterpreterRegisterFileRegister, ebp);
754 __ add(kInterpreterRegisterFileRegister,
755 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp));
756
757 // Get the bytecode array pointer from the frame.
758 __ mov(ebx, Operand(kInterpreterRegisterFileRegister,
759 InterpreterFrameConstants::kFunctionFromRegisterPointer));
760 __ mov(ebx, FieldOperand(ebx, JSFunction::kSharedFunctionInfoOffset));
761 __ mov(kInterpreterBytecodeArrayRegister,
762 FieldOperand(ebx, SharedFunctionInfo::kFunctionDataOffset));
763
764 if (FLAG_debug_code) {
765 // Check function data field is actually a BytecodeArray object.
766 __ AssertNotSmi(kInterpreterBytecodeArrayRegister);
767 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE,
768 ebx);
769 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry);
770 }
771
772 // Get the target bytecode offset from the frame.
773 __ mov(
774 kInterpreterBytecodeOffsetRegister,
775 Operand(kInterpreterRegisterFileRegister,
776 InterpreterFrameConstants::kBytecodeOffsetFromRegisterPointer));
777 __ SmiUntag(kInterpreterBytecodeOffsetRegister);
778
779 // Push dispatch table as a stack located parameter to the bytecode handler -
780 // overwrite the state slot (we don't use these for interpreter deopts).
781 __ LoadRoot(ebx, Heap::kInterpreterTableRootIndex);
782 __ add(ebx, Immediate(FixedArray::kHeaderSize - kHeapObjectTag));
783 DCHECK_EQ(-1, kInterpreterDispatchTableSpillSlot);
784 __ mov(ebx, Operand(esp, -2 * kPointerSize));
785
786 // Dispatch to the target bytecode.
787 __ movzx_b(esi, Operand(kInterpreterBytecodeArrayRegister,
788 kInterpreterBytecodeOffsetRegister, times_1, 0));
789 __ mov(ebx, Operand(ebx, esi, times_pointer_size, 0));
790
791 // Get the context from the frame.
792 // TODO(rmcilroy): Update interpreter frame to expect current context at the
793 // context slot instead of the function context.
794 __ mov(kContextRegister,
795 Operand(kInterpreterRegisterFileRegister,
796 InterpreterFrameConstants::kContextFromRegisterPointer));
797
798 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging
799 // and header removal.
800 __ add(ebx, Immediate(Code::kHeaderSize - kHeapObjectTag));
801 __ jmp(ebx);
802 }
803
804
805 void Builtins::Generate_InterpreterNotifyDeoptimized(MacroAssembler* masm) {
806 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::EAGER);
807 }
808
809
810 void Builtins::Generate_InterpreterNotifySoftDeoptimized(MacroAssembler* masm) {
811 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::SOFT);
812 }
813
814
815 void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
816 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::LAZY);
817 }
818
819
736 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { 820 void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
737 CallRuntimePassFunction(masm, Runtime::kCompileLazy); 821 CallRuntimePassFunction(masm, Runtime::kCompileLazy);
738 GenerateTailCallToReturnedCode(masm); 822 GenerateTailCallToReturnedCode(masm);
739 } 823 }
740 824
741 825
742 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { 826 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
743 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); 827 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent);
744 GenerateTailCallToReturnedCode(masm); 828 GenerateTailCallToReturnedCode(masm);
745 } 829 }
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 2222
2139 __ bind(&ok); 2223 __ bind(&ok);
2140 __ ret(0); 2224 __ ret(0);
2141 } 2225 }
2142 2226
2143 #undef __ 2227 #undef __
2144 } // namespace internal 2228 } // namespace internal
2145 } // namespace v8 2229 } // namespace v8
2146 2230
2147 #endif // V8_TARGET_ARCH_X87 2231 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698