| OLD | NEW |
| 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 2412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2423 return Representation::Double(); | 2423 return Representation::Double(); |
| 2424 case kMathAbs: | 2424 case kMathAbs: |
| 2425 return representation(); | 2425 return representation(); |
| 2426 default: | 2426 default: |
| 2427 UNREACHABLE(); | 2427 UNREACHABLE(); |
| 2428 return Representation::None(); | 2428 return Representation::None(); |
| 2429 } | 2429 } |
| 2430 } | 2430 } |
| 2431 } | 2431 } |
| 2432 | 2432 |
| 2433 virtual void UpdateRepresentation(Representation new_rep, |
| 2434 HInferRepresentationPhase* h_infer, |
| 2435 const char* reason) { |
| 2436 if (flexible_int() && !new_rep.IsSmi()) { |
| 2437 new_rep = Representation::Integer32(); |
| 2438 } |
| 2439 HValue::UpdateRepresentation(new_rep, h_infer, reason); |
| 2440 } |
| 2441 |
| 2442 virtual void RepresentationChanged(Representation new_rep) { |
| 2443 if (flexible_int() && new_rep.IsInteger32()) { |
| 2444 ClearFlag(kFlexibleRepresentation); |
| 2445 } |
| 2446 } |
| 2447 |
| 2433 virtual Range* InferRange(Zone* zone); | 2448 virtual Range* InferRange(Zone* zone); |
| 2434 | 2449 |
| 2435 virtual HValue* Canonicalize(); | 2450 virtual HValue* Canonicalize(); |
| 2436 virtual Representation RepresentationFromInputs(); | 2451 virtual Representation RepresentationFromInputs(); |
| 2437 | 2452 |
| 2438 BuiltinFunctionId op() const { return op_; } | 2453 BuiltinFunctionId op() const { return op_; } |
| 2439 const char* OpName() const; | 2454 const char* OpName() const; |
| 2440 | 2455 |
| 2441 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation) | 2456 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation) |
| 2442 | 2457 |
| 2443 protected: | 2458 protected: |
| 2444 virtual bool DataEquals(HValue* other) { | 2459 virtual bool DataEquals(HValue* other) { |
| 2445 HUnaryMathOperation* b = HUnaryMathOperation::cast(other); | 2460 HUnaryMathOperation* b = HUnaryMathOperation::cast(other); |
| 2446 return op_ == b->op(); | 2461 return op_ == b->op(); |
| 2447 } | 2462 } |
| 2448 | 2463 |
| 2449 private: | 2464 private: |
| 2465 bool flexible_int() { |
| 2466 return op_ == kMathFloor || op_ == kMathRound; |
| 2467 } |
| 2468 |
| 2450 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) | 2469 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) |
| 2451 : HTemplateInstruction<2>(HType::TaggedNumber()), op_(op) { | 2470 : HTemplateInstruction<2>(HType::TaggedNumber()), op_(op) { |
| 2452 SetOperandAt(0, context); | 2471 SetOperandAt(0, context); |
| 2453 SetOperandAt(1, value); | 2472 SetOperandAt(1, value); |
| 2454 switch (op) { | 2473 switch (op) { |
| 2455 case kMathFloor: | 2474 case kMathFloor: |
| 2456 case kMathRound: | 2475 case kMathRound: |
| 2457 // TODO(verwaest): Set representation to flexible int starting as smi. | 2476 set_representation(Representation::Smi()); |
| 2458 set_representation(Representation::Integer32()); | 2477 SetFlag(kFlexibleRepresentation); |
| 2459 break; | 2478 break; |
| 2460 case kMathAbs: | 2479 case kMathAbs: |
| 2461 // Not setting representation here: it is None intentionally. | 2480 // Not setting representation here: it is None intentionally. |
| 2462 SetFlag(kFlexibleRepresentation); | 2481 SetFlag(kFlexibleRepresentation); |
| 2463 // TODO(svenpanne) This flag is actually only needed if representation() | 2482 // TODO(svenpanne) This flag is actually only needed if representation() |
| 2464 // is tagged, and not when it is an unboxed double or unboxed integer. | 2483 // is tagged, and not when it is an unboxed double or unboxed integer. |
| 2465 SetGVNFlag(kChangesNewSpacePromotion); | 2484 SetGVNFlag(kChangesNewSpacePromotion); |
| 2466 break; | 2485 break; |
| 2467 case kMathLog: | 2486 case kMathLog: |
| 2468 case kMathSin: | 2487 case kMathSin: |
| (...skipping 4309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6778 virtual bool IsDeletable() const { return true; } | 6797 virtual bool IsDeletable() const { return true; } |
| 6779 }; | 6798 }; |
| 6780 | 6799 |
| 6781 | 6800 |
| 6782 #undef DECLARE_INSTRUCTION | 6801 #undef DECLARE_INSTRUCTION |
| 6783 #undef DECLARE_CONCRETE_INSTRUCTION | 6802 #undef DECLARE_CONCRETE_INSTRUCTION |
| 6784 | 6803 |
| 6785 } } // namespace v8::internal | 6804 } } // namespace v8::internal |
| 6786 | 6805 |
| 6787 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6806 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |