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 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
976 // The enum cache is valid. Load the map of the object being | 976 // The enum cache is valid. Load the map of the object being |
977 // iterated over and use the cache for the iteration. | 977 // iterated over and use the cache for the iteration. |
978 Label use_cache; | 978 Label use_cache; |
979 __ movp(rax, FieldOperand(rax, HeapObject::kMapOffset)); | 979 __ movp(rax, FieldOperand(rax, HeapObject::kMapOffset)); |
980 __ jmp(&use_cache, Label::kNear); | 980 __ jmp(&use_cache, Label::kNear); |
981 | 981 |
982 // Get the set of properties to enumerate. | 982 // Get the set of properties to enumerate. |
983 __ bind(&call_runtime); | 983 __ bind(&call_runtime); |
984 __ Push(rax); // Duplicate the enumerable object on the stack. | 984 __ Push(rax); // Duplicate the enumerable object on the stack. |
985 __ CallRuntime(Runtime::kForInEnumerate); | 985 __ CallRuntime(Runtime::kForInEnumerate); |
986 | |
Igor Sheludko
2016/07/20 11:06:51
Spurious change?
| |
986 PrepareForBailoutForId(stmt->EnumId(), BailoutState::TOS_REGISTER); | 987 PrepareForBailoutForId(stmt->EnumId(), BailoutState::TOS_REGISTER); |
987 | 988 |
988 // If we got a map from the runtime call, we can do a fast | 989 // If we got a map from the runtime call, we can do a fast |
989 // modification check. Otherwise, we got a fixed array, and we have | 990 // modification check. Otherwise, we got a fixed array, and we have |
990 // to do a slow check. | 991 // to do a slow check. |
991 Label fixed_array; | 992 Label fixed_array; |
992 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), | 993 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), |
993 Heap::kMetaMapRootIndex); | 994 Heap::kMetaMapRootIndex); |
994 __ j(not_equal, &fixed_array); | 995 __ j(not_equal, &fixed_array); |
995 | 996 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1029 __ Push(Smi::FromInt(0)); // Initial index. | 1030 __ Push(Smi::FromInt(0)); // Initial index. |
1030 | 1031 |
1031 // Generate code for doing the condition check. | 1032 // Generate code for doing the condition check. |
1032 __ bind(&loop); | 1033 __ bind(&loop); |
1033 SetExpressionAsStatementPosition(stmt->each()); | 1034 SetExpressionAsStatementPosition(stmt->each()); |
1034 | 1035 |
1035 __ movp(rax, Operand(rsp, 0 * kPointerSize)); // Get the current index. | 1036 __ movp(rax, Operand(rsp, 0 * kPointerSize)); // Get the current index. |
1036 __ cmpp(rax, Operand(rsp, 1 * kPointerSize)); // Compare to the array length. | 1037 __ cmpp(rax, Operand(rsp, 1 * kPointerSize)); // Compare to the array length. |
1037 __ j(above_equal, loop_statement.break_label()); | 1038 __ j(above_equal, loop_statement.break_label()); |
1038 | 1039 |
1039 // Get the current entry of the array into register rbx. | 1040 // Get the current entry of the array into register rax. |
1040 __ movp(rbx, Operand(rsp, 2 * kPointerSize)); | 1041 __ movp(rbx, Operand(rsp, 2 * kPointerSize)); |
1041 SmiIndex index = masm()->SmiToIndex(rax, rax, kPointerSizeLog2); | 1042 SmiIndex index = masm()->SmiToIndex(rax, rax, kPointerSizeLog2); |
1042 __ movp(rbx, FieldOperand(rbx, | 1043 __ movp(rax, |
1043 index.reg, | 1044 FieldOperand(rbx, index.reg, index.scale, FixedArray::kHeaderSize)); |
1044 index.scale, | |
1045 FixedArray::kHeaderSize)); | |
1046 | 1045 |
1047 // Get the expected map from the stack or a smi in the | 1046 // Get the expected map from the stack or a smi in the |
1048 // permanent slow case into register rdx. | 1047 // permanent slow case into register rdx. |
1049 __ movp(rdx, Operand(rsp, 3 * kPointerSize)); | 1048 __ movp(rdx, Operand(rsp, 3 * kPointerSize)); |
1050 | 1049 |
1051 // Check if the expected map still matches that of the enumerable. | 1050 // Check if the expected map still matches that of the enumerable. |
1052 // If not, we may have to filter the key. | 1051 // If not, we may have to filter the key. |
1053 Label update_each; | 1052 Label update_each; |
1054 __ movp(rcx, Operand(rsp, 4 * kPointerSize)); | 1053 __ movp(rbx, Operand(rsp, 4 * kPointerSize)); |
1055 __ cmpp(rdx, FieldOperand(rcx, HeapObject::kMapOffset)); | 1054 __ cmpp(rdx, FieldOperand(rbx, HeapObject::kMapOffset)); |
1056 __ j(equal, &update_each, Label::kNear); | 1055 __ j(equal, &update_each, Label::kNear); |
1057 | 1056 |
1058 // We need to filter the key, record slow-path here. | 1057 // We need to filter the key, record slow-path here. |
1059 int const vector_index = SmiFromSlot(slot)->value(); | 1058 int const vector_index = SmiFromSlot(slot)->value(); |
1060 __ EmitLoadTypeFeedbackVector(rdx); | 1059 __ EmitLoadTypeFeedbackVector(rdx); |
1061 __ Move(FieldOperand(rdx, FixedArray::OffsetOfElementAt(vector_index)), | 1060 __ Move(FieldOperand(rdx, FixedArray::OffsetOfElementAt(vector_index)), |
1062 TypeFeedbackVector::MegamorphicSentinel(isolate())); | 1061 TypeFeedbackVector::MegamorphicSentinel(isolate())); |
1063 | 1062 |
1064 // Convert the entry to a string or null if it isn't a property | 1063 // 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 | 1064 // ForInFilterStub. ForInFilter returns undefined if the receiver doesn't |
1066 // just skip it. | 1065 // have the key or returns the name-converted key. |
1067 __ Push(rcx); // Enumerable. | 1066 ForInFilterStub has_stub(isolate()); |
1068 __ Push(rbx); // Current entry. | 1067 __ CallStub(&has_stub); |
1069 __ CallRuntime(Runtime::kForInFilter); | |
1070 PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER); | 1068 PrepareForBailoutForId(stmt->FilterId(), BailoutState::TOS_REGISTER); |
1071 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 1069 __ CompareRoot(result_register(), Heap::kUndefinedValueRootIndex); |
1070 RestoreContext(); | |
Igor Sheludko
2016/07/20 11:06:51
I would prefer to see the RestoreContext() call ri
Camillo Bruni
2016/07/20 12:42:42
right, changed.
| |
1072 __ j(equal, loop_statement.continue_label()); | 1071 __ j(equal, loop_statement.continue_label()); |
1073 __ movp(rbx, rax); | |
1074 | 1072 |
1075 // Update the 'each' property or variable from the possibly filtered | 1073 // Update the 'each' property or variable from the possibly filtered |
1076 // entry in register rbx. | 1074 // entry in register rax. |
1077 __ bind(&update_each); | 1075 __ bind(&update_each); |
1078 __ movp(result_register(), rbx); | |
1079 // Perform the assignment as if via '='. | 1076 // Perform the assignment as if via '='. |
1080 { EffectContext context(this); | 1077 { EffectContext context(this); |
1081 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); | 1078 EmitAssignment(stmt->each(), stmt->EachFeedbackSlot()); |
1082 PrepareForBailoutForId(stmt->AssignmentId(), BailoutState::NO_REGISTERS); | 1079 PrepareForBailoutForId(stmt->AssignmentId(), BailoutState::NO_REGISTERS); |
1083 } | 1080 } |
1084 | 1081 |
1085 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body(). | 1082 // Both Crankshaft and Turbofan expect BodyId to be right before stmt->body(). |
1086 PrepareForBailoutForId(stmt->BodyId(), BailoutState::NO_REGISTERS); | 1083 PrepareForBailoutForId(stmt->BodyId(), BailoutState::NO_REGISTERS); |
1087 // Generate code for the body of the loop. | 1084 // Generate code for the body of the loop. |
1088 Visit(stmt->body()); | 1085 Visit(stmt->body()); |
(...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3666 DCHECK_EQ( | 3663 DCHECK_EQ( |
3667 isolate->builtins()->OnStackReplacement()->entry(), | 3664 isolate->builtins()->OnStackReplacement()->entry(), |
3668 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3665 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3669 return ON_STACK_REPLACEMENT; | 3666 return ON_STACK_REPLACEMENT; |
3670 } | 3667 } |
3671 | 3668 |
3672 } // namespace internal | 3669 } // namespace internal |
3673 } // namespace v8 | 3670 } // namespace v8 |
3674 | 3671 |
3675 #endif // V8_TARGET_ARCH_X64 | 3672 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |