Index: runtime/vm/flow_graph.cc |
diff --git a/runtime/vm/flow_graph.cc b/runtime/vm/flow_graph.cc |
index fc203796bd10e13f5a4cda81c80f24ecfcbe3a4d..bcc18fbd9717e79255e99150ea1f92b0105d0ff1 100644 |
--- a/runtime/vm/flow_graph.cc |
+++ b/runtime/vm/flow_graph.cc |
@@ -26,36 +26,34 @@ DECLARE_FLAG(bool, verify_compiler); |
FlowGraph::FlowGraph(const ParsedFunction& parsed_function, |
GraphEntryInstr* graph_entry, |
intptr_t max_block_id) |
- : thread_(Thread::Current()), |
- parent_(), |
- current_ssa_temp_index_(0), |
- max_block_id_(max_block_id), |
- parsed_function_(parsed_function), |
- num_copied_params_(parsed_function.num_copied_params()), |
- num_non_copied_params_(parsed_function.num_non_copied_params()), |
- graph_entry_(graph_entry), |
- preorder_(), |
- postorder_(), |
- reverse_postorder_(), |
- optimized_block_order_(), |
- constant_null_(NULL), |
- constant_dead_(NULL), |
- constant_empty_context_(NULL), |
- block_effects_(NULL), |
- licm_allowed_(true), |
- loop_headers_(NULL), |
- loop_invariant_loads_(NULL), |
- deferred_prefixes_(parsed_function.deferred_prefixes()), |
- captured_parameters_(new(zone()) BitVector(zone(), variable_count())), |
- inlining_id_(-1) { |
+ : thread_(Thread::Current()), |
+ parent_(), |
+ current_ssa_temp_index_(0), |
+ max_block_id_(max_block_id), |
+ parsed_function_(parsed_function), |
+ num_copied_params_(parsed_function.num_copied_params()), |
+ num_non_copied_params_(parsed_function.num_non_copied_params()), |
+ graph_entry_(graph_entry), |
+ preorder_(), |
+ postorder_(), |
+ reverse_postorder_(), |
+ optimized_block_order_(), |
+ constant_null_(NULL), |
+ constant_dead_(NULL), |
+ constant_empty_context_(NULL), |
+ block_effects_(NULL), |
+ licm_allowed_(true), |
+ loop_headers_(NULL), |
+ loop_invariant_loads_(NULL), |
+ deferred_prefixes_(parsed_function.deferred_prefixes()), |
+ captured_parameters_(new (zone()) BitVector(zone(), variable_count())), |
+ inlining_id_(-1) { |
DiscoverBlocks(); |
} |
-void FlowGraph::EnsureSSATempIndex(Definition* defn, |
- Definition* replacement) { |
- if ((replacement->ssa_temp_index() == -1) && |
- (defn->ssa_temp_index() != -1)) { |
+void FlowGraph::EnsureSSATempIndex(Definition* defn, Definition* replacement) { |
+ if ((replacement->ssa_temp_index() == -1) && (defn->ssa_temp_index() != -1)) { |
AllocateSSAIndexes(replacement); |
} |
} |
@@ -100,7 +98,7 @@ void FlowGraph::AddToDeferredPrefixes( |
ZoneGrowableArray<const LibraryPrefix*>* from) { |
ZoneGrowableArray<const LibraryPrefix*>* to = deferred_prefixes(); |
for (intptr_t i = 0; i < from->length(); i++) { |
- const LibraryPrefix* prefix = (*from)[i]; |
+ const LibraryPrefix* prefix = (*from)[i]; |
for (intptr_t j = 0; j < to->length(); j++) { |
if ((*to)[j]->raw() == prefix->raw()) { |
return; |
@@ -113,17 +111,14 @@ void FlowGraph::AddToDeferredPrefixes( |
bool FlowGraph::ShouldReorderBlocks(const Function& function, |
bool is_optimized) { |
- return is_optimized |
- && FLAG_reorder_basic_blocks |
- && !function.is_intrinsic(); |
+ return is_optimized && FLAG_reorder_basic_blocks && !function.is_intrinsic(); |
} |
GrowableArray<BlockEntryInstr*>* FlowGraph::CodegenBlockOrder( |
bool is_optimized) { |
- return ShouldReorderBlocks(function(), is_optimized) |
- ? &optimized_block_order_ |
- : &reverse_postorder_; |
+ return ShouldReorderBlocks(function(), is_optimized) ? &optimized_block_order_ |
+ : &reverse_postorder_; |
} |
@@ -131,8 +126,8 @@ ConstantInstr* FlowGraph::GetConstant(const Object& object) { |
ConstantInstr* constant = constant_instr_pool_.LookupValue(object); |
if (constant == NULL) { |
// Otherwise, allocate and add it to the pool. |
- constant = new(zone()) ConstantInstr( |
- Object::ZoneHandle(zone(), object.raw())); |
+ constant = |
+ new (zone()) ConstantInstr(Object::ZoneHandle(zone(), object.raw())); |
constant->set_ssa_temp_index(alloc_ssa_temp_index()); |
AddToInitialDefinitions(constant); |
@@ -195,8 +190,8 @@ Instruction* FlowGraph::AppendTo(Instruction* prev, |
class BlockTraversalState { |
public: |
explicit BlockTraversalState(BlockEntryInstr* block) |
- : block_(block), |
- next_successor_ix_(block->last_instruction()->SuccessorCount() - 1) { } |
+ : block_(block), |
+ next_successor_ix_(block->last_instruction()->SuccessorCount() - 1) {} |
bool HasNextSuccessor() const { return next_successor_ix_ >= 0; } |
BlockEntryInstr* NextSuccessor() { |
@@ -227,7 +222,7 @@ void FlowGraph::DiscoverBlocks() { |
graph_entry_->DiscoverBlock(NULL, &preorder_, &parent_); |
block_stack.Add(BlockTraversalState(graph_entry_)); |
while (!block_stack.is_empty()) { |
- BlockTraversalState &state = block_stack.Last(); |
+ BlockTraversalState& state = block_stack.Last(); |
BlockEntryInstr* block = state.block(); |
if (state.HasNextSuccessor()) { |
// Process successors one-by-one. |
@@ -261,9 +256,8 @@ void FlowGraph::DiscoverBlocks() { |
void FlowGraph::MergeBlocks() { |
bool changed = false; |
- BitVector* merged = new(zone()) BitVector(zone(), postorder().length()); |
- for (BlockIterator block_it = reverse_postorder_iterator(); |
- !block_it.Done(); |
+ BitVector* merged = new (zone()) BitVector(zone(), postorder().length()); |
+ for (BlockIterator block_it = reverse_postorder_iterator(); !block_it.Done(); |
block_it.Advance()) { |
BlockEntryInstr* block = block_it.Current(); |
if (block->IsGraphEntry()) continue; |
@@ -271,8 +265,7 @@ void FlowGraph::MergeBlocks() { |
Instruction* last = block->last_instruction(); |
BlockEntryInstr* successor = NULL; |
- while ((!last->IsIndirectGoto()) && |
- (last->SuccessorCount() == 1) && |
+ while ((!last->IsIndirectGoto()) && (last->SuccessorCount() == 1) && |
(!last->SuccessorAt(0)->IsIndirectEntry()) && |
(last->SuccessorAt(0)->PredecessorCount() == 1) && |
(block->try_index() == last->SuccessorAt(0)->try_index())) { |
@@ -288,8 +281,7 @@ void FlowGraph::MergeBlocks() { |
merged->Add(successor->postorder_number()); |
changed = true; |
if (FLAG_trace_optimization) { |
- OS::Print("Merged blocks B%" Pd " and B%" Pd "\n", |
- block->block_id(), |
+ OS::Print("Merged blocks B%" Pd " and B%" Pd "\n", block->block_id(), |
successor->block_id()); |
} |
} |
@@ -321,8 +313,7 @@ static void VerifyUseListsInInstruction(Instruction* instr) { |
for (intptr_t i = 0; i < instr->InputCount(); ++i) { |
Value* use = instr->InputAt(i); |
ASSERT(use->definition() != NULL); |
- ASSERT((use->definition() != instr) || |
- use->definition()->IsPhi() || |
+ ASSERT((use->definition() != instr) || use->definition()->IsPhi() || |
use->definition()->IsMaterializeObject()); |
ASSERT(use->instruction() == instr); |
ASSERT(use->use_index() == i); |
@@ -381,7 +372,8 @@ static void VerifyUseListsInInstruction(Instruction* instr) { |
} |
void FlowGraph::ComputeIsReceiverRecursive( |
- PhiInstr* phi, GrowableArray<PhiInstr*>* unmark) const { |
+ PhiInstr* phi, |
+ GrowableArray<PhiInstr*>* unmark) const { |
if (phi->is_receiver() != PhiInstr::kUnknownReceiver) return; |
phi->set_is_receiver(PhiInstr::kReceiver); |
for (intptr_t i = 0; i < phi->InputCount(); ++i) { |
@@ -448,14 +440,17 @@ bool FlowGraph::InstanceCallNeedsClassCheck(InstanceCallInstr* call, |
Definition* callee_receiver = call->ArgumentAt(0); |
ASSERT(callee_receiver != NULL); |
if (function().IsDynamicFunction() && IsReceiver(callee_receiver)) { |
- const String& name = (kind == RawFunction::kMethodExtractor) |
- ? String::Handle(zone(), Field::NameFromGetter(call->function_name())) |
- : call->function_name(); |
+ const String& name = |
+ (kind == RawFunction::kMethodExtractor) |
+ ? String::Handle(zone(), |
+ Field::NameFromGetter(call->function_name())) |
+ : call->function_name(); |
const Class& cls = Class::Handle(zone(), function().Owner()); |
intptr_t subclass_count = 0; |
if (!thread()->cha()->HasOverride(cls, name, &subclass_count)) { |
if (FLAG_trace_cha) { |
- THR_Print(" **(CHA) Instance call needs no check, " |
+ THR_Print( |
+ " **(CHA) Instance call needs no check, " |
"no overrides of '%s' '%s'\n", |
name.ToCString(), cls.ToCString()); |
} |
@@ -467,7 +462,6 @@ bool FlowGraph::InstanceCallNeedsClassCheck(InstanceCallInstr* call, |
} |
- |
bool FlowGraph::VerifyUseLists() { |
// Verify the initial definitions. |
for (intptr_t i = 0; i < graph_entry_->initial_definitions()->length(); ++i) { |
@@ -494,15 +488,14 @@ bool FlowGraph::VerifyUseLists() { |
LivenessAnalysis::LivenessAnalysis( |
- intptr_t variable_count, |
- const GrowableArray<BlockEntryInstr*>& postorder) |
+ intptr_t variable_count, |
+ const GrowableArray<BlockEntryInstr*>& postorder) |
: zone_(Thread::Current()->zone()), |
variable_count_(variable_count), |
postorder_(postorder), |
live_out_(postorder.length()), |
kill_(postorder.length()), |
- live_in_(postorder.length()) { |
-} |
+ live_in_(postorder.length()) {} |
bool LivenessAnalysis::UpdateLiveOut(const BlockEntryInstr& block) { |
@@ -553,9 +546,9 @@ void LivenessAnalysis::ComputeLiveInAndLiveOutSets() { |
void LivenessAnalysis::Analyze() { |
const intptr_t block_count = postorder_.length(); |
for (intptr_t i = 0; i < block_count; i++) { |
- live_out_.Add(new(zone()) BitVector(zone(), variable_count_)); |
- kill_.Add(new(zone()) BitVector(zone(), variable_count_)); |
- live_in_.Add(new(zone()) BitVector(zone(), variable_count_)); |
+ live_out_.Add(new (zone()) BitVector(zone(), variable_count_)); |
+ kill_.Add(new (zone()) BitVector(zone(), variable_count_)); |
+ live_in_.Add(new (zone()) BitVector(zone(), variable_count_)); |
} |
ComputeInitialSets(); |
@@ -599,7 +592,7 @@ class VariableLivenessAnalysis : public LivenessAnalysis { |
: LivenessAnalysis(flow_graph->variable_count(), flow_graph->postorder()), |
flow_graph_(flow_graph), |
num_non_copied_params_(flow_graph->num_non_copied_params()), |
- assigned_vars_() { } |
+ assigned_vars_() {} |
// For every block (in preorder) compute and return set of variables that |
// have new assigned values flowing out of that block. |
@@ -672,7 +665,7 @@ class VariableLivenessAnalysis : public LivenessAnalysis { |
void VariableLivenessAnalysis::ComputeInitialSets() { |
const intptr_t block_count = postorder_.length(); |
- BitVector* last_loads = new(zone()) BitVector(zone(), variable_count_); |
+ BitVector* last_loads = new (zone()) BitVector(zone(), variable_count_); |
for (intptr_t i = 0; i < block_count; i++) { |
BlockEntryInstr* block = postorder_[i]; |
@@ -743,10 +736,8 @@ void FlowGraph::ComputeSSA( |
GrowableArray<PhiInstr*> live_phis; |
- InsertPhis(preorder_, |
- variable_liveness.ComputeAssignedVars(), |
- dominance_frontier, |
- &live_phis); |
+ InsertPhis(preorder_, variable_liveness.ComputeAssignedVars(), |
+ dominance_frontier, &live_phis); |
// Rename uses to reference inserted phis where appropriate. |
@@ -780,8 +771,8 @@ void FlowGraph::ComputeDominators( |
// All arrays are maps between preorder basic-block numbers. |
intptr_t size = parent_.length(); |
- GrowableArray<intptr_t> idom(size); // Immediate dominator. |
- GrowableArray<intptr_t> semi(size); // Semidominator. |
+ GrowableArray<intptr_t> idom(size); // Immediate dominator. |
+ GrowableArray<intptr_t> semi(size); // Semidominator. |
GrowableArray<intptr_t> label(size); // Label for link-eval forest. |
// 1. First pass: compute semidominators as in Lengauer-Tarjan. |
@@ -798,7 +789,7 @@ void FlowGraph::ComputeDominators( |
idom.Add(parent_[i]); |
semi.Add(i); |
label.Add(i); |
- dominance_frontier->Add(new(zone()) BitVector(zone(), size)); |
+ dominance_frontier->Add(new (zone()) BitVector(zone(), size)); |
} |
// Loop over the blocks in reverse preorder (not including the graph |
@@ -877,11 +868,10 @@ void FlowGraph::CompressPath(intptr_t start_index, |
} |
-void FlowGraph::InsertPhis( |
- const GrowableArray<BlockEntryInstr*>& preorder, |
- const GrowableArray<BitVector*>& assigned_vars, |
- const GrowableArray<BitVector*>& dom_frontier, |
- GrowableArray<PhiInstr*>* live_phis) { |
+void FlowGraph::InsertPhis(const GrowableArray<BlockEntryInstr*>& preorder, |
+ const GrowableArray<BitVector*>& assigned_vars, |
+ const GrowableArray<BitVector*>& dom_frontier, |
+ GrowableArray<PhiInstr*>* live_phis) { |
const intptr_t block_count = preorder.length(); |
// Map preorder block number to the highest variable index that has a phi |
// in that block. Use it to avoid inserting multiple phis for the same |
@@ -901,8 +891,8 @@ void FlowGraph::InsertPhis( |
// Insert phis for each variable in turn. |
GrowableArray<BlockEntryInstr*> worklist; |
for (intptr_t var_index = 0; var_index < variable_count(); ++var_index) { |
- const bool always_live = !FLAG_prune_dead_locals || |
- (var_index == CurrentContextEnvIndex()); |
+ const bool always_live = |
+ !FLAG_prune_dead_locals || (var_index == CurrentContextEnvIndex()); |
// Add to the worklist each block containing an assignment. |
for (intptr_t block_index = 0; block_index < block_count; ++block_index) { |
if (assigned_vars[block_index]->Contains(var_index)) { |
@@ -915,14 +905,13 @@ void FlowGraph::InsertPhis( |
BlockEntryInstr* current = worklist.RemoveLast(); |
// Ensure a phi for each block in the dominance frontier of current. |
for (BitVector::Iterator it(dom_frontier[current->preorder_number()]); |
- !it.Done(); |
- it.Advance()) { |
+ !it.Done(); it.Advance()) { |
int index = it.Current(); |
if (has_already[index] < var_index) { |
BlockEntryInstr* block = preorder[index]; |
ASSERT(block->IsJoinEntry()); |
- PhiInstr* phi = block->AsJoinEntry()->InsertPhi(var_index, |
- variable_count()); |
+ PhiInstr* phi = |
+ block->AsJoinEntry()->InsertPhi(var_index, variable_count()); |
if (always_live) { |
phi->mark_alive(); |
live_phis->Add(phi); |
@@ -950,8 +939,8 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis, |
// Add global constants to the initial definitions. |
constant_null_ = GetConstant(Object::ZoneHandle()); |
constant_dead_ = GetConstant(Symbols::OptimizedOut()); |
- constant_empty_context_ = GetConstant(Context::Handle( |
- isolate()->object_store()->empty_context())); |
+ constant_empty_context_ = |
+ GetConstant(Context::Handle(isolate()->object_store()->empty_context())); |
// Add parameters to the initial definitions and renaming environment. |
if (inlining_parameters != NULL) { |
@@ -968,7 +957,7 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis, |
// are unknown and so treated like parameters. |
intptr_t count = IsCompiledForOsr() ? variable_count() : parameter_count(); |
for (intptr_t i = 0; i < count; ++i) { |
- ParameterInstr* param = new(zone()) ParameterInstr(i, entry); |
+ ParameterInstr* param = new (zone()) ParameterInstr(i, entry); |
param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. |
AddToInitialDefinitions(param); |
env.Add(param); |
@@ -1007,13 +996,10 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis, |
void FlowGraph::AttachEnvironment(Instruction* instr, |
GrowableArray<Definition*>* env) { |
Environment* deopt_env = |
- Environment::From(zone(), |
- *env, |
- num_non_copied_params_, |
- parsed_function_); |
+ Environment::From(zone(), *env, num_non_copied_params_, parsed_function_); |
if (instr->IsClosureCall()) { |
- deopt_env = deopt_env->DeepCopy(zone(), |
- deopt_env->Length() - instr->InputCount()); |
+ deopt_env = |
+ deopt_env->DeepCopy(zone(), deopt_env->Length() - instr->InputCount()); |
} |
instr->SetEnvironment(deopt_env); |
for (Environment::DeepIterator it(deopt_env); !it.Done(); it.Advance()) { |
@@ -1054,7 +1040,7 @@ void FlowGraph::RenameRecursive(BlockEntryInstr* block_entry, |
} else if (block_entry->IsCatchBlockEntry()) { |
// Add real definitions for all locals and parameters. |
for (intptr_t i = 0; i < env->length(); ++i) { |
- ParameterInstr* param = new(zone()) ParameterInstr(i, block_entry); |
+ ParameterInstr* param = new (zone()) ParameterInstr(i, block_entry); |
param->set_ssa_temp_index(alloc_ssa_temp_index()); // New SSA temp. |
(*env)[i] = param; |
block_entry->AsCatchBlockEntry()->initial_definitions()->Add(param); |
@@ -1067,8 +1053,7 @@ void FlowGraph::RenameRecursive(BlockEntryInstr* block_entry, |
for (intptr_t i = 0; i < variable_count(); i++) { |
// TODO(fschneider): Make sure that live_in always contains the |
// CurrentContext variable to avoid the special case here. |
- if (FLAG_prune_dead_locals && |
- !live_in->Contains(i) && |
+ if (FLAG_prune_dead_locals && !live_in->Contains(i) && |
(i != CurrentContextEnvIndex())) { |
(*env)[i] = constant_dead(); |
} |
@@ -1099,10 +1084,8 @@ void FlowGraph::RenameRecursive(BlockEntryInstr* block_entry, |
Definition* reaching_defn = env->RemoveLast(); |
Definition* input_defn = v->definition(); |
if (input_defn != reaching_defn) { |
- ASSERT(input_defn->IsLoadLocal() || |
- input_defn->IsStoreLocal() || |
- input_defn->IsDropTemps() || |
- input_defn->IsConstant()); |
+ ASSERT(input_defn->IsLoadLocal() || input_defn->IsStoreLocal() || |
+ input_defn->IsDropTemps() || input_defn->IsConstant()); |
// Assert we are not referencing nulls in the initial environment. |
ASSERT(reaching_defn->ssa_temp_index() != -1); |
v->set_definition(reaching_defn); |
@@ -1123,9 +1106,7 @@ void FlowGraph::RenameRecursive(BlockEntryInstr* block_entry, |
StoreLocalInstr* store = definition->AsStoreLocal(); |
DropTempsInstr* drop = definition->AsDropTemps(); |
ConstantInstr* constant = definition->AsConstant(); |
- if ((load != NULL) || |
- (store != NULL) || |
- (drop != NULL) || |
+ if ((load != NULL) || (store != NULL) || (drop != NULL) || |
(constant != NULL)) { |
Definition* result = NULL; |
if (store != NULL) { |
@@ -1220,7 +1201,7 @@ void FlowGraph::RenameRecursive(BlockEntryInstr* block_entry, |
PhiInstr* phi = (*successor->phis())[i]; |
if (phi != NULL) { |
// Rename input operand. |
- Value* use = new(zone()) Value((*env)[i]); |
+ Value* use = new (zone()) Value((*env)[i]); |
phi->SetInputAt(pred_index, use); |
} |
} |
@@ -1238,14 +1219,11 @@ void FlowGraph::RemoveDeadPhis(GrowableArray<PhiInstr*>* live_phis) { |
if (join == NULL) continue; |
for (PhiIterator phi_it(join); !phi_it.Done(); phi_it.Advance()) { |
PhiInstr* phi = phi_it.Current(); |
- if (phi == NULL || |
- phi->is_alive() || |
- (phi->input_use_list() != NULL) || |
+ if (phi == NULL || phi->is_alive() || (phi->input_use_list() != NULL) || |
(phi->env_use_list() == NULL)) { |
continue; |
} |
- for (Value::Iterator it(phi->env_use_list()); |
- !it.Done(); |
+ for (Value::Iterator it(phi->env_use_list()); !it.Done(); |
it.Advance()) { |
Value* use = it.Current(); |
if (use->instruction()->MayThrow() && |
@@ -1280,12 +1258,10 @@ void FlowGraph::RemoveDeadPhis(GrowableArray<PhiInstr*>* live_phis) { |
void FlowGraph::RemoveRedefinitions() { |
// Remove redefinition instructions inserted to inhibit hoisting. |
- for (BlockIterator block_it = reverse_postorder_iterator(); |
- !block_it.Done(); |
+ for (BlockIterator block_it = reverse_postorder_iterator(); !block_it.Done(); |
block_it.Advance()) { |
for (ForwardInstructionIterator instr_it(block_it.Current()); |
- !instr_it.Done(); |
- instr_it.Advance()) { |
+ !instr_it.Done(); instr_it.Advance()) { |
RedefinitionInstr* redefinition = instr_it.Current()->AsRedefinition(); |
if (redefinition != NULL) { |
Definition* original; |
@@ -1305,7 +1281,7 @@ void FlowGraph::RemoveRedefinitions() { |
// Design & Implementation" (Muchnick) p192. |
BitVector* FlowGraph::FindLoop(BlockEntryInstr* m, BlockEntryInstr* n) const { |
GrowableArray<BlockEntryInstr*> stack; |
- BitVector* loop = new(zone()) BitVector(zone(), preorder_.length()); |
+ BitVector* loop = new (zone()) BitVector(zone(), preorder_.length()); |
loop->Add(n->preorder_number()); |
if (n != m) { |
@@ -1329,11 +1305,9 @@ BitVector* FlowGraph::FindLoop(BlockEntryInstr* m, BlockEntryInstr* n) const { |
ZoneGrowableArray<BlockEntryInstr*>* FlowGraph::ComputeLoops() const { |
ZoneGrowableArray<BlockEntryInstr*>* loop_headers = |
- new(zone()) ZoneGrowableArray<BlockEntryInstr*>(); |
+ new (zone()) ZoneGrowableArray<BlockEntryInstr*>(); |
- for (BlockIterator it = postorder_iterator(); |
- !it.Done(); |
- it.Advance()) { |
+ for (BlockIterator it = postorder_iterator(); !it.Done(); it.Advance()) { |
BlockEntryInstr* block = it.Current(); |
for (intptr_t i = 0; i < block->PredecessorCount(); ++i) { |
BlockEntryInstr* pred = block->PredecessorAt(i); |
@@ -1364,8 +1338,7 @@ ZoneGrowableArray<BlockEntryInstr*>* FlowGraph::ComputeLoops() const { |
for (intptr_t i = 0; i < loop_headers->length(); ++i) { |
BlockEntryInstr* header = (*loop_headers)[i]; |
OS::Print("Loop header B%" Pd "\n", header->block_id()); |
- for (BitVector::Iterator it(header->loop_info()); |
- !it.Done(); |
+ for (BitVector::Iterator it(header->loop_info()); !it.Done(); |
it.Advance()) { |
OS::Print(" B%" Pd "\n", preorder_[it.Current()]->block_id()); |
} |
@@ -1379,8 +1352,7 @@ intptr_t FlowGraph::InstructionCount() const { |
intptr_t size = 0; |
// Iterate each block, skipping the graph entry. |
for (intptr_t i = 1; i < preorder_.length(); ++i) { |
- for (ForwardInstructionIterator it(preorder_[i]); |
- !it.Done(); |
+ for (ForwardInstructionIterator it(preorder_[i]); !it.Done(); |
it.Advance()) { |
++size; |
} |
@@ -1390,7 +1362,7 @@ intptr_t FlowGraph::InstructionCount() const { |
void FlowGraph::ComputeBlockEffects() { |
- block_effects_ = new(zone()) BlockEffects(this); |
+ block_effects_ = new (zone()) BlockEffects(this); |
} |
@@ -1402,7 +1374,7 @@ BlockEffects::BlockEffects(FlowGraph* flow_graph) |
const intptr_t block_count = flow_graph->postorder().length(); |
// Set of blocks that contain side-effects. |
- BitVector* kill = new(zone) BitVector(zone, block_count); |
+ BitVector* kill = new (zone) BitVector(zone, block_count); |
// Per block available-after sets. Block A is available after the block B if |
// and only if A is either equal to B or A is available at B and B contains no |
@@ -1411,16 +1383,13 @@ BlockEffects::BlockEffects(FlowGraph* flow_graph) |
GrowableArray<BitVector*> available_after(block_count); |
// Discover all blocks with side-effects. |
- for (BlockIterator it = flow_graph->postorder_iterator(); |
- !it.Done(); |
+ for (BlockIterator it = flow_graph->postorder_iterator(); !it.Done(); |
it.Advance()) { |
available_at_.Add(NULL); |
available_after.Add(NULL); |
BlockEntryInstr* block = it.Current(); |
- for (ForwardInstructionIterator it(block); |
- !it.Done(); |
- it.Advance()) { |
+ for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { |
if (!it.Current()->Effects().IsNone()) { |
kill->Add(block->postorder_number()); |
break; |
@@ -1428,7 +1397,7 @@ BlockEffects::BlockEffects(FlowGraph* flow_graph) |
} |
} |
- BitVector* temp = new(zone) BitVector(zone, block_count); |
+ BitVector* temp = new (zone) BitVector(zone, block_count); |
// Recompute available-at based on predecessors' available-after until the fix |
// point is reached. |
@@ -1437,8 +1406,7 @@ BlockEffects::BlockEffects(FlowGraph* flow_graph) |
changed = false; |
for (BlockIterator it = flow_graph->reverse_postorder_iterator(); |
- !it.Done(); |
- it.Advance()) { |
+ !it.Done(); it.Advance()) { |
BlockEntryInstr* block = it.Current(); |
const intptr_t block_num = block->postorder_number(); |
@@ -1461,9 +1429,8 @@ BlockEffects::BlockEffects(FlowGraph* flow_graph) |
// Available-at changed: update it and recompute available-after. |
if (available_at_[block_num] == NULL) { |
current = available_at_[block_num] = |
- new(zone) BitVector(zone, block_count); |
- available_after[block_num] = |
- new(zone) BitVector(zone, block_count); |
+ new (zone) BitVector(zone, block_count); |
+ available_after[block_num] = new (zone) BitVector(zone, block_count); |
// Block is always available after itself. |
available_after[block_num]->Add(block_num); |
} |
@@ -1483,14 +1450,14 @@ BlockEffects::BlockEffects(FlowGraph* flow_graph) |
bool BlockEffects::IsAvailableAt(Instruction* instr, |
BlockEntryInstr* block) const { |
return (instr->Dependencies().IsNone()) || |
- IsSideEffectFreePath(instr->GetBlock(), block); |
+ IsSideEffectFreePath(instr->GetBlock(), block); |
} |
bool BlockEffects::CanBeMovedTo(Instruction* instr, |
BlockEntryInstr* block) const { |
return (instr->Dependencies().IsNone()) || |
- IsSideEffectFreePath(block, instr->GetBlock()); |
+ IsSideEffectFreePath(block, instr->GetBlock()); |
} |
@@ -1511,13 +1478,12 @@ void FlowGraph::ConvertUse(Value* use, Representation from_rep) { |
if (from_rep == to_rep || to_rep == kNoRepresentation) { |
return; |
} |
- InsertConversion(from_rep, to_rep, use, /*is_environment_use=*/ false); |
+ InsertConversion(from_rep, to_rep, use, /*is_environment_use=*/false); |
} |
static bool IsUnboxedInteger(Representation rep) { |
- return (rep == kUnboxedInt32) || |
- (rep == kUnboxedUint32) || |
+ return (rep == kUnboxedInt32) || (rep == kUnboxedUint32) || |
(rep == kUnboxedMint); |
} |
@@ -1556,24 +1522,24 @@ void FlowGraph::InsertConversion(Representation from, |
Definition* converted = NULL; |
if (IsUnboxedInteger(from) && IsUnboxedInteger(to)) { |
- const intptr_t deopt_id = (to == kUnboxedInt32) && (deopt_target != NULL) ? |
- deopt_target->DeoptimizationTarget() : Thread::kNoDeoptId; |
- converted = new(Z) UnboxedIntConverterInstr(from, |
- to, |
- use->CopyWithType(), |
- deopt_id); |
+ const intptr_t deopt_id = (to == kUnboxedInt32) && (deopt_target != NULL) |
+ ? deopt_target->DeoptimizationTarget() |
+ : Thread::kNoDeoptId; |
+ converted = new (Z) |
+ UnboxedIntConverterInstr(from, to, use->CopyWithType(), deopt_id); |
} else if ((from == kUnboxedInt32) && (to == kUnboxedDouble)) { |
converted = new Int32ToDoubleInstr(use->CopyWithType()); |
- } else if ((from == kUnboxedMint) && |
- (to == kUnboxedDouble) && |
+ } else if ((from == kUnboxedMint) && (to == kUnboxedDouble) && |
CanConvertUnboxedMintToDouble()) { |
- const intptr_t deopt_id = (deopt_target != NULL) ? |
- deopt_target->DeoptimizationTarget() : Thread::kNoDeoptId; |
+ const intptr_t deopt_id = (deopt_target != NULL) |
+ ? deopt_target->DeoptimizationTarget() |
+ : Thread::kNoDeoptId; |
ASSERT(CanUnboxDouble()); |
converted = new MintToDoubleInstr(use->CopyWithType(), deopt_id); |
} else if ((from == kTagged) && Boxing::Supports(to)) { |
- const intptr_t deopt_id = (deopt_target != NULL) ? |
- deopt_target->DeoptimizationTarget() : Thread::kNoDeoptId; |
+ const intptr_t deopt_id = (deopt_target != NULL) |
+ ? deopt_target->DeoptimizationTarget() |
+ : Thread::kNoDeoptId; |
converted = UnboxInstr::Create(to, use->CopyWithType(), deopt_id); |
} else if ((to == kTagged) && Boxing::Supports(from)) { |
converted = BoxInstr::Create(from, use->CopyWithType()); |
@@ -1582,14 +1548,15 @@ void FlowGraph::InsertConversion(Representation from, |
// Insert two "dummy" conversion instructions with the correct |
// "from" and "to" representation. The inserted instructions will |
// trigger a deoptimization if executed. See #12417 for a discussion. |
- const intptr_t deopt_id = (deopt_target != NULL) ? |
- deopt_target->DeoptimizationTarget() : Thread::kNoDeoptId; |
+ const intptr_t deopt_id = (deopt_target != NULL) |
+ ? deopt_target->DeoptimizationTarget() |
+ : Thread::kNoDeoptId; |
ASSERT(Boxing::Supports(from)); |
ASSERT(Boxing::Supports(to)); |
Definition* boxed = BoxInstr::Create(from, use->CopyWithType()); |
use->BindTo(boxed); |
InsertBefore(insert_before, boxed, NULL, FlowGraph::kValue); |
- converted = UnboxInstr::Create(to, new(Z) Value(boxed), deopt_id); |
+ converted = UnboxInstr::Create(to, new (Z) Value(boxed), deopt_id); |
} |
ASSERT(converted != NULL); |
InsertBefore(insert_before, converted, use->instruction()->env(), |
@@ -1613,23 +1580,19 @@ void FlowGraph::ConvertEnvironmentUse(Value* use, Representation from_rep) { |
if (from_rep == to_rep) { |
return; |
} |
- InsertConversion(from_rep, to_rep, use, /*is_environment_use=*/ true); |
+ InsertConversion(from_rep, to_rep, use, /*is_environment_use=*/true); |
} |
void FlowGraph::InsertConversionsFor(Definition* def) { |
const Representation from_rep = def->representation(); |
- for (Value::Iterator it(def->input_use_list()); |
- !it.Done(); |
- it.Advance()) { |
+ for (Value::Iterator it(def->input_use_list()); !it.Done(); it.Advance()) { |
ConvertUse(it.Current(), from_rep); |
} |
if (graph_entry()->SuccessorCount() > 1) { |
- for (Value::Iterator it(def->env_use_list()); |
- !it.Done(); |
- it.Advance()) { |
+ for (Value::Iterator it(def->env_use_list()); !it.Done(); it.Advance()) { |
Value* use = it.Current(); |
if (use->instruction()->MayThrow() && |
use->instruction()->GetBlock()->InsideTryBlock()) { |
@@ -1668,9 +1631,7 @@ static void UnboxPhi(PhiInstr* phi) { |
break; |
} |
- if ((kSmiBits < 32) && |
- (unboxed == kTagged) && |
- phi->Type()->IsInt() && |
+ if ((kSmiBits < 32) && (unboxed == kTagged) && phi->Type()->IsInt() && |
RangeUtils::Fits(phi->range(), RangeBoundary::kRangeBoundaryInt64)) { |
// On 32-bit platforms conservatively unbox phis that: |
// - are proven to be of type Int; |
@@ -1695,15 +1656,14 @@ static void UnboxPhi(PhiInstr* phi) { |
// We checked inputs. Check if phi is used in at least one unbox |
// operation. |
bool has_unboxed_use = false; |
- for (Value* use = phi->input_use_list(); |
- use != NULL; |
+ for (Value* use = phi->input_use_list(); use != NULL; |
use = use->next_use()) { |
Instruction* instr = use->instruction(); |
if (instr->IsUnbox()) { |
has_unboxed_use = true; |
break; |
} else if (IsUnboxedInteger( |
- instr->RequiredInputRepresentation(use->use_index()))) { |
+ instr->RequiredInputRepresentation(use->use_index()))) { |
has_unboxed_use = true; |
break; |
} |
@@ -1717,7 +1677,8 @@ static void UnboxPhi(PhiInstr* phi) { |
if (should_unbox) { |
unboxed = |
RangeUtils::Fits(phi->range(), RangeBoundary::kRangeBoundaryInt32) |
- ? kUnboxedInt32 : kUnboxedMint; |
+ ? kUnboxedInt32 |
+ : kUnboxedMint; |
} |
} |
@@ -1728,8 +1689,7 @@ static void UnboxPhi(PhiInstr* phi) { |
void FlowGraph::SelectRepresentations() { |
// Conservatively unbox all phis that were proven to be of Double, |
// Float32x4, or Int32x4 type. |
- for (BlockIterator block_it = reverse_postorder_iterator(); |
- !block_it.Done(); |
+ for (BlockIterator block_it = reverse_postorder_iterator(); !block_it.Done(); |
block_it.Advance()) { |
JoinEntryInstr* join_entry = block_it.Current()->AsJoinEntry(); |
if (join_entry != NULL) { |
@@ -1742,14 +1702,12 @@ void FlowGraph::SelectRepresentations() { |
// Process all instructions and insert conversions where needed. |
// Visit incoming parameters and constants. |
- for (intptr_t i = 0; |
- i < graph_entry()->initial_definitions()->length(); |
+ for (intptr_t i = 0; i < graph_entry()->initial_definitions()->length(); |
i++) { |
InsertConversionsFor((*graph_entry()->initial_definitions())[i]); |
} |
- for (BlockIterator block_it = reverse_postorder_iterator(); |
- !block_it.Done(); |
+ for (BlockIterator block_it = reverse_postorder_iterator(); !block_it.Done(); |
block_it.Advance()) { |
BlockEntryInstr* entry = block_it.Current(); |
JoinEntryInstr* join_entry = entry->AsJoinEntry(); |
@@ -1763,8 +1721,7 @@ void FlowGraph::SelectRepresentations() { |
} |
CatchBlockEntryInstr* catch_entry = entry->AsCatchBlockEntry(); |
if (catch_entry != NULL) { |
- for (intptr_t i = 0; |
- i < catch_entry->initial_definitions()->length(); |
+ for (intptr_t i = 0; i < catch_entry->initial_definitions()->length(); |
i++) { |
InsertConversionsFor((*catch_entry->initial_definitions())[i]); |
} |
@@ -1783,8 +1740,7 @@ void FlowGraph::SelectRepresentations() { |
// Smi widening pass is only meaningful on platforms where Smi |
// is smaller than 32bit. For now only support it on ARM and ia32. |
static bool CanBeWidened(BinarySmiOpInstr* smi_op) { |
- return BinaryInt32OpInstr::IsSupported(smi_op->op_kind(), |
- smi_op->left(), |
+ return BinaryInt32OpInstr::IsSupported(smi_op->op_kind(), smi_op->left(), |
smi_op->right()); |
} |
@@ -1810,17 +1766,13 @@ void FlowGraph::WidenSmiToInt32() { |
// Step 1. Collect all instructions that potentially benefit from widening of |
// their operands (or their result) into int32 range. |
- for (BlockIterator block_it = reverse_postorder_iterator(); |
- !block_it.Done(); |
+ for (BlockIterator block_it = reverse_postorder_iterator(); !block_it.Done(); |
block_it.Advance()) { |
for (ForwardInstructionIterator instr_it(block_it.Current()); |
- !instr_it.Done(); |
- instr_it.Advance()) { |
+ !instr_it.Done(); instr_it.Advance()) { |
BinarySmiOpInstr* smi_op = instr_it.Current()->AsBinarySmiOp(); |
- if ((smi_op != NULL) && |
- smi_op->HasSSATemp() && |
- BenefitsFromWidening(smi_op) && |
- CanBeWidened(smi_op)) { |
+ if ((smi_op != NULL) && smi_op->HasSSATemp() && |
+ BenefitsFromWidening(smi_op) && CanBeWidened(smi_op)) { |
candidates.Add(smi_op); |
} |
} |
@@ -1844,8 +1796,7 @@ void FlowGraph::WidenSmiToInt32() { |
for (intptr_t loop_id = 0; loop_id < loop_headers.length(); ++loop_id) { |
for (BitVector::Iterator loop_it(loop_headers[loop_id]->loop_info()); |
- !loop_it.Done(); |
- loop_it.Advance()) { |
+ !loop_it.Done(); loop_it.Advance()) { |
loops[loop_it.Current()] = loop_id; |
} |
} |
@@ -1858,8 +1809,7 @@ void FlowGraph::WidenSmiToInt32() { |
// BitVector containing SSA indexes of all processed definitions. Used to skip |
// those candidates that belong to dependency graph of another candidate. |
- BitVector* processed = |
- new(Z) BitVector(Z, current_ssa_temp_index()); |
+ BitVector* processed = new (Z) BitVector(Z, current_ssa_temp_index()); |
// Worklist used to collect dependency graph. |
DefinitionWorklist worklist(this, candidates.length()); |
@@ -1898,8 +1848,7 @@ void FlowGraph::WidenSmiToInt32() { |
// Process all inputs. |
for (intptr_t k = 0; k < defn->InputCount(); k++) { |
Definition* input = defn->InputAt(k)->definition(); |
- if (input->IsBinarySmiOp() && |
- CanBeWidened(input->AsBinarySmiOp())) { |
+ if (input->IsBinarySmiOp() && CanBeWidened(input->AsBinarySmiOp())) { |
worklist.Add(input); |
} else if (input->IsPhi() && (input->Type()->ToCid() == kSmiCid)) { |
worklist.Add(input); |
@@ -1924,8 +1873,7 @@ void FlowGraph::WidenSmiToInt32() { |
} |
// Process all uses. |
- for (Value* use = defn->input_use_list(); |
- use != NULL; |
+ for (Value* use = defn->input_use_list(); use != NULL; |
use = use->next_use()) { |
Instruction* instr = use->instruction(); |
Definition* use_defn = instr->AsDefinition(); |
@@ -1935,8 +1883,7 @@ void FlowGraph::WidenSmiToInt32() { |
if (!instr->IsReturn() && !instr->IsPushArgument()) { |
gain--; |
if (FLAG_support_il_printer && FLAG_trace_smi_widening) { |
- THR_Print("v [%" Pd "] (u) %s\n", |
- gain, |
+ THR_Print("v [%" Pd "] (u) %s\n", gain, |
use->instruction()->ToCString()); |
} |
} |
@@ -1953,15 +1900,13 @@ void FlowGraph::WidenSmiToInt32() { |
// sign extension operation. |
gain++; |
if (FLAG_support_il_printer && FLAG_trace_smi_widening) { |
- THR_Print("^ [%" Pd "] (u) %s\n", |
- gain, |
+ THR_Print("^ [%" Pd "] (u) %s\n", gain, |
use->instruction()->ToCString()); |
} |
} else if (defn_loop == loops[instr->GetBlock()->preorder_number()]) { |
gain--; |
if (FLAG_support_il_printer && FLAG_trace_smi_widening) { |
- THR_Print("v [%" Pd "] (u) %s\n", |
- gain, |
+ THR_Print("v [%" Pd "] (u) %s\n", gain, |
use->instruction()->ToCString()); |
} |
} |
@@ -1983,11 +1928,9 @@ void FlowGraph::WidenSmiToInt32() { |
if (defn->IsBinarySmiOp()) { |
BinarySmiOpInstr* smi_op = defn->AsBinarySmiOp(); |
- BinaryInt32OpInstr* int32_op = new(Z) BinaryInt32OpInstr( |
- smi_op->op_kind(), |
- smi_op->left()->CopyWithType(), |
- smi_op->right()->CopyWithType(), |
- smi_op->DeoptimizationTarget()); |
+ BinaryInt32OpInstr* int32_op = new (Z) BinaryInt32OpInstr( |
+ smi_op->op_kind(), smi_op->left()->CopyWithType(), |
+ smi_op->right()->CopyWithType(), smi_op->DeoptimizationTarget()); |
smi_op->ReplaceWith(int32_op, NULL); |
} else if (defn->IsPhi()) { |
@@ -2013,8 +1956,7 @@ void FlowGraph::EliminateEnvironments() { |
// that can deoptimize. |
disallow_licm(); |
- for (BlockIterator block_it = reverse_postorder_iterator(); |
- !block_it.Done(); |
+ for (BlockIterator block_it = reverse_postorder_iterator(); !block_it.Done(); |
block_it.Advance()) { |
BlockEntryInstr* block = block_it.Current(); |
if (!block->IsCatchBlockEntry()) { |
@@ -2039,11 +1981,9 @@ void FlowGraph::EliminateEnvironments() { |
bool FlowGraph::Canonicalize() { |
bool changed = false; |
- for (BlockIterator block_it = reverse_postorder_iterator(); |
- !block_it.Done(); |
+ for (BlockIterator block_it = reverse_postorder_iterator(); !block_it.Done(); |
block_it.Advance()) { |
- for (ForwardInstructionIterator it(block_it.Current()); |
- !it.Done(); |
+ for (ForwardInstructionIterator it(block_it.Current()); !it.Done(); |
it.Advance()) { |
Instruction* current = it.Current(); |
if (current->HasUnmatchedInputRepresentations()) { |
@@ -2074,8 +2014,7 @@ void FlowGraph::TryOptimizePatterns() { |
if (!FLAG_truncating_left_shift) return; |
GrowableArray<BinarySmiOpInstr*> div_mod_merge; |
GrowableArray<InvokeMathCFunctionInstr*> sin_cos_merge; |
- for (BlockIterator block_it = reverse_postorder_iterator(); |
- !block_it.Done(); |
+ for (BlockIterator block_it = reverse_postorder_iterator(); !block_it.Done(); |
block_it.Advance()) { |
// Merging only per basic-block. |
div_mod_merge.Clear(); |
@@ -2085,9 +2024,7 @@ void FlowGraph::TryOptimizePatterns() { |
if (it.Current()->IsBinarySmiOp()) { |
BinarySmiOpInstr* binop = it.Current()->AsBinarySmiOp(); |
if (binop->op_kind() == Token::kBIT_AND) { |
- OptimizeLeftShiftBitAndSmiOp(&it, |
- binop, |
- binop->left()->definition(), |
+ OptimizeLeftShiftBitAndSmiOp(&it, binop, binop->left()->definition(), |
binop->right()->definition()); |
} else if ((binop->op_kind() == Token::kTRUNCDIV) || |
(binop->op_kind() == Token::kMOD)) { |
@@ -2098,8 +2035,7 @@ void FlowGraph::TryOptimizePatterns() { |
} else if (it.Current()->IsBinaryMintOp()) { |
BinaryMintOpInstr* mintop = it.Current()->AsBinaryMintOp(); |
if (mintop->op_kind() == Token::kBIT_AND) { |
- OptimizeLeftShiftBitAndSmiOp(&it, |
- mintop, |
+ OptimizeLeftShiftBitAndSmiOp(&it, mintop, |
mintop->left()->definition(), |
mintop->right()->definition()); |
} |
@@ -2167,10 +2103,8 @@ void FlowGraph::OptimizeLeftShiftBitAndSmiOp( |
ASSERT(bit_and_instr->IsBinarySmiOp() || bit_and_instr->IsBinaryMintOp()); |
if (bit_and_instr->IsBinaryMintOp()) { |
// Replace Mint op with Smi op. |
- BinarySmiOpInstr* smi_op = new(Z) BinarySmiOpInstr( |
- Token::kBIT_AND, |
- new(Z) Value(left_instr), |
- new(Z) Value(right_instr), |
+ BinarySmiOpInstr* smi_op = new (Z) BinarySmiOpInstr( |
+ Token::kBIT_AND, new (Z) Value(left_instr), new (Z) Value(right_instr), |
Thread::kNoDeoptId); // BIT_AND cannot deoptimize. |
bit_and_instr->ReplaceWith(smi_op, current_iterator); |
} |
@@ -2209,38 +2143,34 @@ void FlowGraph::TryMergeTruncDivMod( |
ASSERT((curr_instr->op_kind() == Token::kTRUNCDIV) || |
(curr_instr->op_kind() == Token::kMOD)); |
// Check if there is kMOD/kTRUNDIV binop with same inputs. |
- const Token::Kind other_kind = (curr_instr->op_kind() == Token::kTRUNCDIV) ? |
- Token::kMOD : Token::kTRUNCDIV; |
+ const Token::Kind other_kind = (curr_instr->op_kind() == Token::kTRUNCDIV) |
+ ? Token::kMOD |
+ : Token::kTRUNCDIV; |
Definition* left_def = curr_instr->left()->definition(); |
Definition* right_def = curr_instr->right()->definition(); |
for (intptr_t k = i + 1; k < merge_candidates->length(); k++) { |
BinarySmiOpInstr* other_binop = (*merge_candidates)[k]; |
// 'other_binop' can be NULL if it was already merged. |
- if ((other_binop != NULL) && |
- (other_binop->op_kind() == other_kind) && |
+ if ((other_binop != NULL) && (other_binop->op_kind() == other_kind) && |
(other_binop->left()->definition() == left_def) && |
(other_binop->right()->definition() == right_def)) { |
(*merge_candidates)[k] = NULL; // Clear it. |
ASSERT(curr_instr->HasUses()); |
AppendExtractNthOutputForMerged( |
- curr_instr, |
- MergedMathInstr::OutputIndexOf(curr_instr->op_kind()), |
+ curr_instr, MergedMathInstr::OutputIndexOf(curr_instr->op_kind()), |
kTagged, kSmiCid); |
ASSERT(other_binop->HasUses()); |
AppendExtractNthOutputForMerged( |
- other_binop, |
- MergedMathInstr::OutputIndexOf(other_binop->op_kind()), |
+ other_binop, MergedMathInstr::OutputIndexOf(other_binop->op_kind()), |
kTagged, kSmiCid); |
- ZoneGrowableArray<Value*>* args = new(Z) ZoneGrowableArray<Value*>(2); |
- args->Add(new(Z) Value(curr_instr->left()->definition())); |
- args->Add(new(Z) Value(curr_instr->right()->definition())); |
+ ZoneGrowableArray<Value*>* args = new (Z) ZoneGrowableArray<Value*>(2); |
+ args->Add(new (Z) Value(curr_instr->left()->definition())); |
+ args->Add(new (Z) Value(curr_instr->right()->definition())); |
// Replace with TruncDivMod. |
- MergedMathInstr* div_mod = new(Z) MergedMathInstr( |
- args, |
- curr_instr->deopt_id(), |
- MergedMathInstr::kTruncDivMod); |
+ MergedMathInstr* div_mod = new (Z) MergedMathInstr( |
+ args, curr_instr->deopt_id(), MergedMathInstr::kTruncDivMod); |
curr_instr->ReplaceWith(div_mod, NULL); |
other_binop->ReplaceUsesWith(div_mod); |
other_binop->RemoveFromGraph(); |
@@ -2276,8 +2206,8 @@ void FlowGraph::TryMergeMathUnary( |
(kind == MethodRecognizer::kMathCos)); |
// Check if there is sin/cos binop with same inputs. |
const MethodRecognizer::Kind other_kind = |
- (kind == MethodRecognizer::kMathSin) |
- ? MethodRecognizer::kMathCos : MethodRecognizer::kMathSin; |
+ (kind == MethodRecognizer::kMathSin) ? MethodRecognizer::kMathCos |
+ : MethodRecognizer::kMathSin; |
Definition* def = curr_instr->InputAt(0)->definition(); |
for (intptr_t k = i + 1; k < merge_candidates->length(); k++) { |
InvokeMathCFunctionInstr* other_op = (*merge_candidates)[k]; |
@@ -2291,16 +2221,13 @@ void FlowGraph::TryMergeMathUnary( |
kUnboxedDouble, kDoubleCid); |
ASSERT(other_op->HasUses()); |
AppendExtractNthOutputForMerged( |
- other_op, |
- MergedMathInstr::OutputIndexOf(other_kind), |
+ other_op, MergedMathInstr::OutputIndexOf(other_kind), |
kUnboxedDouble, kDoubleCid); |
- ZoneGrowableArray<Value*>* args = new(Z) ZoneGrowableArray<Value*>(1); |
- args->Add(new(Z) Value(curr_instr->InputAt(0)->definition())); |
+ ZoneGrowableArray<Value*>* args = new (Z) ZoneGrowableArray<Value*>(1); |
+ args->Add(new (Z) Value(curr_instr->InputAt(0)->definition())); |
// Replace with SinCos. |
- MergedMathInstr* sin_cos = |
- new(Z) MergedMathInstr(args, |
- curr_instr->DeoptimizationTarget(), |
- MergedMathInstr::kSinCos); |
+ MergedMathInstr* sin_cos = new (Z) MergedMathInstr( |
+ args, curr_instr->DeoptimizationTarget(), MergedMathInstr::kSinCos); |
curr_instr->ReplaceWith(sin_cos, NULL); |
other_op->ReplaceUsesWith(sin_cos); |
other_op->RemoveFromGraph(); |
@@ -2319,12 +2246,10 @@ void FlowGraph::AppendExtractNthOutputForMerged(Definition* instr, |
Representation rep, |
intptr_t cid) { |
ExtractNthOutputInstr* extract = |
- new(Z) ExtractNthOutputInstr(new(Z) Value(instr), index, rep, cid); |
+ new (Z) ExtractNthOutputInstr(new (Z) Value(instr), index, rep, cid); |
instr->ReplaceUsesWith(extract); |
InsertAfter(instr, extract, NULL, FlowGraph::kValue); |
} |
- |
- |
} // namespace dart |