Chromium Code Reviews| Index: src/runtime/runtime-test.cc |
| diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc |
| index 1778401210ccda2573a3f2aa7df5898441dd265f..50e0d23be8fe51dfdf8af0fbb0869f315eee17cb 100644 |
| --- a/src/runtime/runtime-test.cc |
| +++ b/src/runtime/runtime-test.cc |
| @@ -69,13 +69,8 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) { |
| Code* unoptimized = function->shared()->code(); |
| if (args.length() == 2 && unoptimized->kind() == Code::FUNCTION) { |
| CONVERT_ARG_HANDLE_CHECKED(String, type, 1); |
| - if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("osr")) && FLAG_use_osr) { |
| - // Start patching from the currently patched loop nesting level. |
| - DCHECK(BackEdgeTable::Verify(isolate, unoptimized)); |
| - isolate->runtime_profiler()->AttemptOnStackReplacement( |
| - *function, Code::kMaxLoopNestingMarker); |
| - } else if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("concurrent")) && |
| - isolate->concurrent_recompilation_enabled()) { |
| + if (type->IsOneByteEqualTo(STATIC_CHAR_VECTOR("concurrent")) && |
| + isolate->concurrent_recompilation_enabled()) { |
| function->AttemptConcurrentOptimization(); |
| } |
| } |
| @@ -84,6 +79,46 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) { |
| } |
| +RUNTIME_FUNCTION(Runtime_OptimizeOsr) { |
| + RUNTIME_ASSERT(args.length() == 0); |
| + |
| + HandleScope scope(isolate); |
|
Michael Starzinger
2015/02/09 12:11:06
nit: Please place the HandleScope first before the
titzer
2015/02/09 12:16:02
Done.
|
| + Handle<JSFunction> function = Handle<JSFunction>::null(); |
| + |
| + { |
| + // Find the JavaScript function on the top of the stack. |
| + JavaScriptFrameIterator it(isolate); |
| + while (!it.done()) { |
| + if (it.frame()->is_java_script()) { |
| + function = Handle<JSFunction>(it.frame()->function()); |
| + break; |
| + } |
| + } |
| + if (function.is_null()) return isolate->heap()->undefined_value(); |
| + } |
| + |
| + // The following assertion was lifted from the DCHECK inside |
| + // JSFunction::MarkForOptimization(). |
| + RUNTIME_ASSERT(function->shared()->allows_lazy_compilation() || |
| + (function->code()->kind() == Code::FUNCTION && |
| + function->code()->optimizable())); |
| + |
| + if (!isolate->use_crankshaft()) return isolate->heap()->undefined_value(); |
| + |
| + // If the function is already optimized, just return. |
| + if (function->IsOptimized()) return isolate->heap()->undefined_value(); |
| + |
| + Code* unoptimized = function->shared()->code(); |
| + if (unoptimized->kind() == Code::FUNCTION) { |
| + DCHECK(BackEdgeTable::Verify(isolate, unoptimized)); |
| + isolate->runtime_profiler()->AttemptOnStackReplacement( |
| + *function, Code::kMaxLoopNestingMarker); |
| + } |
| + |
| + return isolate->heap()->undefined_value(); |
| +} |
| + |
| + |
| RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) { |
| HandleScope scope(isolate); |
| DCHECK(args.length() == 1); |