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

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

Issue 1563213002: Type Feedback Vector lives in the closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ports. Created 4 years, 11 months 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
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_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 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); 817 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::SOFT);
818 } 818 }
819 819
820 820
821 void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) { 821 void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
822 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); 822 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::LAZY);
823 } 823 }
824 824
825 825
826 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { 826 void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
827 // ----------- S t a t e -------------
828 // -- edx : new target (preserved for callee)
829 // -- edi : target function (preserved for callee)
830 // -----------------------------------
831 // First lookup code, maybe we don't need to compile!
832 Label gotta_call_runtime, gotta_call_runtime_no_stack;
833 Label maybe_call_runtime;
834 Label try_shared;
835 Label loop_top, loop_bottom;
836
837 Register closure = edi;
838 Register new_target = edx;
839 __ push(new_target);
840 __ push(closure);
841
842 Register map = eax;
843 Register index = ebx;
844 __ mov(map, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset));
845 __ mov(map, FieldOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset));
846 __ mov(index, FieldOperand(map, FixedArray::kLengthOffset));
847 __ cmp(index, Immediate(Smi::FromInt(2)));
848 __ j(less, &gotta_call_runtime);
849
850 // Find literals.
851 // edx : native context
852 // ebx : length / index
853 // eax : optimized code map
854 // stack[0] : new target
855 // stack[4] : closure
856 Register native_context = edx;
857 __ mov(native_context, NativeContextOperand());
858
859 __ bind(&loop_top);
860 Register temp = edi;
861
862 // Does the native context match?
863 __ mov(temp, FieldOperand(map, index, times_half_pointer_size,
864 SharedFunctionInfo::OffsetToPreviousContext()));
865 __ mov(temp, FieldOperand(temp, WeakCell::kValueOffset));
866 __ cmp(temp, native_context);
867 __ j(not_equal, &loop_bottom);
868 // OSR id set to none?
869 __ mov(temp, FieldOperand(map, index, times_half_pointer_size,
870 SharedFunctionInfo::OffsetToPreviousOsrAstId()));
871 const int bailout_id = BailoutId::None().ToInt();
872 __ cmp(temp, Immediate(Smi::FromInt(bailout_id)));
873 __ j(not_equal, &loop_bottom);
874 // Literals available?
875 __ mov(temp, FieldOperand(map, index, times_half_pointer_size,
876 SharedFunctionInfo::OffsetToPreviousLiterals()));
877 __ mov(temp, FieldOperand(temp, WeakCell::kValueOffset));
878 __ JumpIfSmi(temp, &gotta_call_runtime);
879
880 // Save the literals in the closure.
881 __ mov(ecx, Operand(esp, 0));
882 __ mov(FieldOperand(ecx, JSFunction::kLiteralsOffset), temp);
883 __ push(index);
884 __ RecordWriteField(ecx, JSFunction::kLiteralsOffset, temp, index,
885 kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
886 __ pop(index);
887
888 // Code available?
889 Register entry = ecx;
890 __ mov(entry, FieldOperand(map, index, times_half_pointer_size,
891 SharedFunctionInfo::OffsetToPreviousCachedCode()));
892 __ mov(entry, FieldOperand(entry, WeakCell::kValueOffset));
893 __ JumpIfSmi(entry, &maybe_call_runtime);
894
895 // Found literals and code. Get them into the closure and return.
896 __ pop(closure);
897 // Store code entry in the closure.
898 __ lea(entry, FieldOperand(entry, Code::kHeaderSize));
899
900 Label install_optimized_code_and_tailcall;
901 __ bind(&install_optimized_code_and_tailcall);
902 __ mov(FieldOperand(closure, JSFunction::kCodeEntryOffset), entry);
903
904 // Link the closure into the optimized function list.
905 // ecx : code entry
906 // edx : native context
907 // edi : closure
908 __ mov(ebx,
909 ContextOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST));
910 __ mov(FieldOperand(closure, JSFunction::kNextFunctionLinkOffset), ebx);
911 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, ebx, eax,
912 kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
913 const int function_list_offset =
914 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST);
915 __ mov(ContextOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST),
916 closure);
917 // Save closure before the write barrier.
918 __ mov(ebx, closure);
919 __ RecordWriteContextSlot(native_context, function_list_offset, closure, eax,
920 kDontSaveFPRegs);
921 __ mov(closure, ebx);
922 __ pop(new_target);
923 __ jmp(entry);
924
925 __ bind(&loop_bottom);
926 __ sub(index, Immediate(Smi::FromInt(SharedFunctionInfo::kEntryLength)));
927 __ cmp(index, Immediate(Smi::FromInt(1)));
928 __ j(greater, &loop_top);
929
930 // We suck. We didn't even find literals. Hating life, we will go to the
931 // runtime.
932 __ jmp(&gotta_call_runtime);
933
934 __ bind(&maybe_call_runtime);
935 __ pop(closure);
936
937 // Last possibility. Check the context free optimized code map entry.
938 __ mov(entry, FieldOperand(map, FixedArray::kHeaderSize));
939 __ mov(entry, FieldOperand(entry, WeakCell::kValueOffset));
940 __ JumpIfSmi(entry, &try_shared);
941
942 // Store code entry in the closure.
943 __ lea(entry, FieldOperand(entry, Code::kHeaderSize));
944 __ jmp(&install_optimized_code_and_tailcall);
945
946 __ bind(&try_shared);
947 __ pop(new_target);
948 // Is the full code valid?
949 __ mov(entry, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset));
950 __ mov(entry, FieldOperand(entry, SharedFunctionInfo::kCodeOffset));
951 __ mov(ebx, FieldOperand(entry, Code::kFlagsOffset));
952 __ and_(ebx, Code::KindField::kMask);
953 __ shr(ebx, Code::KindField::kShift);
954 __ cmp(ebx, Immediate(Code::BUILTIN));
955 __ j(equal, &gotta_call_runtime_no_stack);
956 // Yes, install the full code.
957 __ lea(entry, FieldOperand(entry, Code::kHeaderSize));
958 __ mov(FieldOperand(closure, JSFunction::kCodeEntryOffset), entry);
959 __ jmp(entry);
960
961 __ bind(&gotta_call_runtime);
962 __ pop(closure);
963 __ pop(new_target);
964 __ bind(&gotta_call_runtime_no_stack);
827 CallRuntimePassFunction(masm, Runtime::kCompileLazy); 965 CallRuntimePassFunction(masm, Runtime::kCompileLazy);
828 GenerateTailCallToReturnedCode(masm); 966 GenerateTailCallToReturnedCode(masm);
829 } 967 }
830 968
831 969
832 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { 970 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
833 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); 971 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent);
834 GenerateTailCallToReturnedCode(masm); 972 GenerateTailCallToReturnedCode(masm);
835 } 973 }
836 974
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after
2424 2562
2425 __ bind(&ok); 2563 __ bind(&ok);
2426 __ ret(0); 2564 __ ret(0);
2427 } 2565 }
2428 2566
2429 #undef __ 2567 #undef __
2430 } // namespace internal 2568 } // namespace internal
2431 } // namespace v8 2569 } // namespace v8
2432 2570
2433 #endif // V8_TARGET_ARCH_IA32 2571 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698