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

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

Issue 10765007: Cleanups. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
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
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/intermediate_language.h » ('j') | 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 "vm/ast_printer.h" 7 #include "vm/ast_printer.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.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 2438 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 } 2449 }
2450 ASSERT(var_count == (parsed_function().stack_local_count() + 2450 ASSERT(var_count == (parsed_function().stack_local_count() +
2451 parsed_function().function().num_fixed_parameters())); 2451 parsed_function().function().num_fixed_parameters()));
2452 2452
2453 // Initialize start environment. 2453 // Initialize start environment.
2454 ZoneGrowableArray<Value*>* start_env = 2454 ZoneGrowableArray<Value*>* start_env =
2455 new ZoneGrowableArray<Value*>(var_count); 2455 new ZoneGrowableArray<Value*>(var_count);
2456 intptr_t i = 0; 2456 intptr_t i = 0;
2457 for (; i < parsed_function().function().num_fixed_parameters(); ++i) { 2457 for (; i < parsed_function().function().num_fixed_parameters(); ++i) {
2458 ParameterInstr* param = new ParameterInstr(i); 2458 ParameterInstr* param = new ParameterInstr(i);
2459 param->set_ssa_temp_index(current_ssa_temp_index_++); // New SSA temp. 2459 param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
2460 start_env->Add(new UseVal(param)); 2460 start_env->Add(new UseVal(param));
2461 } 2461 }
2462 2462
2463 // All locals are initialized with #null. 2463 // All locals are initialized with #null.
2464 Value* null_value = new ConstantVal(Object::ZoneHandle()); 2464 Value* null_value = new ConstantVal(Object::ZoneHandle());
2465 for (; i < var_count; i++) { 2465 for (; i < var_count; i++) {
2466 start_env->Add(null_value); 2466 start_env->Add(null_value);
2467 } 2467 }
2468 graph_entry_->set_start_env(new Environment(start_env)); 2468 graph_entry_->set_start_env(new Environment(start_env));
2469 2469
(...skipping 27 matching lines...) Expand all
2497 ZoneGrowableArray<Value*>* env, 2497 ZoneGrowableArray<Value*>* env,
2498 intptr_t var_count) { 2498 intptr_t var_count) {
2499 // 1. Process phis first. 2499 // 1. Process phis first.
2500 if (block_entry->IsJoinEntry()) { 2500 if (block_entry->IsJoinEntry()) {
2501 JoinEntryInstr* join = block_entry->AsJoinEntry(); 2501 JoinEntryInstr* join = block_entry->AsJoinEntry();
2502 if (join->phis() != NULL) { 2502 if (join->phis() != NULL) {
2503 for (intptr_t i = 0; i < join->phis()->length(); ++i) { 2503 for (intptr_t i = 0; i < join->phis()->length(); ++i) {
2504 PhiInstr* phi = (*join->phis())[i]; 2504 PhiInstr* phi = (*join->phis())[i];
2505 if (phi != NULL) { 2505 if (phi != NULL) {
2506 (*env)[i] = new UseVal(phi); 2506 (*env)[i] = new UseVal(phi);
2507 phi->set_ssa_temp_index(current_ssa_temp_index_++); // New SSA temp. 2507 phi->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp.
2508 } 2508 }
2509 } 2509 }
2510 } 2510 }
2511 } 2511 }
2512 2512
2513 // 2. Process normal instructions. 2513 // 2. Process normal instructions.
2514 for (ForwardInstructionIterator it(block_entry); !it.Done(); it.Advance()) { 2514 for (ForwardInstructionIterator it(block_entry); !it.Done(); it.Advance()) {
2515 Instruction* current = it.Current(); 2515 Instruction* current = it.Current();
2516 // Attach current environment to the instruction. 2516 // Attach current environment to the instruction.
2517 // TODO(fschneider): Currently each instruction gets a full copy of the 2517 // TODO(fschneider): Currently each instruction gets a full copy of the
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 } 2566 }
2567 // Update expression stack and remove from graph. 2567 // Update expression stack and remove from graph.
2568 if (bind->is_used()) { 2568 if (bind->is_used()) {
2569 env->Add(CopyValue((*env)[index])); 2569 env->Add(CopyValue((*env)[index]));
2570 } 2570 }
2571 it.RemoveCurrentFromGraph(); 2571 it.RemoveCurrentFromGraph();
2572 } else { 2572 } else {
2573 // Not a load or store. 2573 // Not a load or store.
2574 if (bind->is_used()) { 2574 if (bind->is_used()) {
2575 // Assign fresh SSA temporary and update expression stack. 2575 // Assign fresh SSA temporary and update expression stack.
2576 bind->set_ssa_temp_index(current_ssa_temp_index_++); 2576 bind->set_ssa_temp_index(alloc_ssa_temp_index());
2577 env->Add(new UseVal(bind)); 2577 env->Add(new UseVal(bind));
2578 } 2578 }
2579 } 2579 }
2580 } 2580 }
2581 } 2581 }
2582 2582
2583 // 3. Process dominated blocks. 2583 // 3. Process dominated blocks.
2584 for (intptr_t i = 0; i < block_entry->dominated_blocks().length(); ++i) { 2584 for (intptr_t i = 0; i < block_entry->dominated_blocks().length(); ++i) {
2585 BlockEntryInstr* block = block_entry->dominated_blocks()[i]; 2585 BlockEntryInstr* block = block_entry->dominated_blocks()[i];
2586 ZoneGrowableArray<Value*>* new_env = 2586 ZoneGrowableArray<Value*>* new_env =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 char* chars = reinterpret_cast<char*>( 2619 char* chars = reinterpret_cast<char*>(
2620 Isolate::Current()->current_zone()->Allocate(len)); 2620 Isolate::Current()->current_zone()->Allocate(len));
2621 OS::SNPrint(chars, len, kFormat, function_name, reason); 2621 OS::SNPrint(chars, len, kFormat, function_name, reason);
2622 const Error& error = Error::Handle( 2622 const Error& error = Error::Handle(
2623 LanguageError::New(String::Handle(String::New(chars)))); 2623 LanguageError::New(String::Handle(String::New(chars))));
2624 Isolate::Current()->long_jump_base()->Jump(1, error); 2624 Isolate::Current()->long_jump_base()->Jump(1, error);
2625 } 2625 }
2626 2626
2627 2627
2628 } // namespace dart 2628 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698