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

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

Issue 15001030: Cleanup and avoid unnecessary code when building type arguments. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 (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 "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.h"
9 #include "vm/code_descriptors.h" 9 #include "vm/code_descriptors.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 2259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 Smi::ZoneHandle(Smi::New(StubCode::kNoInstantiator)))); 2270 Smi::ZoneHandle(Smi::New(StubCode::kNoInstantiator))));
2271 if (call_arguments != NULL) { 2271 if (call_arguments != NULL) {
2272 ASSERT(instantiator == NULL); 2272 ASSERT(instantiator == NULL);
2273 call_arguments->Add(PushArgument(instantiator_val)); 2273 call_arguments->Add(PushArgument(instantiator_val));
2274 } else { 2274 } else {
2275 ASSERT(instantiator != NULL); 2275 ASSERT(instantiator != NULL);
2276 *instantiator = instantiator_val; 2276 *instantiator = instantiator_val;
2277 } 2277 }
2278 return; 2278 return;
2279 } 2279 }
2280 // The type arguments are uninstantiated. The generated pseudo code: 2280 // The type arguments are uninstantiated. We use expression_temp_var to save
2281 // t1 = InstantiatorTypeArguments(); 2281 // the instantiator type arguments becuase they have two uses.
2282 // t2 = ExtractConstructorTypeArguments(t1);
2283 // t1 = ExtractConstructorInstantiator(t1);
2284 // t_n <- t2
2285 // t_n+1 <- t1
2286 // Use expression_temp_var and node->allocated_object_var() locals to keep
2287 // intermediate results around (t1 and t2 above).
2288 ASSERT(owner()->parsed_function().expression_temp_var() != NULL); 2282 ASSERT(owner()->parsed_function().expression_temp_var() != NULL);
2289 const LocalVariable& t1 = *owner()->parsed_function().expression_temp_var(); 2283 const LocalVariable& temp = *owner()->parsed_function().expression_temp_var();
2290 const LocalVariable& t2 = node->allocated_object_var();
2291 const Class& instantiator_class = Class::Handle( 2284 const Class& instantiator_class = Class::Handle(
2292 owner()->parsed_function().function().Owner()); 2285 owner()->parsed_function().function().Owner());
2293 Value* instantiator_type_arguments = BuildInstantiatorTypeArguments( 2286 Value* instantiator_type_arguments = BuildInstantiatorTypeArguments(
2294 node->token_pos(), instantiator_class, NULL); 2287 node->token_pos(), instantiator_class, NULL);
2295 Value* stored_instantiator = 2288 Value* stored_instantiator =
2296 Bind(BuildStoreTemp(t1, instantiator_type_arguments)); 2289 Bind(BuildStoreTemp(temp, instantiator_type_arguments));
2297 // t1: instantiator type arguments.
2298 2290
2299 Value* extract_type_arguments = Bind( 2291 Value* type_arguments_val = Bind(
2300 new ExtractConstructorTypeArgumentsInstr( 2292 new ExtractConstructorTypeArgumentsInstr(
2301 node->token_pos(), 2293 node->token_pos(),
2302 node->type_arguments(), 2294 node->type_arguments(),
2303 instantiator_class, 2295 instantiator_class,
2304 stored_instantiator)); 2296 stored_instantiator));
2305 2297
2306 Do(BuildStoreTemp(t2, extract_type_arguments));
2307 // t2: extracted constructor type arguments.
2308 Value* load_instantiator = Bind(BuildLoadLocal(t1));
2309
2310 Value* extract_instantiator =
2311 Bind(new ExtractConstructorInstantiatorInstr(node,
2312 instantiator_class,
2313 load_instantiator));
2314 Do(BuildStoreTemp(t1, extract_instantiator));
2315 // t2: extracted constructor type arguments.
2316 // t1: extracted constructor instantiator.
2317 Value* type_arguments_val = Bind(BuildLoadLocal(t2));
2318 if (call_arguments != NULL) { 2298 if (call_arguments != NULL) {
2319 ASSERT(type_arguments == NULL); 2299 ASSERT(type_arguments == NULL);
2320 call_arguments->Add(PushArgument(type_arguments_val)); 2300 call_arguments->Add(PushArgument(type_arguments_val));
2321 } else { 2301 } else {
2322 ASSERT(type_arguments != NULL); 2302 ASSERT(type_arguments != NULL);
2323 *type_arguments = type_arguments_val; 2303 *type_arguments = type_arguments_val;
2324 } 2304 }
2325 2305
2326 Value* instantiator_val = Bind(BuildLoadLocal(t1)); 2306 Value* load_instantiator = Bind(BuildLoadLocal(temp));
2307 Value* instantiator_val =
2308 Bind(new ExtractConstructorInstantiatorInstr(node,
2309 instantiator_class,
2310 load_instantiator));
2311
2327 if (call_arguments != NULL) { 2312 if (call_arguments != NULL) {
2328 ASSERT(instantiator == NULL); 2313 ASSERT(instantiator == NULL);
2329 call_arguments->Add(PushArgument(instantiator_val)); 2314 call_arguments->Add(PushArgument(instantiator_val));
2330 } else { 2315 } else {
2331 ASSERT(instantiator != NULL); 2316 ASSERT(instantiator != NULL);
2332 *instantiator = instantiator_val; 2317 *instantiator = instantiator_val;
2333 } 2318 }
2334 } 2319 }
2335 2320
2336 2321
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
3390 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3375 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3391 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3376 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3392 OS::SNPrint(chars, len, kFormat, function_name, reason); 3377 OS::SNPrint(chars, len, kFormat, function_name, reason);
3393 const Error& error = Error::Handle( 3378 const Error& error = Error::Handle(
3394 LanguageError::New(String::Handle(String::New(chars)))); 3379 LanguageError::New(String::Handle(String::New(chars))));
3395 Isolate::Current()->long_jump_base()->Jump(1, error); 3380 Isolate::Current()->long_jump_base()->Jump(1, error);
3396 } 3381 }
3397 3382
3398 3383
3399 } // namespace dart 3384 } // namespace dart
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