OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 7956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7967 | 7967 |
7968 // Make sure to materialize objects before causing any allocation. | 7968 // Make sure to materialize objects before causing any allocation. |
7969 JavaScriptFrameIterator it(isolate); | 7969 JavaScriptFrameIterator it(isolate); |
7970 deoptimizer->MaterializeHeapObjects(&it); | 7970 deoptimizer->MaterializeHeapObjects(&it); |
7971 delete deoptimizer; | 7971 delete deoptimizer; |
7972 | 7972 |
7973 JavaScriptFrame* frame = it.frame(); | 7973 JavaScriptFrame* frame = it.frame(); |
7974 RUNTIME_ASSERT(frame->function()->IsJSFunction()); | 7974 RUNTIME_ASSERT(frame->function()->IsJSFunction()); |
7975 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate); | 7975 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate); |
7976 Handle<Code> optimized_code(function->code()); | 7976 Handle<Code> optimized_code(function->code()); |
7977 RUNTIME_ASSERT(type != Deoptimizer::EAGER || function->IsOptimized()); | 7977 RUNTIME_ASSERT((type != Deoptimizer::EAGER && |
7978 type != Deoptimizer::SOFT) || function->IsOptimized()); | |
7978 | 7979 |
7979 // Avoid doing too much work when running with --always-opt and keep | 7980 // Avoid doing too much work when running with --always-opt and keep |
7980 // the optimized code around. | 7981 // the optimized code around. |
7981 if (FLAG_always_opt || type == Deoptimizer::LAZY) { | 7982 if (FLAG_always_opt || type == Deoptimizer::LAZY) { |
7982 return isolate->heap()->undefined_value(); | 7983 return isolate->heap()->undefined_value(); |
7983 } | 7984 } |
7984 | 7985 |
7985 // Find other optimized activations of the function or functions that | 7986 // Find other optimized activations of the function or functions that |
7986 // share the same optimized code. | 7987 // share the same optimized code. |
7987 bool has_other_activations = false; | 7988 bool has_other_activations = false; |
7988 while (!it.done()) { | 7989 while (!it.done()) { |
7989 JavaScriptFrame* frame = it.frame(); | 7990 JavaScriptFrame* frame = it.frame(); |
7990 JSFunction* other_function = JSFunction::cast(frame->function()); | 7991 JSFunction* other_function = JSFunction::cast(frame->function()); |
7991 if (frame->is_optimized() && other_function->code() == function->code()) { | 7992 if (frame->is_optimized() && other_function->code() == function->code()) { |
7992 has_other_activations = true; | 7993 has_other_activations = true; |
7993 break; | 7994 break; |
7994 } | 7995 } |
7995 it.Advance(); | 7996 it.Advance(); |
7996 } | 7997 } |
7997 | 7998 |
7998 if (!has_other_activations) { | 7999 if (!has_other_activations) { |
7999 ActivationsFinder activations_finder(*function); | 8000 ActivationsFinder activations_finder(*function); |
8000 isolate->thread_manager()->IterateArchivedThreads(&activations_finder); | 8001 isolate->thread_manager()->IterateArchivedThreads(&activations_finder); |
8001 has_other_activations = activations_finder.has_activations(); | 8002 has_other_activations = activations_finder.has_activations(); |
8002 } | 8003 } |
8003 | 8004 |
8005 if (type == Deoptimizer::SOFT) { | |
8006 // Soft opts shouldn't count against the overall re-optimization count that | |
Jakob Kummerow
2013/05/14 11:01:57
nit: s/opts/deopts/
danno
2013/05/14 11:29:09
Done.
| |
8007 // can eventually lead to disabling optimization for a function. | |
8008 int opt_count = function->shared()->opt_count(); | |
8009 if (opt_count > 0) opt_count--; | |
8010 function->shared()->set_opt_count(opt_count); | |
8011 } | |
8012 | |
8004 if (!has_other_activations) { | 8013 if (!has_other_activations) { |
8005 if (FLAG_trace_deopt) { | 8014 if (FLAG_trace_deopt) { |
8006 PrintF("[removing optimized code for: "); | 8015 PrintF("[removing optimized code for: "); |
8007 function->PrintName(); | 8016 function->PrintName(); |
8008 PrintF("]\n"); | 8017 PrintF("]\n"); |
8009 } | 8018 } |
8010 function->ReplaceCode(function->shared()->code()); | 8019 function->ReplaceCode(function->shared()->code()); |
8011 } else { | 8020 } else { |
8012 Deoptimizer::DeoptimizeFunction(*function); | 8021 Deoptimizer::DeoptimizeFunction(*function); |
8013 } | 8022 } |
(...skipping 5493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13507 // Handle last resort GC and make sure to allow future allocations | 13516 // Handle last resort GC and make sure to allow future allocations |
13508 // to grow the heap without causing GCs (if possible). | 13517 // to grow the heap without causing GCs (if possible). |
13509 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13518 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13510 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13519 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13511 "Runtime::PerformGC"); | 13520 "Runtime::PerformGC"); |
13512 } | 13521 } |
13513 } | 13522 } |
13514 | 13523 |
13515 | 13524 |
13516 } } // namespace v8::internal | 13525 } } // namespace v8::internal |
OLD | NEW |