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

X87: Avoid creating weak cells for literal arrays that are empty of literals.

  port 3cfcc7e1 (r36786)

  original commit message:
  It may be that we have a feedback vector, but no literals. In this case
  we can store into the OptimizedCodeMap directly instead of using a WeakCell,
  because all data in the feedback vector is already held weakly.

  The use of a WeakCell in the OptimizedCodeMap is only required when
  there are literals which may hold maps strongly.

  This is to address a performance regression caused by the creation of
  a large number of WeakCells.

BUG=

Review-Url: https://codereview.chromium.org/2081663004
Cr-Commit-Position: refs/heads/master@{#37123}
parent c5ae5bb1
......@@ -898,13 +898,30 @@ void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
const int bailout_id = BailoutId::None().ToInt();
__ cmp(temp, Immediate(Smi::FromInt(bailout_id)));
__ j(not_equal, &loop_bottom);
// Literals available?
Label got_literals, maybe_cleared_weakcell;
__ mov(temp, FieldOperand(map, index, times_half_pointer_size,
SharedFunctionInfo::kOffsetToPreviousLiterals));
// temp contains either a WeakCell pointing to the literals array or the
// literals array directly.
STATIC_ASSERT(WeakCell::kValueOffset == FixedArray::kLengthOffset);
__ JumpIfSmi(FieldOperand(temp, WeakCell::kValueOffset),
&maybe_cleared_weakcell);
// The WeakCell value is a pointer, therefore it's a valid literals array.
__ mov(temp, FieldOperand(temp, WeakCell::kValueOffset));
__ JumpIfSmi(temp, &gotta_call_runtime);
__ jmp(&got_literals);
// We have a smi. If it's 0, then we are looking at a cleared WeakCell
// around the literals array, and we should visit the runtime. If it's > 0,
// then temp already contains the literals array.
__ bind(&maybe_cleared_weakcell);
__ cmp(FieldOperand(temp, WeakCell::kValueOffset), Immediate(0));
__ j(equal, &gotta_call_runtime);
// Save the literals in the closure.
__ bind(&got_literals);
__ mov(ecx, Operand(esp, 0));
__ mov(FieldOperand(ecx, JSFunction::kLiteralsOffset), temp);
__ push(index);
......
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