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 "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/ast/prettyprinter.h" | 8 #include "src/ast/prettyprinter.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/disasm.h" | 10 #include "src/disasm.h" |
(...skipping 2433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2444 buffer_->Add(UINT32_REGISTER, zone()); | 2444 buffer_->Add(UINT32_REGISTER, zone()); |
2445 buffer_->Add(reg.code(), zone()); | 2445 buffer_->Add(reg.code(), zone()); |
2446 } | 2446 } |
2447 | 2447 |
2448 | 2448 |
2449 void Translation::StoreBoolRegister(Register reg) { | 2449 void Translation::StoreBoolRegister(Register reg) { |
2450 buffer_->Add(BOOL_REGISTER, zone()); | 2450 buffer_->Add(BOOL_REGISTER, zone()); |
2451 buffer_->Add(reg.code(), zone()); | 2451 buffer_->Add(reg.code(), zone()); |
2452 } | 2452 } |
2453 | 2453 |
| 2454 void Translation::StoreFloatRegister(FloatRegister reg) { |
| 2455 buffer_->Add(FLOAT_REGISTER, zone()); |
| 2456 buffer_->Add(reg.code(), zone()); |
| 2457 } |
2454 | 2458 |
2455 void Translation::StoreDoubleRegister(DoubleRegister reg) { | 2459 void Translation::StoreDoubleRegister(DoubleRegister reg) { |
2456 buffer_->Add(DOUBLE_REGISTER, zone()); | 2460 buffer_->Add(DOUBLE_REGISTER, zone()); |
2457 buffer_->Add(reg.code(), zone()); | 2461 buffer_->Add(reg.code(), zone()); |
2458 } | 2462 } |
2459 | 2463 |
2460 | 2464 |
2461 void Translation::StoreStackSlot(int index) { | 2465 void Translation::StoreStackSlot(int index) { |
2462 buffer_->Add(STACK_SLOT, zone()); | 2466 buffer_->Add(STACK_SLOT, zone()); |
2463 buffer_->Add(index, zone()); | 2467 buffer_->Add(index, zone()); |
(...skipping 10 matching lines...) Expand all Loading... |
2474 buffer_->Add(UINT32_STACK_SLOT, zone()); | 2478 buffer_->Add(UINT32_STACK_SLOT, zone()); |
2475 buffer_->Add(index, zone()); | 2479 buffer_->Add(index, zone()); |
2476 } | 2480 } |
2477 | 2481 |
2478 | 2482 |
2479 void Translation::StoreBoolStackSlot(int index) { | 2483 void Translation::StoreBoolStackSlot(int index) { |
2480 buffer_->Add(BOOL_STACK_SLOT, zone()); | 2484 buffer_->Add(BOOL_STACK_SLOT, zone()); |
2481 buffer_->Add(index, zone()); | 2485 buffer_->Add(index, zone()); |
2482 } | 2486 } |
2483 | 2487 |
| 2488 void Translation::StoreFloatStackSlot(int index) { |
| 2489 buffer_->Add(FLOAT_STACK_SLOT, zone()); |
| 2490 buffer_->Add(index, zone()); |
| 2491 } |
2484 | 2492 |
2485 void Translation::StoreDoubleStackSlot(int index) { | 2493 void Translation::StoreDoubleStackSlot(int index) { |
2486 buffer_->Add(DOUBLE_STACK_SLOT, zone()); | 2494 buffer_->Add(DOUBLE_STACK_SLOT, zone()); |
2487 buffer_->Add(index, zone()); | 2495 buffer_->Add(index, zone()); |
2488 } | 2496 } |
2489 | 2497 |
2490 | 2498 |
2491 void Translation::StoreLiteral(int literal_id) { | 2499 void Translation::StoreLiteral(int literal_id) { |
2492 buffer_->Add(LITERAL, zone()); | 2500 buffer_->Add(LITERAL, zone()); |
2493 buffer_->Add(literal_id, zone()); | 2501 buffer_->Add(literal_id, zone()); |
(...skipping 20 matching lines...) Expand all Loading... |
2514 switch (opcode) { | 2522 switch (opcode) { |
2515 case GETTER_STUB_FRAME: | 2523 case GETTER_STUB_FRAME: |
2516 case SETTER_STUB_FRAME: | 2524 case SETTER_STUB_FRAME: |
2517 case DUPLICATED_OBJECT: | 2525 case DUPLICATED_OBJECT: |
2518 case ARGUMENTS_OBJECT: | 2526 case ARGUMENTS_OBJECT: |
2519 case CAPTURED_OBJECT: | 2527 case CAPTURED_OBJECT: |
2520 case REGISTER: | 2528 case REGISTER: |
2521 case INT32_REGISTER: | 2529 case INT32_REGISTER: |
2522 case UINT32_REGISTER: | 2530 case UINT32_REGISTER: |
2523 case BOOL_REGISTER: | 2531 case BOOL_REGISTER: |
| 2532 case FLOAT_REGISTER: |
2524 case DOUBLE_REGISTER: | 2533 case DOUBLE_REGISTER: |
2525 case STACK_SLOT: | 2534 case STACK_SLOT: |
2526 case INT32_STACK_SLOT: | 2535 case INT32_STACK_SLOT: |
2527 case UINT32_STACK_SLOT: | 2536 case UINT32_STACK_SLOT: |
2528 case BOOL_STACK_SLOT: | 2537 case BOOL_STACK_SLOT: |
| 2538 case FLOAT_STACK_SLOT: |
2529 case DOUBLE_STACK_SLOT: | 2539 case DOUBLE_STACK_SLOT: |
2530 case LITERAL: | 2540 case LITERAL: |
2531 case COMPILED_STUB_FRAME: | 2541 case COMPILED_STUB_FRAME: |
2532 case TAIL_CALLER_FRAME: | 2542 case TAIL_CALLER_FRAME: |
2533 return 1; | 2543 return 1; |
2534 case BEGIN: | 2544 case BEGIN: |
2535 case ARGUMENTS_ADAPTOR_FRAME: | 2545 case ARGUMENTS_ADAPTOR_FRAME: |
2536 case CONSTRUCT_STUB_FRAME: | 2546 case CONSTRUCT_STUB_FRAME: |
2537 return 2; | 2547 return 2; |
2538 case JS_FRAME: | 2548 case JS_FRAME: |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2809 // static | 2819 // static |
2810 TranslatedValue TranslatedValue::NewDuplicateObject(TranslatedState* container, | 2820 TranslatedValue TranslatedValue::NewDuplicateObject(TranslatedState* container, |
2811 int id) { | 2821 int id) { |
2812 TranslatedValue slot(container, kDuplicatedObject); | 2822 TranslatedValue slot(container, kDuplicatedObject); |
2813 slot.materialization_info_ = {id, -1}; | 2823 slot.materialization_info_ = {id, -1}; |
2814 return slot; | 2824 return slot; |
2815 } | 2825 } |
2816 | 2826 |
2817 | 2827 |
2818 // static | 2828 // static |
| 2829 TranslatedValue TranslatedValue::NewFloat(TranslatedState* container, |
| 2830 float value) { |
| 2831 TranslatedValue slot(container, kFloat); |
| 2832 slot.float_value_ = value; |
| 2833 return slot; |
| 2834 } |
| 2835 |
| 2836 // static |
2819 TranslatedValue TranslatedValue::NewDouble(TranslatedState* container, | 2837 TranslatedValue TranslatedValue::NewDouble(TranslatedState* container, |
2820 double value) { | 2838 double value) { |
2821 TranslatedValue slot(container, kDouble); | 2839 TranslatedValue slot(container, kDouble); |
2822 slot.double_value_ = value; | 2840 slot.double_value_ = value; |
2823 return slot; | 2841 return slot; |
2824 } | 2842 } |
2825 | 2843 |
2826 | 2844 |
2827 // static | 2845 // static |
2828 TranslatedValue TranslatedValue::NewInt32(TranslatedState* container, | 2846 TranslatedValue TranslatedValue::NewInt32(TranslatedState* container, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2879 DCHECK_EQ(kInt32, kind()); | 2897 DCHECK_EQ(kInt32, kind()); |
2880 return int32_value_; | 2898 return int32_value_; |
2881 } | 2899 } |
2882 | 2900 |
2883 | 2901 |
2884 uint32_t TranslatedValue::uint32_value() const { | 2902 uint32_t TranslatedValue::uint32_value() const { |
2885 DCHECK(kind() == kUInt32 || kind() == kBoolBit); | 2903 DCHECK(kind() == kUInt32 || kind() == kBoolBit); |
2886 return uint32_value_; | 2904 return uint32_value_; |
2887 } | 2905 } |
2888 | 2906 |
| 2907 float TranslatedValue::float_value() const { |
| 2908 DCHECK_EQ(kFloat, kind()); |
| 2909 return float_value_; |
| 2910 } |
2889 | 2911 |
2890 double TranslatedValue::double_value() const { | 2912 double TranslatedValue::double_value() const { |
2891 DCHECK_EQ(kDouble, kind()); | 2913 DCHECK_EQ(kDouble, kind()); |
2892 return double_value_; | 2914 return double_value_; |
2893 } | 2915 } |
2894 | 2916 |
2895 | 2917 |
2896 int TranslatedValue::object_length() const { | 2918 int TranslatedValue::object_length() const { |
2897 DCHECK(kind() == kArgumentsObject || kind() == kCapturedObject); | 2919 DCHECK(kind() == kArgumentsObject || kind() == kCapturedObject); |
2898 return materialization_info_.length_; | 2920 return materialization_info_.length_; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2957 Handle<Object> result; | 2979 Handle<Object> result; |
2958 // If we already have a value, then get it. | 2980 // If we already have a value, then get it. |
2959 if (value_.ToHandle(&result)) return result; | 2981 if (value_.ToHandle(&result)) return result; |
2960 | 2982 |
2961 // Otherwise we have to materialize. | 2983 // Otherwise we have to materialize. |
2962 switch (kind()) { | 2984 switch (kind()) { |
2963 case TranslatedValue::kTagged: | 2985 case TranslatedValue::kTagged: |
2964 case TranslatedValue::kInt32: | 2986 case TranslatedValue::kInt32: |
2965 case TranslatedValue::kUInt32: | 2987 case TranslatedValue::kUInt32: |
2966 case TranslatedValue::kBoolBit: | 2988 case TranslatedValue::kBoolBit: |
| 2989 case TranslatedValue::kFloat: |
2967 case TranslatedValue::kDouble: { | 2990 case TranslatedValue::kDouble: { |
2968 MaterializeSimple(); | 2991 MaterializeSimple(); |
2969 return value_.ToHandleChecked(); | 2992 return value_.ToHandleChecked(); |
2970 } | 2993 } |
2971 | 2994 |
2972 case TranslatedValue::kArgumentsObject: | 2995 case TranslatedValue::kArgumentsObject: |
2973 case TranslatedValue::kCapturedObject: | 2996 case TranslatedValue::kCapturedObject: |
2974 case TranslatedValue::kDuplicatedObject: | 2997 case TranslatedValue::kDuplicatedObject: |
2975 return container_->MaterializeObjectAt(object_index()); | 2998 return container_->MaterializeObjectAt(object_index()); |
2976 | 2999 |
(...skipping 21 matching lines...) Expand all Loading... |
2998 switch (kind()) { | 3021 switch (kind()) { |
2999 case kInt32: { | 3022 case kInt32: { |
3000 value_ = Handle<Object>(isolate()->factory()->NewNumber(int32_value())); | 3023 value_ = Handle<Object>(isolate()->factory()->NewNumber(int32_value())); |
3001 return; | 3024 return; |
3002 } | 3025 } |
3003 | 3026 |
3004 case kUInt32: | 3027 case kUInt32: |
3005 value_ = Handle<Object>(isolate()->factory()->NewNumber(uint32_value())); | 3028 value_ = Handle<Object>(isolate()->factory()->NewNumber(uint32_value())); |
3006 return; | 3029 return; |
3007 | 3030 |
| 3031 case kFloat: |
| 3032 value_ = Handle<Object>(isolate()->factory()->NewNumber(float_value())); |
| 3033 return; |
| 3034 |
3008 case kDouble: | 3035 case kDouble: |
3009 value_ = Handle<Object>(isolate()->factory()->NewNumber(double_value())); | 3036 value_ = Handle<Object>(isolate()->factory()->NewNumber(double_value())); |
3010 return; | 3037 return; |
3011 | 3038 |
3012 case kCapturedObject: | 3039 case kCapturedObject: |
3013 case kDuplicatedObject: | 3040 case kDuplicatedObject: |
3014 case kArgumentsObject: | 3041 case kArgumentsObject: |
3015 case kInvalid: | 3042 case kInvalid: |
3016 case kTagged: | 3043 case kTagged: |
3017 case kBoolBit: | 3044 case kBoolBit: |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3274 } | 3301 } |
3275 | 3302 |
3276 case Translation::BEGIN: | 3303 case Translation::BEGIN: |
3277 case Translation::DUPLICATED_OBJECT: | 3304 case Translation::DUPLICATED_OBJECT: |
3278 case Translation::ARGUMENTS_OBJECT: | 3305 case Translation::ARGUMENTS_OBJECT: |
3279 case Translation::CAPTURED_OBJECT: | 3306 case Translation::CAPTURED_OBJECT: |
3280 case Translation::REGISTER: | 3307 case Translation::REGISTER: |
3281 case Translation::INT32_REGISTER: | 3308 case Translation::INT32_REGISTER: |
3282 case Translation::UINT32_REGISTER: | 3309 case Translation::UINT32_REGISTER: |
3283 case Translation::BOOL_REGISTER: | 3310 case Translation::BOOL_REGISTER: |
| 3311 case Translation::FLOAT_REGISTER: |
3284 case Translation::DOUBLE_REGISTER: | 3312 case Translation::DOUBLE_REGISTER: |
3285 case Translation::STACK_SLOT: | 3313 case Translation::STACK_SLOT: |
3286 case Translation::INT32_STACK_SLOT: | 3314 case Translation::INT32_STACK_SLOT: |
3287 case Translation::UINT32_STACK_SLOT: | 3315 case Translation::UINT32_STACK_SLOT: |
3288 case Translation::BOOL_STACK_SLOT: | 3316 case Translation::BOOL_STACK_SLOT: |
| 3317 case Translation::FLOAT_STACK_SLOT: |
3289 case Translation::DOUBLE_STACK_SLOT: | 3318 case Translation::DOUBLE_STACK_SLOT: |
3290 case Translation::LITERAL: | 3319 case Translation::LITERAL: |
3291 break; | 3320 break; |
3292 } | 3321 } |
3293 FATAL("We should never get here - unexpected deopt info."); | 3322 FATAL("We should never get here - unexpected deopt info."); |
3294 return TranslatedFrame::InvalidFrame(); | 3323 return TranslatedFrame::InvalidFrame(); |
3295 } | 3324 } |
3296 | 3325 |
3297 | 3326 |
3298 // static | 3327 // static |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3405 int input_reg = iterator->Next(); | 3434 int input_reg = iterator->Next(); |
3406 if (registers == nullptr) return TranslatedValue::NewInvalid(this); | 3435 if (registers == nullptr) return TranslatedValue::NewInvalid(this); |
3407 intptr_t value = registers->GetRegister(input_reg); | 3436 intptr_t value = registers->GetRegister(input_reg); |
3408 if (trace_file != nullptr) { | 3437 if (trace_file != nullptr) { |
3409 PrintF(trace_file, "%" V8PRIdPTR " ; %s (bool)", value, | 3438 PrintF(trace_file, "%" V8PRIdPTR " ; %s (bool)", value, |
3410 converter.NameOfCPURegister(input_reg)); | 3439 converter.NameOfCPURegister(input_reg)); |
3411 } | 3440 } |
3412 return TranslatedValue::NewBool(this, static_cast<uint32_t>(value)); | 3441 return TranslatedValue::NewBool(this, static_cast<uint32_t>(value)); |
3413 } | 3442 } |
3414 | 3443 |
| 3444 case Translation::FLOAT_REGISTER: { |
| 3445 int input_reg = iterator->Next(); |
| 3446 if (registers == nullptr) return TranslatedValue::NewInvalid(this); |
| 3447 float value = registers->GetFloatRegister(input_reg); |
| 3448 if (trace_file != nullptr) { |
| 3449 PrintF(trace_file, "%e ; %s (float)", value, |
| 3450 FloatRegister::from_code(input_reg).ToString()); |
| 3451 } |
| 3452 return TranslatedValue::NewFloat(this, value); |
| 3453 } |
| 3454 |
3415 case Translation::DOUBLE_REGISTER: { | 3455 case Translation::DOUBLE_REGISTER: { |
3416 int input_reg = iterator->Next(); | 3456 int input_reg = iterator->Next(); |
3417 if (registers == nullptr) return TranslatedValue::NewInvalid(this); | 3457 if (registers == nullptr) return TranslatedValue::NewInvalid(this); |
3418 double value = registers->GetDoubleRegister(input_reg); | 3458 double value = registers->GetDoubleRegister(input_reg); |
3419 if (trace_file != nullptr) { | 3459 if (trace_file != nullptr) { |
3420 PrintF(trace_file, "%e ; %s (bool)", value, | 3460 PrintF(trace_file, "%e ; %s (double)", value, |
3421 DoubleRegister::from_code(input_reg).ToString()); | 3461 DoubleRegister::from_code(input_reg).ToString()); |
3422 } | 3462 } |
3423 return TranslatedValue::NewDouble(this, value); | 3463 return TranslatedValue::NewDouble(this, value); |
3424 } | 3464 } |
3425 | 3465 |
3426 case Translation::STACK_SLOT: { | 3466 case Translation::STACK_SLOT: { |
3427 int slot_offset = | 3467 int slot_offset = |
3428 OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next()); | 3468 OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next()); |
3429 intptr_t value = *(reinterpret_cast<intptr_t*>(fp + slot_offset)); | 3469 intptr_t value = *(reinterpret_cast<intptr_t*>(fp + slot_offset)); |
3430 if (trace_file != nullptr) { | 3470 if (trace_file != nullptr) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3462 int slot_offset = | 3502 int slot_offset = |
3463 OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next()); | 3503 OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next()); |
3464 uint32_t value = GetUInt32Slot(fp, slot_offset); | 3504 uint32_t value = GetUInt32Slot(fp, slot_offset); |
3465 if (trace_file != nullptr) { | 3505 if (trace_file != nullptr) { |
3466 PrintF(trace_file, "%u ; (bool) [fp %c %d] ", value, | 3506 PrintF(trace_file, "%u ; (bool) [fp %c %d] ", value, |
3467 slot_offset < 0 ? '-' : '+', std::abs(slot_offset)); | 3507 slot_offset < 0 ? '-' : '+', std::abs(slot_offset)); |
3468 } | 3508 } |
3469 return TranslatedValue::NewBool(this, value); | 3509 return TranslatedValue::NewBool(this, value); |
3470 } | 3510 } |
3471 | 3511 |
| 3512 case Translation::FLOAT_STACK_SLOT: { |
| 3513 int slot_offset = |
| 3514 OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next()); |
| 3515 float value = ReadFloatValue(fp + slot_offset); |
| 3516 if (trace_file != nullptr) { |
| 3517 PrintF(trace_file, "%e ; (float) [fp %c %d] ", value, |
| 3518 slot_offset < 0 ? '-' : '+', std::abs(slot_offset)); |
| 3519 } |
| 3520 return TranslatedValue::NewFloat(this, value); |
| 3521 } |
| 3522 |
3472 case Translation::DOUBLE_STACK_SLOT: { | 3523 case Translation::DOUBLE_STACK_SLOT: { |
3473 int slot_offset = | 3524 int slot_offset = |
3474 OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next()); | 3525 OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next()); |
3475 double value = ReadDoubleValue(fp + slot_offset); | 3526 double value = ReadDoubleValue(fp + slot_offset); |
3476 if (trace_file != nullptr) { | 3527 if (trace_file != nullptr) { |
3477 PrintF(trace_file, "%e ; (double) [fp %c %d] ", value, | 3528 PrintF(trace_file, "%e ; (double) [fp %c %d] ", value, |
3478 slot_offset < 0 ? '-' : '+', std::abs(slot_offset)); | 3529 slot_offset < 0 ? '-' : '+', std::abs(slot_offset)); |
3479 } | 3530 } |
3480 return TranslatedValue::NewDouble(this, value); | 3531 return TranslatedValue::NewDouble(this, value); |
3481 } | 3532 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3609 CHECK(static_cast<size_t>(*value_index) < frame->values_.size()); | 3660 CHECK(static_cast<size_t>(*value_index) < frame->values_.size()); |
3610 | 3661 |
3611 TranslatedValue* slot = &(frame->values_[*value_index]); | 3662 TranslatedValue* slot = &(frame->values_[*value_index]); |
3612 (*value_index)++; | 3663 (*value_index)++; |
3613 | 3664 |
3614 switch (slot->kind()) { | 3665 switch (slot->kind()) { |
3615 case TranslatedValue::kTagged: | 3666 case TranslatedValue::kTagged: |
3616 case TranslatedValue::kInt32: | 3667 case TranslatedValue::kInt32: |
3617 case TranslatedValue::kUInt32: | 3668 case TranslatedValue::kUInt32: |
3618 case TranslatedValue::kBoolBit: | 3669 case TranslatedValue::kBoolBit: |
| 3670 case TranslatedValue::kFloat: |
3619 case TranslatedValue::kDouble: { | 3671 case TranslatedValue::kDouble: { |
3620 slot->MaterializeSimple(); | 3672 slot->MaterializeSimple(); |
3621 Handle<Object> value = slot->GetValue(); | 3673 Handle<Object> value = slot->GetValue(); |
3622 if (value->IsMutableHeapNumber()) { | 3674 if (value->IsMutableHeapNumber()) { |
3623 HeapNumber::cast(*value)->set_map(isolate()->heap()->heap_number_map()); | 3675 HeapNumber::cast(*value)->set_map(isolate()->heap()->heap_number_map()); |
3624 } | 3676 } |
3625 return value; | 3677 return value; |
3626 } | 3678 } |
3627 | 3679 |
3628 case TranslatedValue::kArgumentsObject: { | 3680 case TranslatedValue::kArgumentsObject: { |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3962 CHECK(value_info->IsMaterializedObject()); | 4014 CHECK(value_info->IsMaterializedObject()); |
3963 | 4015 |
3964 value_info->value_ = | 4016 value_info->value_ = |
3965 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 4017 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
3966 } | 4018 } |
3967 } | 4019 } |
3968 } | 4020 } |
3969 | 4021 |
3970 } // namespace internal | 4022 } // namespace internal |
3971 } // namespace v8 | 4023 } // namespace v8 |
OLD | NEW |