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 7664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7675 if (!JSFunction::CompileLazy(function, KEEP_EXCEPTION)) { | 7675 if (!JSFunction::CompileLazy(function, KEEP_EXCEPTION)) { |
7676 return Failure::Exception(); | 7676 return Failure::Exception(); |
7677 } | 7677 } |
7678 | 7678 |
7679 // All done. Return the compiled code. | 7679 // All done. Return the compiled code. |
7680 ASSERT(function->is_compiled()); | 7680 ASSERT(function->is_compiled()); |
7681 return function->code(); | 7681 return function->code(); |
7682 } | 7682 } |
7683 | 7683 |
7684 | 7684 |
7685 bool AllowOptimization(Isolate* isolate, Handle<JSFunction> function) { | |
7686 // If the function is not compiled ignore the lazy | |
7687 // recompilation. This can happen if the debugger is activated and | |
7688 // the function is returned to the not compiled state. | |
7689 if (!function->shared()->is_compiled()) return false; | |
7690 | |
7691 // If the function is not optimizable or debugger is active continue using the | |
7692 // code from the full compiler. | |
7693 if (!FLAG_crankshaft || | |
7694 function->shared()->optimization_disabled() || | |
7695 isolate->DebuggerHasBreakPoints()) { | |
7696 if (FLAG_trace_opt) { | |
7697 PrintF("[failed to optimize "); | |
7698 function->PrintName(); | |
7699 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n", | |
7700 function->shared()->optimization_disabled() ? "F" : "T", | |
7701 isolate->DebuggerHasBreakPoints() ? "T" : "F"); | |
7702 } | |
7703 return false; | |
7704 } | |
7705 return true; | |
7706 } | |
7707 | |
7708 | |
7685 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyRecompile) { | 7709 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyRecompile) { |
7686 HandleScope scope(isolate); | 7710 HandleScope scope(isolate); |
7687 ASSERT(args.length() == 1); | 7711 ASSERT(args.length() == 1); |
7688 Handle<JSFunction> function = args.at<JSFunction>(0); | 7712 Handle<JSFunction> function = args.at<JSFunction>(0); |
7689 | 7713 |
7690 // If the function is not compiled ignore the lazy | 7714 if (!AllowOptimization(isolate, function)) { |
7691 // recompilation. This can happen if the debugger is activated and | |
7692 // the function is returned to the not compiled state. | |
7693 if (!function->shared()->is_compiled()) { | |
7694 function->ReplaceCode(function->shared()->code()); | 7715 function->ReplaceCode(function->shared()->code()); |
7695 return function->code(); | 7716 return function->code(); |
7696 } | 7717 } |
7697 | |
7698 // If the function is not optimizable or debugger is active continue using the | |
7699 // code from the full compiler. | |
7700 if (!FLAG_crankshaft || | |
7701 !function->shared()->code()->optimizable() || | |
7702 isolate->DebuggerHasBreakPoints()) { | |
7703 if (FLAG_trace_opt) { | |
7704 PrintF("[failed to optimize "); | |
7705 function->PrintName(); | |
7706 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n", | |
7707 function->shared()->code()->optimizable() ? "T" : "F", | |
7708 isolate->DebuggerHasBreakPoints() ? "T" : "F"); | |
7709 } | |
7710 function->ReplaceCode(function->shared()->code()); | |
7711 return function->code(); | |
7712 } | |
7713 function->shared()->code()->set_profiler_ticks(0); | |
Jakob Kummerow
2013/03/05 14:11:55
Where did this line go?
Yang
2013/03/05 15:57:50
Good point, accidentally deleted. Runtime_Parallel
| |
7714 if (JSFunction::CompileOptimized(function, | 7718 if (JSFunction::CompileOptimized(function, |
7715 BailoutId::None(), | 7719 BailoutId::None(), |
7716 CLEAR_EXCEPTION)) { | 7720 CLEAR_EXCEPTION)) { |
7717 return function->code(); | 7721 return function->code(); |
7718 } | 7722 } |
7719 if (FLAG_trace_opt) { | 7723 if (FLAG_trace_opt) { |
7720 PrintF("[failed to optimize "); | 7724 PrintF("[failed to optimize "); |
7721 function->PrintName(); | 7725 function->PrintName(); |
7722 PrintF(": optimized compilation failed]\n"); | 7726 PrintF(": optimized compilation failed]\n"); |
7723 } | 7727 } |
7724 function->ReplaceCode(function->shared()->code()); | 7728 function->ReplaceCode(function->shared()->code()); |
7725 return function->code(); | 7729 return function->code(); |
7726 } | 7730 } |
7727 | 7731 |
7728 | 7732 |
7729 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParallelRecompile) { | 7733 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParallelRecompile) { |
7730 HandleScope handle_scope(isolate); | 7734 HandleScope handle_scope(isolate); |
7735 Handle<JSFunction> function = args.at<JSFunction>(0); | |
7736 if (!AllowOptimization(isolate, function)) { | |
7737 function->ReplaceCode(function->shared()->code()); | |
7738 return function->code(); | |
7739 } | |
7731 ASSERT(FLAG_parallel_recompilation); | 7740 ASSERT(FLAG_parallel_recompilation); |
7732 Compiler::RecompileParallel(args.at<JSFunction>(0)); | 7741 Compiler::RecompileParallel(function); |
7733 return isolate->heap()->undefined_value(); | 7742 return isolate->heap()->undefined_value(); |
7734 } | 7743 } |
7735 | 7744 |
7736 | 7745 |
7737 RUNTIME_FUNCTION(MaybeObject*, Runtime_ForceParallelRecompile) { | 7746 RUNTIME_FUNCTION(MaybeObject*, Runtime_ForceParallelRecompile) { |
7738 if (!V8::UseCrankshaft()) return isolate->heap()->undefined_value(); | 7747 if (!V8::UseCrankshaft()) return isolate->heap()->undefined_value(); |
7739 HandleScope handle_scope(isolate); | 7748 HandleScope handle_scope(isolate); |
7740 ASSERT(FLAG_parallel_recompilation && FLAG_manual_parallel_recompilation); | 7749 ASSERT(FLAG_parallel_recompilation && FLAG_manual_parallel_recompilation); |
7741 if (!isolate->optimizing_compiler_thread()->IsQueueAvailable()) { | 7750 if (!isolate->optimizing_compiler_thread()->IsQueueAvailable()) { |
7742 return isolate->Throw(*isolate->factory()->InternalizeOneByteString( | 7751 return isolate->Throw(*isolate->factory()->InternalizeOneByteString( |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7906 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); | 7915 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); |
7907 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 7916 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
7908 | 7917 |
7909 if (!function->IsOptimizable()) return isolate->heap()->undefined_value(); | 7918 if (!function->IsOptimizable()) return isolate->heap()->undefined_value(); |
7910 function->MarkForLazyRecompilation(); | 7919 function->MarkForLazyRecompilation(); |
7911 | 7920 |
7912 Code* unoptimized = function->shared()->code(); | 7921 Code* unoptimized = function->shared()->code(); |
7913 if (args.length() == 2 && | 7922 if (args.length() == 2 && |
7914 unoptimized->kind() == Code::FUNCTION) { | 7923 unoptimized->kind() == Code::FUNCTION) { |
7915 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); | 7924 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); |
7916 CHECK(type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))); | 7925 if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))) { |
7917 isolate->runtime_profiler()->AttemptOnStackReplacement(*function); | 7926 isolate->runtime_profiler()->AttemptOnStackReplacement(*function); |
7918 unoptimized->set_allow_osr_at_loop_nesting_level( | 7927 unoptimized->set_allow_osr_at_loop_nesting_level( |
7919 Code::kMaxLoopNestingMarker); | 7928 Code::kMaxLoopNestingMarker); |
7929 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("parallel"))) { | |
7930 function->MarkForParallelRecompilation(); | |
7931 } | |
7920 } | 7932 } |
7921 | 7933 |
7922 return isolate->heap()->undefined_value(); | 7934 return isolate->heap()->undefined_value(); |
7923 } | 7935 } |
7924 | 7936 |
7925 | 7937 |
7926 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) { | 7938 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) { |
7927 HandleScope scope(isolate); | 7939 HandleScope scope(isolate); |
7928 ASSERT(args.length() == 1); | 7940 ASSERT(args.length() == 1); |
7929 // The least significant bit (after untagging) indicates whether the | 7941 // The least significant bit (after untagging) indicates whether the |
(...skipping 5401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13331 // Handle last resort GC and make sure to allow future allocations | 13343 // Handle last resort GC and make sure to allow future allocations |
13332 // to grow the heap without causing GCs (if possible). | 13344 // to grow the heap without causing GCs (if possible). |
13333 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13345 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13334 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13346 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13335 "Runtime::PerformGC"); | 13347 "Runtime::PerformGC"); |
13336 } | 13348 } |
13337 } | 13349 } |
13338 | 13350 |
13339 | 13351 |
13340 } } // namespace v8::internal | 13352 } } // namespace v8::internal |
OLD | NEW |