Reviewers: Yang,
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/10702036/
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
8ac139fe85cca56263b2ea5b80d803baff69975a..16734160b38228d1e155ba746c6740e585aff2d6
100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -1023,11 +1023,6 @@ CaseClause::CaseClause(Isolate* isolate,
add_flag(kDontInline); \
add_flag(kDontSelfOptimize); \
}
-#define DONT_INLINE_NODE(NodeType) \
- void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
- increase_node_count(); \
- add_flag(kDontInline); \
- }
#define DONT_SELFOPTIMIZE_NODE(NodeType) \
void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
increase_node_count(); \
@@ -1059,6 +1054,7 @@ REGULAR_NODE(CompareOperation)
REGULAR_NODE(ThisFunction)
REGULAR_NODE(Call)
REGULAR_NODE(CallNew)
+REGULAR_NODE(FunctionLiteral)
// In theory, for VariableProxy we'd have to add:
// if (node->var()->IsLookupSlot()) add_flag(kDontInline);
// But node->var() is usually not bound yet at VariableProxy creation
time, and
@@ -1078,8 +1074,6 @@ DONT_OPTIMIZE_NODE(TryFinallyStatement)
DONT_OPTIMIZE_NODE(DebuggerStatement)
DONT_OPTIMIZE_NODE(SharedFunctionInfoLiteral)
-DONT_INLINE_NODE(FunctionLiteral)
-
DONT_SELFOPTIMIZE_NODE(DoWhileStatement)
DONT_SELFOPTIMIZE_NODE(WhileStatement)
DONT_SELFOPTIMIZE_NODE(ForStatement)
@@ -1103,7 +1097,6 @@ void
AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) {
#undef REGULAR_NODE
#undef DONT_OPTIMIZE_NODE
-#undef DONT_INLINE_NODE
#undef DONT_SELFOPTIMIZE_NODE
Index: test/mjsunit/compiler/inline-literals.js
diff --git a/test/mjsunit/compiler/inline-literals.js
b/test/mjsunit/compiler/inline-literals.js
index
1422586912be98209b9facbfe3db88fa7b56eb14..448799669eea4d958fee3886ae05a613f9351759
100644
--- a/test/mjsunit/compiler/inline-literals.js
+++ b/test/mjsunit/compiler/inline-literals.js
@@ -87,3 +87,24 @@ TestRegExpLiteral("-b", "reg", "exp", "-expreg");
%OptimizeFunctionOnNextCall(TestRegExpLiteral);
TestRegExpLiteral("ab", "reg", "exp", "regexpexpreg");
TestRegExpLiteral("ab", 12345, 54321, "6666666666");
+
+function f2(b, c) {
+ var closure = function(b, c) { return b + c; }
+ var value = b + c;
+ return closure;
+}
+
+function f1(a, b, c) {
+ return a + f2(b, c)(b, c);
+}
+
+function TestFunctionLiteral(a, b, c, expected) {
+ var result = f1(a, b, c);
+ assertEquals(expected, result, "TestFunctionLiteral");
+}
+
+TestFunctionLiteral(1, 2, 3, 6);
+TestFunctionLiteral(4, 5, 6, 15);
+%OptimizeFunctionOnNextCall(TestFunctionLiteral);
+TestFunctionLiteral(7, 8, 9, 24);
+TestFunctionLiteral("a", "b", "c", "abc");
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev