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