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