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

X87: [fullcodegen] [crankshaft] Avoid jumping to the runtime for ForInFilter.

  port 4b59bf53 (r37934)

  original commit message:
  Use the ForInFilterStub directly. Hence we will only jump to the runtime for
  special receivers (instance_type <= LAST_SPECIAL_RECEIVER_TYPE) and for
  converting element indices which are not in the string cache.

BUG=

Review-Url: https://codereview.chromium.org/2176473002
Cr-Commit-Position: refs/heads/master@{#37963}
parent 277838b1
......@@ -1005,9 +1005,9 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
__ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length.
__ j(above_equal, loop_statement.break_label());
// Get the current entry of the array into register ebx.
// Get the current entry of the array into register eax.
__ mov(ebx, Operand(esp, 2 * kPointerSize));
__ mov(ebx, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize));
__ mov(eax, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize));
// Get the expected map from the stack or a smi in the
// permanent slow case into register edx.
......@@ -1016,8 +1016,8 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
// Check if the expected map still matches that of the enumerable.
// If not, we may have to filter the key.
Label update_each;
__ mov(ecx, Operand(esp, 4 * kPointerSize));
__ cmp(edx, FieldOperand(ecx, HeapObject::kMapOffset));
__ mov(ebx, Operand(esp, 4 * kPointerSize));
__ cmp(edx, FieldOperand(ebx, HeapObject::kMapOffset));
__ j(equal, &update_each, Label::kNear);
// We need to filter the key, record slow-path here.
......@@ -1026,21 +1026,19 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
__ mov(FieldOperand(edx, FixedArray::OffsetOfElementAt(vector_index)),
Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate())));
// Convert the entry to a string or null if it isn't a property
// anymore. If the property has been removed while iterating, we
// just skip it.
__ push(ecx); // Enumerable.
__ push(ebx); // Current entry.
__ CallRuntime(Runtime::kForInFilter);
// eax contains the key. The receiver in ebx is the second argument to the
// ForInFilterStub. ForInFilter returns undefined if the receiver doesn't
// have the key or returns the name-converted key.
ForInFilterStub filter_stub(isolate());
__ CallStub(&filter_stub);
RestoreContext();
PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER);
__ cmp(eax, isolate()->factory()->undefined_value());
__ j(equal, loop_statement.continue_label());
__ mov(ebx, eax);
__ JumpIfRoot(result_register(), Heap::kUndefinedValueRootIndex,
loop_statement.continue_label());
// Update the 'each' property or variable from the possibly filtered
// entry in register ebx.
// entry in register eax.
__ bind(&update_each);
__ mov(result_register(), ebx);
// Perform the assignment as if via '='.
{ EffectContext context(this);
EmitAssignment(stmt->each(), stmt->EachFeedbackSlot());
......
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