| OLD | NEW |
| 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 2493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(current_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 Instruction* current = block_entry->successor(); | 2514 for (ForwardInstructionIterator it(block_entry); !it.Done(); it.Advance()) { |
| 2515 while ((current != NULL) && !current->IsBlockEntry()) { | 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 |
| 2518 // enviroment. This should be optimized: Only instructions that can | 2518 // enviroment. This should be optimized: Only instructions that can |
| 2519 // deoptimize will should have uses of the environment values. | 2519 // deoptimize will should have uses of the environment values. |
| 2520 current->set_env(new Environment(env)); | 2520 current->set_env(new Environment(env)); |
| 2521 | 2521 |
| 2522 // 2a. Handle uses: | 2522 // 2a. Handle uses: |
| 2523 // Update expression stack environment for each use. | 2523 // Update expression stack environment for each use. |
| 2524 // For each use of a LoadLocal or StoreLocal: Replace it with the value | 2524 // For each use of a LoadLocal or StoreLocal: Replace it with the value |
| 2525 // from the environment. | 2525 // from the environment. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2561 } else { | 2561 } else { |
| 2562 // The graph construction ensures we do not have an unused LoadLocal | 2562 // The graph construction ensures we do not have an unused LoadLocal |
| 2563 // computation. | 2563 // computation. |
| 2564 ASSERT(bind->is_used()); | 2564 ASSERT(bind->is_used()); |
| 2565 index = load->local().BitIndexIn(var_count); | 2565 index = load->local().BitIndexIn(var_count); |
| 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 current = current->RemoveFromGraph(); | 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(current_ssa_temp_index_++); |
| 2577 env->Add(new UseVal(bind)); | 2577 env->Add(new UseVal(bind)); |
| 2578 } | 2578 } |
| 2579 current = current->successor(); | |
| 2580 } | 2579 } |
| 2581 } else { | |
| 2582 // Not a computation. | |
| 2583 current = current->successor(); | |
| 2584 } | 2580 } |
| 2585 } | 2581 } |
| 2586 | 2582 |
| 2587 // 3. Process dominated blocks. | 2583 // 3. Process dominated blocks. |
| 2588 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) { |
| 2589 BlockEntryInstr* block = block_entry->dominated_blocks()[i]; | 2585 BlockEntryInstr* block = block_entry->dominated_blocks()[i]; |
| 2590 ZoneGrowableArray<Value*>* new_env = | 2586 ZoneGrowableArray<Value*>* new_env = |
| 2591 new ZoneGrowableArray<Value*>(env->length()); | 2587 new ZoneGrowableArray<Value*>(env->length()); |
| 2592 new_env->AddArray(*env); | 2588 new_env->AddArray(*env); |
| 2593 RenameRecursive(block, new_env, var_count); | 2589 RenameRecursive(block, new_env, var_count); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2623 char* chars = reinterpret_cast<char*>( | 2619 char* chars = reinterpret_cast<char*>( |
| 2624 Isolate::Current()->current_zone()->Allocate(len)); | 2620 Isolate::Current()->current_zone()->Allocate(len)); |
| 2625 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2621 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2626 const Error& error = Error::Handle( | 2622 const Error& error = Error::Handle( |
| 2627 LanguageError::New(String::Handle(String::New(chars)))); | 2623 LanguageError::New(String::Handle(String::New(chars)))); |
| 2628 Isolate::Current()->long_jump_base()->Jump(1, error); | 2624 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2629 } | 2625 } |
| 2630 | 2626 |
| 2631 | 2627 |
| 2632 } // namespace dart | 2628 } // namespace dart |
| OLD | NEW |