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_X64 | 5 #if V8_TARGET_ARCH_X64 |
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 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 __ Push(Smi::FromInt(0)); // Initial index. | 1029 __ Push(Smi::FromInt(0)); // Initial index. |
1030 | 1030 |
1031 // Generate code for doing the condition check. | 1031 // Generate code for doing the condition check. |
1032 __ bind(&loop); | 1032 __ bind(&loop); |
1033 SetExpressionAsStatementPosition(stmt->each()); | 1033 SetExpressionAsStatementPosition(stmt->each()); |
1034 | 1034 |
1035 __ movp(rax, Operand(rsp, 0 * kPointerSize)); // Get the current index. | 1035 __ movp(rax, Operand(rsp, 0 * kPointerSize)); // Get the current index. |
1036 __ cmpp(rax, Operand(rsp, 1 * kPointerSize)); // Compare to the array length. | 1036 __ cmpp(rax, Operand(rsp, 1 * kPointerSize)); // Compare to the array length. |
1037 __ j(above_equal, loop_statement.break_label()); | 1037 __ j(above_equal, loop_statement.break_label()); |
1038 | 1038 |
1039 // Get the current entry of the array into register rbx. | 1039 // Get the current entry of the array into register rax. |
1040 __ movp(rbx, Operand(rsp, 2 * kPointerSize)); | 1040 __ movp(rbx, Operand(rsp, 2 * kPointerSize)); |
1041 SmiIndex index = masm()->SmiToIndex(rax, rax, kPointerSizeLog2); | 1041 SmiIndex index = masm()->SmiToIndex(rax, rax, kPointerSizeLog2); |
1042 __ movp(rbx, FieldOperand(rbx, | 1042 __ movp(rax, |
1043 index.reg, | 1043 FieldOperand(rbx, index.reg, index.scale, FixedArray::kHeaderSize)); |
1044 index.scale, | |
1045 FixedArray::kHeaderSize)); | |
1046 | 1044 |
1047 // Get the expected map from the stack or a smi in the | 1045 // Get the expected map from the stack or a smi in the |
1048 // permanent slow case into register rdx. | 1046 // permanent slow case into register rdx. |
1049 __ movp(rdx, Operand(rsp, 3 * kPointerSize)); | 1047 __ movp(rdx, Operand(rsp, 3 * kPointerSize)); |
1050 | 1048 |
1051 // Check if the expected map still matches that of the enumerable. | 1049 // Check if the expected map still matches that of the enumerable. |
1052 // If not, we may have to filter the key. | 1050 // If not, we may have to filter the key. |
1053 Label update_each; | 1051 Label update_each; |
1054 __ movp(rcx, Operand(rsp, 4 * kPointerSize)); | 1052 __ movp(rbx, Operand(rsp, 4 * kPointerSize)); |
1055 __ cmpp(rdx, FieldOperand(rcx, HeapObject::kMapOffset)); | 1053 __ cmpp(rdx, FieldOperand(rbx, HeapObject::kMapOffset)); |
1056 __ j(equal, &update_each, Label::kNear); | 1054 __ j(equal, &update_each, Label::kNear); |
1057 | 1055 |
1058 // We need to filter the key, record slow-path here. | 1056 // We need to filter the key, record slow-path here. |
1059 int const vector_index = SmiFromSlot(slot)->value(); | 1057 int const vector_index = SmiFromSlot(slot)->value(); |
1060 __ EmitLoadTypeFeedbackVector(rdx); | 1058 __ EmitLoadTypeFeedbackVector(rdx); |
1061 __ Move(FieldOperand(rdx, FixedArray::OffsetOfElementAt(vector_index)), | 1059 __ Move(FieldOperand(rdx, FixedArray::OffsetOfElementAt(vector_index)), |
1062 TypeFeedbackVector::MegamorphicSentinel(isolate())); | 1060 TypeFeedbackVector::MegamorphicSentinel(isolate())); |
1063 | 1061 |
1064 // Convert the entry to a string or null if it isn't a property | 1062 // rax contains the key. The receiver in rbx is the second argument to the |
1065 // anymore. If the property has been removed while iterating, we | 1063 // ForInFilterStub. ForInFilter returns undefined if the receiver doesn't |
1066 // just skip it. | 1064 // have the key or returns the name-converted key. |
1067 __ Push(rcx); // Enumerable. | 1065 ForInFilterStub has_stub(isolate()); |
1068 __ Push(rbx); // Current entry. | 1066 __ CallStub(&has_stub); |
1069 __ CallRuntime(Runtime::kForInFilter); | 1067 RestoreContext(); |
1070 PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER); | 1068 PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER); |
1071 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 1069 __ JumpIfRoot(result_register(), Heap::kUndefinedValueRootIndex, |
1072 __ j(equal, loop_statement.continue_label()); | 1070 loop_statement.continue_label()); |
1073 __ movp(rbx, rax); | |
1074 | 1071 |
1075 // Update the 'each' property or variable from the possibly filtered | 1072 // Update the 'each' property or variable from the possibly filtered |
1076 // entry in register rbx. | 1073 // entry in register rax. |
1077 __ bind(&update_each); | 1074 __ bind(&update_each); |
1078 __ movp(result_register(), rbx); | |
1079 // Perform the assignment as if via '='. | 1075 // Perform the assignment as if via '='. |
1080 { EffectContext context(this); | 1076 { EffectContext context(this); |
1081 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); | 1077 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); |
1082 PrepareForBailoutForId(stmt->AssignmentId(), BailoutState::NO_REGISTERS); | 1078 PrepareForBailoutForId(stmt->AssignmentId(), BailoutState::NO_REGISTERS); |
1083 } | 1079 } |
1084 | 1080 |
1085 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body(). | 1081 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body(). |
1086 PrepareForBailoutForId(stmt->BodyId(), BailoutState::NO_REGISTERS); | 1082 PrepareForBailoutForId(stmt->BodyId(), BailoutState::NO_REGISTERS); |
1087 // Generate code for the body of the loop. | 1083 // Generate code for the body of the loop. |
1088 Visit(stmt->body()); | 1084 Visit(stmt->body()); |
(...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3666 DCHECK_EQ( | 3662 DCHECK_EQ( |
3667 isolate->builtins()->OnStackReplacement()->entry(), | 3663 isolate->builtins()->OnStackReplacement()->entry(), |
3668 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3664 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3669 return ON_STACK_REPLACEMENT; | 3665 return ON_STACK_REPLACEMENT; |
3670 } | 3666 } |
3671 | 3667 |
3672 } // namespace internal | 3668 } // namespace internal |
3673 } // namespace v8 | 3669 } // namespace v8 |
3674 | 3670 |
3675 #endif // V8_TARGET_ARCH_X64 | 3671 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |