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

Side by Side Diff: runtime/vm/parser.cc

Issue 18097004: Support fast noSuchMethod dispatch for any number of arguments. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments Created 7 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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 NULL); 1132 NULL);
1133 1133
1134 ReturnNode* return_node = new ReturnNode(ident_pos, closure); 1134 ReturnNode* return_node = new ReturnNode(ident_pos, closure);
1135 current_block_->statements->Add(return_node); 1135 current_block_->statements->Add(return_node);
1136 return CloseBlock(); 1136 return CloseBlock();
1137 } 1137 }
1138 1138
1139 1139
1140 SequenceNode* Parser::ParseNoSuchMethodDispatcher(const Function& func) { 1140 SequenceNode* Parser::ParseNoSuchMethodDispatcher(const Function& func) {
1141 TRACE_PARSER("ParseNoSuchMethodDispatcher"); 1141 TRACE_PARSER("ParseNoSuchMethodDispatcher");
1142 ParamList params;
1143 1142
1144 ASSERT(func.IsNoSuchMethodDispatcher()); 1143 ASSERT(func.IsNoSuchMethodDispatcher());
1145 intptr_t token_pos = func.token_pos(); 1144 intptr_t token_pos = func.token_pos();
1146 ASSERT(func.token_pos() == 0); 1145 ASSERT(func.token_pos() == 0);
1147 ASSERT(current_class().raw() == func.Owner()); 1146 ASSERT(current_class().raw() == func.Owner());
1147
1148 ArgumentsDescriptor desc(Array::Handle(func.saved_args_desc()));
1149 ASSERT(desc.Count() > 0);
1150 ParamList params;
1148 params.AddReceiver(ReceiverType(token_pos)); 1151 params.AddReceiver(ReceiverType(token_pos));
1149 ASSERT(func.num_fixed_parameters() == 1); // Receiver. 1152 for (intptr_t i = 1; i < desc.Count(); ++i) {
1153 ParamDesc p;
1154 char name[64];
1155 OS::SNPrint(name, 64, ":p%"Pd, i);
1156 p.name = &String::ZoneHandle(Symbols::New(name));
1157 p.type = &Type::ZoneHandle(Type::DynamicType());
1158 params.parameters->Add(p);
1159 }
1150 ASSERT(!func.HasOptionalParameters()); 1160 ASSERT(!func.HasOptionalParameters());
1151 1161
1152 // Build local scope for function and populate with the formal parameters. 1162 // Build local scope for function and populate with the formal parameters.
1153 OpenFunctionBlock(func); 1163 OpenFunctionBlock(func);
1154 LocalScope* scope = current_block_->scope; 1164 LocalScope* scope = current_block_->scope;
1155 AddFormalParamsToScope(&params, scope); 1165 AddFormalParamsToScope(&params, scope);
1156 1166
1157 // Receiver is local 0. 1167 // Receiver is local 0.
1158 LocalVariable* receiver = scope->VariableAt(0); 1168 ArgumentListNode* func_args = new ArgumentListNode(token_pos);
1159 LoadLocalNode* load_receiver = new LoadLocalNode(token_pos, receiver); 1169 for (intptr_t i = 0; i < desc.Count(); ++i) {
1170 func_args->Add(new LoadLocalNode(token_pos, scope->VariableAt(i)));
1171 }
1160 1172
1161 ArgumentListNode* func_args = new ArgumentListNode(token_pos);
1162 func_args->Add(load_receiver);
1163 const String& func_name = String::ZoneHandle(func.name()); 1173 const String& func_name = String::ZoneHandle(func.name());
1164 ArgumentListNode* arguments = BuildNoSuchMethodArguments(token_pos, 1174 ArgumentListNode* arguments = BuildNoSuchMethodArguments(token_pos,
1165 func_name, 1175 func_name,
1166 *func_args); 1176 *func_args);
1167 const Function& no_such_method = Function::ZoneHandle( 1177 const Function& no_such_method = Function::ZoneHandle(
1168 Resolver::ResolveDynamicAnyArgs(Class::Handle(func.Owner()), 1178 Resolver::ResolveDynamicAnyArgs(Class::Handle(func.Owner()),
1169 Symbols::NoSuchMethod())); 1179 Symbols::NoSuchMethod()));
1170 StaticCallNode* call = 1180 StaticCallNode* call =
1171 new StaticCallNode(token_pos, no_such_method, arguments); 1181 new StaticCallNode(token_pos, no_such_method, arguments);
1172 1182
(...skipping 8979 matching lines...) Expand 10 before | Expand all | Expand 10 after
10152 void Parser::SkipQualIdent() { 10162 void Parser::SkipQualIdent() {
10153 ASSERT(IsIdentifier()); 10163 ASSERT(IsIdentifier());
10154 ConsumeToken(); 10164 ConsumeToken();
10155 if (CurrentToken() == Token::kPERIOD) { 10165 if (CurrentToken() == Token::kPERIOD) {
10156 ConsumeToken(); // Consume the kPERIOD token. 10166 ConsumeToken(); // Consume the kPERIOD token.
10157 ExpectIdentifier("identifier expected after '.'"); 10167 ExpectIdentifier("identifier expected after '.'");
10158 } 10168 }
10159 } 10169 }
10160 10170
10161 } // namespace dart 10171 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698