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

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

Issue 12086045: On Ia32 optimistically assume that results from int32 and uint32 array loads fit into Smi. Only if … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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/code_generator.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) 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/flow_graph_builder.h" 9 #include "vm/flow_graph_builder.h"
10 #include "vm/flow_graph_compiler.h" 10 #include "vm/flow_graph_compiler.h"
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 needs_store_barrier, array_cid, call->deopt_id()); 726 needs_store_barrier, array_cid, call->deopt_id());
727 call->ReplaceWith(array_op, current_iterator()); 727 call->ReplaceWith(array_op, current_iterator());
728 RemovePushArguments(call); 728 RemovePushArguments(call);
729 return true; 729 return true;
730 } 730 }
731 731
732 732
733 733
734 bool FlowGraphOptimizer::TryReplaceWithLoadIndexed(InstanceCallInstr* call) { 734 bool FlowGraphOptimizer::TryReplaceWithLoadIndexed(InstanceCallInstr* call) {
735 const intptr_t class_id = ReceiverClassId(call); 735 const intptr_t class_id = ReceiverClassId(call);
736 // Set deopt_id to a valid id if the LoadIndexedInstr can cause deopt.
737 intptr_t deopt_id = Isolate::kNoDeoptId;
736 switch (class_id) { 738 switch (class_id) {
737 case kArrayCid: 739 case kArrayCid:
738 case kImmutableArrayCid: 740 case kImmutableArrayCid:
739 case kGrowableObjectArrayCid: 741 case kGrowableObjectArrayCid:
740 case kFloat32ArrayCid: 742 case kFloat32ArrayCid:
741 case kFloat64ArrayCid: 743 case kFloat64ArrayCid:
742 case kInt8ArrayCid: 744 case kInt8ArrayCid:
743 case kUint8ArrayCid: 745 case kUint8ArrayCid:
744 case kUint8ClampedArrayCid: 746 case kUint8ClampedArrayCid:
745 case kExternalUint8ArrayCid: 747 case kExternalUint8ArrayCid:
746 case kInt16ArrayCid: 748 case kInt16ArrayCid:
747 case kUint16ArrayCid: 749 case kUint16ArrayCid:
748 break; 750 break;
749 case kInt32ArrayCid: 751 case kInt32ArrayCid:
750 case kUint32ArrayCid: 752 case kUint32ArrayCid:
751 // Check if elements fit into a smi or the platform supports unboxed 753 // Check if elements fit into a smi or the platform supports unboxed
752 // mints. 754 // mints.
753 if ((kSmiBits < 32) && !FlowGraphCompiler::SupportsUnboxedMints()) { 755 if ((kSmiBits < 32) && !FlowGraphCompiler::SupportsUnboxedMints()) {
754 return false; 756 return false;
755 } 757 }
758 // Set deopt_id if we can optimistically assume that the result is Smi.
759 // TODO(srdjan): Add better signal if this instruction caused
Florian Schneider 2013/01/29 19:57:58 call->ic_data().deopt_reason() should contain the
760 // deoptimization. This solution: only if no deoptimization occured in
761 // this method is it guaranteed that this instruction did not cause
762 // deoptimization.
763 if (flow_graph_->parsed_function().function().deoptimization_counter()
764 > 0) {
765 deopt_id = Isolate::kNoDeoptId;
766 } else {
767 deopt_id = call->deopt_id();
768 }
756 break; 769 break;
757 default: 770 default:
758 return false; 771 return false;
759 } 772 }
760 Value* array = NULL; 773 Value* array = NULL;
761 Value* index = NULL; 774 Value* index = NULL;
762 intptr_t array_cid = PrepareIndexedOp(call, class_id, &array, &index); 775 intptr_t array_cid = PrepareIndexedOp(call, class_id, &array, &index);
763 Definition* array_op = new LoadIndexedInstr(array, index, array_cid); 776 Definition* array_op =
777 new LoadIndexedInstr(array, index, array_cid, deopt_id);
764 call->ReplaceWith(array_op, current_iterator()); 778 call->ReplaceWith(array_op, current_iterator());
765 RemovePushArguments(call); 779 RemovePushArguments(call);
766 return true; 780 return true;
767 } 781 }
768 782
769 783
770 void FlowGraphOptimizer::InsertBefore(Instruction* next, 784 void FlowGraphOptimizer::InsertBefore(Instruction* next,
771 Instruction* instr, 785 Instruction* instr,
772 Environment* env, 786 Environment* env,
773 Definition::UseKind use_kind) { 787 Definition::UseKind use_kind) {
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 if (!skip_check) { 1296 if (!skip_check) {
1283 // Insert bounds check. 1297 // Insert bounds check.
1284 InsertBefore(call, 1298 InsertBefore(call,
1285 new CheckArrayBoundInstr(str->Copy(), 1299 new CheckArrayBoundInstr(str->Copy(),
1286 index->Copy(), 1300 index->Copy(),
1287 cid, 1301 cid,
1288 call), 1302 call),
1289 call->env(), 1303 call->env(),
1290 Definition::kEffect); 1304 Definition::kEffect);
1291 } 1305 }
1292 return new LoadIndexedInstr(str, index, cid); 1306 return new LoadIndexedInstr(str, index, cid, Isolate::kNoDeoptId);
1293 } 1307 }
1294 1308
1295 1309
1296 void FlowGraphOptimizer::ReplaceWithMathCFunction( 1310 void FlowGraphOptimizer::ReplaceWithMathCFunction(
1297 InstanceCallInstr* call, 1311 InstanceCallInstr* call,
1298 MethodRecognizer::Kind recognized_kind) { 1312 MethodRecognizer::Kind recognized_kind) {
1299 AddCheckClass(call, call->ArgumentAt(0)->value()->Copy()); 1313 AddCheckClass(call, call->ArgumentAt(0)->value()->Copy());
1300 ZoneGrowableArray<Value*>* args = 1314 ZoneGrowableArray<Value*>* args =
1301 new ZoneGrowableArray<Value*>(call->ArgumentCount()); 1315 new ZoneGrowableArray<Value*>(call->ArgumentCount());
1302 for (intptr_t i = 0; i < call->ArgumentCount(); i++) { 1316 for (intptr_t i = 0; i < call->ArgumentCount(); i++) {
(...skipping 3294 matching lines...) Expand 10 before | Expand all | Expand 10 after
4597 4611
4598 if (FLAG_trace_constant_propagation) { 4612 if (FLAG_trace_constant_propagation) {
4599 OS::Print("\n==== After constant propagation ====\n"); 4613 OS::Print("\n==== After constant propagation ====\n");
4600 FlowGraphPrinter printer(*graph_); 4614 FlowGraphPrinter printer(*graph_);
4601 printer.PrintBlocks(); 4615 printer.PrintBlocks();
4602 } 4616 }
4603 } 4617 }
4604 4618
4605 4619
4606 } // namespace dart 4620 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.h ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698