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