Chromium Code Reviews| 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 3209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3220 virtual HType CalculateInferredType(); | 3220 virtual HType CalculateInferredType(); |
| 3221 bool IsInteger() { return handle()->IsSmi(); } | 3221 bool IsInteger() { return handle()->IsSmi(); } |
| 3222 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; | 3222 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; |
| 3223 HConstant* CopyToTruncatedInt32(Zone* zone) const; | 3223 HConstant* CopyToTruncatedInt32(Zone* zone) const; |
| 3224 bool HasInteger32Value() const { return has_int32_value_; } | 3224 bool HasInteger32Value() const { return has_int32_value_; } |
| 3225 int32_t Integer32Value() const { | 3225 int32_t Integer32Value() const { |
| 3226 ASSERT(HasInteger32Value()); | 3226 ASSERT(HasInteger32Value()); |
| 3227 return int32_value_; | 3227 return int32_value_; |
| 3228 } | 3228 } |
| 3229 bool HasSmiValue() const { | 3229 bool HasSmiValue() const { |
| 3230 return HasInteger32Value() && Smi::IsValid(Integer32Value()); | 3230 return has_smi_value_; |
| 3231 } | 3231 } |
| 3232 bool HasDoubleValue() const { return has_double_value_; } | 3232 bool HasDoubleValue() const { return has_double_value_; } |
| 3233 double DoubleValue() const { | 3233 double DoubleValue() const { |
| 3234 ASSERT(HasDoubleValue()); | 3234 ASSERT(HasDoubleValue()); |
| 3235 return double_value_; | 3235 return double_value_; |
| 3236 } | 3236 } |
| 3237 bool IsTheHole() const { | 3237 bool IsTheHole() const { |
| 3238 if (HasDoubleValue() && FixedDoubleArray::is_the_hole_nan(double_value_)) { | 3238 if (HasDoubleValue() && FixedDoubleArray::is_the_hole_nan(double_value_)) { |
| 3239 return true; | 3239 return true; |
| 3240 } | 3240 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3320 // constant is non-numeric, handle_ always points to a valid | 3320 // constant is non-numeric, handle_ always points to a valid |
| 3321 // constant HeapObject. | 3321 // constant HeapObject. |
| 3322 Handle<Object> handle_; | 3322 Handle<Object> handle_; |
| 3323 UniqueValueId unique_id_; | 3323 UniqueValueId unique_id_; |
| 3324 | 3324 |
| 3325 // We store the HConstant in the most specific form safely possible. | 3325 // We store the HConstant in the most specific form safely possible. |
| 3326 // The two flags, has_int32_value_ and has_double_value_ tell us if | 3326 // The two flags, has_int32_value_ and has_double_value_ tell us if |
| 3327 // int32_value_ and double_value_ hold valid, safe representations | 3327 // int32_value_ and double_value_ hold valid, safe representations |
| 3328 // of the constant. has_int32_value_ implies has_double_value_ but | 3328 // of the constant. has_int32_value_ implies has_double_value_ but |
| 3329 // not the converse. | 3329 // not the converse. |
| 3330 bool has_smi_value_ : 1; | |
| 3330 bool has_int32_value_ : 1; | 3331 bool has_int32_value_ : 1; |
| 3331 bool has_double_value_ : 1; | 3332 bool has_double_value_ : 1; |
| 3332 bool is_internalized_string_ : 1; // TODO(yangguo): make this part of HType. | 3333 bool is_internalized_string_ : 1; // TODO(yangguo): make this part of HType. |
| 3333 bool is_not_in_new_space_ : 1; | 3334 bool is_not_in_new_space_ : 1; |
| 3334 bool boolean_value_ : 1; | 3335 bool boolean_value_ : 1; |
| 3335 int32_t int32_value_; | 3336 int32_t int32_value_; |
| 3336 double double_value_; | 3337 double double_value_; |
| 3337 HType type_from_value_; | 3338 HType type_from_value_; |
| 3338 }; | 3339 }; |
| 3339 | 3340 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3388 | 3389 |
| 3389 virtual Representation observed_input_representation(int index) { | 3390 virtual Representation observed_input_representation(int index) { |
| 3390 if (index == 0) return Representation::Tagged(); | 3391 if (index == 0) return Representation::Tagged(); |
| 3391 return observed_input_representation_[index - 1]; | 3392 return observed_input_representation_[index - 1]; |
| 3392 } | 3393 } |
| 3393 | 3394 |
| 3394 virtual void InferRepresentation(HInferRepresentation* h_infer); | 3395 virtual void InferRepresentation(HInferRepresentation* h_infer); |
| 3395 virtual Representation RepresentationFromInputs(); | 3396 virtual Representation RepresentationFromInputs(); |
| 3396 virtual void AssumeRepresentation(Representation r); | 3397 virtual void AssumeRepresentation(Representation r); |
| 3397 | 3398 |
| 3399 virtual void UpdateRepresentation(Representation new_rep, | |
| 3400 HInferRepresentation* h_infer, | |
| 3401 const char* reason) { | |
| 3402 // By default, binary instructions don't handle Smis. | |
|
Jakob Kummerow
2013/05/27 07:15:44
nit: s/instructions/operations/ for consistency in
| |
| 3403 if (new_rep.IsSmi()) { | |
| 3404 new_rep = Representation::Integer32(); | |
| 3405 } | |
| 3406 HValue::UpdateRepresentation(new_rep, h_infer, reason); | |
| 3407 } | |
| 3408 | |
| 3398 virtual bool IsCommutative() const { return false; } | 3409 virtual bool IsCommutative() const { return false; } |
| 3399 | 3410 |
| 3400 virtual void PrintDataTo(StringStream* stream); | 3411 virtual void PrintDataTo(StringStream* stream); |
| 3401 | 3412 |
| 3402 DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation) | 3413 DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation) |
| 3403 | 3414 |
| 3404 private: | 3415 private: |
| 3405 bool IgnoreObservedOutputRepresentation(Representation current_rep); | 3416 bool IgnoreObservedOutputRepresentation(Representation current_rep); |
| 3406 | 3417 |
| 3407 Representation observed_input_representation_[2]; | 3418 Representation observed_input_representation_[2]; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3550 | 3561 |
| 3551 class HBoundsCheck: public HTemplateInstruction<2> { | 3562 class HBoundsCheck: public HTemplateInstruction<2> { |
| 3552 public: | 3563 public: |
| 3553 // Normally HBoundsCheck should be created using the | 3564 // Normally HBoundsCheck should be created using the |
| 3554 // HGraphBuilder::AddBoundsCheck() helper. | 3565 // HGraphBuilder::AddBoundsCheck() helper. |
| 3555 // However when building stubs, where we know that the arguments are Int32, | 3566 // However when building stubs, where we know that the arguments are Int32, |
| 3556 // it makes sense to invoke this constructor directly. | 3567 // it makes sense to invoke this constructor directly. |
| 3557 HBoundsCheck(HValue* index, | 3568 HBoundsCheck(HValue* index, |
| 3558 HValue* length, | 3569 HValue* length, |
| 3559 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, | 3570 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, |
| 3560 Representation r = Representation::None()) | 3571 Representation r = Representation::None()) |
|
Jakob Kummerow
2013/05/27 07:15:44
Since you're not using r any more, you can remove
| |
| 3561 : key_mode_(key_mode), skip_check_(false), | 3572 : key_mode_(key_mode), skip_check_(false), |
| 3562 base_(NULL), offset_(0), scale_(0), | 3573 base_(NULL), offset_(0), scale_(0), |
| 3563 responsibility_direction_(DIRECTION_NONE) { | 3574 responsibility_direction_(DIRECTION_NONE) { |
| 3564 SetOperandAt(0, index); | 3575 SetOperandAt(0, index); |
| 3565 SetOperandAt(1, length); | 3576 SetOperandAt(1, length); |
| 3566 if (r.IsNone()) { | 3577 SetFlag(kFlexibleRepresentation); |
| 3567 // In the normal compilation pipeline the representation is flexible | |
| 3568 // (see InferRepresentation). | |
| 3569 SetFlag(kFlexibleRepresentation); | |
| 3570 } else { | |
| 3571 // When compiling stubs we want to set the representation explicitly | |
| 3572 // so the compilation pipeline can skip the HInferRepresentation phase. | |
| 3573 set_representation(r); | |
| 3574 } | |
| 3575 SetFlag(kUseGVN); | 3578 SetFlag(kUseGVN); |
| 3576 } | 3579 } |
| 3577 | 3580 |
| 3578 bool skip_check() { return skip_check_; } | 3581 bool skip_check() { return skip_check_; } |
| 3579 void set_skip_check(bool skip_check) { skip_check_ = skip_check; } | 3582 void set_skip_check(bool skip_check) { skip_check_ = skip_check; } |
| 3580 HValue* base() { return base_; } | 3583 HValue* base() { return base_; } |
| 3581 int offset() { return offset_; } | 3584 int offset() { return offset_; } |
| 3582 int scale() { return scale_; } | 3585 int scale() { return scale_; } |
| 3583 bool index_can_increase() { | 3586 bool index_can_increase() { |
| 3584 return (responsibility_direction_ & DIRECTION_LOWER) == 0; | 3587 return (responsibility_direction_ & DIRECTION_LOWER) == 0; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3711 } else { | 3714 } else { |
| 3712 SetAllSideEffects(); | 3715 SetAllSideEffects(); |
| 3713 ClearFlag(kUseGVN); | 3716 ClearFlag(kUseGVN); |
| 3714 } | 3717 } |
| 3715 } | 3718 } |
| 3716 | 3719 |
| 3717 virtual void UpdateRepresentation(Representation new_rep, | 3720 virtual void UpdateRepresentation(Representation new_rep, |
| 3718 HInferRepresentation* h_infer, | 3721 HInferRepresentation* h_infer, |
| 3719 const char* reason) { | 3722 const char* reason) { |
| 3720 // We only generate either int32 or generic tagged bitwise operations. | 3723 // We only generate either int32 or generic tagged bitwise operations. |
| 3721 if (new_rep.IsDouble()) new_rep = Representation::Integer32(); | 3724 if (new_rep.IsSmi() || new_rep.IsDouble()) { |
| 3725 new_rep = Representation::Integer32(); | |
| 3726 } | |
| 3722 HValue::UpdateRepresentation(new_rep, h_infer, reason); | 3727 HValue::UpdateRepresentation(new_rep, h_infer, reason); |
| 3723 } | 3728 } |
| 3724 | 3729 |
| 3725 virtual void initialize_output_representation(Representation observed) { | 3730 virtual void initialize_output_representation(Representation observed) { |
| 3726 if (observed.IsDouble()) observed = Representation::Integer32(); | 3731 if (observed.IsDouble()) observed = Representation::Integer32(); |
| 3727 HBinaryOperation::initialize_output_representation(observed); | 3732 HBinaryOperation::initialize_output_representation(observed); |
| 3728 } | 3733 } |
| 3729 | 3734 |
| 3730 virtual HType CalculateInferredType(); | 3735 virtual HType CalculateInferredType(); |
| 3731 | 3736 |
| (...skipping 2786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6518 virtual bool IsDeletable() const { return true; } | 6523 virtual bool IsDeletable() const { return true; } |
| 6519 }; | 6524 }; |
| 6520 | 6525 |
| 6521 | 6526 |
| 6522 #undef DECLARE_INSTRUCTION | 6527 #undef DECLARE_INSTRUCTION |
| 6523 #undef DECLARE_CONCRETE_INSTRUCTION | 6528 #undef DECLARE_CONCRETE_INSTRUCTION |
| 6524 | 6529 |
| 6525 } } // namespace v8::internal | 6530 } } // namespace v8::internal |
| 6526 | 6531 |
| 6527 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6532 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |