| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 // ignore all slots that might have been recorded on it. | 359 // ignore all slots that might have been recorded on it. |
| 360 isolate->heap()->mark_compact_collector()->InvalidateCode(codes[i]); | 360 isolate->heap()->mark_compact_collector()->InvalidateCode(codes[i]); |
| 361 } | 361 } |
| 362 } | 362 } |
| 363 | 363 |
| 364 | 364 |
| 365 void Deoptimizer::DeoptimizeAll(Isolate* isolate) { | 365 void Deoptimizer::DeoptimizeAll(Isolate* isolate) { |
| 366 RuntimeCallTimerScope runtimeTimer(isolate, | 366 RuntimeCallTimerScope runtimeTimer(isolate, |
| 367 &RuntimeCallStats::DeoptimizeCode); | 367 &RuntimeCallStats::DeoptimizeCode); |
| 368 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); | 368 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); |
| 369 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | 369 TRACE_EVENT0("v8", "V8.DeoptimizeCode"); |
| 370 isolate, &tracing::TraceEventStatsTable::DeoptimizeCode); | |
| 371 if (FLAG_trace_deopt) { | 370 if (FLAG_trace_deopt) { |
| 372 CodeTracer::Scope scope(isolate->GetCodeTracer()); | 371 CodeTracer::Scope scope(isolate->GetCodeTracer()); |
| 373 PrintF(scope.file(), "[deoptimize all code in all contexts]\n"); | 372 PrintF(scope.file(), "[deoptimize all code in all contexts]\n"); |
| 374 } | 373 } |
| 375 DisallowHeapAllocation no_allocation; | 374 DisallowHeapAllocation no_allocation; |
| 376 // For all contexts, mark all code, then deoptimize. | 375 // For all contexts, mark all code, then deoptimize. |
| 377 Object* context = isolate->heap()->native_contexts_list(); | 376 Object* context = isolate->heap()->native_contexts_list(); |
| 378 while (!context->IsUndefined(isolate)) { | 377 while (!context->IsUndefined(isolate)) { |
| 379 Context* native_context = Context::cast(context); | 378 Context* native_context = Context::cast(context); |
| 380 MarkAllCodeForContext(native_context); | 379 MarkAllCodeForContext(native_context); |
| 381 DeoptimizeMarkedCodeForContext(native_context); | 380 DeoptimizeMarkedCodeForContext(native_context); |
| 382 context = native_context->next_context_link(); | 381 context = native_context->next_context_link(); |
| 383 } | 382 } |
| 384 } | 383 } |
| 385 | 384 |
| 386 | 385 |
| 387 void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) { | 386 void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) { |
| 388 RuntimeCallTimerScope runtimeTimer(isolate, | 387 RuntimeCallTimerScope runtimeTimer(isolate, |
| 389 &RuntimeCallStats::DeoptimizeCode); | 388 &RuntimeCallStats::DeoptimizeCode); |
| 390 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); | 389 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); |
| 391 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | 390 TRACE_EVENT0("v8", "V8.DeoptimizeCode"); |
| 392 isolate, &tracing::TraceEventStatsTable::DeoptimizeCode); | |
| 393 if (FLAG_trace_deopt) { | 391 if (FLAG_trace_deopt) { |
| 394 CodeTracer::Scope scope(isolate->GetCodeTracer()); | 392 CodeTracer::Scope scope(isolate->GetCodeTracer()); |
| 395 PrintF(scope.file(), "[deoptimize marked code in all contexts]\n"); | 393 PrintF(scope.file(), "[deoptimize marked code in all contexts]\n"); |
| 396 } | 394 } |
| 397 DisallowHeapAllocation no_allocation; | 395 DisallowHeapAllocation no_allocation; |
| 398 // For all contexts, deoptimize code already marked. | 396 // For all contexts, deoptimize code already marked. |
| 399 Object* context = isolate->heap()->native_contexts_list(); | 397 Object* context = isolate->heap()->native_contexts_list(); |
| 400 while (!context->IsUndefined(isolate)) { | 398 while (!context->IsUndefined(isolate)) { |
| 401 Context* native_context = Context::cast(context); | 399 Context* native_context = Context::cast(context); |
| 402 DeoptimizeMarkedCodeForContext(native_context); | 400 DeoptimizeMarkedCodeForContext(native_context); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 415 element = code->next_code_link(); | 413 element = code->next_code_link(); |
| 416 } | 414 } |
| 417 } | 415 } |
| 418 | 416 |
| 419 | 417 |
| 420 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { | 418 void Deoptimizer::DeoptimizeFunction(JSFunction* function) { |
| 421 Isolate* isolate = function->GetIsolate(); | 419 Isolate* isolate = function->GetIsolate(); |
| 422 RuntimeCallTimerScope runtimeTimer(isolate, | 420 RuntimeCallTimerScope runtimeTimer(isolate, |
| 423 &RuntimeCallStats::DeoptimizeCode); | 421 &RuntimeCallStats::DeoptimizeCode); |
| 424 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); | 422 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); |
| 425 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | 423 TRACE_EVENT0("v8", "V8.DeoptimizeCode"); |
| 426 isolate, &tracing::TraceEventStatsTable::DeoptimizeCode); | |
| 427 Code* code = function->code(); | 424 Code* code = function->code(); |
| 428 if (code->kind() == Code::OPTIMIZED_FUNCTION) { | 425 if (code->kind() == Code::OPTIMIZED_FUNCTION) { |
| 429 // Mark the code for deoptimization and unlink any functions that also | 426 // Mark the code for deoptimization and unlink any functions that also |
| 430 // refer to that code. The code cannot be shared across native contexts, | 427 // refer to that code. The code cannot be shared across native contexts, |
| 431 // so we only need to search one. | 428 // so we only need to search one. |
| 432 code->set_marked_for_deoptimization(true); | 429 code->set_marked_for_deoptimization(true); |
| 433 DeoptimizeMarkedCodeForContext(function->context()->native_context()); | 430 DeoptimizeMarkedCodeForContext(function->context()->native_context()); |
| 434 } | 431 } |
| 435 } | 432 } |
| 436 | 433 |
| (...skipping 3558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3995 CHECK(value_info->IsMaterializedObject()); | 3992 CHECK(value_info->IsMaterializedObject()); |
| 3996 | 3993 |
| 3997 value_info->value_ = | 3994 value_info->value_ = |
| 3998 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 3995 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
| 3999 } | 3996 } |
| 4000 } | 3997 } |
| 4001 } | 3998 } |
| 4002 | 3999 |
| 4003 } // namespace internal | 4000 } // namespace internal |
| 4004 } // namespace v8 | 4001 } // namespace v8 |
| OLD | NEW |