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

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

Issue 266633007: Merge ConstantInstr -> UnboxDouble to UnboxedConstant. Reduces register usage and allows for variou… (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/intermediate_language.h ('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/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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } 318 }
319 319
320 320
321 bool ConstantInstr::AttributesEqual(Instruction* other) const { 321 bool ConstantInstr::AttributesEqual(Instruction* other) const {
322 ConstantInstr* other_constant = other->AsConstant(); 322 ConstantInstr* other_constant = other->AsConstant();
323 ASSERT(other_constant != NULL); 323 ASSERT(other_constant != NULL);
324 return (value().raw() == other_constant->value().raw()); 324 return (value().raw() == other_constant->value().raw());
325 } 325 }
326 326
327 327
328 UnboxedConstantInstr::UnboxedConstantInstr(const Object& value)
329 : ConstantInstr(value), constant_address_(NULL) {
330 // Only doubles supported for now.
331 ASSERT(value.IsDouble());
332 constant_address_ =
333 FlowGraphBuilder::FindDoubleConstant(Double::Cast(value).value());
334 }
335
328 // Returns true if the value represents a constant. 336 // Returns true if the value represents a constant.
329 bool Value::BindsToConstant() const { 337 bool Value::BindsToConstant() const {
330 return definition()->IsConstant(); 338 return definition()->IsConstant();
331 } 339 }
332 340
333 341
334 // Returns true if the value represents constant null. 342 // Returns true if the value represents constant null.
335 bool Value::BindsToConstantNull() const { 343 bool Value::BindsToConstantNull() const {
336 ConstantInstr* constant = definition()->AsConstant(); 344 ConstantInstr* constant = definition()->AsConstant();
337 return (constant != NULL) && constant->value().IsNull(); 345 return (constant != NULL) && constant->value().IsNull();
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 return Utils::IsPowerOfTwo(Utils::Abs(int_value)); 1225 return Utils::IsPowerOfTwo(Utils::Abs(int_value));
1218 } 1226 }
1219 1227
1220 1228
1221 static bool ToIntegerConstant(Value* value, intptr_t* result) { 1229 static bool ToIntegerConstant(Value* value, intptr_t* result) {
1222 if (!value->BindsToConstant()) { 1230 if (!value->BindsToConstant()) {
1223 if (value->definition()->IsUnboxDouble()) { 1231 if (value->definition()->IsUnboxDouble()) {
1224 return ToIntegerConstant(value->definition()->AsUnboxDouble()->value(), 1232 return ToIntegerConstant(value->definition()->AsUnboxDouble()->value(),
1225 result); 1233 result);
1226 } 1234 }
1227
1228 return false; 1235 return false;
1229 } 1236 }
1230 1237
1231 const Object& constant = value->BoundConstant(); 1238 const Object& constant = value->BoundConstant();
1232 if (constant.IsDouble()) { 1239 if (constant.IsDouble()) {
1233 const Double& double_constant = Double::Cast(constant); 1240 const Double& double_constant = Double::Cast(constant);
1234 *result = static_cast<intptr_t>(double_constant.value()); 1241 *result = static_cast<intptr_t>(double_constant.value());
1235 return (static_cast<double>(*result) == double_constant.value()); 1242 return (static_cast<double>(*result) == double_constant.value());
1236 } else if (constant.IsSmi()) { 1243 } else if (constant.IsSmi()) {
1237 *result = Smi::Cast(constant).Value(); 1244 *result = Smi::Cast(constant).Value();
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 UnboxDoubleInstr* defn = value()->definition()->AsUnboxDouble(); 1601 UnboxDoubleInstr* defn = value()->definition()->AsUnboxDouble();
1595 if ((defn != NULL) && (defn->value()->Type()->ToCid() == kDoubleCid)) { 1602 if ((defn != NULL) && (defn->value()->Type()->ToCid() == kDoubleCid)) {
1596 return defn->value()->definition(); 1603 return defn->value()->definition();
1597 } 1604 }
1598 1605
1599 return this; 1606 return this;
1600 } 1607 }
1601 1608
1602 1609
1603 Definition* UnboxDoubleInstr::Canonicalize(FlowGraph* flow_graph) { 1610 Definition* UnboxDoubleInstr::Canonicalize(FlowGraph* flow_graph) {
1611 if (!HasUses()) return NULL;
1604 // Fold away UnboxDouble(BoxDouble(v)). 1612 // Fold away UnboxDouble(BoxDouble(v)).
1605 BoxDoubleInstr* defn = value()->definition()->AsBoxDouble(); 1613 BoxDoubleInstr* box_defn = value()->definition()->AsBoxDouble();
1606 return (defn != NULL) ? defn->value()->definition() : this; 1614 if (box_defn != NULL) {
1615 return box_defn->value()->definition();
1616 }
1617
1618 ConstantInstr* c = value()->definition()->AsConstant();
1619 if ((c != NULL) && c->value().IsDouble()) {
1620 UnboxedConstantInstr* uc = new UnboxedConstantInstr(c->value());
1621 flow_graph->InsertBefore(this, uc, NULL, Definition::kValue);
1622 return uc;
1623 }
1624
1625 return this;
1607 } 1626 }
1608 1627
1609 1628
1610 Definition* BoxFloat32x4Instr::Canonicalize(FlowGraph* flow_graph) { 1629 Definition* BoxFloat32x4Instr::Canonicalize(FlowGraph* flow_graph) {
1611 if (input_use_list() == NULL) { 1630 if (input_use_list() == NULL) {
1612 // Environments can accomodate any representation. No need to box. 1631 // Environments can accomodate any representation. No need to box.
1613 return value()->definition(); 1632 return value()->definition();
1614 } 1633 }
1615 1634
1616 // Fold away BoxFloat32x4(UnboxFloat32x4(v)). 1635 // Fold away BoxFloat32x4(UnboxFloat32x4(v)).
(...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
3338 case Token::kTRUNCDIV: return 0; 3357 case Token::kTRUNCDIV: return 0;
3339 case Token::kMOD: return 1; 3358 case Token::kMOD: return 1;
3340 default: UNIMPLEMENTED(); return -1; 3359 default: UNIMPLEMENTED(); return -1;
3341 } 3360 }
3342 } 3361 }
3343 3362
3344 3363
3345 #undef __ 3364 #undef __
3346 3365
3347 } // namespace dart 3366 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698