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_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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (strlen(FLAG_stop_at) > 0 && | 102 if (strlen(FLAG_stop_at) > 0 && |
103 literal()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 103 literal()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
104 __ int3(); | 104 __ int3(); |
105 } | 105 } |
106 #endif | 106 #endif |
107 | 107 |
108 if (FLAG_debug_code && info->ExpectsJSReceiverAsReceiver()) { | 108 if (FLAG_debug_code && info->ExpectsJSReceiverAsReceiver()) { |
109 int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize; | 109 int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize; |
110 __ mov(ecx, Operand(esp, receiver_offset)); | 110 __ mov(ecx, Operand(esp, receiver_offset)); |
111 __ AssertNotSmi(ecx); | 111 __ AssertNotSmi(ecx); |
112 __ CmpObjectType(ecx, FIRST_SPEC_OBJECT_TYPE, ecx); | 112 __ CmpObjectType(ecx, FIRST_JS_RECEIVER_TYPE, ecx); |
113 __ Assert(above_equal, kSloppyFunctionExpectsJSReceiverReceiver); | 113 __ Assert(above_equal, kSloppyFunctionExpectsJSReceiverReceiver); |
114 } | 114 } |
115 | 115 |
116 // Open a frame scope to indicate that there is a frame on the stack. The | 116 // Open a frame scope to indicate that there is a frame on the stack. The |
117 // MANUAL indicates that the scope shouldn't actually generate code to set up | 117 // MANUAL indicates that the scope shouldn't actually generate code to set up |
118 // the frame (that is done below). | 118 // the frame (that is done below). |
119 FrameScope frame_scope(masm_, StackFrame::MANUAL); | 119 FrameScope frame_scope(masm_, StackFrame::MANUAL); |
120 | 120 |
121 info->set_prologue_offset(masm_->pc_offset()); | 121 info->set_prologue_offset(masm_->pc_offset()); |
122 __ Prologue(info->IsCodePreAgingActive()); | 122 __ Prologue(info->IsCodePreAgingActive()); |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 __ cmp(eax, isolate()->factory()->undefined_value()); | 966 __ cmp(eax, isolate()->factory()->undefined_value()); |
967 __ j(equal, &exit); | 967 __ j(equal, &exit); |
968 __ cmp(eax, isolate()->factory()->null_value()); | 968 __ cmp(eax, isolate()->factory()->null_value()); |
969 __ j(equal, &exit); | 969 __ j(equal, &exit); |
970 | 970 |
971 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); | 971 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); |
972 | 972 |
973 // Convert the object to a JS object. | 973 // Convert the object to a JS object. |
974 Label convert, done_convert; | 974 Label convert, done_convert; |
975 __ JumpIfSmi(eax, &convert, Label::kNear); | 975 __ JumpIfSmi(eax, &convert, Label::kNear); |
976 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, ecx); | 976 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, ecx); |
977 __ j(above_equal, &done_convert, Label::kNear); | 977 __ j(above_equal, &done_convert, Label::kNear); |
978 __ bind(&convert); | 978 __ bind(&convert); |
979 ToObjectStub stub(isolate()); | 979 ToObjectStub stub(isolate()); |
980 __ CallStub(&stub); | 980 __ CallStub(&stub); |
981 __ bind(&done_convert); | 981 __ bind(&done_convert); |
982 PrepareForBailoutForId(stmt->ToObjectId(), TOS_REG); | 982 PrepareForBailoutForId(stmt->ToObjectId(), TOS_REG); |
983 __ push(eax); | 983 __ push(eax); |
984 | 984 |
985 // Check for proxies. | 985 // Check for proxies. |
986 Label call_runtime, use_cache, fixed_array; | 986 Label call_runtime, use_cache, fixed_array; |
987 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); | 987 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_JS_RECEIVER_TYPE); |
988 __ CmpObjectType(eax, LAST_JS_PROXY_TYPE, ecx); | 988 __ CmpObjectType(eax, LAST_JS_PROXY_TYPE, ecx); |
989 __ j(below_equal, &call_runtime); | 989 __ j(below_equal, &call_runtime); |
990 | 990 |
991 // Check cache validity in generated code. This is a fast case for | 991 // Check cache validity in generated code. This is a fast case for |
992 // the JSObject::IsSimpleEnum cache validity checks. If we cannot | 992 // the JSObject::IsSimpleEnum cache validity checks. If we cannot |
993 // guarantee cache validity, call the runtime system to check cache | 993 // guarantee cache validity, call the runtime system to check cache |
994 // validity or get the property names in a fixed array. | 994 // validity or get the property names in a fixed array. |
995 __ CheckEnumCache(&call_runtime); | 995 __ CheckEnumCache(&call_runtime); |
996 | 996 |
997 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset)); | 997 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 __ bind(&fixed_array); | 1035 __ bind(&fixed_array); |
1036 | 1036 |
1037 // No need for a write barrier, we are storing a Smi in the feedback vector. | 1037 // No need for a write barrier, we are storing a Smi in the feedback vector. |
1038 __ EmitLoadTypeFeedbackVector(ebx); | 1038 __ EmitLoadTypeFeedbackVector(ebx); |
1039 int vector_index = SmiFromSlot(slot)->value(); | 1039 int vector_index = SmiFromSlot(slot)->value(); |
1040 __ mov(FieldOperand(ebx, FixedArray::OffsetOfElementAt(vector_index)), | 1040 __ mov(FieldOperand(ebx, FixedArray::OffsetOfElementAt(vector_index)), |
1041 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate()))); | 1041 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate()))); |
1042 | 1042 |
1043 __ mov(ebx, Immediate(Smi::FromInt(1))); // Smi indicates slow check | 1043 __ mov(ebx, Immediate(Smi::FromInt(1))); // Smi indicates slow check |
1044 __ mov(ecx, Operand(esp, 0 * kPointerSize)); // Get enumerated object | 1044 __ mov(ecx, Operand(esp, 0 * kPointerSize)); // Get enumerated object |
1045 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); | 1045 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_JS_RECEIVER_TYPE); |
1046 __ CmpObjectType(ecx, LAST_JS_PROXY_TYPE, ecx); | 1046 __ CmpObjectType(ecx, LAST_JS_PROXY_TYPE, ecx); |
1047 __ j(above, &non_proxy); | 1047 __ j(above, &non_proxy); |
1048 __ Move(ebx, Immediate(Smi::FromInt(0))); // Zero indicates proxy | 1048 __ Move(ebx, Immediate(Smi::FromInt(0))); // Zero indicates proxy |
1049 __ bind(&non_proxy); | 1049 __ bind(&non_proxy); |
1050 __ push(ebx); // Smi | 1050 __ push(ebx); // Smi |
1051 __ push(eax); // Array | 1051 __ push(eax); // Array |
1052 __ mov(eax, FieldOperand(eax, FixedArray::kLengthOffset)); | 1052 __ mov(eax, FieldOperand(eax, FixedArray::kLengthOffset)); |
1053 __ push(eax); // Fixed array length (as smi). | 1053 __ push(eax); // Fixed array length (as smi). |
1054 __ push(Immediate(Smi::FromInt(0))); // Initial index. | 1054 __ push(Immediate(Smi::FromInt(0))); // Initial index. |
1055 | 1055 |
(...skipping 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2977 VisitForAccumulatorValue(args->at(0)); | 2977 VisitForAccumulatorValue(args->at(0)); |
2978 | 2978 |
2979 Label materialize_true, materialize_false; | 2979 Label materialize_true, materialize_false; |
2980 Label* if_true = NULL; | 2980 Label* if_true = NULL; |
2981 Label* if_false = NULL; | 2981 Label* if_false = NULL; |
2982 Label* fall_through = NULL; | 2982 Label* fall_through = NULL; |
2983 context()->PrepareTest(&materialize_true, &materialize_false, | 2983 context()->PrepareTest(&materialize_true, &materialize_false, |
2984 &if_true, &if_false, &fall_through); | 2984 &if_true, &if_false, &fall_through); |
2985 | 2985 |
2986 __ JumpIfSmi(eax, if_false); | 2986 __ JumpIfSmi(eax, if_false); |
2987 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, ebx); | 2987 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, ebx); |
2988 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 2988 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
2989 Split(above_equal, if_true, if_false, fall_through); | 2989 Split(above_equal, if_true, if_false, fall_through); |
2990 | 2990 |
2991 context()->Plug(if_true, if_false); | 2991 context()->Plug(if_true, if_false); |
2992 } | 2992 } |
2993 | 2993 |
2994 | 2994 |
2995 void FullCodeGenerator::EmitIsSimdValue(CallRuntime* expr) { | 2995 void FullCodeGenerator::EmitIsSimdValue(CallRuntime* expr) { |
2996 ZoneList<Expression*>* args = expr->arguments(); | 2996 ZoneList<Expression*>* args = expr->arguments(); |
2997 DCHECK(args->length() == 1); | 2997 DCHECK(args->length() == 1); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3256 VisitForAccumulatorValue(args->at(0)); | 3256 VisitForAccumulatorValue(args->at(0)); |
3257 | 3257 |
3258 // If the object is a smi, we return null. | 3258 // If the object is a smi, we return null. |
3259 __ JumpIfSmi(eax, &null); | 3259 __ JumpIfSmi(eax, &null); |
3260 | 3260 |
3261 // Check that the object is a JS object but take special care of JS | 3261 // Check that the object is a JS object but take special care of JS |
3262 // functions to make sure they have 'Function' as their class. | 3262 // functions to make sure they have 'Function' as their class. |
3263 // Assume that there are only two callable types, and one of them is at | 3263 // Assume that there are only two callable types, and one of them is at |
3264 // either end of the type range for JS object types. Saves extra comparisons. | 3264 // either end of the type range for JS object types. Saves extra comparisons. |
3265 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); | 3265 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
3266 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, eax); | 3266 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, eax); |
3267 // Map is now in eax. | 3267 // Map is now in eax. |
3268 __ j(below, &null); | 3268 __ j(below, &null); |
3269 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == | 3269 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == |
3270 FIRST_SPEC_OBJECT_TYPE + 1); | 3270 FIRST_JS_RECEIVER_TYPE + 1); |
3271 __ j(equal, &function); | 3271 __ j(equal, &function); |
3272 | 3272 |
3273 __ CmpInstanceType(eax, LAST_SPEC_OBJECT_TYPE); | 3273 __ CmpInstanceType(eax, LAST_JS_RECEIVER_TYPE); |
3274 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == | 3274 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == |
3275 LAST_SPEC_OBJECT_TYPE - 1); | 3275 LAST_JS_RECEIVER_TYPE - 1); |
3276 __ j(equal, &function); | 3276 __ j(equal, &function); |
3277 // Assume that there is no larger type. | 3277 // Assume that there is no larger type. |
3278 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1); | 3278 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1); |
3279 | 3279 |
3280 // Check if the constructor in the map is a JS function. | 3280 // Check if the constructor in the map is a JS function. |
3281 __ GetMapConstructor(eax, eax, ebx); | 3281 __ GetMapConstructor(eax, eax, ebx); |
3282 __ CmpInstanceType(ebx, JS_FUNCTION_TYPE); | 3282 __ CmpInstanceType(ebx, JS_FUNCTION_TYPE); |
3283 __ j(not_equal, &non_function_constructor); | 3283 __ j(not_equal, &non_function_constructor); |
3284 | 3284 |
3285 // eax now contains the constructor function. Grab the | 3285 // eax now contains the constructor function. Grab the |
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4547 // Check for callable and not undetectable objects => true. | 4547 // Check for callable and not undetectable objects => true. |
4548 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); | 4548 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); |
4549 __ movzx_b(ecx, FieldOperand(edx, Map::kBitFieldOffset)); | 4549 __ movzx_b(ecx, FieldOperand(edx, Map::kBitFieldOffset)); |
4550 __ and_(ecx, (1 << Map::kIsCallable) | (1 << Map::kIsUndetectable)); | 4550 __ and_(ecx, (1 << Map::kIsCallable) | (1 << Map::kIsUndetectable)); |
4551 __ cmp(ecx, 1 << Map::kIsCallable); | 4551 __ cmp(ecx, 1 << Map::kIsCallable); |
4552 Split(equal, if_true, if_false, fall_through); | 4552 Split(equal, if_true, if_false, fall_through); |
4553 } else if (String::Equals(check, factory->object_string())) { | 4553 } else if (String::Equals(check, factory->object_string())) { |
4554 __ JumpIfSmi(eax, if_false); | 4554 __ JumpIfSmi(eax, if_false); |
4555 __ cmp(eax, isolate()->factory()->null_value()); | 4555 __ cmp(eax, isolate()->factory()->null_value()); |
4556 __ j(equal, if_true); | 4556 __ j(equal, if_true); |
4557 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); | 4557 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); |
4558 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, edx); | 4558 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, edx); |
4559 __ j(below, if_false); | 4559 __ j(below, if_false); |
4560 // Check for callable or undetectable objects => false. | 4560 // Check for callable or undetectable objects => false. |
4561 __ test_b(FieldOperand(edx, Map::kBitFieldOffset), | 4561 __ test_b(FieldOperand(edx, Map::kBitFieldOffset), |
4562 (1 << Map::kIsCallable) | (1 << Map::kIsUndetectable)); | 4562 (1 << Map::kIsCallable) | (1 << Map::kIsUndetectable)); |
4563 Split(zero, if_true, if_false, fall_through); | 4563 Split(zero, if_true, if_false, fall_through); |
4564 // clang-format off | 4564 // clang-format off |
4565 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ | 4565 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ |
4566 } else if (String::Equals(check, factory->type##_string())) { \ | 4566 } else if (String::Equals(check, factory->type##_string())) { \ |
4567 __ JumpIfSmi(eax, if_false); \ | 4567 __ JumpIfSmi(eax, if_false); \ |
4568 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), \ | 4568 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), \ |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4866 Assembler::target_address_at(call_target_address, | 4866 Assembler::target_address_at(call_target_address, |
4867 unoptimized_code)); | 4867 unoptimized_code)); |
4868 return OSR_AFTER_STACK_CHECK; | 4868 return OSR_AFTER_STACK_CHECK; |
4869 } | 4869 } |
4870 | 4870 |
4871 | 4871 |
4872 } // namespace internal | 4872 } // namespace internal |
4873 } // namespace v8 | 4873 } // namespace v8 |
4874 | 4874 |
4875 #endif // V8_TARGET_ARCH_X87 | 4875 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |