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

Unified Diff: src/arm64/builtins-arm64.cc

Issue 1668103002: Type Feedback Vector lives in the closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/arm64/macro-assembler-arm64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm64/builtins-arm64.cc
diff --git a/src/arm64/builtins-arm64.cc b/src/arm64/builtins-arm64.cc
index d84d1a6ae3fd680a31dd7f585ab29980a7a57885..246075fc275524b87733cd7b9566899dfb11e294 100644
--- a/src/arm64/builtins-arm64.cc
+++ b/src/arm64/builtins-arm64.cc
@@ -1197,6 +1197,137 @@ void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) {
void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
+ // ----------- S t a t e -------------
+ // -- x3 : new target (preserved for callee)
+ // -- x1 : target function (preserved for callee)
+ // -----------------------------------
+ // First lookup code, maybe we don't need to compile!
+ Label gotta_call_runtime;
+ Label maybe_call_runtime;
+ Label try_shared;
+ Label loop_top, loop_bottom;
+
+ Register closure = x1;
+ Register new_target = x3;
+ Register map = x0;
+ Register index = x2;
+ __ Ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
+ __ Ldr(map,
+ FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset));
+ __ Ldrsw(index, UntagSmiFieldMemOperand(map, FixedArray::kLengthOffset));
+ __ Cmp(index, Operand(2));
+ __ B(lt, &gotta_call_runtime);
+
+ // Find literals.
+ // x3 : native context
+ // x2 : length / index
+ // x0 : optimized code map
+ // stack[0] : new target
+ // stack[4] : closure
+ Register native_context = x4;
+ __ Ldr(native_context, NativeContextMemOperand());
+
+ __ Bind(&loop_top);
+ Register temp = x5;
+ Register array_pointer = x6;
+
+ // Does the native context match?
+ __ Add(array_pointer, map, Operand(index, LSL, kPointerSizeLog2));
+ __ Ldr(temp, FieldMemOperand(array_pointer,
+ SharedFunctionInfo::OffsetToPreviousContext()));
+ __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset));
+ __ Cmp(temp, native_context);
+ __ B(ne, &loop_bottom);
+ // OSR id set to none?
+ __ Ldr(temp, FieldMemOperand(array_pointer,
+ SharedFunctionInfo::OffsetToPreviousOsrAstId()));
+ const int bailout_id = BailoutId::None().ToInt();
+ __ Cmp(temp, Operand(Smi::FromInt(bailout_id)));
+ __ B(ne, &loop_bottom);
+ // Literals available?
+ __ Ldr(temp, FieldMemOperand(array_pointer,
+ SharedFunctionInfo::OffsetToPreviousLiterals()));
+ __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset));
+ __ JumpIfSmi(temp, &gotta_call_runtime);
+
+ // Save the literals in the closure.
+ __ Str(temp, FieldMemOperand(closure, JSFunction::kLiteralsOffset));
+ __ RecordWriteField(closure, JSFunction::kLiteralsOffset, temp, x7,
+ kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET,
+ OMIT_SMI_CHECK);
+
+ // Code available?
+ Register entry = x7;
+ __ Ldr(entry,
+ FieldMemOperand(array_pointer,
+ SharedFunctionInfo::OffsetToPreviousCachedCode()));
+ __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset));
+ __ JumpIfSmi(entry, &maybe_call_runtime);
+
+ // Found literals and code. Get them into the closure and return.
+ __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag));
+
+ Label install_optimized_code_and_tailcall;
+ __ Bind(&install_optimized_code_and_tailcall);
+ __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset));
+ __ RecordWriteCodeEntryField(closure, entry, x5);
+
+ // Link the closure into the optimized function list.
+ // x7 : code entry
+ // x4 : native context
+ // x1 : closure
+ __ Ldr(x8,
+ ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST));
+ __ Str(x8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset));
+ __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, x8, x0,
+ kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET,
+ OMIT_SMI_CHECK);
+ const int function_list_offset =
+ Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST);
+ __ Str(closure,
+ ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST));
+ __ Mov(x5, closure);
+ __ RecordWriteContextSlot(native_context, function_list_offset, x5, x0,
+ kLRHasNotBeenSaved, kDontSaveFPRegs);
+ __ Jump(entry);
+
+ __ Bind(&loop_bottom);
+ __ Sub(index, index, Operand(SharedFunctionInfo::kEntryLength));
+ __ Cmp(index, Operand(1));
+ __ B(gt, &loop_top);
+
+ // We found neither literals nor code.
+ __ B(&gotta_call_runtime);
+
+ __ Bind(&maybe_call_runtime);
+
+ // Last possibility. Check the context free optimized code map entry.
+ __ Ldr(entry, FieldMemOperand(map, FixedArray::kHeaderSize +
+ SharedFunctionInfo::kSharedCodeIndex));
+ __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset));
+ __ JumpIfSmi(entry, &try_shared);
+
+ // Store code entry in the closure.
+ __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag));
+ __ B(&install_optimized_code_and_tailcall);
+
+ __ Bind(&try_shared);
+ // Is the full code valid?
+ __ Ldr(entry,
+ FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
+ __ Ldr(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset));
+ __ Ldr(x5, FieldMemOperand(entry, Code::kFlagsOffset));
+ __ and_(x5, x5, Operand(Code::KindField::kMask));
+ __ Mov(x5, Operand(x5, LSR, Code::KindField::kShift));
+ __ Cmp(x5, Operand(Code::BUILTIN));
+ __ B(eq, &gotta_call_runtime);
+ // Yes, install the full code.
+ __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag));
+ __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset));
+ __ RecordWriteCodeEntryField(closure, entry, x5);
+ __ Jump(entry);
+
+ __ Bind(&gotta_call_runtime);
CallRuntimePassFunction(masm, Runtime::kCompileLazy);
GenerateTailCallToReturnedCode(masm);
}
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/arm64/macro-assembler-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698