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

Unified Diff: src/compiler.cc

Issue 1994223002: [Compiler] Skip Ignition for asm.js code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index d99f8d181b2e53d3407d0eb75ec005777718e749..742a4c50e19c74e420f8ede70b7eab82ae3a3d14 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -939,6 +939,13 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) {
return info.code();
}
+bool ShouldOptimizeForAsm(Isolate* isolate, Handle<JSFunction> function) {
+ // If the debugger is active, do not compile with turbofan unless we can
+ // deopt from turbofan code.
+ return FLAG_turbo_asm && function->shared()->asm_function() &&
+ (FLAG_turbo_asm_deoptimization || !isolate->debug()->is_active());
+}
+
MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) {
Isolate* isolate = function->GetIsolate();
DCHECK(!isolate->has_pending_exception());
@@ -965,23 +972,53 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) {
return Handle<Code>(function->shared()->code());
}
- Zone zone(isolate->allocator());
- ParseInfo parse_info(&zone, function);
- CompilationInfo info(&parse_info, function);
- Handle<Code> result;
- ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code);
-
- if (FLAG_always_opt) {
+ if (FLAG_always_opt || ShouldOptimizeForAsm(isolate, function)) {
Handle<Code> opt_code;
if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT)
.ToHandle(&opt_code)) {
- result = opt_code;
+ DCHECK(function->shared()->is_compiled());
+ return opt_code;
}
}
+ Zone zone(isolate->allocator());
+ ParseInfo parse_info(&zone, function);
+ CompilationInfo info(&parse_info, function);
+ Handle<Code> result;
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code);
+
return result;
}
+bool GetEagerCode(CompilationInfo* info) {
rmcilroy 2016/05/20 10:04:16 I factored this code out of NewSharedFunctionInfoF
+ Isolate* isolate = info->isolate();
+ DCHECK(!isolate->has_pending_exception());
+ DCHECK(info->code().is_null());
+ DCHECK_NOT_NULL(info->literal());
+ DCHECK_NOT_NULL(info->scope());
+ TimerEventScope<TimerEventCompileCode> compile_timer(isolate);
+ TRACE_EVENT0("v8", "V8.CompileCode");
+
+ if (!Renumber(info->parse_info()) || !GenerateUnoptimizedCode(info)) {
+ return false;
+ }
+
+ // Code generation will ensure that the feedback vector is present and
+ // appropriately sized.
+ DCHECK(!info->code().is_null());
+
+ if (info->literal()->should_eager_compile() &&
+ info->literal()->should_be_used_once_hint()) {
+ info->code()->MarkToBeExecutedOnce(isolate);
+ }
+
+ // Update the shared function info with the scope info.
+ InstallSharedScopeInfo(info, info->shared_info());
+ // Install compilation result on the shared function info.
+ InstallSharedCompilationResult(info, info->shared_info());
+
+ return true;
+}
Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral(
Isolate* isolate, FunctionLiteral* literal, Handle<Script> script) {
@@ -1644,23 +1681,9 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
!(FLAG_ignition && FLAG_ignition_eager && !isolate->serializer_enabled());
// Generate code
- TimerEventScope<TimerEventCompileCode> timer(isolate);
- TRACE_EVENT0("v8", "V8.CompileCode");
if (lazy) {
info.SetCode(isolate->builtins()->CompileLazy());
- } else if (Renumber(info.parse_info()) && GenerateUnoptimizedCode(&info)) {
- // Code generation will ensure that the feedback vector is present and
- // appropriately sized.
- DCHECK(!info.code().is_null());
- if (literal->should_eager_compile() &&
- literal->should_be_used_once_hint()) {
- info.code()->MarkToBeExecutedOnce(isolate);
- }
- // Update the shared function info with the scope info.
- InstallSharedScopeInfo(&info, result);
- // Install compilation result on the shared function info.
- InstallSharedCompilationResult(&info, result);
- } else {
+ } else if (!GetEagerCode(&info)) {
return Handle<SharedFunctionInfo>::null();
}
@@ -1764,9 +1787,11 @@ void Compiler::FinalizeCompilationJob(CompilationJob* raw_job) {
void Compiler::PostInstantiation(Handle<JSFunction> function,
PretenureFlag pretenure) {
+ Isolate* isolate = function->GetIsolate();
Handle<SharedFunctionInfo> shared(function->shared());
- if (FLAG_always_opt && shared->allows_lazy_compilation()) {
+ if ((FLAG_always_opt || ShouldOptimizeForAsm(isolate, function)) &&
+ shared->allows_lazy_compilation()) {
function->MarkForOptimization();
}
@@ -1782,7 +1807,6 @@ void Compiler::PostInstantiation(Handle<JSFunction> function,
if (cached.literals != nullptr) {
function->set_literals(cached.literals);
} else {
- Isolate* isolate = function->GetIsolate();
int number_of_literals = shared->num_literals();
Handle<LiteralsArray> literals =
LiteralsArray::New(isolate, handle(shared->feedback_vector()),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698