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

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

Issue 181183004: VM: Improve receiver class check in polymorphic inlining. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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
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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 return AttributesEqual(other); 89 return AttributesEqual(other);
90 } 90 }
91 91
92 92
93 bool Value::Equals(Value* other) const { 93 bool Value::Equals(Value* other) const {
94 return definition() == other->definition(); 94 return definition() == other->definition();
95 } 95 }
96 96
97 97
98 static int LowestFirst(const intptr_t* a, const intptr_t* b) {
99 return *a - *b;
100 }
101
102
98 CheckClassInstr::CheckClassInstr(Value* value, 103 CheckClassInstr::CheckClassInstr(Value* value,
99 intptr_t deopt_id, 104 intptr_t deopt_id,
100 const ICData& unary_checks, 105 const ICData& unary_checks,
101 intptr_t token_pos) 106 intptr_t token_pos)
102 : unary_checks_(unary_checks), licm_hoisted_(false), token_pos_(token_pos) { 107 : unary_checks_(unary_checks),
108 cids_(unary_checks.NumberOfChecks()),
109 licm_hoisted_(false),
110 token_pos_(token_pos) {
103 ASSERT(unary_checks.IsZoneHandle()); 111 ASSERT(unary_checks.IsZoneHandle());
104 // Expected useful check data. 112 // Expected useful check data.
105 ASSERT(!unary_checks_.IsNull()); 113 ASSERT(!unary_checks_.IsNull());
106 ASSERT(unary_checks_.NumberOfChecks() > 0); 114 ASSERT(unary_checks_.NumberOfChecks() > 0);
107 ASSERT(unary_checks_.NumArgsTested() == 1); 115 ASSERT(unary_checks_.NumArgsTested() == 1);
108 SetInputAt(0, value); 116 SetInputAt(0, value);
109 deopt_id_ = deopt_id; 117 deopt_id_ = deopt_id;
110 // Otherwise use CheckSmiInstr. 118 // Otherwise use CheckSmiInstr.
111 ASSERT((unary_checks_.NumberOfChecks() != 1) || 119 ASSERT((unary_checks_.NumberOfChecks() != 1) ||
112 (unary_checks_.GetReceiverClassIdAt(0) != kSmiCid)); 120 (unary_checks_.GetReceiverClassIdAt(0) != kSmiCid));
121 for (intptr_t i = 0; i < unary_checks.NumberOfChecks(); ++i) {
122 cids_.Add(unary_checks.GetReceiverClassIdAt(i));
123 }
124 cids_.Sort(LowestFirst);
113 } 125 }
114 126
115 127
116 bool CheckClassInstr::AttributesEqual(Instruction* other) const { 128 bool CheckClassInstr::AttributesEqual(Instruction* other) const {
117 CheckClassInstr* other_check = other->AsCheckClass(); 129 CheckClassInstr* other_check = other->AsCheckClass();
118 ASSERT(other_check != NULL); 130 ASSERT(other_check != NULL);
119 if (unary_checks().NumberOfChecks() != 131 if (unary_checks().NumberOfChecks() !=
120 other_check->unary_checks().NumberOfChecks()) { 132 other_check->unary_checks().NumberOfChecks()) {
121 return false; 133 return false;
122 } 134 }
(...skipping 22 matching lines...) Expand all
145 return false; 157 return false;
146 } 158 }
147 CompileType* in_type = value()->Type(); 159 CompileType* in_type = value()->Type();
148 const intptr_t cid = unary_checks().GetCidAt(0); 160 const intptr_t cid = unary_checks().GetCidAt(0);
149 // Performance check: use CheckSmiInstr instead. 161 // Performance check: use CheckSmiInstr instead.
150 ASSERT(cid != kSmiCid); 162 ASSERT(cid != kSmiCid);
151 return in_type->is_nullable() && (in_type->ToNullableCid() == cid); 163 return in_type->is_nullable() && (in_type->ToNullableCid() == cid);
152 } 164 }
153 165
154 166
167 bool CheckClassInstr::IsDenseSwitch() const {
168 if (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) return false;
169 if (cids_.length() > 2 &&
170 cids_[cids_.length() - 1] - cids_[0] < kBitsPerWord) {
171 return true;
172 }
173 return false;
174 }
175
176
177 intptr_t CheckClassInstr::ComputeCidMask() const {
178 ASSERT(IsDenseSwitch());
179 intptr_t mask = 0;
180 for (intptr_t i = 0; i < cids_.length(); ++i) {
181 mask |= 1 << (cids_[i] - cids_[0]);
182 }
183 return mask;
184 }
185
186
187 bool CheckClassInstr::IsDenseMask(intptr_t mask) {
188 // Returns true if the mask is a continuos sequence of ones in its binary
189 // representation (i.e. no holes)
190 return mask == -1 || Utils::IsPowerOfTwo(mask + 1);
191 }
192
193
155 bool LoadFieldInstr::IsUnboxedLoad() const { 194 bool LoadFieldInstr::IsUnboxedLoad() const {
156 return FLAG_unbox_numeric_fields 195 return FLAG_unbox_numeric_fields
157 && (field() != NULL) 196 && (field() != NULL)
158 && field()->IsUnboxedField(); 197 && field()->IsUnboxedField();
159 } 198 }
160 199
161 200
162 bool LoadFieldInstr::IsPotentialUnboxedLoad() const { 201 bool LoadFieldInstr::IsPotentialUnboxedLoad() const {
163 return FLAG_unbox_numeric_fields 202 return FLAG_unbox_numeric_fields
164 && (field() != NULL) 203 && (field() != NULL)
(...skipping 3810 matching lines...) Expand 10 before | Expand all | Expand 10 after
3975 case Token::kTRUNCDIV: return 0; 4014 case Token::kTRUNCDIV: return 0;
3976 case Token::kMOD: return 1; 4015 case Token::kMOD: return 1;
3977 default: UNIMPLEMENTED(); return -1; 4016 default: UNIMPLEMENTED(); return -1;
3978 } 4017 }
3979 } 4018 }
3980 4019
3981 4020
3982 #undef __ 4021 #undef __
3983 4022
3984 } // namespace dart 4023 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698