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 "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/ast/prettyprinter.h" | 8 #include "src/ast/prettyprinter.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/disasm.h" | 10 #include "src/disasm.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 void Deoptimizer::VisitAllOptimizedFunctions( | 222 void Deoptimizer::VisitAllOptimizedFunctions( |
223 Isolate* isolate, | 223 Isolate* isolate, |
224 OptimizedFunctionVisitor* visitor) { | 224 OptimizedFunctionVisitor* visitor) { |
225 DisallowHeapAllocation no_allocation; | 225 DisallowHeapAllocation no_allocation; |
226 | 226 |
227 // Run through the list of all native contexts. | 227 // Run through the list of all native contexts. |
228 Object* context = isolate->heap()->native_contexts_list(); | 228 Object* context = isolate->heap()->native_contexts_list(); |
229 while (!context->IsUndefined()) { | 229 while (!context->IsUndefined()) { |
230 VisitAllOptimizedFunctionsForContext(Context::cast(context), visitor); | 230 VisitAllOptimizedFunctionsForContext(Context::cast(context), visitor); |
231 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); | 231 context = Context::cast(context)->next_context_link(); |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
235 | 235 |
236 // Unlink functions referring to code marked for deoptimization, then move | 236 // Unlink functions referring to code marked for deoptimization, then move |
237 // marked code from the optimized code list to the deoptimized code list, | 237 // marked code from the optimized code list to the deoptimized code list, |
238 // and patch code for lazy deopt. | 238 // and patch code for lazy deopt. |
239 void Deoptimizer::DeoptimizeMarkedCodeForContext(Context* context) { | 239 void Deoptimizer::DeoptimizeMarkedCodeForContext(Context* context) { |
240 DisallowHeapAllocation no_allocation; | 240 DisallowHeapAllocation no_allocation; |
241 | 241 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 CodeTracer::Scope scope(isolate->GetCodeTracer()); | 378 CodeTracer::Scope scope(isolate->GetCodeTracer()); |
379 PrintF(scope.file(), "[deoptimize all code in all contexts]\n"); | 379 PrintF(scope.file(), "[deoptimize all code in all contexts]\n"); |
380 } | 380 } |
381 DisallowHeapAllocation no_allocation; | 381 DisallowHeapAllocation no_allocation; |
382 // For all contexts, mark all code, then deoptimize. | 382 // For all contexts, mark all code, then deoptimize. |
383 Object* context = isolate->heap()->native_contexts_list(); | 383 Object* context = isolate->heap()->native_contexts_list(); |
384 while (!context->IsUndefined()) { | 384 while (!context->IsUndefined()) { |
385 Context* native_context = Context::cast(context); | 385 Context* native_context = Context::cast(context); |
386 MarkAllCodeForContext(native_context); | 386 MarkAllCodeForContext(native_context); |
387 DeoptimizeMarkedCodeForContext(native_context); | 387 DeoptimizeMarkedCodeForContext(native_context); |
388 context = native_context->get(Context::NEXT_CONTEXT_LINK); | 388 context = native_context->next_context_link(); |
389 } | 389 } |
390 } | 390 } |
391 | 391 |
392 | 392 |
393 void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) { | 393 void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) { |
394 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); | 394 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); |
395 TRACE_EVENT0("v8", "V8.DeoptimizeCode"); | 395 TRACE_EVENT0("v8", "V8.DeoptimizeCode"); |
396 if (FLAG_trace_deopt) { | 396 if (FLAG_trace_deopt) { |
397 CodeTracer::Scope scope(isolate->GetCodeTracer()); | 397 CodeTracer::Scope scope(isolate->GetCodeTracer()); |
398 PrintF(scope.file(), "[deoptimize marked code in all contexts]\n"); | 398 PrintF(scope.file(), "[deoptimize marked code in all contexts]\n"); |
399 } | 399 } |
400 DisallowHeapAllocation no_allocation; | 400 DisallowHeapAllocation no_allocation; |
401 // For all contexts, deoptimize code already marked. | 401 // For all contexts, deoptimize code already marked. |
402 Object* context = isolate->heap()->native_contexts_list(); | 402 Object* context = isolate->heap()->native_contexts_list(); |
403 while (!context->IsUndefined()) { | 403 while (!context->IsUndefined()) { |
404 Context* native_context = Context::cast(context); | 404 Context* native_context = Context::cast(context); |
405 DeoptimizeMarkedCodeForContext(native_context); | 405 DeoptimizeMarkedCodeForContext(native_context); |
406 context = native_context->get(Context::NEXT_CONTEXT_LINK); | 406 context = native_context->next_context_link(); |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
410 | 410 |
411 void Deoptimizer::MarkAllCodeForContext(Context* context) { | 411 void Deoptimizer::MarkAllCodeForContext(Context* context) { |
412 Object* element = context->OptimizedCodeListHead(); | 412 Object* element = context->OptimizedCodeListHead(); |
413 while (!element->IsUndefined()) { | 413 while (!element->IsUndefined()) { |
414 Code* code = Code::cast(element); | 414 Code* code = Code::cast(element); |
415 CHECK_EQ(code->kind(), Code::OPTIMIZED_FUNCTION); | 415 CHECK_EQ(code->kind(), Code::OPTIMIZED_FUNCTION); |
416 code->set_marked_for_deoptimization(true); | 416 code->set_marked_for_deoptimization(true); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 Object* context = isolate->heap()->native_contexts_list(); | 653 Object* context = isolate->heap()->native_contexts_list(); |
654 while (!context->IsUndefined()) { | 654 while (!context->IsUndefined()) { |
655 Context* native_context = Context::cast(context); | 655 Context* native_context = Context::cast(context); |
656 Object* element = native_context->DeoptimizedCodeListHead(); | 656 Object* element = native_context->DeoptimizedCodeListHead(); |
657 while (!element->IsUndefined()) { | 657 while (!element->IsUndefined()) { |
658 Code* code = Code::cast(element); | 658 Code* code = Code::cast(element); |
659 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); | 659 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); |
660 length++; | 660 length++; |
661 element = code->next_code_link(); | 661 element = code->next_code_link(); |
662 } | 662 } |
663 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); | 663 context = Context::cast(context)->next_context_link(); |
664 } | 664 } |
665 return length; | 665 return length; |
666 } | 666 } |
667 | 667 |
668 namespace { | 668 namespace { |
669 | 669 |
670 int LookupCatchHandler(TranslatedFrame* translated_frame, int* data_out) { | 670 int LookupCatchHandler(TranslatedFrame* translated_frame, int* data_out) { |
671 switch (translated_frame->kind()) { | 671 switch (translated_frame->kind()) { |
672 case TranslatedFrame::kFunction: { | 672 case TranslatedFrame::kFunction: { |
673 BailoutId node_id = translated_frame->node_id(); | 673 BailoutId node_id = translated_frame->node_id(); |
(...skipping 3137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3811 CHECK(value_info->IsMaterializedObject()); | 3811 CHECK(value_info->IsMaterializedObject()); |
3812 | 3812 |
3813 value_info->value_ = | 3813 value_info->value_ = |
3814 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 3814 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
3815 } | 3815 } |
3816 } | 3816 } |
3817 } | 3817 } |
3818 | 3818 |
3819 } // namespace internal | 3819 } // namespace internal |
3820 } // namespace v8 | 3820 } // namespace v8 |
OLD | NEW |