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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 CodeTracer::Scope scope(isolate->GetCodeTracer()); | 380 CodeTracer::Scope scope(isolate->GetCodeTracer()); |
381 PrintF(scope.file(), "[deoptimize all code in all contexts]\n"); | 381 PrintF(scope.file(), "[deoptimize all code in all contexts]\n"); |
382 } | 382 } |
383 DisallowHeapAllocation no_allocation; | 383 DisallowHeapAllocation no_allocation; |
384 // For all contexts, mark all code, then deoptimize. | 384 // For all contexts, mark all code, then deoptimize. |
385 Object* context = isolate->heap()->native_contexts_list(); | 385 Object* context = isolate->heap()->native_contexts_list(); |
386 while (!context->IsUndefined()) { | 386 while (!context->IsUndefined()) { |
387 Context* native_context = Context::cast(context); | 387 Context* native_context = Context::cast(context); |
388 MarkAllCodeForContext(native_context); | 388 MarkAllCodeForContext(native_context); |
389 DeoptimizeMarkedCodeForContext(native_context); | 389 DeoptimizeMarkedCodeForContext(native_context); |
390 context = native_context->get(Context::NEXT_CONTEXT_LINK); | 390 context = native_context->next_context_link(); |
391 } | 391 } |
392 } | 392 } |
393 | 393 |
394 | 394 |
395 void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) { | 395 void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) { |
396 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); | 396 TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); |
397 TRACE_EVENT0("v8", "V8.DeoptimizeCode"); | 397 TRACE_EVENT0("v8", "V8.DeoptimizeCode"); |
398 if (FLAG_trace_deopt) { | 398 if (FLAG_trace_deopt) { |
399 CodeTracer::Scope scope(isolate->GetCodeTracer()); | 399 CodeTracer::Scope scope(isolate->GetCodeTracer()); |
400 PrintF(scope.file(), "[deoptimize marked code in all contexts]\n"); | 400 PrintF(scope.file(), "[deoptimize marked code in all contexts]\n"); |
401 } | 401 } |
402 DisallowHeapAllocation no_allocation; | 402 DisallowHeapAllocation no_allocation; |
403 // For all contexts, deoptimize code already marked. | 403 // For all contexts, deoptimize code already marked. |
404 Object* context = isolate->heap()->native_contexts_list(); | 404 Object* context = isolate->heap()->native_contexts_list(); |
405 while (!context->IsUndefined()) { | 405 while (!context->IsUndefined()) { |
406 Context* native_context = Context::cast(context); | 406 Context* native_context = Context::cast(context); |
407 DeoptimizeMarkedCodeForContext(native_context); | 407 DeoptimizeMarkedCodeForContext(native_context); |
408 context = native_context->get(Context::NEXT_CONTEXT_LINK); | 408 context = native_context->next_context_link(); |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 | 412 |
413 void Deoptimizer::MarkAllCodeForContext(Context* context) { | 413 void Deoptimizer::MarkAllCodeForContext(Context* context) { |
414 Object* element = context->OptimizedCodeListHead(); | 414 Object* element = context->OptimizedCodeListHead(); |
415 while (!element->IsUndefined()) { | 415 while (!element->IsUndefined()) { |
416 Code* code = Code::cast(element); | 416 Code* code = Code::cast(element); |
417 CHECK_EQ(code->kind(), Code::OPTIMIZED_FUNCTION); | 417 CHECK_EQ(code->kind(), Code::OPTIMIZED_FUNCTION); |
418 code->set_marked_for_deoptimization(true); | 418 code->set_marked_for_deoptimization(true); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 Object* context = isolate->heap()->native_contexts_list(); | 655 Object* context = isolate->heap()->native_contexts_list(); |
656 while (!context->IsUndefined()) { | 656 while (!context->IsUndefined()) { |
657 Context* native_context = Context::cast(context); | 657 Context* native_context = Context::cast(context); |
658 Object* element = native_context->DeoptimizedCodeListHead(); | 658 Object* element = native_context->DeoptimizedCodeListHead(); |
659 while (!element->IsUndefined()) { | 659 while (!element->IsUndefined()) { |
660 Code* code = Code::cast(element); | 660 Code* code = Code::cast(element); |
661 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); | 661 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); |
662 length++; | 662 length++; |
663 element = code->next_code_link(); | 663 element = code->next_code_link(); |
664 } | 664 } |
665 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); | 665 context = Context::cast(context)->next_context_link(); |
666 } | 666 } |
667 return length; | 667 return length; |
668 } | 668 } |
669 | 669 |
670 namespace { | 670 namespace { |
671 | 671 |
672 int LookupCatchHandler(TranslatedFrame* translated_frame, int* data_out) { | 672 int LookupCatchHandler(TranslatedFrame* translated_frame, int* data_out) { |
673 switch (translated_frame->kind()) { | 673 switch (translated_frame->kind()) { |
674 case TranslatedFrame::kFunction: { | 674 case TranslatedFrame::kFunction: { |
675 BailoutId node_id = translated_frame->node_id(); | 675 BailoutId node_id = translated_frame->node_id(); |
(...skipping 3240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3916 CHECK(value_info->IsMaterializedObject()); | 3916 CHECK(value_info->IsMaterializedObject()); |
3917 | 3917 |
3918 value_info->value_ = | 3918 value_info->value_ = |
3919 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 3919 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
3920 } | 3920 } |
3921 } | 3921 } |
3922 } | 3922 } |
3923 | 3923 |
3924 } // namespace internal | 3924 } // namespace internal |
3925 } // namespace v8 | 3925 } // namespace v8 |
OLD | NEW |