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

Unified Diff: src/arm/builtins-arm.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 | « no previous file | src/arm/macro-assembler-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm/builtins-arm.cc
diff --git a/src/arm/builtins-arm.cc b/src/arm/builtins-arm.cc
index bb9c06cdd56996845de36edf015296592b1a87d0..183fa7190c03b95e0e88401f9564c105517029c8 100644
--- a/src/arm/builtins-arm.cc
+++ b/src/arm/builtins-arm.cc
@@ -1248,6 +1248,153 @@ void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) {
void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
+ // ----------- S t a t e -------------
+ // -- r3 : new target (preserved for callee)
+ // -- r1 : target function (preserved for callee)
+ // -----------------------------------
+ // First lookup code, maybe we don't need to compile!
+ Label gotta_call_runtime, gotta_call_runtime_no_stack;
+ Label maybe_call_runtime;
+ Label try_shared;
+ Label loop_top, loop_bottom;
+
+ Register closure = r1;
+ Register new_target = r3;
+ __ push(new_target);
+ __ push(closure);
+
+ Register map = r0;
+ Register index = r2;
+ __ ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
+ __ ldr(map,
+ FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset));
+ __ ldr(index, FieldMemOperand(map, FixedArray::kLengthOffset));
+ __ cmp(index, Operand(Smi::FromInt(2)));
+ __ b(lt, &gotta_call_runtime);
+
+ // Find literals.
+ // r3 : native context
+ // r2 : length / index
+ // r0 : optimized code map
+ // stack[0] : new target
+ // stack[4] : closure
+ Register native_context = r3;
+ __ ldr(native_context, NativeContextMemOperand());
+
+ __ bind(&loop_top);
+ Register temp = r1;
+ Register array_pointer = r5;
+
+ // Does the native context match?
+ __ add(array_pointer, map, Operand::PointerOffsetFromSmiKey(index));
+ __ 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.
+ __ ldr(r4, MemOperand(sp, 0));
+ __ str(temp, FieldMemOperand(r4, JSFunction::kLiteralsOffset));
+ __ push(index);
+ __ RecordWriteField(r4, JSFunction::kLiteralsOffset, temp, index,
+ kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET,
+ OMIT_SMI_CHECK);
+ __ pop(index);
+
+ // Code available?
+ Register entry = r4;
+ __ 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.
+ __ pop(closure);
+ // Store code entry in the closure.
+ __ 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, r5);
+
+ // Link the closure into the optimized function list.
+ // r4 : code entry
+ // r3 : native context
+ // r1 : closure
+ __ ldr(r5,
+ ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST));
+ __ str(r5, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset));
+ __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, r5, r0,
+ 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));
+ // Save closure before the write barrier.
+ __ mov(r5, closure);
+ __ RecordWriteContextSlot(native_context, function_list_offset, closure, r0,
+ kLRHasNotBeenSaved, kDontSaveFPRegs);
+ __ mov(closure, r5);
+ __ pop(new_target);
+ __ Jump(entry);
+
+ __ bind(&loop_bottom);
+ __ sub(index, index, Operand(Smi::FromInt(SharedFunctionInfo::kEntryLength)));
+ __ cmp(index, Operand(Smi::FromInt(1)));
+ __ b(gt, &loop_top);
+
+ // We found neither literals nor code.
+ __ jmp(&gotta_call_runtime);
+
+ __ bind(&maybe_call_runtime);
+ __ pop(closure);
+
+ // 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));
+ __ jmp(&install_optimized_code_and_tailcall);
+
+ __ bind(&try_shared);
+ __ pop(new_target);
+ // Is the full code valid?
+ __ ldr(entry,
+ FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
+ __ ldr(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset));
+ __ ldr(r5, FieldMemOperand(entry, Code::kFlagsOffset));
+ __ and_(r5, r5, Operand(Code::KindField::kMask));
+ __ mov(r5, Operand(r5, LSR, Code::KindField::kShift));
+ __ cmp(r5, Operand(Code::BUILTIN));
+ __ b(eq, &gotta_call_runtime_no_stack);
+ // Yes, install the full code.
+ __ add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag));
+ __ str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset));
+ __ RecordWriteCodeEntryField(closure, entry, r5);
+ __ Jump(entry);
+
+ __ bind(&gotta_call_runtime);
+ __ pop(closure);
+ __ pop(new_target);
+ __ bind(&gotta_call_runtime_no_stack);
CallRuntimePassFunction(masm, Runtime::kCompileLazy);
GenerateTailCallToReturnedCode(masm);
}
« no previous file with comments | « no previous file | src/arm/macro-assembler-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698