OLD | NEW |
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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
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 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 __ push(Immediate(Smi::FromInt(0))); // Initial index. | 1006 __ push(Immediate(Smi::FromInt(0))); // Initial index. |
1007 | 1007 |
1008 // Generate code for doing the condition check. | 1008 // Generate code for doing the condition check. |
1009 __ bind(&loop); | 1009 __ bind(&loop); |
1010 SetExpressionAsStatementPosition(stmt->each()); | 1010 SetExpressionAsStatementPosition(stmt->each()); |
1011 | 1011 |
1012 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index. | 1012 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index. |
1013 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length. | 1013 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length. |
1014 __ j(above_equal, loop_statement.break_label()); | 1014 __ j(above_equal, loop_statement.break_label()); |
1015 | 1015 |
1016 // Get the current entry of the array into register ebx. | 1016 // Get the current entry of the array into register eax. |
1017 __ mov(ebx, Operand(esp, 2 * kPointerSize)); | 1017 __ mov(ebx, Operand(esp, 2 * kPointerSize)); |
1018 __ mov(ebx, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize)); | 1018 __ mov(eax, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize)); |
1019 | 1019 |
1020 // Get the expected map from the stack or a smi in the | 1020 // Get the expected map from the stack or a smi in the |
1021 // permanent slow case into register edx. | 1021 // permanent slow case into register edx. |
1022 __ mov(edx, Operand(esp, 3 * kPointerSize)); | 1022 __ mov(edx, Operand(esp, 3 * kPointerSize)); |
1023 | 1023 |
1024 // Check if the expected map still matches that of the enumerable. | 1024 // Check if the expected map still matches that of the enumerable. |
1025 // If not, we may have to filter the key. | 1025 // If not, we may have to filter the key. |
1026 Label update_each; | 1026 Label update_each; |
1027 __ mov(ecx, Operand(esp, 4 * kPointerSize)); | 1027 __ mov(ebx, Operand(esp, 4 * kPointerSize)); |
1028 __ cmp(edx, FieldOperand(ecx, HeapObject::kMapOffset)); | 1028 __ cmp(edx, FieldOperand(ebx, HeapObject::kMapOffset)); |
1029 __ j(equal, &update_each, Label::kNear); | 1029 __ j(equal, &update_each, Label::kNear); |
1030 | 1030 |
1031 // We need to filter the key, record slow-path here. | 1031 // We need to filter the key, record slow-path here. |
1032 int const vector_index = SmiFromSlot(slot)->value(); | 1032 int const vector_index = SmiFromSlot(slot)->value(); |
1033 __ EmitLoadTypeFeedbackVector(edx); | 1033 __ EmitLoadTypeFeedbackVector(edx); |
1034 __ mov(FieldOperand(edx, FixedArray::OffsetOfElementAt(vector_index)), | 1034 __ mov(FieldOperand(edx, FixedArray::OffsetOfElementAt(vector_index)), |
1035 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate()))); | 1035 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate()))); |
1036 | 1036 |
1037 // Convert the entry to a string or null if it isn't a property | 1037 // eax contains the key. The receiver in ebx is the second argument to the |
1038 // anymore. If the property has been removed while iterating, we | 1038 // ForInFilterStub. ForInFilter returns undefined if the receiver doesn't |
1039 // just skip it. | 1039 // have the key or returns the name-converted key. |
1040 __ push(ecx); // Enumerable. | 1040 ForInFilterStub filter_stub(isolate()); |
1041 __ push(ebx); // Current entry. | 1041 __ CallStub(&filter_stub); |
1042 __ CallRuntime(Runtime::kForInFilter); | 1042 RestoreContext(); |
1043 PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER); | 1043 PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER); |
1044 __ cmp(eax, isolate()->factory()->undefined_value()); | 1044 __ JumpIfRoot(result_register(), Heap::kUndefinedValueRootIndex, |
1045 __ j(equal, loop_statement.continue_label()); | 1045 loop_statement.continue_label()); |
1046 __ mov(ebx, eax); | |
1047 | 1046 |
1048 // Update the 'each' property or variable from the possibly filtered | 1047 // Update the 'each' property or variable from the possibly filtered |
1049 // entry in register ebx. | 1048 // entry in register eax. |
1050 __ bind(&update_each); | 1049 __ bind(&update_each); |
1051 __ mov(result_register(), ebx); | |
1052 // Perform the assignment as if via '='. | 1050 // Perform the assignment as if via '='. |
1053 { EffectContext context(this); | 1051 { EffectContext context(this); |
1054 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); | 1052 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); |
1055 PrepareForBailoutForId(stmt->AssignmentId(), BailoutState::NO_REGISTERS); | 1053 PrepareForBailoutForId(stmt->AssignmentId(), BailoutState::NO_REGISTERS); |
1056 } | 1054 } |
1057 | 1055 |
1058 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body(). | 1056 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body(). |
1059 PrepareForBailoutForId(stmt->BodyId(), BailoutState::NO_REGISTERS); | 1057 PrepareForBailoutForId(stmt->BodyId(), BailoutState::NO_REGISTERS); |
1060 // Generate code for the body of the loop. | 1058 // Generate code for the body of the loop. |
1061 Visit(stmt->body()); | 1059 Visit(stmt->body()); |
(...skipping 2614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3676 isolate->builtins()->OnStackReplacement()->entry(), | 3674 isolate->builtins()->OnStackReplacement()->entry(), |
3677 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3675 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3678 return ON_STACK_REPLACEMENT; | 3676 return ON_STACK_REPLACEMENT; |
3679 } | 3677 } |
3680 | 3678 |
3681 | 3679 |
3682 } // namespace internal | 3680 } // namespace internal |
3683 } // namespace v8 | 3681 } // namespace v8 |
3684 | 3682 |
3685 #endif // V8_TARGET_ARCH_IA32 | 3683 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |