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

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

Issue 10915022: Implement argument definition test in the vm. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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/flow_graph_builder.h" 5 #include "vm/flow_graph_builder.h"
6 6
7 #include "vm/ast_printer.h" 7 #include "vm/ast_printer.h"
8 #include "vm/code_descriptors.h" 8 #include "vm/code_descriptors.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 Goto(jump_target); 1315 Goto(jump_target);
1316 } 1316 }
1317 1317
1318 1318
1319 void EffectGraphVisitor::VisitArgumentListNode(ArgumentListNode* node) { 1319 void EffectGraphVisitor::VisitArgumentListNode(ArgumentListNode* node) {
1320 InlineBailout("EffectGraphVisitor::VisitArgumentListNode"); 1320 InlineBailout("EffectGraphVisitor::VisitArgumentListNode");
1321 UNREACHABLE(); 1321 UNREACHABLE();
1322 } 1322 }
1323 1323
1324 1324
1325 void EffectGraphVisitor::VisitArgumentDefinitionTestNode(
1326 ArgumentDefinitionTestNode* node) {
1327 Computation* load = BuildLoadLocal(node->saved_arguments_descriptor());
1328 Value* arguments_descriptor = Bind(load);
1329 ArgumentDefinitionTestComp* arg_def_test =
1330 new ArgumentDefinitionTestComp(node, arguments_descriptor);
1331 ReturnComputation(arg_def_test);
1332 }
1333
1334
1325 void EffectGraphVisitor::VisitArrayNode(ArrayNode* node) { 1335 void EffectGraphVisitor::VisitArrayNode(ArrayNode* node) {
1326 InlineBailout("EffectGraphVisitor::VisitArrayNode"); 1336 InlineBailout("EffectGraphVisitor::VisitArrayNode");
1327 // Translate the array elements and collect their values. 1337 // Translate the array elements and collect their values.
1328 ZoneGrowableArray<PushArgumentInstr*>* arguments = 1338 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1329 new ZoneGrowableArray<PushArgumentInstr*>(node->length()); 1339 new ZoneGrowableArray<PushArgumentInstr*>(node->length());
1330 for (int i = 0; i < node->length(); ++i) { 1340 for (int i = 0; i < node->length(); ++i) {
1331 ValueGraphVisitor for_value(owner(), temp_index()); 1341 ValueGraphVisitor for_value(owner(), temp_index());
1332 node->ElementAt(i)->Visit(&for_value); 1342 node->ElementAt(i)->Visit(&for_value);
1333 Append(for_value); 1343 Append(for_value);
1334 arguments->Add(PushArgument(for_value.value())); 1344 arguments->Add(PushArgument(for_value.value()));
(...skipping 12 matching lines...) Expand all
1347 1357
1348 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { 1358 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) {
1349 InlineBailout("EffectGraphVisitor::VisitClosureNode"); 1359 InlineBailout("EffectGraphVisitor::VisitClosureNode");
1350 const Function& function = node->function(); 1360 const Function& function = node->function();
1351 1361
1352 Value* receiver = NULL; 1362 Value* receiver = NULL;
1353 if (function.IsNonImplicitClosureFunction()) { 1363 if (function.IsNonImplicitClosureFunction()) {
1354 // The context scope may have already been set by the non-optimizing 1364 // The context scope may have already been set by the non-optimizing
1355 // compiler. If it was not, set it here. 1365 // compiler. If it was not, set it here.
1356 if (function.context_scope() == ContextScope::null()) { 1366 if (function.context_scope() == ContextScope::null()) {
1367 // TODO(regis): Why are we not doing this in the parser?
1357 const ContextScope& context_scope = ContextScope::ZoneHandle( 1368 const ContextScope& context_scope = ContextScope::ZoneHandle(
1358 node->scope()->PreserveOuterScope(owner()->context_level())); 1369 node->scope()->PreserveOuterScope(owner()->context_level()));
1359 ASSERT(!function.HasCode()); 1370 ASSERT(!function.HasCode());
1360 ASSERT(function.context_scope() == ContextScope::null()); 1371 ASSERT(function.context_scope() == ContextScope::null());
1361 function.set_context_scope(context_scope); 1372 function.set_context_scope(context_scope);
1362 } 1373 }
1363 receiver = BuildNullValue(); 1374 receiver = BuildNullValue();
1364 } else if (function.IsImplicitInstanceClosureFunction()) { 1375 } else if (function.IsImplicitInstanceClosureFunction()) {
1365 ValueGraphVisitor for_receiver(owner(), temp_index()); 1376 ValueGraphVisitor for_receiver(owner(), temp_index());
1366 node->receiver()->Visit(&for_receiver); 1377 node->receiver()->Visit(&for_receiver);
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 } 2237 }
2227 2238
2228 Do(new ChainContextComp(allocated_context)); 2239 Do(new ChainContextComp(allocated_context));
2229 owner()->set_context_level(scope->context_level()); 2240 owner()->set_context_level(scope->context_level());
2230 2241
2231 // If this node_sequence is the body of the function being compiled, copy 2242 // If this node_sequence is the body of the function being compiled, copy
2232 // the captured parameters from the frame into the context. 2243 // the captured parameters from the frame into the context.
2233 if (node == owner()->parsed_function().node_sequence()) { 2244 if (node == owner()->parsed_function().node_sequence()) {
2234 ASSERT(scope->context_level() == 1); 2245 ASSERT(scope->context_level() == 1);
2235 const Function& function = owner()->parsed_function().function(); 2246 const Function& function = owner()->parsed_function().function();
2236 const int num_params = function.NumberOfParameters(); 2247 int num_params = function.NumberOfParameters();
2237 int param_frame_index = (num_params == function.num_fixed_parameters()) ? 2248 int param_frame_index = (num_params == function.num_fixed_parameters()) ?
2238 (1 + num_params) : ParsedFunction::kFirstLocalSlotIndex; 2249 (1 + num_params) : ParsedFunction::kFirstLocalSlotIndex;
2250 // Handle the saved arguments descriptor as an additional parameter.
2251 if (owner()->parsed_function().GetSavedArgumentsDescriptorVar() != NULL) {
2252 ASSERT(param_frame_index == ParsedFunction::kFirstLocalSlotIndex);
2253 num_params++;
2254 }
2239 for (int pos = 0; pos < num_params; param_frame_index--, pos++) { 2255 for (int pos = 0; pos < num_params; param_frame_index--, pos++) {
2240 const LocalVariable& parameter = *scope->VariableAt(pos); 2256 const LocalVariable& parameter = *scope->VariableAt(pos);
2241 ASSERT(parameter.owner() == scope); 2257 ASSERT(parameter.owner() == scope);
2242 if (parameter.is_captured()) { 2258 if (parameter.is_captured()) {
2243 // Create a temporary local describing the original position. 2259 // Create a temporary local describing the original position.
2244 const String& temp_name = String::ZoneHandle(String::Concat( 2260 const String& temp_name = String::ZoneHandle(String::Concat(
2245 parameter.name(), String::Handle(Symbols::New("-orig")))); 2261 parameter.name(), String::Handle(Symbols::New("-orig"))));
2246 LocalVariable* temp_local = new LocalVariable( 2262 LocalVariable* temp_local = new LocalVariable(
2247 0, // Token index. 2263 0, // Token index.
2248 temp_name, 2264 temp_name,
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
2523 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 2539 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
2524 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 2540 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
2525 OS::SNPrint(chars, len, kFormat, function_name, reason); 2541 OS::SNPrint(chars, len, kFormat, function_name, reason);
2526 const Error& error = Error::Handle( 2542 const Error& error = Error::Handle(
2527 LanguageError::New(String::Handle(String::New(chars)))); 2543 LanguageError::New(String::Handle(String::New(chars))));
2528 Isolate::Current()->long_jump_base()->Jump(1, error); 2544 Isolate::Current()->long_jump_base()->Jump(1, error);
2529 } 2545 }
2530 2546
2531 2547
2532 } // namespace dart 2548 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698