OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #include "src/deoptimizer.h" | 5 #include "src/deoptimizer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 2775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2786 TranslatedValue TranslatedValue::NewDuplicateObject(TranslatedState* container, | 2786 TranslatedValue TranslatedValue::NewDuplicateObject(TranslatedState* container, |
2787 int id) { | 2787 int id) { |
2788 TranslatedValue slot(container, kDuplicatedObject); | 2788 TranslatedValue slot(container, kDuplicatedObject); |
2789 slot.materialization_info_ = {id, -1}; | 2789 slot.materialization_info_ = {id, -1}; |
2790 return slot; | 2790 return slot; |
2791 } | 2791 } |
2792 | 2792 |
2793 | 2793 |
2794 // static | 2794 // static |
2795 TranslatedValue TranslatedValue::NewFloat(TranslatedState* container, | 2795 TranslatedValue TranslatedValue::NewFloat(TranslatedState* container, |
2796 float value) { | 2796 Float32 value) { |
2797 TranslatedValue slot(container, kFloat); | 2797 TranslatedValue slot(container, kFloat); |
2798 slot.float_value_ = value; | 2798 slot.float_value_ = value; |
2799 return slot; | 2799 return slot; |
2800 } | 2800 } |
2801 | 2801 |
2802 // static | 2802 // static |
2803 TranslatedValue TranslatedValue::NewDouble(TranslatedState* container, | 2803 TranslatedValue TranslatedValue::NewDouble(TranslatedState* container, |
2804 double value) { | 2804 Float64 value) { |
2805 TranslatedValue slot(container, kDouble); | 2805 TranslatedValue slot(container, kDouble); |
2806 slot.double_value_ = value; | 2806 slot.double_value_ = value; |
2807 return slot; | 2807 return slot; |
2808 } | 2808 } |
2809 | 2809 |
2810 | 2810 |
2811 // static | 2811 // static |
2812 TranslatedValue TranslatedValue::NewInt32(TranslatedState* container, | 2812 TranslatedValue TranslatedValue::NewInt32(TranslatedState* container, |
2813 int32_t value) { | 2813 int32_t value) { |
2814 TranslatedValue slot(container, kInt32); | 2814 TranslatedValue slot(container, kInt32); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2863 DCHECK_EQ(kInt32, kind()); | 2863 DCHECK_EQ(kInt32, kind()); |
2864 return int32_value_; | 2864 return int32_value_; |
2865 } | 2865 } |
2866 | 2866 |
2867 | 2867 |
2868 uint32_t TranslatedValue::uint32_value() const { | 2868 uint32_t TranslatedValue::uint32_value() const { |
2869 DCHECK(kind() == kUInt32 || kind() == kBoolBit); | 2869 DCHECK(kind() == kUInt32 || kind() == kBoolBit); |
2870 return uint32_value_; | 2870 return uint32_value_; |
2871 } | 2871 } |
2872 | 2872 |
2873 float TranslatedValue::float_value() const { | 2873 Float32 TranslatedValue::float_value() const { |
2874 DCHECK_EQ(kFloat, kind()); | 2874 DCHECK_EQ(kFloat, kind()); |
2875 return float_value_; | 2875 return float_value_; |
2876 } | 2876 } |
2877 | 2877 |
2878 double TranslatedValue::double_value() const { | 2878 Float64 TranslatedValue::double_value() const { |
2879 DCHECK_EQ(kDouble, kind()); | 2879 DCHECK_EQ(kDouble, kind()); |
2880 return double_value_; | 2880 return double_value_; |
2881 } | 2881 } |
2882 | 2882 |
2883 | 2883 |
2884 int TranslatedValue::object_length() const { | 2884 int TranslatedValue::object_length() const { |
2885 DCHECK(kind() == kArgumentsObject || kind() == kCapturedObject); | 2885 DCHECK(kind() == kArgumentsObject || kind() == kCapturedObject); |
2886 return materialization_info_.length_; | 2886 return materialization_info_.length_; |
2887 } | 2887 } |
2888 | 2888 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2978 if (!value_.is_null()) return; | 2978 if (!value_.is_null()) return; |
2979 | 2979 |
2980 Object* raw_value = GetRawValue(); | 2980 Object* raw_value = GetRawValue(); |
2981 if (raw_value != isolate()->heap()->arguments_marker()) { | 2981 if (raw_value != isolate()->heap()->arguments_marker()) { |
2982 // We can get the value without allocation, just return it here. | 2982 // We can get the value without allocation, just return it here. |
2983 value_ = Handle<Object>(raw_value, isolate()); | 2983 value_ = Handle<Object>(raw_value, isolate()); |
2984 return; | 2984 return; |
2985 } | 2985 } |
2986 | 2986 |
2987 switch (kind()) { | 2987 switch (kind()) { |
2988 case kInt32: { | 2988 case kInt32: |
2989 value_ = Handle<Object>(isolate()->factory()->NewNumber(int32_value())); | 2989 value_ = Handle<Object>(isolate()->factory()->NewNumber(int32_value())); |
2990 return; | 2990 return; |
2991 } | |
2992 | 2991 |
2993 case kUInt32: | 2992 case kUInt32: |
2994 value_ = Handle<Object>(isolate()->factory()->NewNumber(uint32_value())); | 2993 value_ = Handle<Object>(isolate()->factory()->NewNumber(uint32_value())); |
2995 return; | 2994 return; |
2996 | 2995 |
2997 case kFloat: | 2996 case kFloat: { |
2998 value_ = Handle<Object>(isolate()->factory()->NewNumber(float_value())); | 2997 double scalar_value = float_value().get_scalar(); |
| 2998 value_ = Handle<Object>(isolate()->factory()->NewNumber(scalar_value)); |
2999 return; | 2999 return; |
| 3000 } |
3000 | 3001 |
3001 case kDouble: | 3002 case kDouble: { |
3002 value_ = Handle<Object>(isolate()->factory()->NewNumber(double_value())); | 3003 if (double_value().is_hole_nan()) { |
| 3004 value_ = isolate()->factory()->hole_nan_value(); |
| 3005 return; |
| 3006 } |
| 3007 double scalar_value = double_value().get_scalar(); |
| 3008 value_ = Handle<Object>(isolate()->factory()->NewNumber(scalar_value)); |
3003 return; | 3009 return; |
| 3010 } |
3004 | 3011 |
3005 case kCapturedObject: | 3012 case kCapturedObject: |
3006 case kDuplicatedObject: | 3013 case kDuplicatedObject: |
3007 case kArgumentsObject: | 3014 case kArgumentsObject: |
3008 case kInvalid: | 3015 case kInvalid: |
3009 case kTagged: | 3016 case kTagged: |
3010 case kBoolBit: | 3017 case kBoolBit: |
3011 FATAL("internal error: unexpected materialization."); | 3018 FATAL("internal error: unexpected materialization."); |
3012 break; | 3019 break; |
3013 } | 3020 } |
(...skipping 27 matching lines...) Expand all Loading... |
3041 | 3048 |
3042 uint32_t TranslatedState::GetUInt32Slot(Address fp, int slot_offset) { | 3049 uint32_t TranslatedState::GetUInt32Slot(Address fp, int slot_offset) { |
3043 Address address = fp + slot_offset; | 3050 Address address = fp + slot_offset; |
3044 #if V8_TARGET_BIG_ENDIAN && V8_HOST_ARCH_64_BIT | 3051 #if V8_TARGET_BIG_ENDIAN && V8_HOST_ARCH_64_BIT |
3045 return Memory::uint32_at(address + kIntSize); | 3052 return Memory::uint32_at(address + kIntSize); |
3046 #else | 3053 #else |
3047 return Memory::uint32_at(address); | 3054 return Memory::uint32_at(address); |
3048 #endif | 3055 #endif |
3049 } | 3056 } |
3050 | 3057 |
| 3058 Float32 TranslatedState::GetFloatSlot(Address fp, int slot_offset) { |
| 3059 return Float32::FromBits(GetUInt32Slot(fp, slot_offset)); |
| 3060 } |
| 3061 |
| 3062 Float64 TranslatedState::GetDoubleSlot(Address fp, int slot_offset) { |
| 3063 return Float64::FromBits(Memory::uint64_at(fp + slot_offset)); |
| 3064 } |
3051 | 3065 |
3052 void TranslatedValue::Handlify() { | 3066 void TranslatedValue::Handlify() { |
3053 if (kind() == kTagged) { | 3067 if (kind() == kTagged) { |
3054 value_ = Handle<Object>(raw_literal(), isolate()); | 3068 value_ = Handle<Object>(raw_literal(), isolate()); |
3055 raw_literal_ = nullptr; | 3069 raw_literal_ = nullptr; |
3056 } | 3070 } |
3057 } | 3071 } |
3058 | 3072 |
3059 | 3073 |
3060 TranslatedFrame TranslatedFrame::JSFrame(BailoutId node_id, | 3074 TranslatedFrame TranslatedFrame::JSFrame(BailoutId node_id, |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3396 if (trace_file != nullptr) { | 3410 if (trace_file != nullptr) { |
3397 PrintF(trace_file, "%" V8PRIdPTR " ; %s (bool)", value, | 3411 PrintF(trace_file, "%" V8PRIdPTR " ; %s (bool)", value, |
3398 converter.NameOfCPURegister(input_reg)); | 3412 converter.NameOfCPURegister(input_reg)); |
3399 } | 3413 } |
3400 return TranslatedValue::NewBool(this, static_cast<uint32_t>(value)); | 3414 return TranslatedValue::NewBool(this, static_cast<uint32_t>(value)); |
3401 } | 3415 } |
3402 | 3416 |
3403 case Translation::FLOAT_REGISTER: { | 3417 case Translation::FLOAT_REGISTER: { |
3404 int input_reg = iterator->Next(); | 3418 int input_reg = iterator->Next(); |
3405 if (registers == nullptr) return TranslatedValue::NewInvalid(this); | 3419 if (registers == nullptr) return TranslatedValue::NewInvalid(this); |
3406 float value = registers->GetFloatRegister(input_reg); | 3420 Float32 value = registers->GetFloatRegister(input_reg); |
3407 if (trace_file != nullptr) { | 3421 if (trace_file != nullptr) { |
3408 PrintF(trace_file, "%e ; %s (float)", value, | 3422 PrintF(trace_file, "%e ; %s (float)", value.get_scalar(), |
3409 RegisterConfiguration::Crankshaft()->GetFloatRegisterName( | 3423 RegisterConfiguration::Crankshaft()->GetFloatRegisterName( |
3410 input_reg)); | 3424 input_reg)); |
3411 } | 3425 } |
3412 return TranslatedValue::NewFloat(this, value); | 3426 return TranslatedValue::NewFloat(this, value); |
3413 } | 3427 } |
3414 | 3428 |
3415 case Translation::DOUBLE_REGISTER: { | 3429 case Translation::DOUBLE_REGISTER: { |
3416 int input_reg = iterator->Next(); | 3430 int input_reg = iterator->Next(); |
3417 if (registers == nullptr) return TranslatedValue::NewInvalid(this); | 3431 if (registers == nullptr) return TranslatedValue::NewInvalid(this); |
3418 double value = registers->GetDoubleRegister(input_reg); | 3432 Float64 value = registers->GetDoubleRegister(input_reg); |
3419 if (trace_file != nullptr) { | 3433 if (trace_file != nullptr) { |
3420 PrintF(trace_file, "%e ; %s (double)", value, | 3434 PrintF(trace_file, "%e ; %s (double)", value.get_scalar(), |
3421 RegisterConfiguration::Crankshaft()->GetDoubleRegisterName( | 3435 RegisterConfiguration::Crankshaft()->GetDoubleRegisterName( |
3422 input_reg)); | 3436 input_reg)); |
3423 } | 3437 } |
3424 return TranslatedValue::NewDouble(this, value); | 3438 return TranslatedValue::NewDouble(this, value); |
3425 } | 3439 } |
3426 | 3440 |
3427 case Translation::STACK_SLOT: { | 3441 case Translation::STACK_SLOT: { |
3428 int slot_offset = | 3442 int slot_offset = |
3429 OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next()); | 3443 OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next()); |
3430 intptr_t value = *(reinterpret_cast<intptr_t*>(fp + slot_offset)); | 3444 intptr_t value = *(reinterpret_cast<intptr_t*>(fp + slot_offset)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3466 if (trace_file != nullptr) { | 3480 if (trace_file != nullptr) { |
3467 PrintF(trace_file, "%u ; (bool) [fp %c %d] ", value, | 3481 PrintF(trace_file, "%u ; (bool) [fp %c %d] ", value, |
3468 slot_offset < 0 ? '-' : '+', std::abs(slot_offset)); | 3482 slot_offset < 0 ? '-' : '+', std::abs(slot_offset)); |
3469 } | 3483 } |
3470 return TranslatedValue::NewBool(this, value); | 3484 return TranslatedValue::NewBool(this, value); |
3471 } | 3485 } |
3472 | 3486 |
3473 case Translation::FLOAT_STACK_SLOT: { | 3487 case Translation::FLOAT_STACK_SLOT: { |
3474 int slot_offset = | 3488 int slot_offset = |
3475 OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next()); | 3489 OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next()); |
3476 float value = ReadFloatValue(fp + slot_offset); | 3490 Float32 value = GetFloatSlot(fp, slot_offset); |
3477 if (trace_file != nullptr) { | 3491 if (trace_file != nullptr) { |
3478 PrintF(trace_file, "%e ; (float) [fp %c %d] ", value, | 3492 PrintF(trace_file, "%e ; (float) [fp %c %d] ", value.get_scalar(), |
3479 slot_offset < 0 ? '-' : '+', std::abs(slot_offset)); | 3493 slot_offset < 0 ? '-' : '+', std::abs(slot_offset)); |
3480 } | 3494 } |
3481 return TranslatedValue::NewFloat(this, value); | 3495 return TranslatedValue::NewFloat(this, value); |
3482 } | 3496 } |
3483 | 3497 |
3484 case Translation::DOUBLE_STACK_SLOT: { | 3498 case Translation::DOUBLE_STACK_SLOT: { |
3485 int slot_offset = | 3499 int slot_offset = |
3486 OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next()); | 3500 OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next()); |
3487 double value = ReadDoubleValue(fp + slot_offset); | 3501 Float64 value = GetDoubleSlot(fp, slot_offset); |
3488 if (trace_file != nullptr) { | 3502 if (trace_file != nullptr) { |
3489 PrintF(trace_file, "%e ; (double) [fp %c %d] ", value, | 3503 PrintF(trace_file, "%e ; (double) [fp %c %d] ", value.get_scalar(), |
3490 slot_offset < 0 ? '-' : '+', std::abs(slot_offset)); | 3504 slot_offset < 0 ? '-' : '+', std::abs(slot_offset)); |
3491 } | 3505 } |
3492 return TranslatedValue::NewDouble(this, value); | 3506 return TranslatedValue::NewDouble(this, value); |
3493 } | 3507 } |
3494 | 3508 |
3495 case Translation::LITERAL: { | 3509 case Translation::LITERAL: { |
3496 int literal_index = iterator->Next(); | 3510 int literal_index = iterator->Next(); |
3497 Object* value = literal_array->get(literal_index); | 3511 Object* value = literal_array->get(literal_index); |
3498 if (trace_file != nullptr) { | 3512 if (trace_file != nullptr) { |
3499 PrintF(trace_file, "0x%08" V8PRIxPTR " ; (literal %d) ", | 3513 PrintF(trace_file, "0x%08" V8PRIxPTR " ; (literal %d) ", |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3850 CHECK(lengthObject->ToInt32(&length)); | 3864 CHECK(lengthObject->ToInt32(&length)); |
3851 Handle<FixedArrayBase> object = | 3865 Handle<FixedArrayBase> object = |
3852 isolate_->factory()->NewFixedDoubleArray(length); | 3866 isolate_->factory()->NewFixedDoubleArray(length); |
3853 slot->value_ = object; | 3867 slot->value_ = object; |
3854 if (length > 0) { | 3868 if (length > 0) { |
3855 Handle<FixedDoubleArray> double_array = | 3869 Handle<FixedDoubleArray> double_array = |
3856 Handle<FixedDoubleArray>::cast(object); | 3870 Handle<FixedDoubleArray>::cast(object); |
3857 for (int i = 0; i < length; ++i) { | 3871 for (int i = 0; i < length; ++i) { |
3858 Handle<Object> value = materializer.FieldAt(value_index); | 3872 Handle<Object> value = materializer.FieldAt(value_index); |
3859 CHECK(value->IsNumber()); | 3873 CHECK(value->IsNumber()); |
3860 double_array->set(i, value->Number()); | 3874 if (value.is_identical_to(isolate_->factory()->hole_nan_value())) { |
| 3875 double_array->set_the_hole(isolate_, i); |
| 3876 } else { |
| 3877 double_array->set(i, value->Number()); |
| 3878 } |
3861 } | 3879 } |
3862 } | 3880 } |
3863 return object; | 3881 return object; |
3864 } | 3882 } |
3865 case STRING_TYPE: | 3883 case STRING_TYPE: |
3866 case ONE_BYTE_STRING_TYPE: | 3884 case ONE_BYTE_STRING_TYPE: |
3867 case CONS_ONE_BYTE_STRING_TYPE: | 3885 case CONS_ONE_BYTE_STRING_TYPE: |
3868 case SLICED_STRING_TYPE: | 3886 case SLICED_STRING_TYPE: |
3869 case SLICED_ONE_BYTE_STRING_TYPE: | 3887 case SLICED_ONE_BYTE_STRING_TYPE: |
3870 case EXTERNAL_STRING_TYPE: | 3888 case EXTERNAL_STRING_TYPE: |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4185 CHECK(value_info->IsMaterializedObject()); | 4203 CHECK(value_info->IsMaterializedObject()); |
4186 | 4204 |
4187 value_info->value_ = | 4205 value_info->value_ = |
4188 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 4206 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
4189 } | 4207 } |
4190 } | 4208 } |
4191 } | 4209 } |
4192 | 4210 |
4193 } // namespace internal | 4211 } // namespace internal |
4194 } // namespace v8 | 4212 } // namespace v8 |
OLD | NEW |