Reviewers: Vyacheslav Egorov,

Message:
Could you please take a look?

This decreases code space size from 20MB to 7MB in the example that we talked
about offline.

Description:
Allow more functions to be lazy compiled.

[email protected]


Please review this at https://chromiumcodereview.appspot.com/10121007/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/ast.h
  M src/ast.cc
  M src/compiler.cc
  M src/scopes.h
  M src/scopes.cc


Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index 6ee48d5b0e88391f7abdd0204c584dfee136b319..86d0e246c66cde623f9973650e94a9d5c143eee8 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -155,6 +155,9 @@ bool FunctionLiteral::AllowsLazyCompilation() {
   return scope()->AllowsLazyCompilation();
 }

+bool FunctionLiteral::AllowsLazyCompilationForNative() {
+  return scope()->AllowsLazyCompilationForNative();
+}

 int FunctionLiteral::start_position() const {
   return scope()->start_position();
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index dad80576bdde36dcd8a22d4740b06960b9f50d50..4b6f8987687aa87bf33b585bc577916fd00d9ec0 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -2061,6 +2061,8 @@ class FunctionLiteral: public Expression {

   bool AllowsLazyCompilation();

+  bool AllowsLazyCompilationForNative();
+
   Handle<String> debug_name() const {
     if (name_->length() > 0) return name_;
     return inferred_name();
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index c9c2480fa2c6dbf326b1bc3314bb5d46de302cd8..efdc52121e54de835bcaed85e100597c3580a47c 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -717,7 +717,8 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal,
   // if a function uses the special natives syntax, which is something the
   // parser records.
   bool allow_lazy = literal->AllowsLazyCompilation() &&
-      !LiveEditFunctionTracker::IsActive(info.isolate());
+      !LiveEditFunctionTracker::IsActive(info.isolate()) &&
+      (!info.is_native() || literal->AllowsLazyCompilationForNative());

   Handle<ScopeInfo> scope_info(ScopeInfo::Empty());

Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index 6f6032a320d30bbd2d9b7a572c77671f2eb61967..af8423423f6c52d39bfdce78d7ab0ccdeec0ac98 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -630,6 +630,11 @@ bool Scope::AllocateVariables(CompilationInfo* info,


 bool Scope::AllowsLazyCompilation() const {
+  return !force_eager_compilation_;
+}
+
+
+bool Scope::AllowsLazyCompilationForNative() const {
   return !force_eager_compilation_ && HasTrivialOuterContext();
 }

Index: src/scopes.h
diff --git a/src/scopes.h b/src/scopes.h
index e1a658aa8e041a3901f9573a93f687d976ca0467..61d5f64ef58b609f12f92397e3309b78758e13d6 100644
--- a/src/scopes.h
+++ b/src/scopes.h
@@ -361,6 +361,8 @@ class Scope: public ZoneObject {
   // Determine if we can use lazy compilation for this scope.
   bool AllowsLazyCompilation() const;

+  bool AllowsLazyCompilationForNative() const;
+
   // True if we can lazily recompile functions with this scope.
   bool allows_lazy_recompilation() const {
     return !force_eager_compilation_;


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to