Reviewers: fschneider,

Description:
Allow inlining of functions containing function literals.

[email protected]
BUG=v8:1322
TEST=mjsunit/compiler/inline-literals


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

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

Affected files:
  M src/ast.cc
  M test/mjsunit/compiler/inline-literals.js


Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index 7e886fa35afd07a15edd5a3559e483c739913a6f..43f1ed95d96f94484a9a42f672e71ce4907c935b 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -1010,6 +1010,7 @@ INCREASE_NODE_COUNT(ReturnStatement)
 INCREASE_NODE_COUNT(Conditional)
 INCREASE_NODE_COUNT(Literal)
 INCREASE_NODE_COUNT(ObjectLiteral)
+INCREASE_NODE_COUNT(FunctionLiteral)
 INCREASE_NODE_COUNT(Assignment)
 INCREASE_NODE_COUNT(Throw)
 INCREASE_NODE_COUNT(Property)
@@ -1083,12 +1084,6 @@ void AstConstructionVisitor::VisitDebuggerStatement(DebuggerStatement* node) {
 }


-void AstConstructionVisitor::VisitFunctionLiteral(FunctionLiteral* node) {
-  increase_node_count();
-  add_flag(kDontInline);
-}
-
-
 void AstConstructionVisitor::VisitSharedFunctionInfoLiteral(
     SharedFunctionInfoLiteral* node) {
   increase_node_count();
Index: test/mjsunit/compiler/inline-literals.js
diff --git a/test/mjsunit/compiler/inline-literals.js b/test/mjsunit/compiler/inline-literals.js index f78abe82d16aa795be48375adc08fc86db02f3ad..33d15f5b0444e8f64c2f12c89d84c845fafe44ae 100644
--- a/test/mjsunit/compiler/inline-literals.js
+++ b/test/mjsunit/compiler/inline-literals.js
@@ -45,6 +45,26 @@ function TestObjectLiteral(a, b, c) {

 TestObjectLiteral(1, 2, 3);
 TestObjectLiteral(1, 2, 3);
-%OptimizeFunctionOnNextCall(TestObjectLiteral);
+%OptimizeFunctionOnNextCall(o1);
 TestObjectLiteral(1, 2, 3);
 TestObjectLiteral('a', 'b', 'c');
+
+function f2() {
+  return function(b, c) { return b + c; };
+}
+
+function f1(a, b, c) {
+  return a + f2()(b, c);
+}
+
+function TestFunctionLiteral(a, b, c) {
+  var expected = a + b + c;
+  var result = f1(a, b, c);
+  assertEquals(expected, result, "TestFunctionLiteral");
+}
+
+TestFunctionLiteral(1, 2, 3);
+TestFunctionLiteral(1, 2, 3);
+%OptimizeFunctionOnNextCall(f1);
+TestFunctionLiteral(1, 2, 3);
+TestFunctionLiteral('a', 'b', 'c');


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

Reply via email to