Index: src/ast/collect-eager-literals.cc |
diff --git a/src/ast/collect-eager-literals.cc b/src/ast/collect-eager-literals.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0b8a21e3dac81db4ef263f66f293e3190c7157c4 |
--- /dev/null |
+++ b/src/ast/collect-eager-literals.cc |
@@ -0,0 +1,43 @@ |
+// Copyright 2016 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "src/ast/collect-eager-literals.h" |
+ |
+#include "src/ast/ast.h" |
+#include "src/compilation-info.h" |
+#include "src/parsing/parse-info.h" |
+ |
+namespace v8 { |
+namespace internal { |
+ |
+CollectEagerLiterals::CollectEagerLiterals(CompilationInfo* info) |
+ : AstTraversalVisitor(info->isolate(), info->parse_info()->literal()), |
+ parse_info_(info->parse_info()) {} |
+ |
+CollectEagerLiterals::~CollectEagerLiterals() {} |
+ |
+void CollectEagerLiterals::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
+ i::Variable* variable = decl->proxy()->var(); |
+ DCHECK(variable->mode() == LET || variable->mode() == VAR); |
+ if (variable->location() == VariableLocation::UNALLOCATED) { |
Michael Starzinger
2016/10/17 13:16:03
Why have this special handling here? Any FunctionD
jochen (gone - plz use gerrit)
2016/10/17 13:19:10
VisitFunctionLiteral doesn't visit the declaration
Michael Starzinger
2016/10/17 13:37:48
Not sure I fully understand your response, AstTrav
|
+ if (decl->fun()->ShouldEagerCompile()) { |
+ eager_literals_.insert(decl->fun()); |
+ } else { |
+ return; |
Michael Starzinger
2016/10/17 13:16:03
nit: Why return here? Shouldn't we always fall thr
jochen (gone - plz use gerrit)
2016/10/17 13:19:10
if a function doesn't eager compiler, it might not
Michael Starzinger
2016/10/17 13:37:48
Then this should go into VisitFunctionLiteral belo
|
+ } |
+ } |
+ AstTraversalVisitor::VisitFunctionDeclaration(decl); |
+} |
+ |
+void CollectEagerLiterals::VisitFunctionLiteral(FunctionLiteral* fun) { |
+ if (fun->ShouldEagerCompile()) { |
+ if (fun != parse_info_->literal()) { |
+ eager_literals_.insert(fun); |
+ } |
+ AstTraversalVisitor::VisitFunctionLiteral(fun); |
+ } |
+} |
+ |
+} // namespace internal |
+} // namespace v8 |