Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/ast.cc

Issue 12642011: Allow inlining of functions containing array literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1000 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1001 increase_node_count(); \ 1001 increase_node_count(); \
1002 } 1002 }
1003 #define DONT_OPTIMIZE_NODE(NodeType) \ 1003 #define DONT_OPTIMIZE_NODE(NodeType) \
1004 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1004 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1005 increase_node_count(); \ 1005 increase_node_count(); \
1006 add_flag(kDontOptimize); \ 1006 add_flag(kDontOptimize); \
1007 add_flag(kDontInline); \ 1007 add_flag(kDontInline); \
1008 add_flag(kDontSelfOptimize); \ 1008 add_flag(kDontSelfOptimize); \
1009 } 1009 }
1010 #define DONT_INLINE_NODE(NodeType) \
1011 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1012 increase_node_count(); \
1013 add_flag(kDontInline); \
1014 }
1015 #define DONT_SELFOPTIMIZE_NODE(NodeType) \ 1010 #define DONT_SELFOPTIMIZE_NODE(NodeType) \
1016 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1011 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1017 increase_node_count(); \ 1012 increase_node_count(); \
1018 add_flag(kDontSelfOptimize); \ 1013 add_flag(kDontSelfOptimize); \
1019 } 1014 }
1020 #define DONT_CACHE_NODE(NodeType) \ 1015 #define DONT_CACHE_NODE(NodeType) \
1021 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1016 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1022 increase_node_count(); \ 1017 increase_node_count(); \
1023 add_flag(kDontOptimize); \ 1018 add_flag(kDontOptimize); \
1024 add_flag(kDontInline); \ 1019 add_flag(kDontInline); \
1025 add_flag(kDontSelfOptimize); \ 1020 add_flag(kDontSelfOptimize); \
1026 add_flag(kDontCache); \ 1021 add_flag(kDontCache); \
1027 } 1022 }
1028 1023
1029 REGULAR_NODE(VariableDeclaration) 1024 REGULAR_NODE(VariableDeclaration)
1030 REGULAR_NODE(FunctionDeclaration) 1025 REGULAR_NODE(FunctionDeclaration)
1031 REGULAR_NODE(Block) 1026 REGULAR_NODE(Block)
1032 REGULAR_NODE(ExpressionStatement) 1027 REGULAR_NODE(ExpressionStatement)
1033 REGULAR_NODE(EmptyStatement) 1028 REGULAR_NODE(EmptyStatement)
1034 REGULAR_NODE(IfStatement) 1029 REGULAR_NODE(IfStatement)
1035 REGULAR_NODE(ContinueStatement) 1030 REGULAR_NODE(ContinueStatement)
1036 REGULAR_NODE(BreakStatement) 1031 REGULAR_NODE(BreakStatement)
1037 REGULAR_NODE(ReturnStatement) 1032 REGULAR_NODE(ReturnStatement)
1038 REGULAR_NODE(SwitchStatement) 1033 REGULAR_NODE(SwitchStatement)
1039 REGULAR_NODE(Conditional) 1034 REGULAR_NODE(Conditional)
1040 REGULAR_NODE(Literal) 1035 REGULAR_NODE(Literal)
1036 REGULAR_NODE(ArrayLiteral)
1041 REGULAR_NODE(ObjectLiteral) 1037 REGULAR_NODE(ObjectLiteral)
1042 REGULAR_NODE(RegExpLiteral) 1038 REGULAR_NODE(RegExpLiteral)
1043 REGULAR_NODE(FunctionLiteral) 1039 REGULAR_NODE(FunctionLiteral)
1044 REGULAR_NODE(Assignment) 1040 REGULAR_NODE(Assignment)
1045 REGULAR_NODE(Throw) 1041 REGULAR_NODE(Throw)
1046 REGULAR_NODE(Property) 1042 REGULAR_NODE(Property)
1047 REGULAR_NODE(UnaryOperation) 1043 REGULAR_NODE(UnaryOperation)
1048 REGULAR_NODE(CountOperation) 1044 REGULAR_NODE(CountOperation)
1049 REGULAR_NODE(BinaryOperation) 1045 REGULAR_NODE(BinaryOperation)
1050 REGULAR_NODE(CompareOperation) 1046 REGULAR_NODE(CompareOperation)
(...skipping 13 matching lines...) Expand all
1064 DONT_OPTIMIZE_NODE(ModuleVariable) 1060 DONT_OPTIMIZE_NODE(ModuleVariable)
1065 DONT_OPTIMIZE_NODE(ModulePath) 1061 DONT_OPTIMIZE_NODE(ModulePath)
1066 DONT_OPTIMIZE_NODE(ModuleUrl) 1062 DONT_OPTIMIZE_NODE(ModuleUrl)
1067 DONT_OPTIMIZE_NODE(ModuleStatement) 1063 DONT_OPTIMIZE_NODE(ModuleStatement)
1068 DONT_OPTIMIZE_NODE(WithStatement) 1064 DONT_OPTIMIZE_NODE(WithStatement)
1069 DONT_OPTIMIZE_NODE(TryCatchStatement) 1065 DONT_OPTIMIZE_NODE(TryCatchStatement)
1070 DONT_OPTIMIZE_NODE(TryFinallyStatement) 1066 DONT_OPTIMIZE_NODE(TryFinallyStatement)
1071 DONT_OPTIMIZE_NODE(DebuggerStatement) 1067 DONT_OPTIMIZE_NODE(DebuggerStatement)
1072 DONT_OPTIMIZE_NODE(SharedFunctionInfoLiteral) 1068 DONT_OPTIMIZE_NODE(SharedFunctionInfoLiteral)
1073 1069
1074 DONT_INLINE_NODE(ArrayLiteral) // TODO(1322): Allow materialized literals.
1075
1076 DONT_SELFOPTIMIZE_NODE(DoWhileStatement) 1070 DONT_SELFOPTIMIZE_NODE(DoWhileStatement)
1077 DONT_SELFOPTIMIZE_NODE(WhileStatement) 1071 DONT_SELFOPTIMIZE_NODE(WhileStatement)
1078 DONT_SELFOPTIMIZE_NODE(ForStatement) 1072 DONT_SELFOPTIMIZE_NODE(ForStatement)
1079 DONT_SELFOPTIMIZE_NODE(ForInStatement) 1073 DONT_SELFOPTIMIZE_NODE(ForInStatement)
1080 1074
1081 DONT_CACHE_NODE(ModuleLiteral) 1075 DONT_CACHE_NODE(ModuleLiteral)
1082 1076
1083 void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) { 1077 void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) {
1084 increase_node_count(); 1078 increase_node_count();
1085 if (node->is_jsruntime()) { 1079 if (node->is_jsruntime()) {
1086 // Don't try to inline JS runtime calls because we don't (currently) even 1080 // Don't try to inline JS runtime calls because we don't (currently) even
1087 // optimize them. 1081 // optimize them.
1088 add_flag(kDontInline); 1082 add_flag(kDontInline);
1089 } else if (node->function()->intrinsic_type == Runtime::INLINE && 1083 } else if (node->function()->intrinsic_type == Runtime::INLINE &&
1090 (node->name()->IsOneByteEqualTo( 1084 (node->name()->IsOneByteEqualTo(
1091 STATIC_ASCII_VECTOR("_ArgumentsLength")) || 1085 STATIC_ASCII_VECTOR("_ArgumentsLength")) ||
1092 node->name()->IsOneByteEqualTo(STATIC_ASCII_VECTOR("_Arguments")))) { 1086 node->name()->IsOneByteEqualTo(STATIC_ASCII_VECTOR("_Arguments")))) {
1093 // Don't inline the %_ArgumentsLength or %_Arguments because their 1087 // Don't inline the %_ArgumentsLength or %_Arguments because their
1094 // implementation will not work. There is no stack frame to get them 1088 // implementation will not work. There is no stack frame to get them
1095 // from. 1089 // from.
1096 add_flag(kDontInline); 1090 add_flag(kDontInline);
1097 } 1091 }
1098 } 1092 }
1099 1093
1100 #undef REGULAR_NODE 1094 #undef REGULAR_NODE
1101 #undef DONT_OPTIMIZE_NODE 1095 #undef DONT_OPTIMIZE_NODE
1102 #undef DONT_INLINE_NODE
1103 #undef DONT_SELFOPTIMIZE_NODE 1096 #undef DONT_SELFOPTIMIZE_NODE
1104 #undef DONT_CACHE_NODE 1097 #undef DONT_CACHE_NODE
1105 1098
1106 1099
1107 Handle<String> Literal::ToString() { 1100 Handle<String> Literal::ToString() {
1108 if (handle_->IsString()) return Handle<String>::cast(handle_); 1101 if (handle_->IsString()) return Handle<String>::cast(handle_);
1109 ASSERT(handle_->IsNumber()); 1102 ASSERT(handle_->IsNumber());
1110 char arr[100]; 1103 char arr[100];
1111 Vector<char> buffer(arr, ARRAY_SIZE(arr)); 1104 Vector<char> buffer(arr, ARRAY_SIZE(arr));
1112 const char* str; 1105 const char* str;
1113 if (handle_->IsSmi()) { 1106 if (handle_->IsSmi()) {
1114 // Optimization only, the heap number case would subsume this. 1107 // Optimization only, the heap number case would subsume this.
1115 OS::SNPrintF(buffer, "%d", Smi::cast(*handle_)->value()); 1108 OS::SNPrintF(buffer, "%d", Smi::cast(*handle_)->value());
1116 str = arr; 1109 str = arr;
1117 } else { 1110 } else {
1118 str = DoubleToCString(handle_->Number(), buffer); 1111 str = DoubleToCString(handle_->Number(), buffer);
1119 } 1112 }
1120 return FACTORY->NewStringFromAscii(CStrVector(str)); 1113 return FACTORY->NewStringFromAscii(CStrVector(str));
1121 } 1114 }
1122 1115
1123 1116
1124 } } // namespace v8::internal 1117 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698