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

Unified Diff: src/hydrogen-instructions.h

Issue 22623007: Fix smi-based math floor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Better field names Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index f977a750d946a6b24d657b08229fc4a238c368b2..a03faca5c85ff989f6c35449e24b41e82b2b5ce3 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -2430,6 +2430,21 @@ class HUnaryMathOperation: public HTemplateInstruction<2> {
}
}
+ virtual void UpdateRepresentation(Representation new_rep,
+ HInferRepresentationPhase* h_infer,
+ const char* reason) {
+ if (flexible_int() && !new_rep.IsSmi()) {
+ new_rep = Representation::Integer32();
+ }
+ HValue::UpdateRepresentation(new_rep, h_infer, reason);
+ }
+
+ virtual void RepresentationChanged(Representation new_rep) {
+ if (flexible_int() && new_rep.IsInteger32()) {
+ ClearFlag(kFlexibleRepresentation);
+ }
+ }
+
virtual Range* InferRange(Zone* zone);
virtual HValue* Canonicalize();
@@ -2447,6 +2462,10 @@ class HUnaryMathOperation: public HTemplateInstruction<2> {
}
private:
+ bool flexible_int() {
+ return op_ == kMathFloor || op_ == kMathRound;
+ }
+
HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op)
: HTemplateInstruction<2>(HType::TaggedNumber()), op_(op) {
SetOperandAt(0, context);
@@ -2454,8 +2473,8 @@ class HUnaryMathOperation: public HTemplateInstruction<2> {
switch (op) {
case kMathFloor:
case kMathRound:
- // TODO(verwaest): Set representation to flexible int starting as smi.
- set_representation(Representation::Integer32());
+ set_representation(Representation::Smi());
+ SetFlag(kFlexibleRepresentation);
break;
case kMathAbs:
// Not setting representation here: it is None intentionally.
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698