| 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 364 |
| 365 // We might be in the middle of incremental marking with compaction. | 365 // We might be in the middle of incremental marking with compaction. |
| 366 // Tell collector to treat this code object in a special way and | 366 // Tell collector to treat this code object in a special way and |
| 367 // ignore all slots that might have been recorded on it. | 367 // ignore all slots that might have been recorded on it. |
| 368 isolate->heap()->mark_compact_collector()->InvalidateCode(codes[i]); | 368 isolate->heap()->mark_compact_collector()->InvalidateCode(codes[i]); |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 | 371 |
| 372 | 372 |
| 373 void Deoptimizer::DeoptimizeAll(Isolate* isolate) { | 373 void Deoptimizer::DeoptimizeAll(Isolate* isolate) { |
| 374 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); |
| 374 if (FLAG_trace_deopt) { | 375 if (FLAG_trace_deopt) { |
| 375 CodeTracer::Scope scope(isolate->GetCodeTracer()); | 376 CodeTracer::Scope scope(isolate->GetCodeTracer()); |
| 376 PrintF(scope.file(), "[deoptimize all code in all contexts]\n"); | 377 PrintF(scope.file(), "[deoptimize all code in all contexts]\n"); |
| 377 } | 378 } |
| 378 DisallowHeapAllocation no_allocation; | 379 DisallowHeapAllocation no_allocation; |
| 379 // For all contexts, mark all code, then deoptimize. | 380 // For all contexts, mark all code, then deoptimize. |
| 380 Object* context = isolate->heap()->native_contexts_list(); | 381 Object* context = isolate->heap()->native_contexts_list(); |
| 381 while (!context->IsUndefined()) { | 382 while (!context->IsUndefined()) { |
| 382 Context* native_context = Context::cast(context); | 383 Context* native_context = Context::cast(context); |
| 383 MarkAllCodeForContext(native_context); | 384 MarkAllCodeForContext(native_context); |
| 384 DeoptimizeMarkedCodeForContext(native_context); | 385 DeoptimizeMarkedCodeForContext(native_context); |
| 385 context = native_context->get(Context::NEXT_CONTEXT_LINK); | 386 context = native_context->get(Context::NEXT_CONTEXT_LINK); |
| 386 } | 387 } |
| 387 } | 388 } |
| 388 | 389 |
| 389 | 390 |
| 390 void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) { | 391 void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) { |
| 392 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); |
| 391 if (FLAG_trace_deopt) { | 393 if (FLAG_trace_deopt) { |
| 392 CodeTracer::Scope scope(isolate->GetCodeTracer()); | 394 CodeTracer::Scope scope(isolate->GetCodeTracer()); |
| 393 PrintF(scope.file(), "[deoptimize marked code in all contexts]\n"); | 395 PrintF(scope.file(), "[deoptimize marked code in all contexts]\n"); |
| 394 } | 396 } |
| 395 DisallowHeapAllocation no_allocation; | 397 DisallowHeapAllocation no_allocation; |
| 396 // For all contexts, deoptimize code already marked. | 398 // For all contexts, deoptimize code already marked. |
| 397 Object* context = isolate->heap()->native_contexts_list(); | 399 Object* context = isolate->heap()->native_contexts_list(); |
| 398 while (!context->IsUndefined()) { | 400 while (!context->IsUndefined()) { |
| 399 Context* native_context = Context::cast(context); | 401 Context* native_context = Context::cast(context); |
| 400 DeoptimizeMarkedCodeForContext(native_context); | 402 DeoptimizeMarkedCodeForContext(native_context); |
| 401 context = native_context->get(Context::NEXT_CONTEXT_LINK); | 403 context = native_context->get(Context::NEXT_CONTEXT_LINK); |
| 402 } | 404 } |
| 403 } | 405 } |
| 404 | 406 |
| 405 | 407 |
| 406 void Deoptimizer::MarkAllCodeForContext(Context* context) { | 408 void Deoptimizer::MarkAllCodeForContext(Context* context) { |
| 407 Object* element = context->OptimizedCodeListHead(); | 409 Object* element = context->OptimizedCodeListHead(); |
| 408 while (!element->IsUndefined()) { | 410 while (!element->IsUndefined()) { |
| 409 Code* code = Code::cast(element); | 411 Code* code = Code::cast(element); |
| 410 CHECK_EQ(code->kind(), Code::OPTIMIZED_FUNCTION); | 412 CHECK_EQ(code->kind(), Code::OPTIMIZED_FUNCTION); |
| 411 code->set_marked_for_deoptimization(true); | 413 code->set_marked_for_deoptimization(true); |
| 412 element = code->next_code_link(); | 414 element = code->next_code_link(); |
| 413 } | 415 } |
| 414 } | 416 } |
| 415 | 417 |
| 416 | 418 |
| 417 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { | 419 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { |
| 420 TimerEventScope<TimerEventDeoptimizeCode> timer(function->GetIsolate()); |
| 418 Code* code = function->code(); | 421 Code* code = function->code(); |
| 419 if (code->kind() == Code::OPTIMIZED_FUNCTION) { | 422 if (code->kind() == Code::OPTIMIZED_FUNCTION) { |
| 420 // Mark the code for deoptimization and unlink any functions that also | 423 // Mark the code for deoptimization and unlink any functions that also |
| 421 // refer to that code. The code cannot be shared across native contexts, | 424 // refer to that code. The code cannot be shared across native contexts, |
| 422 // so we only need to search one. | 425 // so we only need to search one. |
| 423 code->set_marked_for_deoptimization(true); | 426 code->set_marked_for_deoptimization(true); |
| 424 DeoptimizeMarkedCodeForContext(function->context()->native_context()); | 427 DeoptimizeMarkedCodeForContext(function->context()->native_context()); |
| 425 } | 428 } |
| 426 } | 429 } |
| 427 | 430 |
| (...skipping 3304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3732 CHECK(value_info->IsMaterializedObject()); | 3735 CHECK(value_info->IsMaterializedObject()); |
| 3733 | 3736 |
| 3734 value_info->value_ = | 3737 value_info->value_ = |
| 3735 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 3738 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
| 3736 } | 3739 } |
| 3737 } | 3740 } |
| 3738 } | 3741 } |
| 3739 | 3742 |
| 3740 } // namespace internal | 3743 } // namespace internal |
| 3741 } // namespace v8 | 3744 } // namespace v8 |
| OLD | NEW |