Chromium Code Reviews| 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 | 419 |
| 420 // We might be in the middle of incremental marking with compaction. | 420 // We might be in the middle of incremental marking with compaction. |
| 421 // Tell collector to treat this code object in a special way and | 421 // Tell collector to treat this code object in a special way and |
| 422 // ignore all slots that might have been recorded on it. | 422 // ignore all slots that might have been recorded on it. |
| 423 isolate->heap()->mark_compact_collector()->InvalidateCode(codes[i]); | 423 isolate->heap()->mark_compact_collector()->InvalidateCode(codes[i]); |
| 424 } | 424 } |
| 425 } | 425 } |
| 426 | 426 |
| 427 | 427 |
| 428 void Deoptimizer::DeoptimizeAll(Isolate* isolate) { | 428 void Deoptimizer::DeoptimizeAll(Isolate* isolate) { |
| 429 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); | |
| 429 if (FLAG_trace_deopt) { | 430 if (FLAG_trace_deopt) { |
| 430 CodeTracer::Scope scope(isolate->GetCodeTracer()); | 431 CodeTracer::Scope scope(isolate->GetCodeTracer()); |
| 431 PrintF(scope.file(), "[deoptimize all code in all contexts]\n"); | 432 PrintF(scope.file(), "[deoptimize all code in all contexts]\n"); |
| 432 } | 433 } |
| 433 DisallowHeapAllocation no_allocation; | 434 DisallowHeapAllocation no_allocation; |
| 434 // For all contexts, mark all code, then deoptimize. | 435 // For all contexts, mark all code, then deoptimize. |
| 435 Object* context = isolate->heap()->native_contexts_list(); | 436 Object* context = isolate->heap()->native_contexts_list(); |
| 436 while (!context->IsUndefined()) { | 437 while (!context->IsUndefined()) { |
| 437 Context* native_context = Context::cast(context); | 438 Context* native_context = Context::cast(context); |
| 438 MarkAllCodeForContext(native_context); | 439 MarkAllCodeForContext(native_context); |
| 439 DeoptimizeMarkedCodeForContext(native_context); | 440 DeoptimizeMarkedCodeForContext(native_context); |
| 440 context = native_context->get(Context::NEXT_CONTEXT_LINK); | 441 context = native_context->get(Context::NEXT_CONTEXT_LINK); |
| 441 } | 442 } |
| 442 } | 443 } |
| 443 | 444 |
| 444 | 445 |
| 445 void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) { | 446 void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) { |
| 447 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); | |
| 446 if (FLAG_trace_deopt) { | 448 if (FLAG_trace_deopt) { |
| 447 CodeTracer::Scope scope(isolate->GetCodeTracer()); | 449 CodeTracer::Scope scope(isolate->GetCodeTracer()); |
| 448 PrintF(scope.file(), "[deoptimize marked code in all contexts]\n"); | 450 PrintF(scope.file(), "[deoptimize marked code in all contexts]\n"); |
| 449 } | 451 } |
| 450 DisallowHeapAllocation no_allocation; | 452 DisallowHeapAllocation no_allocation; |
| 451 // For all contexts, deoptimize code already marked. | 453 // For all contexts, deoptimize code already marked. |
| 452 Object* context = isolate->heap()->native_contexts_list(); | 454 Object* context = isolate->heap()->native_contexts_list(); |
| 453 while (!context->IsUndefined()) { | 455 while (!context->IsUndefined()) { |
| 454 Context* native_context = Context::cast(context); | 456 Context* native_context = Context::cast(context); |
| 455 DeoptimizeMarkedCodeForContext(native_context); | 457 DeoptimizeMarkedCodeForContext(native_context); |
| 456 context = native_context->get(Context::NEXT_CONTEXT_LINK); | 458 context = native_context->get(Context::NEXT_CONTEXT_LINK); |
| 457 } | 459 } |
| 458 } | 460 } |
| 459 | 461 |
| 460 | 462 |
| 461 void Deoptimizer::MarkAllCodeForContext(Context* context) { | 463 void Deoptimizer::MarkAllCodeForContext(Context* context) { |
| 462 Object* element = context->OptimizedCodeListHead(); | 464 Object* element = context->OptimizedCodeListHead(); |
| 463 while (!element->IsUndefined()) { | 465 while (!element->IsUndefined()) { |
| 464 Code* code = Code::cast(element); | 466 Code* code = Code::cast(element); |
| 465 CHECK_EQ(code->kind(), Code::OPTIMIZED_FUNCTION); | 467 CHECK_EQ(code->kind(), Code::OPTIMIZED_FUNCTION); |
| 466 code->set_marked_for_deoptimization(true); | 468 code->set_marked_for_deoptimization(true); |
| 467 element = code->next_code_link(); | 469 element = code->next_code_link(); |
| 468 } | 470 } |
| 469 } | 471 } |
| 470 | 472 |
| 471 | 473 |
| 472 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { | 474 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { |
| 473 Code* code = function->code(); | 475 Code* code = function->code(); |
| 474 if (code->kind() == Code::OPTIMIZED_FUNCTION) { | 476 if (code->kind() == Code::OPTIMIZED_FUNCTION) { |
| 477 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); | |
|
Michael Starzinger
2016/02/09 09:42:43
nit: Let's keep this "as simple as possible" by mo
| |
| 475 // Mark the code for deoptimization and unlink any functions that also | 478 // Mark the code for deoptimization and unlink any functions that also |
| 476 // refer to that code. The code cannot be shared across native contexts, | 479 // refer to that code. The code cannot be shared across native contexts, |
| 477 // so we only need to search one. | 480 // so we only need to search one. |
| 478 code->set_marked_for_deoptimization(true); | 481 code->set_marked_for_deoptimization(true); |
| 479 DeoptimizeMarkedCodeForContext(function->context()->native_context()); | 482 DeoptimizeMarkedCodeForContext(function->context()->native_context()); |
| 480 } | 483 } |
| 481 } | 484 } |
| 482 | 485 |
| 483 | 486 |
| 484 void Deoptimizer::ComputeOutputFrames(Deoptimizer* deoptimizer) { | 487 void Deoptimizer::ComputeOutputFrames(Deoptimizer* deoptimizer) { |
| 485 deoptimizer->DoComputeOutputFrames(); | 488 deoptimizer->DoComputeOutputFrames(); |
|
Michael Starzinger
2016/02/09 09:42:43
As discussed offline: This is also a beefy method
| |
| 486 } | 489 } |
| 487 | 490 |
| 488 | 491 |
| 489 bool Deoptimizer::TraceEnabledFor(BailoutType deopt_type, | 492 bool Deoptimizer::TraceEnabledFor(BailoutType deopt_type, |
| 490 StackFrame::Type frame_type) { | 493 StackFrame::Type frame_type) { |
| 491 switch (deopt_type) { | 494 switch (deopt_type) { |
| 492 case EAGER: | 495 case EAGER: |
| 493 case SOFT: | 496 case SOFT: |
| 494 case LAZY: | 497 case LAZY: |
| 495 case DEBUGGER: | 498 case DEBUGGER: |
| (...skipping 3215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3711 DCHECK(value_info->IsMaterializedObject()); | 3714 DCHECK(value_info->IsMaterializedObject()); |
| 3712 | 3715 |
| 3713 value_info->value_ = | 3716 value_info->value_ = |
| 3714 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 3717 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
| 3715 } | 3718 } |
| 3716 } | 3719 } |
| 3717 } | 3720 } |
| 3718 | 3721 |
| 3719 } // namespace internal | 3722 } // namespace internal |
| 3720 } // namespace v8 | 3723 } // namespace v8 |
| OLD | NEW |