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

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

Issue 10553040: Inline binary And operation for Mint and Smi in new compilers. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 | « no previous file | 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_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/flow_graph_builder.h" 7 #include "vm/flow_graph_builder.h"
8 #include "vm/il_printer.h" 8 #include "vm/il_printer.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 10
(...skipping 17 matching lines...) Expand all
28 for (intptr_t i = 0; i < block_order_.length(); ++i) { 28 for (intptr_t i = 0; i < block_order_.length(); ++i) {
29 Instruction* instr = block_order_[i]->Accept(this); 29 Instruction* instr = block_order_[i]->Accept(this);
30 // Optimize all successors until an exit, branch, or a block entry. 30 // Optimize all successors until an exit, branch, or a block entry.
31 while ((instr != NULL) && !instr->IsBlockEntry()) { 31 while ((instr != NULL) && !instr->IsBlockEntry()) {
32 instr = instr->Accept(this); 32 instr = instr->Accept(this);
33 } 33 }
34 } 34 }
35 } 35 }
36 36
37 37
38 static bool ICDataHasReceiverClass(const ICData& ic_data, const Class& cls) { 38 static bool ICDataHasReceiverClass(const ICData& ic_data, intptr_t class_id) {
39 ASSERT(!cls.IsNull());
40 ASSERT(ic_data.num_args_tested() > 0); 39 ASSERT(ic_data.num_args_tested() > 0);
41 Class& test_class = Class::Handle(); 40 Class& test_class = Class::Handle();
42 Function& target = Function::Handle(); 41 Function& target = Function::Handle();
43 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) { 42 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) {
44 ic_data.GetOneClassCheckAt(i, &test_class, &target); 43 ic_data.GetOneClassCheckAt(i, &test_class, &target);
45 if (cls.raw() == test_class.raw()) { 44 if (test_class.id() == class_id) {
46 return true; 45 return true;
47 } 46 }
48 } 47 }
49 return false; 48 return false;
50 } 49 }
51 50
52 51
53 static bool ICDataHasTwoReceiverClasses(const ICData& ic_data, 52 static bool ICDataHasReceiverArgumentClasses(const ICData& ic_data,
54 const Class& cls1, 53 intptr_t receiver_class_id,
55 const Class& cls2) { 54 intptr_t argument_class_id) {
56 ASSERT(!cls1.IsNull() && !cls2.IsNull());
57 if (ic_data.num_args_tested() != 2) { 55 if (ic_data.num_args_tested() != 2) {
58 return false; 56 return false;
59 } 57 }
60 Function& target = Function::Handle(); 58 Function& target = Function::Handle();
61 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) { 59 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) {
62 GrowableArray<const Class*> classes; 60 GrowableArray<const Class*> classes;
63 ic_data.GetCheckAt(i, &classes, &target); 61 ic_data.GetCheckAt(i, &classes, &target);
64 ASSERT(classes.length() == 2); 62 ASSERT(classes.length() == 2);
65 if (classes[0]->raw() == cls1.raw()) { 63 if (classes[0]->id() == receiver_class_id) {
66 if (classes[1]->raw() == cls2.raw()) { 64 if (classes[1]->id() == argument_class_id) {
67 return true; 65 return true;
68 } 66 }
69 } 67 }
70 } 68 }
71 return false; 69 return false;
72 } 70 }
73 71
74 72
75 static bool HasOneSmi(const ICData& ic_data) { 73 static bool HasOneSmi(const ICData& ic_data) {
76 const Class& smi_class = 74 return ICDataHasReceiverClass(ic_data, kSmi);
77 Class::Handle(Isolate::Current()->object_store()->smi_class());
78 return ICDataHasReceiverClass(ic_data, smi_class);
79 } 75 }
80 76
81 77
82 static bool HasTwoSmi(const ICData& ic_data) { 78 static bool HasTwoSmi(const ICData& ic_data) {
83 const Class& smi_class = 79 return ICDataHasReceiverArgumentClasses(ic_data, kSmi, kSmi);
84 Class::Handle(Isolate::Current()->object_store()->smi_class()); 80 }
85 return ICDataHasTwoReceiverClasses(ic_data, smi_class, smi_class); 81
82
83 static bool HasMintSmi(const ICData& ic_data) {
84 return ICDataHasReceiverArgumentClasses(ic_data, kMint, kSmi);
86 } 85 }
87 86
88 87
89 static bool HasOneDouble(const ICData& ic_data) { 88 static bool HasOneDouble(const ICData& ic_data) {
90 const Class& double_class = 89 return ICDataHasReceiverClass(ic_data, kDouble);
91 Class::Handle(Isolate::Current()->object_store()->double_class());
92 return ICDataHasReceiverClass(ic_data, double_class);
93 } 90 }
94 91
95 92
96 static bool HasTwoDouble(const ICData& ic_data) { 93 static bool HasTwoDouble(const ICData& ic_data) {
97 const Class& double_class = 94 return ICDataHasReceiverArgumentClasses(ic_data, kDouble, kDouble);
98 Class::Handle(Isolate::Current()->object_store()->double_class());
99 return ICDataHasTwoReceiverClasses(ic_data, double_class, double_class);
100 } 95 }
101 96
102 97
103 bool FlowGraphOptimizer::TryReplaceWithBinaryOp(InstanceCallComp* comp, 98 bool FlowGraphOptimizer::TryReplaceWithBinaryOp(InstanceCallComp* comp,
104 Token::Kind op_kind) { 99 Token::Kind op_kind) {
100 BinaryOpComp::OperandsType operands_type;
101
102 if (HasMintSmi(*comp->ic_data())) {
103 // We check for Mint receiver and Smi argument, but we try to support any
104 // combination of Mint and Smi.
105 if (op_kind != Token::kBIT_AND) {
106 // TODO(regis): Not yet supported.
107 return false;
108 }
109
110 operands_type = BinaryOpComp::kMintOperands;
111 }
112
105 if (comp->ic_data()->NumberOfChecks() != 1) { 113 if (comp->ic_data()->NumberOfChecks() != 1) {
106 // TODO(srdjan): Not yet supported. 114 // TODO(srdjan): Not yet supported.
107 return false; 115 return false;
108 } 116 }
109 117
110 BinaryOpComp::OperandsType operands_type;
111
112 if (HasTwoSmi(*comp->ic_data())) { 118 if (HasTwoSmi(*comp->ic_data())) {
113 if (op_kind == Token::kDIV || 119 if (op_kind == Token::kDIV ||
114 op_kind == Token::kMOD) { 120 op_kind == Token::kMOD) {
115 // TODO(srdjan): Not yet supported. 121 // TODO(srdjan): Not yet supported.
116 return false; 122 return false;
117 } 123 }
118 124
119 operands_type = BinaryOpComp::kSmiOperands; 125 operands_type = BinaryOpComp::kSmiOperands;
120 } else if (HasTwoDouble(*comp->ic_data())) { 126 } else if (HasTwoDouble(*comp->ic_data())) {
121 if (op_kind != Token::kADD && 127 if (op_kind != Token::kADD &&
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 instr->computation()->Accept(this); 591 instr->computation()->Accept(this);
586 } 592 }
587 593
588 594
589 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { 595 void FlowGraphOptimizer::VisitBind(BindInstr* instr) {
590 instr->computation()->Accept(this); 596 instr->computation()->Accept(this);
591 } 597 }
592 598
593 599
594 } // namespace dart 600 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698