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

Side by Side Diff: src/hydrogen-instructions.h

Issue 23022005: Fix Math.round/floor that had bogus Smi representation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/hydrogen-instructions.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2415 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 return Representation::Double(); 2426 return Representation::Double();
2427 case kMathAbs: 2427 case kMathAbs:
2428 return representation(); 2428 return representation();
2429 default: 2429 default:
2430 UNREACHABLE(); 2430 UNREACHABLE();
2431 return Representation::None(); 2431 return Representation::None();
2432 } 2432 }
2433 } 2433 }
2434 } 2434 }
2435 2435
2436 virtual void UpdateRepresentation(Representation new_rep,
2437 HInferRepresentationPhase* h_infer,
2438 const char* reason) {
2439 if (flexible_int() && !new_rep.IsSmi()) {
2440 new_rep = Representation::Integer32();
2441 }
2442 HValue::UpdateRepresentation(new_rep, h_infer, reason);
2443 }
2444
2445 virtual void RepresentationChanged(Representation new_rep) {
2446 if (flexible_int() && new_rep.IsInteger32()) {
2447 ClearFlag(kFlexibleRepresentation);
2448 }
2449 }
2450
2451 virtual Range* InferRange(Zone* zone); 2436 virtual Range* InferRange(Zone* zone);
2452 2437
2453 virtual HValue* Canonicalize(); 2438 virtual HValue* Canonicalize();
2454 virtual Representation RepresentationFromInputs(); 2439 virtual Representation RepresentationFromInputs();
2455 2440
2456 BuiltinFunctionId op() const { return op_; } 2441 BuiltinFunctionId op() const { return op_; }
2457 const char* OpName() const; 2442 const char* OpName() const;
2458 2443
2459 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation) 2444 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation)
2460 2445
2461 protected: 2446 protected:
2462 virtual bool DataEquals(HValue* other) { 2447 virtual bool DataEquals(HValue* other) {
2463 HUnaryMathOperation* b = HUnaryMathOperation::cast(other); 2448 HUnaryMathOperation* b = HUnaryMathOperation::cast(other);
2464 return op_ == b->op(); 2449 return op_ == b->op();
2465 } 2450 }
2466 2451
2467 private: 2452 private:
2468 bool flexible_int() {
2469 return op_ == kMathFloor || op_ == kMathRound;
2470 }
2471
2472 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) 2453 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op)
2473 : HTemplateInstruction<2>(HType::TaggedNumber()), op_(op) { 2454 : HTemplateInstruction<2>(HType::TaggedNumber()), op_(op) {
2474 SetOperandAt(0, context); 2455 SetOperandAt(0, context);
2475 SetOperandAt(1, value); 2456 SetOperandAt(1, value);
2476 switch (op) { 2457 switch (op) {
2477 case kMathFloor: 2458 case kMathFloor:
2478 case kMathRound: 2459 case kMathRound:
2479 set_representation(Representation::Smi()); 2460 set_representation(Representation::Integer32());
2480 SetFlag(kFlexibleRepresentation);
2481 break; 2461 break;
2482 case kMathAbs: 2462 case kMathAbs:
2483 // Not setting representation here: it is None intentionally. 2463 // Not setting representation here: it is None intentionally.
2484 SetFlag(kFlexibleRepresentation); 2464 SetFlag(kFlexibleRepresentation);
2485 // TODO(svenpanne) This flag is actually only needed if representation() 2465 // TODO(svenpanne) This flag is actually only needed if representation()
2486 // is tagged, and not when it is an unboxed double or unboxed integer. 2466 // is tagged, and not when it is an unboxed double or unboxed integer.
2487 SetGVNFlag(kChangesNewSpacePromotion); 2467 SetGVNFlag(kChangesNewSpacePromotion);
2488 break; 2468 break;
2489 case kMathLog: 2469 case kMathLog:
2490 case kMathSin: 2470 case kMathSin:
(...skipping 4316 matching lines...) Expand 10 before | Expand all | Expand 10 after
6807 virtual bool IsDeletable() const { return true; } 6787 virtual bool IsDeletable() const { return true; }
6808 }; 6788 };
6809 6789
6810 6790
6811 #undef DECLARE_INSTRUCTION 6791 #undef DECLARE_INSTRUCTION
6812 #undef DECLARE_CONCRETE_INSTRUCTION 6792 #undef DECLARE_CONCRETE_INSTRUCTION
6813 6793
6814 } } // namespace v8::internal 6794 } } // namespace v8::internal
6815 6795
6816 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6796 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698