| 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/codegen.h" | 8 #include "src/codegen.h" |
| 9 #include "src/disasm.h" | 9 #include "src/disasm.h" |
| 10 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 } | 729 } |
| 730 } | 730 } |
| 731 | 731 |
| 732 BailoutId node_id = input_data->AstId(bailout_id_); | 732 BailoutId node_id = input_data->AstId(bailout_id_); |
| 733 ByteArray* translations = input_data->TranslationByteArray(); | 733 ByteArray* translations = input_data->TranslationByteArray(); |
| 734 unsigned translation_index = | 734 unsigned translation_index = |
| 735 input_data->TranslationIndex(bailout_id_)->value(); | 735 input_data->TranslationIndex(bailout_id_)->value(); |
| 736 | 736 |
| 737 TranslationIterator state_iterator(translations, translation_index); | 737 TranslationIterator state_iterator(translations, translation_index); |
| 738 translated_state_.Init( | 738 translated_state_.Init( |
| 739 input_->GetFramePointerAddress(), function_, &state_iterator, | 739 input_->GetFramePointerAddress(), &state_iterator, |
| 740 input_data->LiteralArray(), input_->GetRegisterValues(), | 740 input_data->LiteralArray(), input_->GetRegisterValues(), |
| 741 trace_scope_ == nullptr ? nullptr : trace_scope_->file()); | 741 trace_scope_ == nullptr ? nullptr : trace_scope_->file()); |
| 742 | 742 |
| 743 // Do the input frame to output frame(s) translation. | 743 // Do the input frame to output frame(s) translation. |
| 744 size_t count = translated_state_.frames().size(); | 744 size_t count = translated_state_.frames().size(); |
| 745 DCHECK(output_ == NULL); | 745 DCHECK(output_ == NULL); |
| 746 output_ = new FrameDescription*[count]; | 746 output_ = new FrameDescription*[count]; |
| 747 for (size_t i = 0; i < count; ++i) { | 747 for (size_t i = 0; i < count; ++i) { |
| 748 output_[i] = NULL; | 748 output_[i] = NULL; |
| 749 } | 749 } |
| (...skipping 1929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2679 raw_shared_info_ = nullptr; | 2679 raw_shared_info_ = nullptr; |
| 2680 } | 2680 } |
| 2681 for (auto& value : values_) { | 2681 for (auto& value : values_) { |
| 2682 value.Handlify(); | 2682 value.Handlify(); |
| 2683 } | 2683 } |
| 2684 } | 2684 } |
| 2685 | 2685 |
| 2686 | 2686 |
| 2687 TranslatedFrame TranslatedState::CreateNextTranslatedFrame( | 2687 TranslatedFrame TranslatedState::CreateNextTranslatedFrame( |
| 2688 TranslationIterator* iterator, FixedArray* literal_array, Address fp, | 2688 TranslationIterator* iterator, FixedArray* literal_array, Address fp, |
| 2689 JSFunction* frame_function, FILE* trace_file) { | 2689 FILE* trace_file) { |
| 2690 Translation::Opcode opcode = | 2690 Translation::Opcode opcode = |
| 2691 static_cast<Translation::Opcode>(iterator->Next()); | 2691 static_cast<Translation::Opcode>(iterator->Next()); |
| 2692 switch (opcode) { | 2692 switch (opcode) { |
| 2693 case Translation::JS_FRAME: { | 2693 case Translation::JS_FRAME: { |
| 2694 BailoutId node_id = BailoutId(iterator->Next()); | 2694 BailoutId node_id = BailoutId(iterator->Next()); |
| 2695 SharedFunctionInfo* shared_info = | 2695 SharedFunctionInfo* shared_info = |
| 2696 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); | 2696 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); |
| 2697 int height = iterator->Next(); | 2697 int height = iterator->Next(); |
| 2698 if (trace_file != nullptr) { | 2698 if (trace_file != nullptr) { |
| 2699 base::SmartArrayPointer<char> name = | 2699 base::SmartArrayPointer<char> name = |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3002 | 3002 |
| 3003 TranslatedState::TranslatedState(JavaScriptFrame* frame) | 3003 TranslatedState::TranslatedState(JavaScriptFrame* frame) |
| 3004 : isolate_(nullptr), | 3004 : isolate_(nullptr), |
| 3005 stack_frame_pointer_(nullptr), | 3005 stack_frame_pointer_(nullptr), |
| 3006 has_adapted_arguments_(false) { | 3006 has_adapted_arguments_(false) { |
| 3007 int deopt_index = Safepoint::kNoDeoptimizationIndex; | 3007 int deopt_index = Safepoint::kNoDeoptimizationIndex; |
| 3008 DeoptimizationInputData* data = | 3008 DeoptimizationInputData* data = |
| 3009 static_cast<OptimizedFrame*>(frame)->GetDeoptimizationData(&deopt_index); | 3009 static_cast<OptimizedFrame*>(frame)->GetDeoptimizationData(&deopt_index); |
| 3010 TranslationIterator it(data->TranslationByteArray(), | 3010 TranslationIterator it(data->TranslationByteArray(), |
| 3011 data->TranslationIndex(deopt_index)->value()); | 3011 data->TranslationIndex(deopt_index)->value()); |
| 3012 Init(frame->fp(), frame->function(), &it, data->LiteralArray(), | 3012 Init(frame->fp(), &it, data->LiteralArray(), nullptr /* registers */, |
| 3013 nullptr /* registers */, nullptr /* trace file */); | 3013 nullptr /* trace file */); |
| 3014 } | 3014 } |
| 3015 | 3015 |
| 3016 | 3016 |
| 3017 TranslatedState::TranslatedState() | 3017 TranslatedState::TranslatedState() |
| 3018 : isolate_(nullptr), | 3018 : isolate_(nullptr), |
| 3019 stack_frame_pointer_(nullptr), | 3019 stack_frame_pointer_(nullptr), |
| 3020 has_adapted_arguments_(false) {} | 3020 has_adapted_arguments_(false) {} |
| 3021 | 3021 |
| 3022 | 3022 |
| 3023 void TranslatedState::Init(Address input_frame_pointer, | 3023 void TranslatedState::Init(Address input_frame_pointer, |
| 3024 JSFunction* input_frame_function, | |
| 3025 TranslationIterator* iterator, | 3024 TranslationIterator* iterator, |
| 3026 FixedArray* literal_array, RegisterValues* registers, | 3025 FixedArray* literal_array, RegisterValues* registers, |
| 3027 FILE* trace_file) { | 3026 FILE* trace_file) { |
| 3028 DCHECK(frames_.empty()); | 3027 DCHECK(frames_.empty()); |
| 3029 | 3028 |
| 3030 isolate_ = literal_array->GetIsolate(); | 3029 isolate_ = literal_array->GetIsolate(); |
| 3031 // Read out the 'header' translation. | 3030 // Read out the 'header' translation. |
| 3032 Translation::Opcode opcode = | 3031 Translation::Opcode opcode = |
| 3033 static_cast<Translation::Opcode>(iterator->Next()); | 3032 static_cast<Translation::Opcode>(iterator->Next()); |
| 3034 CHECK(opcode == Translation::BEGIN); | 3033 CHECK(opcode == Translation::BEGIN); |
| 3035 | 3034 |
| 3036 int count = iterator->Next(); | 3035 int count = iterator->Next(); |
| 3037 iterator->Next(); // Drop JS frames count. | 3036 iterator->Next(); // Drop JS frames count. |
| 3038 | 3037 |
| 3039 frames_.reserve(count); | 3038 frames_.reserve(count); |
| 3040 | 3039 |
| 3041 std::stack<int> nested_counts; | 3040 std::stack<int> nested_counts; |
| 3042 | 3041 |
| 3043 // Read the frames | 3042 // Read the frames |
| 3044 for (int i = 0; i < count; i++) { | 3043 for (int i = 0; i < count; i++) { |
| 3045 // Read the frame descriptor. | 3044 // Read the frame descriptor. |
| 3046 frames_.push_back( | 3045 frames_.push_back(CreateNextTranslatedFrame( |
| 3047 CreateNextTranslatedFrame(iterator, literal_array, input_frame_pointer, | 3046 iterator, literal_array, input_frame_pointer, trace_file)); |
| 3048 input_frame_function, trace_file)); | |
| 3049 TranslatedFrame& frame = frames_.back(); | 3047 TranslatedFrame& frame = frames_.back(); |
| 3050 | 3048 |
| 3051 // Read the values. | 3049 // Read the values. |
| 3052 int values_to_process = frame.GetValueCount(); | 3050 int values_to_process = frame.GetValueCount(); |
| 3053 while (values_to_process > 0 || !nested_counts.empty()) { | 3051 while (values_to_process > 0 || !nested_counts.empty()) { |
| 3054 if (trace_file != nullptr) { | 3052 if (trace_file != nullptr) { |
| 3055 if (nested_counts.empty()) { | 3053 if (nested_counts.empty()) { |
| 3056 // For top level values, print the value number. | 3054 // For top level values, print the value number. |
| 3057 PrintF(trace_file, " %3i: ", | 3055 PrintF(trace_file, " %3i: ", |
| 3058 frame.GetValueCount() - values_to_process); | 3056 frame.GetValueCount() - values_to_process); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3397 DCHECK(value_info->IsMaterializedObject()); | 3395 DCHECK(value_info->IsMaterializedObject()); |
| 3398 | 3396 |
| 3399 value_info->value_ = | 3397 value_info->value_ = |
| 3400 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 3398 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
| 3401 } | 3399 } |
| 3402 } | 3400 } |
| 3403 } | 3401 } |
| 3404 | 3402 |
| 3405 } // namespace internal | 3403 } // namespace internal |
| 3406 } // namespace v8 | 3404 } // namespace v8 |
| OLD | NEW |