Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: src/runtime.cc

Issue 21340002: Generate a custom OSR entrypoint for OSR compiles on all platforms, and transition to optimized cod… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use FixedArray::OffsetAt and add comment to codegen. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 2cbaad10fc8566914961340cbb9a9889c47cede1..3b687901dbfb86fc8af034675267d8ce32dfb9bc 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -8139,9 +8139,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyRecompile) {
return function->code();
}
function->shared()->code()->set_profiler_ticks(0);
- if (JSFunction::CompileOptimized(function,
- BailoutId::None(),
- CLEAR_EXCEPTION)) {
+ if (JSFunction::CompileOptimized(function, CLEAR_EXCEPTION)) {
return function->code();
}
if (FLAG_trace_opt) {
@@ -8223,7 +8221,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
ASSERT(AllowHeapAllocation::IsAllowed());
- ASSERT(deoptimizer->compiled_code_kind() == Code::OPTIMIZED_FUNCTION);
+ Handle<Code> optimized_code(deoptimizer->compiled_code());
+ ASSERT(optimized_code->kind() == Code::OPTIMIZED_FUNCTION);
+
+ Handle<JSFunction> function(deoptimizer->function());
+ ASSERT(!function.is_null());
// Make sure to materialize objects before causing any allocation.
JavaScriptFrameIterator it(isolate);
@@ -8231,25 +8233,18 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
delete deoptimizer;
JavaScriptFrame* frame = it.frame();
- RUNTIME_ASSERT(frame->function()->IsJSFunction());
- Handle<JSFunction> function(frame->function(), isolate);
- Handle<Code> optimized_code(function->code());
- RUNTIME_ASSERT((type != Deoptimizer::EAGER &&
- type != Deoptimizer::SOFT) || function->IsOptimized());
+ ASSERT(frame->function() == *function);
// Avoid doing too much work when running with --always-opt and keep
// the optimized code around.
if (FLAG_always_opt || type == Deoptimizer::LAZY) {
return isolate->heap()->undefined_value();
}
- // Find other optimized activations of the function or functions that
- // share the same optimized code.
+ // Find other activations of the optimized code.
bool has_other_activations = false;
while (!it.done()) {
- JavaScriptFrame* frame = it.frame();
- JSFunction* other_function = frame->function();
- if (frame->is_optimized() && other_function->code() == function->code()) {
+ if (it.frame()->function()->code() == *optimized_code) {
Michael Starzinger 2013/08/01 09:25:30 Yep, this method is looking good to me now.
has_other_activations = true;
break;
}
@@ -8439,6 +8434,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
}
BailoutId ast_id = BailoutId::None();
+ Handle<Code> osr_code = Handle<Code>::null();
if (succeeded) {
// The top JS function is this one, the PC is somewhere in the
// unoptimized code.
@@ -8474,26 +8470,26 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
PrintF("]\n");
}
- // Try to compile the optimized code. A true return value from
- // CompileOptimized means that compilation succeeded, not necessarily
- // that optimization succeeded.
- if (JSFunction::CompileOptimized(function, ast_id, CLEAR_EXCEPTION) &&
- function->IsOptimized()) {
+ // Try to compile the function for OSR. A non-null return value indicates
+ // the compilation succeeded for the given AST id.
+ osr_code = JSFunction::CompileOsr(function, ast_id, CLEAR_EXCEPTION);
+
+ if (!osr_code.is_null() &&
+ osr_code->kind() == Code::OPTIMIZED_FUNCTION) {
DeoptimizationInputData* data = DeoptimizationInputData::cast(
- function->code()->deoptimization_data());
- if (data->OsrPcOffset()->value() >= 0) {
+ osr_code->deoptimization_data());
+ if (data->OsrPcOffset()->value() >= 0
+ && BailoutId(data->OsrAstId()->value()) == ast_id) {
if (FLAG_trace_osr) {
PrintF("[on-stack replacement offset %d in optimized code]\n",
data->OsrPcOffset()->value());
}
- ASSERT(BailoutId(data->OsrAstId()->value()) == ast_id);
} else {
- // We may never generate the desired OSR entry if we emit an
- // early deoptimize.
- succeeded = false;
+ // The code we got back did not match our OSR compile request.
+ osr_code = Handle<Code>::null();
}
} else {
- succeeded = false;
+ osr_code = Handle<Code>::null();
}
}
@@ -8510,18 +8506,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
*interrupt_code,
*replacement_code);
- // If the optimization attempt succeeded, return the AST id tagged as a
- // smi. This tells the builtin that we need to translate the unoptimized
- // frame to an optimized one.
- if (succeeded) {
- ASSERT(function->code()->kind() == Code::OPTIMIZED_FUNCTION);
- return Smi::FromInt(ast_id.ToInt());
- } else {
- if (function->IsMarkedForLazyRecompilation()) {
- function->ReplaceCode(function->shared()->code());
- }
- return Smi::FromInt(-1);
- }
+ // Return the code object to the calling builtin. If non-null, the builtin
+ // will jump directly to its OSR entrypoint.
+ return osr_code.is_null() ? NULL : *osr_code;
}
« no previous file with comments | « src/objects.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698