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

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

Issue 294223003: Last cross-platform cleanup in preparation of improved ARM code for indexed (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/intermediate_language_arm.cc » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 304 }
305 305
306 306
307 307
308 // Used by TryMergeDivMod. 308 // Used by TryMergeDivMod.
309 // Inserts a load-indexed instruction between a TRUNCDIV or MOD instruction, 309 // Inserts a load-indexed instruction between a TRUNCDIV or MOD instruction,
310 // and the using instruction. This is an intermediate step before merging. 310 // and the using instruction. This is an intermediate step before merging.
311 void FlowGraphOptimizer::AppendLoadIndexedForMerged(Definition* instr, 311 void FlowGraphOptimizer::AppendLoadIndexedForMerged(Definition* instr,
312 intptr_t ix, 312 intptr_t ix,
313 intptr_t cid) { 313 intptr_t cid) {
314 const intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(cid); 314 const intptr_t index_scale = Instance::ElementSizeFor(cid);
315 ConstantInstr* index_instr = 315 ConstantInstr* index_instr =
316 flow_graph()->GetConstant(Smi::Handle(Smi::New(ix))); 316 flow_graph()->GetConstant(Smi::Handle(Smi::New(ix)));
317 LoadIndexedInstr* load = new LoadIndexedInstr(new Value(instr), 317 LoadIndexedInstr* load = new LoadIndexedInstr(new Value(instr),
318 new Value(index_instr), 318 new Value(index_instr),
319 index_scale, 319 index_scale,
320 cid, 320 cid,
321 Isolate::kNoDeoptId, 321 Isolate::kNoDeoptId,
322 instr->token_pos()); 322 instr->token_pos());
323 instr->ReplaceUsesWith(load); 323 instr->ReplaceUsesWith(load);
324 flow_graph()->InsertAfter(instr, load, NULL, FlowGraph::kValue); 324 flow_graph()->InsertAfter(instr, load, NULL, FlowGraph::kValue);
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 1294
1295 if (array_cid == kTypedDataFloat32ArrayCid) { 1295 if (array_cid == kTypedDataFloat32ArrayCid) {
1296 stored_value = 1296 stored_value =
1297 new DoubleToFloatInstr(new Value(stored_value), call->deopt_id()); 1297 new DoubleToFloatInstr(new Value(stored_value), call->deopt_id());
1298 cursor = flow_graph()->AppendTo(cursor, 1298 cursor = flow_graph()->AppendTo(cursor,
1299 stored_value, 1299 stored_value,
1300 NULL, 1300 NULL,
1301 FlowGraph::kValue); 1301 FlowGraph::kValue);
1302 } 1302 }
1303 1303
1304 intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(array_cid); 1304 const intptr_t index_scale = Instance::ElementSizeFor(array_cid);
1305 *last = new StoreIndexedInstr(new Value(array), 1305 *last = new StoreIndexedInstr(new Value(array),
1306 new Value(index), 1306 new Value(index),
1307 new Value(stored_value), 1307 new Value(stored_value),
1308 needs_store_barrier, 1308 needs_store_barrier,
1309 index_scale, 1309 index_scale,
1310 array_cid, 1310 array_cid,
1311 call->deopt_id(), 1311 call->deopt_id(),
1312 call->token_pos()); 1312 call->token_pos());
1313 flow_graph()->AppendTo(cursor, 1313 flow_graph()->AppendTo(cursor,
1314 *last, 1314 *last,
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 intptr_t deopt_id = Isolate::kNoDeoptId; 1646 intptr_t deopt_id = Isolate::kNoDeoptId;
1647 if ((array_cid == kTypedDataInt32ArrayCid) || 1647 if ((array_cid == kTypedDataInt32ArrayCid) ||
1648 (array_cid == kTypedDataUint32ArrayCid)) { 1648 (array_cid == kTypedDataUint32ArrayCid)) {
1649 // Set deopt_id if we can optimistically assume that the result is Smi. 1649 // Set deopt_id if we can optimistically assume that the result is Smi.
1650 // Assume mixed Mint/Smi if this instruction caused deoptimization once. 1650 // Assume mixed Mint/Smi if this instruction caused deoptimization once.
1651 deopt_id = ic_data.HasDeoptReasons() ? 1651 deopt_id = ic_data.HasDeoptReasons() ?
1652 Isolate::kNoDeoptId : call->deopt_id(); 1652 Isolate::kNoDeoptId : call->deopt_id();
1653 } 1653 }
1654 1654
1655 // Array load and return. 1655 // Array load and return.
1656 intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(array_cid); 1656 intptr_t index_scale = Instance::ElementSizeFor(array_cid);
1657 *last = new LoadIndexedInstr(new Value(array), 1657 *last = new LoadIndexedInstr(new Value(array),
1658 new Value(index), 1658 new Value(index),
1659 index_scale, 1659 index_scale,
1660 array_cid, 1660 array_cid,
1661 deopt_id, 1661 deopt_id,
1662 call->token_pos()); 1662 call->token_pos());
1663 cursor = flow_graph()->AppendTo( 1663 cursor = flow_graph()->AppendTo(
1664 cursor, 1664 cursor,
1665 *last, 1665 *last,
1666 deopt_id != Isolate::kNoDeoptId ? call->env() : NULL, 1666 deopt_id != Isolate::kNoDeoptId ? call->env() : NULL,
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
2717 cursor = flow_graph()->AppendTo(cursor, 2717 cursor = flow_graph()->AppendTo(cursor,
2718 new CheckArrayBoundInstr(new Value(length), 2718 new CheckArrayBoundInstr(new Value(length),
2719 new Value(index), 2719 new Value(index),
2720 call->deopt_id()), 2720 call->deopt_id()),
2721 call->env(), 2721 call->env(),
2722 FlowGraph::kEffect); 2722 FlowGraph::kEffect);
2723 2723
2724 LoadIndexedInstr* load_indexed = new LoadIndexedInstr( 2724 LoadIndexedInstr* load_indexed = new LoadIndexedInstr(
2725 new Value(str), 2725 new Value(str),
2726 new Value(index), 2726 new Value(index),
2727 FlowGraphCompiler::ElementSizeFor(cid), 2727 Instance::ElementSizeFor(cid),
2728 cid, 2728 cid,
2729 Isolate::kNoDeoptId, 2729 Isolate::kNoDeoptId,
2730 call->token_pos()); 2730 call->token_pos());
2731 2731
2732 cursor = flow_graph()->AppendTo(cursor, 2732 cursor = flow_graph()->AppendTo(cursor,
2733 load_indexed, 2733 load_indexed,
2734 NULL, 2734 NULL,
2735 FlowGraph::kValue); 2735 FlowGraph::kValue);
2736 ASSERT(cursor == load_indexed); 2736 ASSERT(cursor == load_indexed);
2737 return load_indexed; 2737 return load_indexed;
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
3701 call->token_pos()); 3701 call->token_pos());
3702 length->set_is_immutable(true); 3702 length->set_is_immutable(true);
3703 length->set_result_cid(kSmiCid); 3703 length->set_result_cid(kSmiCid);
3704 length->set_recognized_kind( 3704 length->set_recognized_kind(
3705 LoadFieldInstr::RecognizedKindFromArrayCid(array_cid)); 3705 LoadFieldInstr::RecognizedKindFromArrayCid(array_cid));
3706 *cursor = flow_graph()->AppendTo(*cursor, 3706 *cursor = flow_graph()->AppendTo(*cursor,
3707 length, 3707 length,
3708 NULL, 3708 NULL,
3709 FlowGraph::kValue); 3709 FlowGraph::kValue);
3710 3710
3711 intptr_t element_size = FlowGraphCompiler::ElementSizeFor(array_cid); 3711 intptr_t element_size = Instance::ElementSizeFor(array_cid);
3712 ConstantInstr* bytes_per_element = 3712 ConstantInstr* bytes_per_element =
3713 flow_graph()->GetConstant(Smi::Handle(Smi::New(element_size))); 3713 flow_graph()->GetConstant(Smi::Handle(Smi::New(element_size)));
3714 BinarySmiOpInstr* len_in_bytes = 3714 BinarySmiOpInstr* len_in_bytes =
3715 new BinarySmiOpInstr(Token::kMUL, 3715 new BinarySmiOpInstr(Token::kMUL,
3716 new Value(length), 3716 new Value(length),
3717 new Value(bytes_per_element), 3717 new Value(bytes_per_element),
3718 call->deopt_id(), call->token_pos()); 3718 call->deopt_id(), call->token_pos());
3719 *cursor = flow_graph()->AppendTo(*cursor, len_in_bytes, call->env(), 3719 *cursor = flow_graph()->AppendTo(*cursor, len_in_bytes, call->env(),
3720 FlowGraph::kValue); 3720 FlowGraph::kValue);
3721 3721
3722 ConstantInstr* length_adjustment = 3722 ConstantInstr* length_adjustment =
3723 flow_graph()->GetConstant(Smi::Handle(Smi::New( 3723 flow_graph()->GetConstant(Smi::Handle(Smi::New(
3724 FlowGraphCompiler::ElementSizeFor(view_cid) - 1))); 3724 Instance::ElementSizeFor(view_cid) - 1)));
3725 // adjusted_length = len_in_bytes - (element_size - 1). 3725 // adjusted_length = len_in_bytes - (element_size - 1).
3726 BinarySmiOpInstr* adjusted_length = 3726 BinarySmiOpInstr* adjusted_length =
3727 new BinarySmiOpInstr(Token::kSUB, 3727 new BinarySmiOpInstr(Token::kSUB,
3728 new Value(len_in_bytes), 3728 new Value(len_in_bytes),
3729 new Value(length_adjustment), 3729 new Value(length_adjustment),
3730 call->deopt_id(), call->token_pos()); 3730 call->deopt_id(), call->token_pos());
3731 *cursor = flow_graph()->AppendTo(*cursor, adjusted_length, call->env(), 3731 *cursor = flow_graph()->AppendTo(*cursor, adjusted_length, call->env(),
3732 FlowGraph::kValue); 3732 FlowGraph::kValue);
3733 3733
3734 // Check adjusted_length > 0. 3734 // Check adjusted_length > 0.
(...skipping 5963 matching lines...) Expand 10 before | Expand all | Expand 10 after
9698 } 9698 }
9699 9699
9700 // Insert materializations at environment uses. 9700 // Insert materializations at environment uses.
9701 for (intptr_t i = 0; i < exits.length(); i++) { 9701 for (intptr_t i = 0; i < exits.length(); i++) {
9702 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots); 9702 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots);
9703 } 9703 }
9704 } 9704 }
9705 9705
9706 9706
9707 } // namespace dart 9707 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698