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

Unified Diff: src/runtime/runtime-compiler.cc

Issue 844503002: Fix bug in Runtime_CompileOptimized resulting from stack overflow. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add test. Created 5 years, 11 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 | « no previous file | test/mjsunit/regress/regress-446389.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-compiler.cc
diff --git a/src/runtime/runtime-compiler.cc b/src/runtime/runtime-compiler.cc
index ebd0c13f0f9b1ef2e2bb44d5bfcb4d017d5e041c..6526dcff8bf3dad096bb6470e541fddcedc4b966 100644
--- a/src/runtime/runtime-compiler.cc
+++ b/src/runtime/runtime-compiler.cc
@@ -69,9 +69,20 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized) {
concurrent ? Compiler::CONCURRENT : Compiler::NOT_CONCURRENT;
Handle<Code> code;
if (Compiler::GetOptimizedCode(function, unoptimized, mode).ToHandle(&code)) {
+ // Optimization succeeded, return optimized code.
function->ReplaceCode(*code);
} else {
- function->ReplaceCode(function->shared()->code());
+ // Optimization failed, get unoptimized code.
+ if (isolate->has_pending_exception()) { // Possible stack overflow.
+ return isolate->heap()->exception();
+ }
+ code = Handle<Code>(function->shared()->code(), isolate);
+ if (code->kind() != Code::FUNCTION &&
+ code->kind() != Code::OPTIMIZED_FUNCTION) {
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, code, Compiler::GetUnoptimizedCode(function));
+ }
+ function->ReplaceCode(*code);
}
DCHECK(function->code()->kind() == Code::FUNCTION ||
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-446389.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698