Reviewers: danno, Michael Starzinger,
Description:
Widen the intake valve for TurboFan.
[email protected],[email protected]
BUG=
Please review this at https://codereview.chromium.org/582703002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+74, -10 lines):
M src/compiler.h
M src/compiler.cc
M src/flag-definitions.h
M src/objects.h
M src/objects-inl.h
M src/parser.cc
M src/runtime.cc
M src/scopeinfo.cc
M src/scopes.h
M src/scopes.cc
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index
644f7e9022e6a4066664782dc986b33168787dd7..32ba947928193073c19a0c16acb079790ede6368
100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -623,6 +623,7 @@ static void SetFunctionInfo(Handle<SharedFunctionInfo>
function_info,
function_info->set_bailout_reason(lit->dont_optimize_reason());
function_info->set_dont_cache(lit->flags()->Contains(kDontCache));
function_info->set_kind(lit->kind());
+ function_info->set_asm_function(lit->scope()->asm_function());
}
@@ -729,6 +730,38 @@ MaybeHandle<Code>
Compiler::GetUnoptimizedCode(Handle<JSFunction> function) {
MaybeHandle<Code> Compiler::GetLazyCode(Handle<JSFunction> function) {
DCHECK(!function->GetIsolate()->has_pending_exception());
DCHECK(!function->is_compiled());
+
+ if (FLAG_turbo_asm && function->shared()->asm_function()) {
+ CompilationInfoWithZone info(function);
+
+ VMState<COMPILER> state(info.isolate());
+ PostponeInterruptsScope postpone(info.isolate());
+
+ if (FLAG_trace_opt) {
+ // TODO(titzer): record and report full stats here.
+ PrintF("[optimizing asm ");
+ function->ShortPrint();
+ PrintF("]\n");
+ }
+
+ if (!Parser::Parse(&info)) return MaybeHandle<Code>();
+ if (!Rewriter::Rewrite(&info)) return MaybeHandle<Code>();
+ if (!Scope::Analyze(&info)) return MaybeHandle<Code>();
+ if (FLAG_turbo_deoptimization && !EnsureDeoptimizationSupport(&info)) {
+ return MaybeHandle<Code>();
+ }
+
+ info.SetOptimizing(BailoutId::None(),
+ Handle<Code>(function->shared()->code()));
+
+ info.MarkAsContextSpecializing();
+ info.MarkAsTypingEnabled();
+ info.MarkAsInliningDisabled();
+ compiler::Pipeline pipeline(&info);
+ pipeline.GenerateCode();
+ if (!info.code().is_null()) return info.code();
+ }
+
if (function->shared()->is_compiled()) {
return Handle<Code>(function->shared()->code());
}
Index: src/compiler.h
diff --git a/src/compiler.h b/src/compiler.h
index
a7e83c8720ffd8be6d6db1b2710a6da93a8d2cbe..ea93f408c653127fe2c3cd58bf49140df3efdf6b
100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -197,6 +197,8 @@ class CompilationInfo {
void MarkAsInliningEnabled() { SetFlag(kInliningEnabled); }
+ void MarkAsInliningDisabled() { SetFlag(kInliningEnabled, false); }
+
bool is_inlining_enabled() const { return GetFlag(kInliningEnabled); }
void MarkAsTypingEnabled() { SetFlag(kTypingEnabled); }
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index
c77d801413a1271f3d7050720cd615bfb1b552d0..d4f28d340f6b316cb025212041e740d1419ab26a
100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -332,6 +332,7 @@ DEFINE_STRING(turbo_filter, "~", "optimization filter
for TurboFan compiler")
DEFINE_BOOL(trace_turbo, false, "trace generated TurboFan IR")
DEFINE_BOOL(trace_turbo_types, true, "trace generated TurboFan types")
DEFINE_BOOL(trace_turbo_scheduler, false, "trace generated TurboFan
scheduler")
+DEFINE_BOOL(turbo_asm, false, "enable TurboFan for asm.js code")
DEFINE_BOOL(turbo_verify, false, "verify TurboFan graphs at each phase")
DEFINE_BOOL(turbo_stats, false, "print TurboFan statistics")
#if V8_TURBOFAN_BACKEND
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
8c8b40c856fb438a6e9bdf7426aa08240f108b3e..e46dd8e7dd0e898142b730e96c1ac100080c907a
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -5447,6 +5447,7 @@ BOOL_ACCESSORS(SharedFunctionInfo,
compiler_hints,
has_duplicate_parameters,
kHasDuplicateParameters)
+BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, asm_function,
kIsAsmFunction)
#if V8_HOST_ARCH_32_BIT
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
90dbfa5d1f0714e879e169a27bd5c6375143a46e..a2f9c80b0e61ad2c79c6125e1736cf0c4139ab69
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -4471,6 +4471,12 @@ class ScopeInfo : public FixedArray {
// Return if contexts are allocated for this scope.
bool HasContext();
+ // Return if this is a function scope with "use asm".
+ bool IsAsmModule() { return AsmModuleField::decode(Flags()); }
+
+ // Return if this is a nested function within an asm module scope.
+ bool IsAsmFunction() { return AsmFunctionField::decode(Flags()); }
+
// Return the function_name if present.
String* FunctionName();
@@ -4625,6 +4631,8 @@ class ScopeInfo : public FixedArray {
class StrictModeField: public BitField<StrictMode, 4, 1>
{};
class FunctionVariableField: public BitField<FunctionVariableInfo, 5, 2>
{};
class FunctionVariableMode: public BitField<VariableMode, 7, 3>
{};
+ class AsmModuleField : public BitField<bool, 10, 1> {};
+ class AsmFunctionField : public BitField<bool, 11, 1> {};
// BitFields representing the encoded information for context locals in
the
// ContextLocalInfoEntries part.
@@ -7127,6 +7135,9 @@ class SharedFunctionInfo: public HeapObject {
// Indicates that this function is a concise method.
DECL_BOOLEAN_ACCESSORS(is_concise_method)
+ // Indicates that this function is an asm function.
+ DECL_BOOLEAN_ACCESSORS(asm_function)
+
inline FunctionKind kind();
inline void set_kind(FunctionKind kind);
@@ -7327,6 +7338,7 @@ class SharedFunctionInfo: public HeapObject {
kIsArrow,
kIsGenerator,
kIsConciseMethod,
+ kIsAsmFunction,
kCompilerHintsCount // Pseudo entry
};
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index
2e552e10f3b1256ab9b8bf6b0c87bd070900515e..596ddf3d096b8b620dc49b508d0abfacc126cf30
100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1113,6 +1113,7 @@ void*
Parser::ParseSourceElements(ZoneList<Statement*>* processor,
// Store the usage count; The actual use counter on the isolate
is
// incremented after parsing is done.
++use_counts_[v8::Isolate::kUseAsm];
+ scope_->SetAsmModule();
}
} else {
// End of the directive prologue.
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
d5cd2a823a66448510a33ef8693c65979b4105ca..9f6f55d594e595a6b23d15f9163b971759249875
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -8468,13 +8468,9 @@ RUNTIME_FUNCTION(Runtime_CompileLazy) {
Handle<Code> code;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, code,
Compiler::GetLazyCode(function));
+ DCHECK(code->kind() == Code::FUNCTION ||
+ code->kind() == Code::OPTIMIZED_FUNCTION);
function->ReplaceCode(*code);
-
- // All done. Return the compiled code.
- DCHECK(function->is_compiled());
- DCHECK(function->code()->kind() == Code::FUNCTION ||
- (FLAG_always_opt &&
- function->code()->kind() == Code::OPTIMIZED_FUNCTION));
return *code;
}
Index: src/scopeinfo.cc
diff --git a/src/scopeinfo.cc b/src/scopeinfo.cc
index
6aed7252a17f045278eea67de3ec9c6499369780..75bf014358cd44731f558225919e513846730900
100644
--- a/src/scopeinfo.cc
+++ b/src/scopeinfo.cc
@@ -54,10 +54,12 @@ Handle<ScopeInfo> ScopeInfo::Create(Scope* scope, Zone*
zone) {
// Encode the flags.
int flags = ScopeTypeField::encode(scope->scope_type()) |
- CallsEvalField::encode(scope->calls_eval()) |
- StrictModeField::encode(scope->strict_mode()) |
- FunctionVariableField::encode(function_name_info) |
- FunctionVariableMode::encode(function_variable_mode);
+ CallsEvalField::encode(scope->calls_eval()) |
+ StrictModeField::encode(scope->strict_mode()) |
+ FunctionVariableField::encode(function_name_info) |
+ FunctionVariableMode::encode(function_variable_mode) |
+ AsmModuleField::encode(scope->asm_module()) |
+ AsmFunctionField::encode(scope->asm_function());
scope_info->SetFlags(flags);
scope_info->SetParameterCount(parameter_count);
scope_info->SetStackLocalCount(stack_local_count);
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index
e1297b332ca52bd224bce0129ae3c72d3419ceac..440c7f280b4820c2dd814a2f6187b4705e6de99a
100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -160,6 +160,8 @@ void Scope::SetDefaults(ScopeType scope_type,
scope_inside_with_ = false;
scope_contains_with_ = false;
scope_calls_eval_ = false;
+ asm_module_ = false;
+ asm_function_ = outer_scope != NULL && outer_scope->asm_module_;
// Inherit the strict mode from the parent scope.
strict_mode_ = outer_scope != NULL ? outer_scope->strict_mode_ : SLOPPY;
outer_scope_calls_sloppy_eval_ = false;
@@ -222,6 +224,8 @@ Scope* Scope::DeserializeScopeChain(Context* context,
Scope* global_scope,
Handle<ScopeInfo>(scope_info),
global_scope->ast_value_factory_,
zone);
+ if (scope_info->IsAsmFunction()) current_scope->asm_function_ = true;
+ if (scope_info->IsAsmModule()) current_scope->asm_module_ = true;
} else if (context->IsBlockContext()) {
ScopeInfo* scope_info = ScopeInfo::cast(context->extension());
current_scope = new(zone) Scope(current_scope,
@@ -1165,6 +1169,9 @@ void Scope::PropagateScopeInfo(bool
outer_scope_calls_sloppy_eval ) {
if (inner->force_eager_compilation_) {
force_eager_compilation_ = true;
}
+ if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) {
+ inner->asm_function_ = true;
+ }
}
}
Index: src/scopes.h
diff --git a/src/scopes.h b/src/scopes.h
index
2757bf2402a6479b0d2bd486495e61f5d6eb2ee8..06c6c9995f1023e1bb064cd6357928375779e724
100644
--- a/src/scopes.h
+++ b/src/scopes.h
@@ -214,6 +214,9 @@ class Scope: public ZoneObject {
// Set the strict mode flag (unless disabled by a global flag).
void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode;
}
+ // Set the ASM module flag.
+ void SetAsmModule() { asm_module_ = true; }
+
// Position in the source where this scope begins and ends.
//
// * For the scope of a with statement
@@ -281,6 +284,8 @@ class Scope: public ZoneObject {
bool outer_scope_calls_sloppy_eval() const {
return outer_scope_calls_sloppy_eval_;
}
+ bool asm_module() const { return asm_module_; }
+ bool asm_function() const { return asm_function_; }
// Is this scope inside a with statement.
bool inside_with() const { return scope_inside_with_; }
@@ -463,6 +468,10 @@ class Scope: public ZoneObject {
// This scope or a nested catch scope or with scope contain an 'eval'
call. At
// the 'eval' call site this scope is the declaration scope.
bool scope_calls_eval_;
+ // This scope contains an "use asm" annotation.
+ bool asm_module_;
+ // This scope's outer context is an asm module.
+ bool asm_function_;
// The strict mode of this scope.
StrictMode strict_mode_;
// Source positions.
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.