| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 if (strlen(FLAG_stop_at) > 0 && | 101 if (strlen(FLAG_stop_at) > 0 && |
| 102 info->literal()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 102 info->literal()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
| 103 __ int3(); | 103 __ int3(); |
| 104 } | 104 } |
| 105 #endif | 105 #endif |
| 106 | 106 |
| 107 if (FLAG_debug_code && info->ExpectsJSReceiverAsReceiver()) { | 107 if (FLAG_debug_code && info->ExpectsJSReceiverAsReceiver()) { |
| 108 StackArgumentsAccessor args(rsp, info->scope()->num_parameters()); | 108 StackArgumentsAccessor args(rsp, info->scope()->num_parameters()); |
| 109 __ movp(rcx, args.GetReceiverOperand()); | 109 __ movp(rcx, args.GetReceiverOperand()); |
| 110 __ AssertNotSmi(rcx); | 110 __ AssertNotSmi(rcx); |
| 111 __ CmpObjectType(rcx, FIRST_SPEC_OBJECT_TYPE, rcx); | 111 __ CmpObjectType(rcx, FIRST_JS_RECEIVER_TYPE, rcx); |
| 112 __ Assert(above_equal, kSloppyFunctionExpectsJSReceiverReceiver); | 112 __ Assert(above_equal, kSloppyFunctionExpectsJSReceiverReceiver); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Open a frame scope to indicate that there is a frame on the stack. The | 115 // Open a frame scope to indicate that there is a frame on the stack. The |
| 116 // MANUAL indicates that the scope shouldn't actually generate code to set up | 116 // MANUAL indicates that the scope shouldn't actually generate code to set up |
| 117 // the frame (that is done below). | 117 // the frame (that is done below). |
| 118 FrameScope frame_scope(masm_, StackFrame::MANUAL); | 118 FrameScope frame_scope(masm_, StackFrame::MANUAL); |
| 119 | 119 |
| 120 info->set_prologue_offset(masm_->pc_offset()); | 120 info->set_prologue_offset(masm_->pc_offset()); |
| 121 __ Prologue(info->IsCodePreAgingActive()); | 121 __ Prologue(info->IsCodePreAgingActive()); |
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 Register null_value = rdi; | 989 Register null_value = rdi; |
| 990 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 990 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
| 991 __ cmpp(rax, null_value); | 991 __ cmpp(rax, null_value); |
| 992 __ j(equal, &exit); | 992 __ j(equal, &exit); |
| 993 | 993 |
| 994 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); | 994 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); |
| 995 | 995 |
| 996 // Convert the object to a JS object. | 996 // Convert the object to a JS object. |
| 997 Label convert, done_convert; | 997 Label convert, done_convert; |
| 998 __ JumpIfSmi(rax, &convert, Label::kNear); | 998 __ JumpIfSmi(rax, &convert, Label::kNear); |
| 999 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rcx); | 999 __ CmpObjectType(rax, FIRST_JS_RECEIVER_TYPE, rcx); |
| 1000 __ j(above_equal, &done_convert, Label::kNear); | 1000 __ j(above_equal, &done_convert, Label::kNear); |
| 1001 __ bind(&convert); | 1001 __ bind(&convert); |
| 1002 ToObjectStub stub(isolate()); | 1002 ToObjectStub stub(isolate()); |
| 1003 __ CallStub(&stub); | 1003 __ CallStub(&stub); |
| 1004 __ bind(&done_convert); | 1004 __ bind(&done_convert); |
| 1005 PrepareForBailoutForId(stmt->ToObjectId(), TOS_REG); | 1005 PrepareForBailoutForId(stmt->ToObjectId(), TOS_REG); |
| 1006 __ Push(rax); | 1006 __ Push(rax); |
| 1007 | 1007 |
| 1008 // Check for proxies. | 1008 // Check for proxies. |
| 1009 Label call_runtime; | 1009 Label call_runtime; |
| 1010 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); | 1010 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_JS_RECEIVER_TYPE); |
| 1011 __ CmpObjectType(rax, LAST_JS_PROXY_TYPE, rcx); | 1011 __ CmpObjectType(rax, LAST_JS_PROXY_TYPE, rcx); |
| 1012 __ j(below_equal, &call_runtime); | 1012 __ j(below_equal, &call_runtime); |
| 1013 | 1013 |
| 1014 // Check cache validity in generated code. This is a fast case for | 1014 // Check cache validity in generated code. This is a fast case for |
| 1015 // the JSObject::IsSimpleEnum cache validity checks. If we cannot | 1015 // the JSObject::IsSimpleEnum cache validity checks. If we cannot |
| 1016 // guarantee cache validity, call the runtime system to check cache | 1016 // guarantee cache validity, call the runtime system to check cache |
| 1017 // validity or get the property names in a fixed array. | 1017 // validity or get the property names in a fixed array. |
| 1018 __ CheckEnumCache(null_value, &call_runtime); | 1018 __ CheckEnumCache(null_value, &call_runtime); |
| 1019 | 1019 |
| 1020 // The enum cache is valid. Load the map of the object being | 1020 // The enum cache is valid. Load the map of the object being |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 Label non_proxy; | 1065 Label non_proxy; |
| 1066 __ bind(&fixed_array); | 1066 __ bind(&fixed_array); |
| 1067 | 1067 |
| 1068 // No need for a write barrier, we are storing a Smi in the feedback vector. | 1068 // No need for a write barrier, we are storing a Smi in the feedback vector. |
| 1069 __ EmitLoadTypeFeedbackVector(rbx); | 1069 __ EmitLoadTypeFeedbackVector(rbx); |
| 1070 int vector_index = SmiFromSlot(slot)->value(); | 1070 int vector_index = SmiFromSlot(slot)->value(); |
| 1071 __ Move(FieldOperand(rbx, FixedArray::OffsetOfElementAt(vector_index)), | 1071 __ Move(FieldOperand(rbx, FixedArray::OffsetOfElementAt(vector_index)), |
| 1072 TypeFeedbackVector::MegamorphicSentinel(isolate())); | 1072 TypeFeedbackVector::MegamorphicSentinel(isolate())); |
| 1073 __ Move(rbx, Smi::FromInt(1)); // Smi indicates slow check | 1073 __ Move(rbx, Smi::FromInt(1)); // Smi indicates slow check |
| 1074 __ movp(rcx, Operand(rsp, 0 * kPointerSize)); // Get enumerated object | 1074 __ movp(rcx, Operand(rsp, 0 * kPointerSize)); // Get enumerated object |
| 1075 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); | 1075 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_JS_RECEIVER_TYPE); |
| 1076 __ CmpObjectType(rcx, LAST_JS_PROXY_TYPE, rcx); | 1076 __ CmpObjectType(rcx, LAST_JS_PROXY_TYPE, rcx); |
| 1077 __ j(above, &non_proxy); | 1077 __ j(above, &non_proxy); |
| 1078 __ Move(rbx, Smi::FromInt(0)); // Zero indicates proxy | 1078 __ Move(rbx, Smi::FromInt(0)); // Zero indicates proxy |
| 1079 __ bind(&non_proxy); | 1079 __ bind(&non_proxy); |
| 1080 __ Push(rbx); // Smi | 1080 __ Push(rbx); // Smi |
| 1081 __ Push(rax); // Array | 1081 __ Push(rax); // Array |
| 1082 __ movp(rax, FieldOperand(rax, FixedArray::kLengthOffset)); | 1082 __ movp(rax, FieldOperand(rax, FixedArray::kLengthOffset)); |
| 1083 __ Push(rax); // Fixed array length (as smi). | 1083 __ Push(rax); // Fixed array length (as smi). |
| 1084 __ Push(Smi::FromInt(0)); // Initial index. | 1084 __ Push(Smi::FromInt(0)); // Initial index. |
| 1085 | 1085 |
| (...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2969 VisitForAccumulatorValue(args->at(0)); | 2969 VisitForAccumulatorValue(args->at(0)); |
| 2970 | 2970 |
| 2971 Label materialize_true, materialize_false; | 2971 Label materialize_true, materialize_false; |
| 2972 Label* if_true = NULL; | 2972 Label* if_true = NULL; |
| 2973 Label* if_false = NULL; | 2973 Label* if_false = NULL; |
| 2974 Label* fall_through = NULL; | 2974 Label* fall_through = NULL; |
| 2975 context()->PrepareTest(&materialize_true, &materialize_false, | 2975 context()->PrepareTest(&materialize_true, &materialize_false, |
| 2976 &if_true, &if_false, &fall_through); | 2976 &if_true, &if_false, &fall_through); |
| 2977 | 2977 |
| 2978 __ JumpIfSmi(rax, if_false); | 2978 __ JumpIfSmi(rax, if_false); |
| 2979 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rbx); | 2979 __ CmpObjectType(rax, FIRST_JS_RECEIVER_TYPE, rbx); |
| 2980 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 2980 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
| 2981 Split(above_equal, if_true, if_false, fall_through); | 2981 Split(above_equal, if_true, if_false, fall_through); |
| 2982 | 2982 |
| 2983 context()->Plug(if_true, if_false); | 2983 context()->Plug(if_true, if_false); |
| 2984 } | 2984 } |
| 2985 | 2985 |
| 2986 | 2986 |
| 2987 void FullCodeGenerator::EmitIsSimdValue(CallRuntime* expr) { | 2987 void FullCodeGenerator::EmitIsSimdValue(CallRuntime* expr) { |
| 2988 ZoneList<Expression*>* args = expr->arguments(); | 2988 ZoneList<Expression*>* args = expr->arguments(); |
| 2989 DCHECK(args->length() == 1); | 2989 DCHECK(args->length() == 1); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3248 VisitForAccumulatorValue(args->at(0)); | 3248 VisitForAccumulatorValue(args->at(0)); |
| 3249 | 3249 |
| 3250 // If the object is a smi, we return null. | 3250 // If the object is a smi, we return null. |
| 3251 __ JumpIfSmi(rax, &null); | 3251 __ JumpIfSmi(rax, &null); |
| 3252 | 3252 |
| 3253 // Check that the object is a JS object but take special care of JS | 3253 // Check that the object is a JS object but take special care of JS |
| 3254 // functions to make sure they have 'Function' as their class. | 3254 // functions to make sure they have 'Function' as their class. |
| 3255 // Assume that there are only two callable types, and one of them is at | 3255 // Assume that there are only two callable types, and one of them is at |
| 3256 // either end of the type range for JS object types. Saves extra comparisons. | 3256 // either end of the type range for JS object types. Saves extra comparisons. |
| 3257 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); | 3257 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
| 3258 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rax); | 3258 __ CmpObjectType(rax, FIRST_JS_RECEIVER_TYPE, rax); |
| 3259 // Map is now in rax. | 3259 // Map is now in rax. |
| 3260 __ j(below, &null); | 3260 __ j(below, &null); |
| 3261 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == | 3261 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 3262 FIRST_SPEC_OBJECT_TYPE + 1); | 3262 FIRST_JS_RECEIVER_TYPE + 1); |
| 3263 __ j(equal, &function); | 3263 __ j(equal, &function); |
| 3264 | 3264 |
| 3265 __ CmpInstanceType(rax, LAST_SPEC_OBJECT_TYPE); | 3265 __ CmpInstanceType(rax, LAST_JS_RECEIVER_TYPE); |
| 3266 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == | 3266 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 3267 LAST_SPEC_OBJECT_TYPE - 1); | 3267 LAST_JS_RECEIVER_TYPE - 1); |
| 3268 __ j(equal, &function); | 3268 __ j(equal, &function); |
| 3269 // Assume that there is no larger type. | 3269 // Assume that there is no larger type. |
| 3270 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1); | 3270 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1); |
| 3271 | 3271 |
| 3272 // Check if the constructor in the map is a JS function. | 3272 // Check if the constructor in the map is a JS function. |
| 3273 __ GetMapConstructor(rax, rax, rbx); | 3273 __ GetMapConstructor(rax, rax, rbx); |
| 3274 __ CmpInstanceType(rbx, JS_FUNCTION_TYPE); | 3274 __ CmpInstanceType(rbx, JS_FUNCTION_TYPE); |
| 3275 __ j(not_equal, &non_function_constructor); | 3275 __ j(not_equal, &non_function_constructor); |
| 3276 | 3276 |
| 3277 // rax now contains the constructor function. Grab the | 3277 // rax now contains the constructor function. Grab the |
| (...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4561 __ movp(rdx, FieldOperand(rax, HeapObject::kMapOffset)); | 4561 __ movp(rdx, FieldOperand(rax, HeapObject::kMapOffset)); |
| 4562 __ movzxbl(rdx, FieldOperand(rdx, Map::kBitFieldOffset)); | 4562 __ movzxbl(rdx, FieldOperand(rdx, Map::kBitFieldOffset)); |
| 4563 __ andb(rdx, | 4563 __ andb(rdx, |
| 4564 Immediate((1 << Map::kIsCallable) | (1 << Map::kIsUndetectable))); | 4564 Immediate((1 << Map::kIsCallable) | (1 << Map::kIsUndetectable))); |
| 4565 __ cmpb(rdx, Immediate(1 << Map::kIsCallable)); | 4565 __ cmpb(rdx, Immediate(1 << Map::kIsCallable)); |
| 4566 Split(equal, if_true, if_false, fall_through); | 4566 Split(equal, if_true, if_false, fall_through); |
| 4567 } else if (String::Equals(check, factory->object_string())) { | 4567 } else if (String::Equals(check, factory->object_string())) { |
| 4568 __ JumpIfSmi(rax, if_false); | 4568 __ JumpIfSmi(rax, if_false); |
| 4569 __ CompareRoot(rax, Heap::kNullValueRootIndex); | 4569 __ CompareRoot(rax, Heap::kNullValueRootIndex); |
| 4570 __ j(equal, if_true); | 4570 __ j(equal, if_true); |
| 4571 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); | 4571 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); |
| 4572 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rdx); | 4572 __ CmpObjectType(rax, FIRST_JS_RECEIVER_TYPE, rdx); |
| 4573 __ j(below, if_false); | 4573 __ j(below, if_false); |
| 4574 // Check for callable or undetectable objects => false. | 4574 // Check for callable or undetectable objects => false. |
| 4575 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), | 4575 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), |
| 4576 Immediate((1 << Map::kIsCallable) | (1 << Map::kIsUndetectable))); | 4576 Immediate((1 << Map::kIsCallable) | (1 << Map::kIsUndetectable))); |
| 4577 Split(zero, if_true, if_false, fall_through); | 4577 Split(zero, if_true, if_false, fall_through); |
| 4578 // clang-format off | 4578 // clang-format off |
| 4579 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ | 4579 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ |
| 4580 } else if (String::Equals(check, factory->type##_string())) { \ | 4580 } else if (String::Equals(check, factory->type##_string())) { \ |
| 4581 __ JumpIfSmi(rax, if_false); \ | 4581 __ JumpIfSmi(rax, if_false); \ |
| 4582 __ movp(rax, FieldOperand(rax, HeapObject::kMapOffset)); \ | 4582 __ movp(rax, FieldOperand(rax, HeapObject::kMapOffset)); \ |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4881 Assembler::target_address_at(call_target_address, | 4881 Assembler::target_address_at(call_target_address, |
| 4882 unoptimized_code)); | 4882 unoptimized_code)); |
| 4883 return OSR_AFTER_STACK_CHECK; | 4883 return OSR_AFTER_STACK_CHECK; |
| 4884 } | 4884 } |
| 4885 | 4885 |
| 4886 | 4886 |
| 4887 } // namespace internal | 4887 } // namespace internal |
| 4888 } // namespace v8 | 4888 } // namespace v8 |
| 4889 | 4889 |
| 4890 #endif // V8_TARGET_ARCH_X64 | 4890 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |