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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 } | 940 } |
941 | 941 |
942 // For the bottommost output frame the context can be gotten from the input | 942 // For the bottommost output frame the context can be gotten from the input |
943 // frame. For all subsequent output frames it can be gotten from the function | 943 // frame. For all subsequent output frames it can be gotten from the function |
944 // so long as we don't inline functions that need local contexts. | 944 // so long as we don't inline functions that need local contexts. |
945 Register context_reg = JavaScriptFrame::context_register(); | 945 Register context_reg = JavaScriptFrame::context_register(); |
946 output_offset -= kPointerSize; | 946 output_offset -= kPointerSize; |
947 input_offset -= kPointerSize; | 947 input_offset -= kPointerSize; |
948 // Read the context from the translations. | 948 // Read the context from the translations. |
949 Object* context = value_iterator->GetRawValue(); | 949 Object* context = value_iterator->GetRawValue(); |
950 // The context should not be a placeholder for a materialized object. | |
951 CHECK(context != isolate_->heap()->arguments_marker()); | |
952 if (context == isolate_->heap()->undefined_value()) { | 950 if (context == isolate_->heap()->undefined_value()) { |
953 // If the context was optimized away, just use the context from | 951 // If the context was optimized away, just use the context from |
954 // the activation. This should only apply to Crankshaft code. | 952 // the activation. This should only apply to Crankshaft code. |
955 CHECK(!compiled_code_->is_turbofanned()); | 953 CHECK(!compiled_code_->is_turbofanned()); |
956 context = | 954 context = |
957 is_bottommost | 955 is_bottommost |
958 ? reinterpret_cast<Object*>(input_->GetFrameSlot(input_offset)) | 956 ? reinterpret_cast<Object*>(input_->GetFrameSlot(input_offset)) |
959 : function->context(); | 957 : function->context(); |
960 } | 958 } |
961 value = reinterpret_cast<intptr_t>(context); | 959 value = reinterpret_cast<intptr_t>(context); |
962 output_frame->SetContext(value); | 960 output_frame->SetContext(value); |
963 if (is_topmost) output_frame->SetRegister(context_reg.code(), value); | 961 if (is_topmost) output_frame->SetRegister(context_reg.code(), value); |
964 WriteValueToOutput(context, input_index, frame_index, output_offset, | 962 WriteValueToOutput(context, input_index, frame_index, output_offset, |
965 "context "); | 963 "context "); |
| 964 if (context == isolate_->heap()->arguments_marker()) { |
| 965 Address output_address = |
| 966 reinterpret_cast<Address>(output_[frame_index]->GetTop()) + |
| 967 output_offset; |
| 968 values_to_materialize_.push_back({output_address, value_iterator}); |
| 969 } |
966 value_iterator++; | 970 value_iterator++; |
967 input_index++; | 971 input_index++; |
968 | 972 |
969 // The function was mentioned explicitly in the BEGIN_FRAME. | 973 // The function was mentioned explicitly in the BEGIN_FRAME. |
970 output_offset -= kPointerSize; | 974 output_offset -= kPointerSize; |
971 input_offset -= kPointerSize; | 975 input_offset -= kPointerSize; |
972 value = reinterpret_cast<intptr_t>(function); | 976 value = reinterpret_cast<intptr_t>(function); |
973 // The function for the bottommost output frame should also agree with the | 977 // The function for the bottommost output frame should also agree with the |
974 // input frame. | 978 // input frame. |
975 DCHECK(!is_bottommost || input_->GetFrameSlot(input_offset) == value); | 979 DCHECK(!is_bottommost || input_->GetFrameSlot(input_offset) == value); |
(...skipping 2509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3485 object->set_elements(FixedArrayBase::cast(*elements)); | 3489 object->set_elements(FixedArrayBase::cast(*elements)); |
3486 object->set_length(*length); | 3490 object->set_length(*length); |
3487 return object; | 3491 return object; |
3488 } | 3492 } |
3489 case FIXED_ARRAY_TYPE: { | 3493 case FIXED_ARRAY_TYPE: { |
3490 Handle<Object> lengthObject = MaterializeAt(frame_index, value_index); | 3494 Handle<Object> lengthObject = MaterializeAt(frame_index, value_index); |
3491 int32_t length = 0; | 3495 int32_t length = 0; |
3492 CHECK(lengthObject->ToInt32(&length)); | 3496 CHECK(lengthObject->ToInt32(&length)); |
3493 Handle<FixedArray> object = | 3497 Handle<FixedArray> object = |
3494 isolate_->factory()->NewFixedArray(length); | 3498 isolate_->factory()->NewFixedArray(length); |
| 3499 // We need to set the map, because the fixed array we are |
| 3500 // materializing could be a context or an arguments object, |
| 3501 // in which case we must retain that information. |
| 3502 object->set_map(*map); |
3495 slot->value_ = object; | 3503 slot->value_ = object; |
3496 for (int i = 0; i < length; ++i) { | 3504 for (int i = 0; i < length; ++i) { |
3497 Handle<Object> value = MaterializeAt(frame_index, value_index); | 3505 Handle<Object> value = MaterializeAt(frame_index, value_index); |
3498 object->set(i, *value); | 3506 object->set(i, *value); |
3499 } | 3507 } |
3500 return object; | 3508 return object; |
3501 } | 3509 } |
3502 case FIXED_DOUBLE_ARRAY_TYPE: { | 3510 case FIXED_DOUBLE_ARRAY_TYPE: { |
| 3511 DCHECK_EQ(*map, isolate_->heap()->fixed_double_array_map()); |
3503 Handle<Object> lengthObject = MaterializeAt(frame_index, value_index); | 3512 Handle<Object> lengthObject = MaterializeAt(frame_index, value_index); |
3504 int32_t length = 0; | 3513 int32_t length = 0; |
3505 CHECK(lengthObject->ToInt32(&length)); | 3514 CHECK(lengthObject->ToInt32(&length)); |
3506 Handle<FixedArrayBase> object = | 3515 Handle<FixedArrayBase> object = |
3507 isolate_->factory()->NewFixedDoubleArray(length); | 3516 isolate_->factory()->NewFixedDoubleArray(length); |
3508 slot->value_ = object; | 3517 slot->value_ = object; |
3509 if (length > 0) { | 3518 if (length > 0) { |
3510 Handle<FixedDoubleArray> double_array = | 3519 Handle<FixedDoubleArray> double_array = |
3511 Handle<FixedDoubleArray>::cast(object); | 3520 Handle<FixedDoubleArray>::cast(object); |
3512 for (int i = 0; i < length; ++i) { | 3521 for (int i = 0; i < length; ++i) { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3700 DCHECK(value_info->IsMaterializedObject()); | 3709 DCHECK(value_info->IsMaterializedObject()); |
3701 | 3710 |
3702 value_info->value_ = | 3711 value_info->value_ = |
3703 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 3712 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
3704 } | 3713 } |
3705 } | 3714 } |
3706 } | 3715 } |
3707 | 3716 |
3708 } // namespace internal | 3717 } // namespace internal |
3709 } // namespace v8 | 3718 } // namespace v8 |
OLD | NEW |