Commit f9677ecf authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [TypeFeedbackVector] Root literal arrays in function literals slots.

  port b8294aaa (r42264)

  original commit message:
  Literal arrays and feedback vectors for a function can be garbage
  collected if we don't have a rooted closure for the function, which
  happens often. It's expensive to come back from this (recreating
  boilerplates and gathering feedback again), and the cost is
  disproportionate if the function was inlined into optimized code.

  To guard against losing these arrays when we need them, we'll now
  create literal arrays when creating the feedback vector for the outer
  closure, and root them strongly in that vector.

BUG=

Review-Url: https://codereview.chromium.org/2627973007
Cr-Commit-Position: refs/heads/master@{#42351}
parent 7d42244a
......@@ -1026,6 +1026,12 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
Register new_target = edx;
Register argument_count = eax;
// Do we have a valid feedback vector?
__ mov(ebx, FieldOperand(closure, JSFunction::kLiteralsOffset));
__ mov(ebx, FieldOperand(ebx, LiteralsArray::kFeedbackVectorOffset));
__ cmp(ebx, masm->isolate()->factory()->undefined_value());
__ j(equal, &gotta_call_runtime_no_stack);
__ push(argument_count);
__ push(new_target);
__ push(closure);
......@@ -1038,7 +1044,6 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
__ cmp(index, Immediate(Smi::FromInt(2)));
__ j(less, &gotta_call_runtime);
// Find literals.
// edx : native context
// ebx : length / index
// eax : optimized code map
......@@ -1056,20 +1061,6 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
__ mov(temp, FieldOperand(temp, WeakCell::kValueOffset));
__ cmp(temp, native_context);
__ j(not_equal, &loop_bottom);
// Literals available?
__ mov(temp, FieldOperand(map, index, times_half_pointer_size,
SharedFunctionInfo::kOffsetToPreviousLiterals));
__ mov(temp, FieldOperand(temp, WeakCell::kValueOffset));
__ JumpIfSmi(temp, &gotta_call_runtime);
// Save the literals in the closure.
__ mov(ecx, Operand(esp, 0));
__ mov(FieldOperand(ecx, JSFunction::kLiteralsOffset), temp);
__ push(index);
__ RecordWriteField(ecx, JSFunction::kLiteralsOffset, temp, index,
kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
__ pop(index);
// Code available?
Register entry = ecx;
__ mov(entry, FieldOperand(map, index, times_half_pointer_size,
......@@ -1077,7 +1068,7 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
__ mov(entry, FieldOperand(entry, WeakCell::kValueOffset));
__ JumpIfSmi(entry, &try_shared);
// Found literals and code. Get them into the closure and return.
// Found code. Get it into the closure and return.
__ pop(closure);
// Store code entry in the closure.
__ lea(entry, FieldOperand(entry, Code::kHeaderSize));
......@@ -1111,7 +1102,7 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
__ cmp(index, Immediate(Smi::FromInt(1)));
__ j(greater, &loop_top);
// We found neither literals nor code.
// We found no code.
__ jmp(&gotta_call_runtime);
__ bind(&try_shared);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment