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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 Object* element = context->OptimizedCodeListHead(); | 384 Object* element = context->OptimizedCodeListHead(); |
385 Isolate* isolate = context->GetIsolate(); | 385 Isolate* isolate = context->GetIsolate(); |
386 while (!element->IsUndefined(isolate)) { | 386 while (!element->IsUndefined(isolate)) { |
387 Code* code = Code::cast(element); | 387 Code* code = Code::cast(element); |
388 CHECK_EQ(code->kind(), Code::OPTIMIZED_FUNCTION); | 388 CHECK_EQ(code->kind(), Code::OPTIMIZED_FUNCTION); |
389 code->set_marked_for_deoptimization(true); | 389 code->set_marked_for_deoptimization(true); |
390 element = code->next_code_link(); | 390 element = code->next_code_link(); |
391 } | 391 } |
392 } | 392 } |
393 | 393 |
394 | 394 void Deoptimizer::DeoptimizeFunction(JSFunction* function, Code* code) { |
395 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { | |
396 Isolate* isolate = function->GetIsolate(); | 395 Isolate* isolate = function->GetIsolate(); |
397 RuntimeCallTimerScope runtimeTimer(isolate, | 396 RuntimeCallTimerScope runtimeTimer(isolate, |
398 &RuntimeCallStats::DeoptimizeCode); | 397 &RuntimeCallStats::DeoptimizeCode); |
399 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); | 398 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); |
400 TRACE_EVENT0("v8", "V8.DeoptimizeCode"); | 399 TRACE_EVENT0("v8", "V8.DeoptimizeCode"); |
401 Code* code = function->code(); | 400 if (code == nullptr) code = function->code(); |
402 if (code->kind() == Code::OPTIMIZED_FUNCTION) { | 401 if (code->kind() == Code::OPTIMIZED_FUNCTION) { |
403 // Mark the code for deoptimization and unlink any functions that also | 402 // Mark the code for deoptimization and unlink any functions that also |
404 // refer to that code. The code cannot be shared across native contexts, | 403 // refer to that code. The code cannot be shared across native contexts, |
405 // so we only need to search one. | 404 // so we only need to search one. |
406 code->set_marked_for_deoptimization(true); | 405 code->set_marked_for_deoptimization(true); |
407 DeoptimizeMarkedCodeForContext(function->context()->native_context()); | 406 DeoptimizeMarkedCodeForContext(function->context()->native_context()); |
408 } | 407 } |
409 } | 408 } |
410 | 409 |
411 | 410 |
(...skipping 3515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3927 } | 3926 } |
3928 *args_count = | 3927 *args_count = |
3929 frames_[i].shared_info()->internal_formal_parameter_count() + 1; | 3928 frames_[i].shared_info()->internal_formal_parameter_count() + 1; |
3930 return &(frames_[i]); | 3929 return &(frames_[i]); |
3931 } | 3930 } |
3932 } | 3931 } |
3933 } | 3932 } |
3934 return nullptr; | 3933 return nullptr; |
3935 } | 3934 } |
3936 | 3935 |
3937 | 3936 void TranslatedState::StoreMaterializedValuesAndDeopt(JavaScriptFrame* frame) { |
3938 void TranslatedState::StoreMaterializedValuesAndDeopt() { | |
3939 MaterializedObjectStore* materialized_store = | 3937 MaterializedObjectStore* materialized_store = |
3940 isolate_->materialized_object_store(); | 3938 isolate_->materialized_object_store(); |
3941 Handle<FixedArray> previously_materialized_objects = | 3939 Handle<FixedArray> previously_materialized_objects = |
3942 materialized_store->Get(stack_frame_pointer_); | 3940 materialized_store->Get(stack_frame_pointer_); |
3943 | 3941 |
3944 Handle<Object> marker = isolate_->factory()->arguments_marker(); | 3942 Handle<Object> marker = isolate_->factory()->arguments_marker(); |
3945 | 3943 |
3946 int length = static_cast<int>(object_positions_.size()); | 3944 int length = static_cast<int>(object_positions_.size()); |
3947 bool new_store = false; | 3945 bool new_store = false; |
3948 if (previously_materialized_objects.is_null()) { | 3946 if (previously_materialized_objects.is_null()) { |
(...skipping 25 matching lines...) Expand all Loading... |
3974 CHECK(previously_materialized_objects->get(i) == *value); | 3972 CHECK(previously_materialized_objects->get(i) == *value); |
3975 } | 3973 } |
3976 } | 3974 } |
3977 } | 3975 } |
3978 if (new_store && value_changed) { | 3976 if (new_store && value_changed) { |
3979 materialized_store->Set(stack_frame_pointer_, | 3977 materialized_store->Set(stack_frame_pointer_, |
3980 previously_materialized_objects); | 3978 previously_materialized_objects); |
3981 CHECK(frames_[0].kind() == TranslatedFrame::kFunction || | 3979 CHECK(frames_[0].kind() == TranslatedFrame::kFunction || |
3982 frames_[0].kind() == TranslatedFrame::kInterpretedFunction || | 3980 frames_[0].kind() == TranslatedFrame::kInterpretedFunction || |
3983 frames_[0].kind() == TranslatedFrame::kTailCallerFunction); | 3981 frames_[0].kind() == TranslatedFrame::kTailCallerFunction); |
3984 Object* const function = frames_[0].front().GetRawValue(); | 3982 CHECK_EQ(frame->function(), frames_[0].front().GetRawValue()); |
3985 Deoptimizer::DeoptimizeFunction(JSFunction::cast(function)); | 3983 Deoptimizer::DeoptimizeFunction(frame->function(), frame->LookupCode()); |
3986 } | 3984 } |
3987 } | 3985 } |
3988 | 3986 |
3989 | 3987 |
3990 void TranslatedState::UpdateFromPreviouslyMaterializedObjects() { | 3988 void TranslatedState::UpdateFromPreviouslyMaterializedObjects() { |
3991 MaterializedObjectStore* materialized_store = | 3989 MaterializedObjectStore* materialized_store = |
3992 isolate_->materialized_object_store(); | 3990 isolate_->materialized_object_store(); |
3993 Handle<FixedArray> previously_materialized_objects = | 3991 Handle<FixedArray> previously_materialized_objects = |
3994 materialized_store->Get(stack_frame_pointer_); | 3992 materialized_store->Get(stack_frame_pointer_); |
3995 | 3993 |
(...skipping 15 matching lines...) Expand all Loading... |
4011 CHECK(value_info->IsMaterializedObject()); | 4009 CHECK(value_info->IsMaterializedObject()); |
4012 | 4010 |
4013 value_info->value_ = | 4011 value_info->value_ = |
4014 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 4012 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
4015 } | 4013 } |
4016 } | 4014 } |
4017 } | 4015 } |
4018 | 4016 |
4019 } // namespace internal | 4017 } // namespace internal |
4020 } // namespace v8 | 4018 } // namespace v8 |
OLD | NEW |