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

Side by Side Diff: src/full-codegen/x87/full-codegen-x87.cc

Issue 2176473002: X87: [fullcodegen] [crankshaft] Avoid jumping to the runtime for ForInFilter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 __ push(Immediate(Smi::FromInt(0))); // Initial index. 998 __ push(Immediate(Smi::FromInt(0))); // Initial index.
999 999
1000 // Generate code for doing the condition check. 1000 // Generate code for doing the condition check.
1001 __ bind(&loop); 1001 __ bind(&loop);
1002 SetExpressionAsStatementPosition(stmt->each()); 1002 SetExpressionAsStatementPosition(stmt->each());
1003 1003
1004 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index. 1004 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index.
1005 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length. 1005 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length.
1006 __ j(above_equal, loop_statement.break_label()); 1006 __ j(above_equal, loop_statement.break_label());
1007 1007
1008 // Get the current entry of the array into register ebx. 1008 // Get the current entry of the array into register eax.
1009 __ mov(ebx, Operand(esp, 2 * kPointerSize)); 1009 __ mov(ebx, Operand(esp, 2 * kPointerSize));
1010 __ mov(ebx, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize)); 1010 __ mov(eax, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize));
1011 1011
1012 // Get the expected map from the stack or a smi in the 1012 // Get the expected map from the stack or a smi in the
1013 // permanent slow case into register edx. 1013 // permanent slow case into register edx.
1014 __ mov(edx, Operand(esp, 3 * kPointerSize)); 1014 __ mov(edx, Operand(esp, 3 * kPointerSize));
1015 1015
1016 // Check if the expected map still matches that of the enumerable. 1016 // Check if the expected map still matches that of the enumerable.
1017 // If not, we may have to filter the key. 1017 // If not, we may have to filter the key.
1018 Label update_each; 1018 Label update_each;
1019 __ mov(ecx, Operand(esp, 4 * kPointerSize)); 1019 __ mov(ebx, Operand(esp, 4 * kPointerSize));
1020 __ cmp(edx, FieldOperand(ecx, HeapObject::kMapOffset)); 1020 __ cmp(edx, FieldOperand(ebx, HeapObject::kMapOffset));
1021 __ j(equal, &update_each, Label::kNear); 1021 __ j(equal, &update_each, Label::kNear);
1022 1022
1023 // We need to filter the key, record slow-path here. 1023 // We need to filter the key, record slow-path here.
1024 int const vector_index = SmiFromSlot(slot)->value(); 1024 int const vector_index = SmiFromSlot(slot)->value();
1025 __ EmitLoadTypeFeedbackVector(edx); 1025 __ EmitLoadTypeFeedbackVector(edx);
1026 __ mov(FieldOperand(edx, FixedArray::OffsetOfElementAt(vector_index)), 1026 __ mov(FieldOperand(edx, FixedArray::OffsetOfElementAt(vector_index)),
1027 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate()))); 1027 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate())));
1028 1028
1029 // Convert the entry to a string or null if it isn't a property 1029 // eax contains the key. The receiver in ebx is the second argument to the
1030 // anymore. If the property has been removed while iterating, we 1030 // ForInFilterStub. ForInFilter returns undefined if the receiver doesn't
1031 // just skip it. 1031 // have the key or returns the name-converted key.
1032 __ push(ecx); // Enumerable. 1032 ForInFilterStub filter_stub(isolate());
1033 __ push(ebx); // Current entry. 1033 __ CallStub(&filter_stub);
1034 __ CallRuntime(Runtime::kForInFilter); 1034 RestoreContext();
1035 PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER); 1035 PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER);
1036 __ cmp(eax, isolate()->factory()->undefined_value()); 1036 __ JumpIfRoot(result_register(), Heap::kUndefinedValueRootIndex,
1037 __ j(equal, loop_statement.continue_label()); 1037 loop_statement.continue_label());
1038 __ mov(ebx, eax);
1039 1038
1040 // Update the 'each' property or variable from the possibly filtered 1039 // Update the 'each' property or variable from the possibly filtered
1041 // entry in register ebx. 1040 // entry in register eax.
1042 __ bind(&update_each); 1041 __ bind(&update_each);
1043 __ mov(result_register(), ebx);
1044 // Perform the assignment as if via '='. 1042 // Perform the assignment as if via '='.
1045 { EffectContext context(this); 1043 { EffectContext context(this);
1046 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); 1044 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot());
1047 PrepareForBailoutForId(stmt->AssignmentId(), BailoutState::NO_REGISTERS); 1045 PrepareForBailoutForId(stmt->AssignmentId(), BailoutState::NO_REGISTERS);
1048 } 1046 }
1049 1047
1050 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body(). 1048 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body().
1051 PrepareForBailoutForId(stmt->BodyId(), BailoutState::NO_REGISTERS); 1049 PrepareForBailoutForId(stmt->BodyId(), BailoutState::NO_REGISTERS);
1052 // Generate code for the body of the loop. 1050 // Generate code for the body of the loop.
1053 Visit(stmt->body()); 1051 Visit(stmt->body());
(...skipping 2614 matching lines...) Expand 10 before | Expand all | Expand 10 after
3668 isolate->builtins()->OnStackReplacement()->entry(), 3666 isolate->builtins()->OnStackReplacement()->entry(),
3669 Assembler::target_address_at(call_target_address, unoptimized_code)); 3667 Assembler::target_address_at(call_target_address, unoptimized_code));
3670 return ON_STACK_REPLACEMENT; 3668 return ON_STACK_REPLACEMENT;
3671 } 3669 }
3672 3670
3673 3671
3674 } // namespace internal 3672 } // namespace internal
3675 } // namespace v8 3673 } // namespace v8
3676 3674
3677 #endif // V8_TARGET_ARCH_X87 3675 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698