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> |
| 8 |
7 #include "src/accessors.h" | 9 #include "src/accessors.h" |
8 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
9 #include "src/codegen.h" | 11 #include "src/codegen.h" |
10 #include "src/disasm.h" | 12 #include "src/disasm.h" |
11 #include "src/frames-inl.h" | 13 #include "src/frames-inl.h" |
12 #include "src/full-codegen/full-codegen.h" | 14 #include "src/full-codegen/full-codegen.h" |
13 #include "src/global-handles.h" | 15 #include "src/global-handles.h" |
14 #include "src/interpreter/interpreter.h" | 16 #include "src/interpreter/interpreter.h" |
15 #include "src/macro-assembler.h" | 17 #include "src/macro-assembler.h" |
16 #include "src/tracing/trace-event.h" | 18 #include "src/tracing/trace-event.h" |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 // We also make space for the exception itself. | 869 // We also make space for the exception itself. |
868 height_in_bytes = (height + 1) * kPointerSize; | 870 height_in_bytes = (height + 1) * kPointerSize; |
869 CHECK(is_topmost); | 871 CHECK(is_topmost); |
870 } | 872 } |
871 | 873 |
872 JSFunction* function = JSFunction::cast(value_iterator->GetRawValue()); | 874 JSFunction* function = JSFunction::cast(value_iterator->GetRawValue()); |
873 value_iterator++; | 875 value_iterator++; |
874 input_index++; | 876 input_index++; |
875 if (trace_scope_ != NULL) { | 877 if (trace_scope_ != NULL) { |
876 PrintF(trace_scope_->file(), " translating frame "); | 878 PrintF(trace_scope_->file(), " translating frame "); |
877 base::SmartArrayPointer<char> name = shared->DebugName()->ToCString(); | 879 std::unique_ptr<char[]> name = shared->DebugName()->ToCString(); |
878 PrintF(trace_scope_->file(), "%s", name.get()); | 880 PrintF(trace_scope_->file(), "%s", name.get()); |
879 PrintF(trace_scope_->file(), " => node=%d, height=%d%s\n", node_id.ToInt(), | 881 PrintF(trace_scope_->file(), " => node=%d, height=%d%s\n", node_id.ToInt(), |
880 height_in_bytes, goto_catch_handler ? " (throw)" : ""); | 882 height_in_bytes, goto_catch_handler ? " (throw)" : ""); |
881 } | 883 } |
882 | 884 |
883 // The 'fixed' part of the frame consists of the incoming parameters and | 885 // The 'fixed' part of the frame consists of the incoming parameters and |
884 // the part described by JavaScriptFrameConstants. | 886 // the part described by JavaScriptFrameConstants. |
885 unsigned fixed_frame_size = ComputeJavascriptFixedSize(shared); | 887 unsigned fixed_frame_size = ComputeJavascriptFixedSize(shared); |
886 unsigned output_frame_size = height_in_bytes + fixed_frame_size; | 888 unsigned output_frame_size = height_in_bytes + fixed_frame_size; |
887 | 889 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 int input_index = 0; | 1088 int input_index = 0; |
1087 | 1089 |
1088 int bytecode_offset = translated_frame->node_id().ToInt(); | 1090 int bytecode_offset = translated_frame->node_id().ToInt(); |
1089 unsigned height = translated_frame->height(); | 1091 unsigned height = translated_frame->height(); |
1090 unsigned height_in_bytes = height * kPointerSize; | 1092 unsigned height_in_bytes = height * kPointerSize; |
1091 JSFunction* function = JSFunction::cast(value_iterator->GetRawValue()); | 1093 JSFunction* function = JSFunction::cast(value_iterator->GetRawValue()); |
1092 value_iterator++; | 1094 value_iterator++; |
1093 input_index++; | 1095 input_index++; |
1094 if (trace_scope_ != NULL) { | 1096 if (trace_scope_ != NULL) { |
1095 PrintF(trace_scope_->file(), " translating interpreted frame "); | 1097 PrintF(trace_scope_->file(), " translating interpreted frame "); |
1096 base::SmartArrayPointer<char> name = shared->DebugName()->ToCString(); | 1098 std::unique_ptr<char[]> name = shared->DebugName()->ToCString(); |
1097 PrintF(trace_scope_->file(), "%s", name.get()); | 1099 PrintF(trace_scope_->file(), "%s", name.get()); |
1098 PrintF(trace_scope_->file(), " => bytecode_offset=%d, height=%d%s\n", | 1100 PrintF(trace_scope_->file(), " => bytecode_offset=%d, height=%d%s\n", |
1099 bytecode_offset, height_in_bytes, | 1101 bytecode_offset, height_in_bytes, |
1100 goto_catch_handler ? " (throw)" : ""); | 1102 goto_catch_handler ? " (throw)" : ""); |
1101 } | 1103 } |
1102 if (goto_catch_handler) { | 1104 if (goto_catch_handler) { |
1103 bytecode_offset = catch_handler_pc_offset_; | 1105 bytecode_offset = catch_handler_pc_offset_; |
1104 } | 1106 } |
1105 | 1107 |
1106 // The 'fixed' part of the frame consists of the incoming parameters and | 1108 // The 'fixed' part of the frame consists of the incoming parameters and |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 void Deoptimizer::DoComputeTailCallerFrame(TranslatedFrame* translated_frame, | 1433 void Deoptimizer::DoComputeTailCallerFrame(TranslatedFrame* translated_frame, |
1432 int frame_index) { | 1434 int frame_index) { |
1433 SharedFunctionInfo* shared = translated_frame->raw_shared_info(); | 1435 SharedFunctionInfo* shared = translated_frame->raw_shared_info(); |
1434 | 1436 |
1435 bool is_bottommost = (0 == frame_index); | 1437 bool is_bottommost = (0 == frame_index); |
1436 // Tail caller frame can't be topmost. | 1438 // Tail caller frame can't be topmost. |
1437 CHECK_NE(output_count_ - 1, frame_index); | 1439 CHECK_NE(output_count_ - 1, frame_index); |
1438 | 1440 |
1439 if (trace_scope_ != NULL) { | 1441 if (trace_scope_ != NULL) { |
1440 PrintF(trace_scope_->file(), " translating tail caller frame "); | 1442 PrintF(trace_scope_->file(), " translating tail caller frame "); |
1441 base::SmartArrayPointer<char> name = shared->DebugName()->ToCString(); | 1443 std::unique_ptr<char[]> name = shared->DebugName()->ToCString(); |
1442 PrintF(trace_scope_->file(), "%s\n", name.get()); | 1444 PrintF(trace_scope_->file(), "%s\n", name.get()); |
1443 } | 1445 } |
1444 | 1446 |
1445 if (!is_bottommost) return; | 1447 if (!is_bottommost) return; |
1446 | 1448 |
1447 // Drop arguments adaptor frame below current frame if it exsits. | 1449 // Drop arguments adaptor frame below current frame if it exsits. |
1448 Address fp_address = input_->GetFramePointerAddress(); | 1450 Address fp_address = input_->GetFramePointerAddress(); |
1449 Address adaptor_fp_address = | 1451 Address adaptor_fp_address = |
1450 Memory::Address_at(fp_address + CommonFrameConstants::kCallerFPOffset); | 1452 Memory::Address_at(fp_address + CommonFrameConstants::kCallerFPOffset); |
1451 | 1453 |
(...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3178 FILE* trace_file) { | 3180 FILE* trace_file) { |
3179 Translation::Opcode opcode = | 3181 Translation::Opcode opcode = |
3180 static_cast<Translation::Opcode>(iterator->Next()); | 3182 static_cast<Translation::Opcode>(iterator->Next()); |
3181 switch (opcode) { | 3183 switch (opcode) { |
3182 case Translation::JS_FRAME: { | 3184 case Translation::JS_FRAME: { |
3183 BailoutId node_id = BailoutId(iterator->Next()); | 3185 BailoutId node_id = BailoutId(iterator->Next()); |
3184 SharedFunctionInfo* shared_info = | 3186 SharedFunctionInfo* shared_info = |
3185 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); | 3187 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); |
3186 int height = iterator->Next(); | 3188 int height = iterator->Next(); |
3187 if (trace_file != nullptr) { | 3189 if (trace_file != nullptr) { |
3188 base::SmartArrayPointer<char> name = | 3190 std::unique_ptr<char[]> name = shared_info->DebugName()->ToCString(); |
3189 shared_info->DebugName()->ToCString(); | |
3190 PrintF(trace_file, " reading input frame %s", name.get()); | 3191 PrintF(trace_file, " reading input frame %s", name.get()); |
3191 int arg_count = shared_info->internal_formal_parameter_count() + 1; | 3192 int arg_count = shared_info->internal_formal_parameter_count() + 1; |
3192 PrintF(trace_file, " => node=%d, args=%d, height=%d; inputs:\n", | 3193 PrintF(trace_file, " => node=%d, args=%d, height=%d; inputs:\n", |
3193 node_id.ToInt(), arg_count, height); | 3194 node_id.ToInt(), arg_count, height); |
3194 } | 3195 } |
3195 return TranslatedFrame::JSFrame(node_id, shared_info, height); | 3196 return TranslatedFrame::JSFrame(node_id, shared_info, height); |
3196 } | 3197 } |
3197 | 3198 |
3198 case Translation::INTERPRETED_FRAME: { | 3199 case Translation::INTERPRETED_FRAME: { |
3199 BailoutId bytecode_offset = BailoutId(iterator->Next()); | 3200 BailoutId bytecode_offset = BailoutId(iterator->Next()); |
3200 SharedFunctionInfo* shared_info = | 3201 SharedFunctionInfo* shared_info = |
3201 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); | 3202 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); |
3202 int height = iterator->Next(); | 3203 int height = iterator->Next(); |
3203 if (trace_file != nullptr) { | 3204 if (trace_file != nullptr) { |
3204 base::SmartArrayPointer<char> name = | 3205 std::unique_ptr<char[]> name = shared_info->DebugName()->ToCString(); |
3205 shared_info->DebugName()->ToCString(); | |
3206 PrintF(trace_file, " reading input frame %s", name.get()); | 3206 PrintF(trace_file, " reading input frame %s", name.get()); |
3207 int arg_count = shared_info->internal_formal_parameter_count() + 1; | 3207 int arg_count = shared_info->internal_formal_parameter_count() + 1; |
3208 PrintF(trace_file, | 3208 PrintF(trace_file, |
3209 " => bytecode_offset=%d, args=%d, height=%d; inputs:\n", | 3209 " => bytecode_offset=%d, args=%d, height=%d; inputs:\n", |
3210 bytecode_offset.ToInt(), arg_count, height); | 3210 bytecode_offset.ToInt(), arg_count, height); |
3211 } | 3211 } |
3212 return TranslatedFrame::InterpretedFrame(bytecode_offset, shared_info, | 3212 return TranslatedFrame::InterpretedFrame(bytecode_offset, shared_info, |
3213 height); | 3213 height); |
3214 } | 3214 } |
3215 | 3215 |
3216 case Translation::ARGUMENTS_ADAPTOR_FRAME: { | 3216 case Translation::ARGUMENTS_ADAPTOR_FRAME: { |
3217 SharedFunctionInfo* shared_info = | 3217 SharedFunctionInfo* shared_info = |
3218 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); | 3218 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); |
3219 int height = iterator->Next(); | 3219 int height = iterator->Next(); |
3220 if (trace_file != nullptr) { | 3220 if (trace_file != nullptr) { |
3221 base::SmartArrayPointer<char> name = | 3221 std::unique_ptr<char[]> name = shared_info->DebugName()->ToCString(); |
3222 shared_info->DebugName()->ToCString(); | |
3223 PrintF(trace_file, " reading arguments adaptor frame %s", name.get()); | 3222 PrintF(trace_file, " reading arguments adaptor frame %s", name.get()); |
3224 PrintF(trace_file, " => height=%d; inputs:\n", height); | 3223 PrintF(trace_file, " => height=%d; inputs:\n", height); |
3225 } | 3224 } |
3226 return TranslatedFrame::ArgumentsAdaptorFrame(shared_info, height); | 3225 return TranslatedFrame::ArgumentsAdaptorFrame(shared_info, height); |
3227 } | 3226 } |
3228 | 3227 |
3229 case Translation::TAIL_CALLER_FRAME: { | 3228 case Translation::TAIL_CALLER_FRAME: { |
3230 SharedFunctionInfo* shared_info = | 3229 SharedFunctionInfo* shared_info = |
3231 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); | 3230 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); |
3232 if (trace_file != nullptr) { | 3231 if (trace_file != nullptr) { |
3233 base::SmartArrayPointer<char> name = | 3232 std::unique_ptr<char[]> name = shared_info->DebugName()->ToCString(); |
3234 shared_info->DebugName()->ToCString(); | |
3235 PrintF(trace_file, " reading tail caller frame marker %s\n", | 3233 PrintF(trace_file, " reading tail caller frame marker %s\n", |
3236 name.get()); | 3234 name.get()); |
3237 } | 3235 } |
3238 return TranslatedFrame::TailCallerFrame(shared_info); | 3236 return TranslatedFrame::TailCallerFrame(shared_info); |
3239 } | 3237 } |
3240 | 3238 |
3241 case Translation::CONSTRUCT_STUB_FRAME: { | 3239 case Translation::CONSTRUCT_STUB_FRAME: { |
3242 SharedFunctionInfo* shared_info = | 3240 SharedFunctionInfo* shared_info = |
3243 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); | 3241 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); |
3244 int height = iterator->Next(); | 3242 int height = iterator->Next(); |
3245 if (trace_file != nullptr) { | 3243 if (trace_file != nullptr) { |
3246 base::SmartArrayPointer<char> name = | 3244 std::unique_ptr<char[]> name = shared_info->DebugName()->ToCString(); |
3247 shared_info->DebugName()->ToCString(); | |
3248 PrintF(trace_file, " reading construct stub frame %s", name.get()); | 3245 PrintF(trace_file, " reading construct stub frame %s", name.get()); |
3249 PrintF(trace_file, " => height=%d; inputs:\n", height); | 3246 PrintF(trace_file, " => height=%d; inputs:\n", height); |
3250 } | 3247 } |
3251 return TranslatedFrame::ConstructStubFrame(shared_info, height); | 3248 return TranslatedFrame::ConstructStubFrame(shared_info, height); |
3252 } | 3249 } |
3253 | 3250 |
3254 case Translation::GETTER_STUB_FRAME: { | 3251 case Translation::GETTER_STUB_FRAME: { |
3255 SharedFunctionInfo* shared_info = | 3252 SharedFunctionInfo* shared_info = |
3256 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); | 3253 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); |
3257 if (trace_file != nullptr) { | 3254 if (trace_file != nullptr) { |
3258 base::SmartArrayPointer<char> name = | 3255 std::unique_ptr<char[]> name = shared_info->DebugName()->ToCString(); |
3259 shared_info->DebugName()->ToCString(); | |
3260 PrintF(trace_file, " reading getter frame %s; inputs:\n", name.get()); | 3256 PrintF(trace_file, " reading getter frame %s; inputs:\n", name.get()); |
3261 } | 3257 } |
3262 return TranslatedFrame::AccessorFrame(TranslatedFrame::kGetter, | 3258 return TranslatedFrame::AccessorFrame(TranslatedFrame::kGetter, |
3263 shared_info); | 3259 shared_info); |
3264 } | 3260 } |
3265 | 3261 |
3266 case Translation::SETTER_STUB_FRAME: { | 3262 case Translation::SETTER_STUB_FRAME: { |
3267 SharedFunctionInfo* shared_info = | 3263 SharedFunctionInfo* shared_info = |
3268 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); | 3264 SharedFunctionInfo::cast(literal_array->get(iterator->Next())); |
3269 if (trace_file != nullptr) { | 3265 if (trace_file != nullptr) { |
3270 base::SmartArrayPointer<char> name = | 3266 std::unique_ptr<char[]> name = shared_info->DebugName()->ToCString(); |
3271 shared_info->DebugName()->ToCString(); | |
3272 PrintF(trace_file, " reading setter frame %s; inputs:\n", name.get()); | 3267 PrintF(trace_file, " reading setter frame %s; inputs:\n", name.get()); |
3273 } | 3268 } |
3274 return TranslatedFrame::AccessorFrame(TranslatedFrame::kSetter, | 3269 return TranslatedFrame::AccessorFrame(TranslatedFrame::kSetter, |
3275 shared_info); | 3270 shared_info); |
3276 } | 3271 } |
3277 | 3272 |
3278 case Translation::COMPILED_STUB_FRAME: { | 3273 case Translation::COMPILED_STUB_FRAME: { |
3279 int height = iterator->Next(); | 3274 int height = iterator->Next(); |
3280 if (trace_file != nullptr) { | 3275 if (trace_file != nullptr) { |
3281 PrintF(trace_file, | 3276 PrintF(trace_file, |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4003 CHECK(value_info->IsMaterializedObject()); | 3998 CHECK(value_info->IsMaterializedObject()); |
4004 | 3999 |
4005 value_info->value_ = | 4000 value_info->value_ = |
4006 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 4001 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
4007 } | 4002 } |
4008 } | 4003 } |
4009 } | 4004 } |
4010 | 4005 |
4011 } // namespace internal | 4006 } // namespace internal |
4012 } // namespace v8 | 4007 } // namespace v8 |
OLD | NEW |