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

Side by Side Diff: src/ast.cc

Issue 10690043: Implement proper module linking. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 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
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 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 #define DONT_INLINE_NODE(NodeType) \ 1026 #define DONT_INLINE_NODE(NodeType) \
1027 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1027 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1028 increase_node_count(); \ 1028 increase_node_count(); \
1029 add_flag(kDontInline); \ 1029 add_flag(kDontInline); \
1030 } 1030 }
1031 #define DONT_SELFOPTIMIZE_NODE(NodeType) \ 1031 #define DONT_SELFOPTIMIZE_NODE(NodeType) \
1032 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1032 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1033 increase_node_count(); \ 1033 increase_node_count(); \
1034 add_flag(kDontSelfOptimize); \ 1034 add_flag(kDontSelfOptimize); \
1035 } 1035 }
1036 #define DONT_CACHE_NODE(NodeType) \
1037 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1038 increase_node_count(); \
1039 add_flag(kDontOptimize); \
1040 add_flag(kDontInline); \
1041 add_flag(kDontSelfOptimize); \
1042 add_flag(kDontCache); \
1043 }
1036 1044
1037 REGULAR_NODE(VariableDeclaration) 1045 REGULAR_NODE(VariableDeclaration)
1038 REGULAR_NODE(FunctionDeclaration) 1046 REGULAR_NODE(FunctionDeclaration)
1039 REGULAR_NODE(Block) 1047 REGULAR_NODE(Block)
1040 REGULAR_NODE(ExpressionStatement) 1048 REGULAR_NODE(ExpressionStatement)
1041 REGULAR_NODE(EmptyStatement) 1049 REGULAR_NODE(EmptyStatement)
1042 REGULAR_NODE(IfStatement) 1050 REGULAR_NODE(IfStatement)
1043 REGULAR_NODE(ContinueStatement) 1051 REGULAR_NODE(ContinueStatement)
1044 REGULAR_NODE(BreakStatement) 1052 REGULAR_NODE(BreakStatement)
1045 REGULAR_NODE(ReturnStatement) 1053 REGULAR_NODE(ReturnStatement)
(...skipping 12 matching lines...) Expand all
1058 REGULAR_NODE(CompareOperation) 1066 REGULAR_NODE(CompareOperation)
1059 REGULAR_NODE(ThisFunction) 1067 REGULAR_NODE(ThisFunction)
1060 REGULAR_NODE(Call) 1068 REGULAR_NODE(Call)
1061 REGULAR_NODE(CallNew) 1069 REGULAR_NODE(CallNew)
1062 // In theory, for VariableProxy we'd have to add: 1070 // In theory, for VariableProxy we'd have to add:
1063 // if (node->var()->IsLookupSlot()) add_flag(kDontInline); 1071 // if (node->var()->IsLookupSlot()) add_flag(kDontInline);
1064 // But node->var() is usually not bound yet at VariableProxy creation time, and 1072 // But node->var() is usually not bound yet at VariableProxy creation time, and
1065 // LOOKUP variables only result from constructs that cannot be inlined anyway. 1073 // LOOKUP variables only result from constructs that cannot be inlined anyway.
1066 REGULAR_NODE(VariableProxy) 1074 REGULAR_NODE(VariableProxy)
1067 1075
1076 // We currently do not optimize any modules. Note in particular, that module
1077 // instance objects associated with ModuleLiterals are allocated during
1078 // scope resolution, and references to them are embedded into the code.
1079 // That code may hence neither be cached nor re-compiled.
1068 DONT_OPTIMIZE_NODE(ModuleDeclaration) 1080 DONT_OPTIMIZE_NODE(ModuleDeclaration)
1069 DONT_OPTIMIZE_NODE(ImportDeclaration) 1081 DONT_OPTIMIZE_NODE(ImportDeclaration)
1070 DONT_OPTIMIZE_NODE(ExportDeclaration) 1082 DONT_OPTIMIZE_NODE(ExportDeclaration)
1071 DONT_OPTIMIZE_NODE(ModuleLiteral) 1083 DONT_CACHE_NODE(ModuleLiteral)
Michael Starzinger 2012/07/06 10:53:22 Can we move that out into a separate group instead
rossberg 2012/07/06 15:39:28 Done.
1072 DONT_OPTIMIZE_NODE(ModuleVariable) 1084 DONT_OPTIMIZE_NODE(ModuleVariable)
1073 DONT_OPTIMIZE_NODE(ModulePath) 1085 DONT_OPTIMIZE_NODE(ModulePath)
1074 DONT_OPTIMIZE_NODE(ModuleUrl) 1086 DONT_OPTIMIZE_NODE(ModuleUrl)
1075 DONT_OPTIMIZE_NODE(WithStatement) 1087 DONT_OPTIMIZE_NODE(WithStatement)
1076 DONT_OPTIMIZE_NODE(TryCatchStatement) 1088 DONT_OPTIMIZE_NODE(TryCatchStatement)
1077 DONT_OPTIMIZE_NODE(TryFinallyStatement) 1089 DONT_OPTIMIZE_NODE(TryFinallyStatement)
1078 DONT_OPTIMIZE_NODE(DebuggerStatement) 1090 DONT_OPTIMIZE_NODE(DebuggerStatement)
1079 DONT_OPTIMIZE_NODE(SharedFunctionInfoLiteral) 1091 DONT_OPTIMIZE_NODE(SharedFunctionInfoLiteral)
1080 1092
1081 DONT_INLINE_NODE(FunctionLiteral) 1093 DONT_INLINE_NODE(FunctionLiteral)
(...skipping 15 matching lines...) Expand all
1097 // Don't inline the %_ArgumentsLength or %_Arguments because their 1109 // Don't inline the %_ArgumentsLength or %_Arguments because their
1098 // implementation will not work. There is no stack frame to get them 1110 // implementation will not work. There is no stack frame to get them
1099 // from. 1111 // from.
1100 add_flag(kDontInline); 1112 add_flag(kDontInline);
1101 } 1113 }
1102 } 1114 }
1103 1115
1104 #undef REGULAR_NODE 1116 #undef REGULAR_NODE
1105 #undef DONT_OPTIMIZE_NODE 1117 #undef DONT_OPTIMIZE_NODE
1106 #undef DONT_INLINE_NODE 1118 #undef DONT_INLINE_NODE
1107 #undef DONT_SELFOPTIMIZE_NODE 1119 #undef DONT_SELFOPTIMIZE_NODE
Michael Starzinger 2012/07/06 10:53:22 Also #undef DONT_CACHE_NODE here.
rossberg 2012/07/06 15:39:28 Done.
1108 1120
1109 1121
1110 Handle<String> Literal::ToString() { 1122 Handle<String> Literal::ToString() {
1111 if (handle_->IsString()) return Handle<String>::cast(handle_); 1123 if (handle_->IsString()) return Handle<String>::cast(handle_);
1112 ASSERT(handle_->IsNumber()); 1124 ASSERT(handle_->IsNumber());
1113 char arr[100]; 1125 char arr[100];
1114 Vector<char> buffer(arr, ARRAY_SIZE(arr)); 1126 Vector<char> buffer(arr, ARRAY_SIZE(arr));
1115 const char* str; 1127 const char* str;
1116 if (handle_->IsSmi()) { 1128 if (handle_->IsSmi()) {
1117 // Optimization only, the heap number case would subsume this. 1129 // Optimization only, the heap number case would subsume this.
1118 OS::SNPrintF(buffer, "%d", Smi::cast(*handle_)->value()); 1130 OS::SNPrintF(buffer, "%d", Smi::cast(*handle_)->value());
1119 str = arr; 1131 str = arr;
1120 } else { 1132 } else {
1121 str = DoubleToCString(handle_->Number(), buffer); 1133 str = DoubleToCString(handle_->Number(), buffer);
1122 } 1134 }
1123 return FACTORY->NewStringFromAscii(CStrVector(str)); 1135 return FACTORY->NewStringFromAscii(CStrVector(str));
1124 } 1136 }
1125 1137
1126 1138
1127 } } // namespace v8::internal 1139 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698