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