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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 | 345 |
| 346 private: | 346 private: |
| 347 Address raw_address_; | 347 Address raw_address_; |
| 348 }; | 348 }; |
| 349 | 349 |
| 350 | 350 |
| 351 class HType { | 351 class HType { |
| 352 public: | 352 public: |
| 353 HType() : type_(kUninitialized) { } | 353 HType() : type_(kUninitialized) { } |
| 354 | 354 |
| 355 static HType None() { return HType(kNone); } | |
| 355 static HType Tagged() { return HType(kTagged); } | 356 static HType Tagged() { return HType(kTagged); } |
| 356 static HType TaggedPrimitive() { return HType(kTaggedPrimitive); } | 357 static HType TaggedPrimitive() { return HType(kTaggedPrimitive); } |
| 357 static HType TaggedNumber() { return HType(kTaggedNumber); } | 358 static HType TaggedNumber() { return HType(kTaggedNumber); } |
| 358 static HType Smi() { return HType(kSmi); } | 359 static HType Smi() { return HType(kSmi); } |
| 359 static HType HeapNumber() { return HType(kHeapNumber); } | 360 static HType HeapNumber() { return HType(kHeapNumber); } |
| 360 static HType String() { return HType(kString); } | 361 static HType String() { return HType(kString); } |
| 361 static HType Boolean() { return HType(kBoolean); } | 362 static HType Boolean() { return HType(kBoolean); } |
| 362 static HType NonPrimitive() { return HType(kNonPrimitive); } | 363 static HType NonPrimitive() { return HType(kNonPrimitive); } |
| 363 static HType JSArray() { return HType(kJSArray); } | 364 static HType JSArray() { return HType(kJSArray); } |
| 364 static HType JSObject() { return HType(kJSObject); } | 365 static HType JSObject() { return HType(kJSObject); } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 ASSERT(type_ != kUninitialized); | 441 ASSERT(type_ != kUninitialized); |
| 441 return IsHeapNumber() || IsString() || IsBoolean() || IsNonPrimitive(); | 442 return IsHeapNumber() || IsString() || IsBoolean() || IsNonPrimitive(); |
| 442 } | 443 } |
| 443 | 444 |
| 444 static HType TypeFromValue(Handle<Object> value); | 445 static HType TypeFromValue(Handle<Object> value); |
| 445 | 446 |
| 446 const char* ToString(); | 447 const char* ToString(); |
| 447 | 448 |
| 448 private: | 449 private: |
| 449 enum Type { | 450 enum Type { |
| 451 kNone = 0x0, // 0000 0000 0000 0000 | |
| 450 kTagged = 0x1, // 0000 0000 0000 0001 | 452 kTagged = 0x1, // 0000 0000 0000 0001 |
| 451 kTaggedPrimitive = 0x5, // 0000 0000 0000 0101 | 453 kTaggedPrimitive = 0x5, // 0000 0000 0000 0101 |
| 452 kTaggedNumber = 0xd, // 0000 0000 0000 1101 | 454 kTaggedNumber = 0xd, // 0000 0000 0000 1101 |
| 453 kSmi = 0x1d, // 0000 0000 0001 1101 | 455 kSmi = 0x1d, // 0000 0000 0001 1101 |
| 454 kHeapNumber = 0x2d, // 0000 0000 0010 1101 | 456 kHeapNumber = 0x2d, // 0000 0000 0010 1101 |
| 455 kString = 0x45, // 0000 0000 0100 0101 | 457 kString = 0x45, // 0000 0000 0100 0101 |
| 456 kBoolean = 0x85, // 0000 0000 1000 0101 | 458 kBoolean = 0x85, // 0000 0000 1000 0101 |
| 457 kNonPrimitive = 0x101, // 0000 0001 0000 0001 | 459 kNonPrimitive = 0x101, // 0000 0001 0000 0001 |
| 458 kJSObject = 0x301, // 0000 0011 0000 0001 | 460 kJSObject = 0x301, // 0000 0011 0000 0001 |
| 459 kJSArray = 0x701, // 0000 0111 0000 0001 | 461 kJSArray = 0x701, // 0000 0111 0000 0001 |
| (...skipping 2997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3457 bool is_not_in_new_space = true, | 3459 bool is_not_in_new_space = true, |
| 3458 Handle<Object> optional_handle = Handle<Object>::null()); | 3460 Handle<Object> optional_handle = Handle<Object>::null()); |
| 3459 HConstant(Handle<Object> handle, | 3461 HConstant(Handle<Object> handle, |
| 3460 UniqueValueId unique_id, | 3462 UniqueValueId unique_id, |
| 3461 Representation r, | 3463 Representation r, |
| 3462 HType type, | 3464 HType type, |
| 3463 bool is_internalized_string, | 3465 bool is_internalized_string, |
| 3464 bool is_not_in_new_space, | 3466 bool is_not_in_new_space, |
| 3465 bool is_cell, | 3467 bool is_cell, |
| 3466 bool boolean_value); | 3468 bool boolean_value); |
| 3469 HConstant(ExternalReference reference, | |
| 3470 Representation r = Representation::External()); | |
| 3467 | 3471 |
| 3468 Handle<Object> handle() { | 3472 Handle<Object> handle() { |
| 3469 if (handle_.is_null()) { | 3473 if (handle_.is_null()) { |
| 3470 Factory* factory = Isolate::Current()->factory(); | 3474 Factory* factory = Isolate::Current()->factory(); |
| 3471 // Default arguments to is_not_in_new_space depend on this heap number | 3475 // Default arguments to is_not_in_new_space depend on this heap number |
| 3472 // to be tenured so that it's guaranteed not be be located in new space. | 3476 // to be tenured so that it's guaranteed not be be located in new space. |
| 3473 handle_ = factory->NewNumber(double_value_, TENURED); | 3477 handle_ = factory->NewNumber(double_value_, TENURED); |
| 3474 } | 3478 } |
| 3475 AllowDeferredHandleDereference smi_check; | 3479 AllowDeferredHandleDereference smi_check; |
| 3476 ASSERT(has_int32_value_ || !handle_->IsSmi()); | 3480 ASSERT(has_int32_value_ || !handle_->IsSmi()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3521 } | 3525 } |
| 3522 | 3526 |
| 3523 virtual Representation RequiredInputRepresentation(int index) { | 3527 virtual Representation RequiredInputRepresentation(int index) { |
| 3524 return Representation::None(); | 3528 return Representation::None(); |
| 3525 } | 3529 } |
| 3526 | 3530 |
| 3527 virtual Representation KnownOptimalRepresentation() { | 3531 virtual Representation KnownOptimalRepresentation() { |
| 3528 if (HasSmiValue()) return Representation::Smi(); | 3532 if (HasSmiValue()) return Representation::Smi(); |
| 3529 if (HasInteger32Value()) return Representation::Integer32(); | 3533 if (HasInteger32Value()) return Representation::Integer32(); |
| 3530 if (HasNumberValue()) return Representation::Double(); | 3534 if (HasNumberValue()) return Representation::Double(); |
| 3535 if (HasExternalValue()) return Representation::External(); | |
| 3531 return Representation::Tagged(); | 3536 return Representation::Tagged(); |
| 3532 } | 3537 } |
| 3533 | 3538 |
| 3534 virtual bool EmitAtUses(); | 3539 virtual bool EmitAtUses(); |
| 3535 virtual void PrintDataTo(StringStream* stream); | 3540 virtual void PrintDataTo(StringStream* stream); |
| 3536 virtual HType CalculateInferredType(); | 3541 virtual HType CalculateInferredType(); |
| 3537 bool IsInteger() { return handle()->IsSmi(); } | 3542 bool IsInteger() { return handle()->IsSmi(); } |
| 3538 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; | 3543 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; |
| 3539 Maybe<HConstant*> CopyToTruncatedInt32(Zone* zone); | 3544 Maybe<HConstant*> CopyToTruncatedInt32(Zone* zone); |
| 3540 Maybe<HConstant*> CopyToTruncatedNumber(Zone* zone); | 3545 Maybe<HConstant*> CopyToTruncatedNumber(Zone* zone); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3572 ASSERT(!handle_.is_null()); | 3577 ASSERT(!handle_.is_null()); |
| 3573 return type_from_value_.IsString(); | 3578 return type_from_value_.IsString(); |
| 3574 } | 3579 } |
| 3575 Handle<String> StringValue() const { | 3580 Handle<String> StringValue() const { |
| 3576 ASSERT(HasStringValue()); | 3581 ASSERT(HasStringValue()); |
| 3577 return Handle<String>::cast(handle_); | 3582 return Handle<String>::cast(handle_); |
| 3578 } | 3583 } |
| 3579 bool HasInternalizedStringValue() const { | 3584 bool HasInternalizedStringValue() const { |
| 3580 return HasStringValue() && is_internalized_string_; | 3585 return HasStringValue() && is_internalized_string_; |
| 3581 } | 3586 } |
| 3587 bool HasExternalValue() const { return has_external_value_; } | |
| 3588 ExternalReference ExternalValue() const { return external_value_; } | |
| 3582 | 3589 |
| 3583 bool BooleanValue() const { return boolean_value_; } | 3590 bool BooleanValue() const { return boolean_value_; } |
| 3584 | 3591 |
| 3585 virtual intptr_t Hashcode() { | 3592 virtual intptr_t Hashcode() { |
| 3586 if (has_int32_value_) { | 3593 if (has_int32_value_) { |
| 3587 return static_cast<intptr_t>(int32_value_); | 3594 return static_cast<intptr_t>(int32_value_); |
| 3588 } else if (has_double_value_) { | 3595 } else if (has_double_value_) { |
| 3589 return static_cast<intptr_t>(BitCast<int64_t>(double_value_)); | 3596 return static_cast<intptr_t>(BitCast<int64_t>(double_value_)); |
| 3597 } else if (has_external_value_) { | |
| 3598 return reinterpret_cast<intptr_t>(external_value_.address()); | |
| 3590 } else { | 3599 } else { |
| 3591 ASSERT(!handle_.is_null()); | 3600 ASSERT(!handle_.is_null()); |
| 3592 return unique_id_.Hashcode(); | 3601 return unique_id_.Hashcode(); |
| 3593 } | 3602 } |
| 3594 } | 3603 } |
| 3595 | 3604 |
| 3596 virtual void FinalizeUniqueValueId() { | 3605 virtual void FinalizeUniqueValueId() { |
| 3597 if (!has_double_value_) { | 3606 if (!has_double_value_ && !has_external_value_) { |
| 3598 ASSERT(!handle_.is_null()); | 3607 ASSERT(!handle_.is_null()); |
| 3599 unique_id_ = UniqueValueId(handle_); | 3608 unique_id_ = UniqueValueId(handle_); |
| 3600 } | 3609 } |
| 3601 } | 3610 } |
| 3602 | 3611 |
| 3603 bool UniqueValueIdsMatch(UniqueValueId other) { | 3612 bool UniqueValueIdsMatch(UniqueValueId other) { |
| 3604 return !has_double_value_ && unique_id_ == other; | 3613 return !has_double_value_ && !has_external_value_ && unique_id_ == other; |
| 3605 } | 3614 } |
| 3606 | 3615 |
| 3607 #ifdef DEBUG | 3616 #ifdef DEBUG |
| 3608 virtual void Verify() { } | 3617 virtual void Verify() { } |
| 3609 #endif | 3618 #endif |
| 3610 | 3619 |
| 3611 DECLARE_CONCRETE_INSTRUCTION(Constant) | 3620 DECLARE_CONCRETE_INSTRUCTION(Constant) |
| 3612 | 3621 |
| 3613 protected: | 3622 protected: |
| 3614 virtual Range* InferRange(Zone* zone); | 3623 virtual Range* InferRange(Zone* zone); |
| 3615 | 3624 |
| 3616 virtual bool DataEquals(HValue* other) { | 3625 virtual bool DataEquals(HValue* other) { |
| 3617 HConstant* other_constant = HConstant::cast(other); | 3626 HConstant* other_constant = HConstant::cast(other); |
| 3618 if (has_int32_value_) { | 3627 if (has_int32_value_) { |
| 3619 return other_constant->has_int32_value_ && | 3628 return other_constant->has_int32_value_ && |
| 3620 int32_value_ == other_constant->int32_value_; | 3629 int32_value_ == other_constant->int32_value_; |
| 3621 } else if (has_double_value_) { | 3630 } else if (has_double_value_) { |
| 3622 return other_constant->has_double_value_ && | 3631 return other_constant->has_double_value_ && |
| 3623 BitCast<int64_t>(double_value_) == | 3632 BitCast<int64_t>(double_value_) == |
| 3624 BitCast<int64_t>(other_constant->double_value_); | 3633 BitCast<int64_t>(other_constant->double_value_); |
| 3634 } else if (has_external_value_) { | |
| 3635 return other_constant->has_external_value_ && | |
| 3636 external_value_ == other_constant->external_value_; | |
| 3625 } else { | 3637 } else { |
| 3626 ASSERT(!handle_.is_null()); | 3638 ASSERT(!handle_.is_null()); |
| 3627 return !other_constant->handle_.is_null() && | 3639 return !other_constant->handle_.is_null() && |
| 3628 unique_id_ == other_constant->unique_id_; | 3640 unique_id_ == other_constant->unique_id_; |
| 3629 } | 3641 } |
| 3630 } | 3642 } |
| 3631 | 3643 |
| 3632 private: | 3644 private: |
| 3633 void Initialize(Representation r); | 3645 void Initialize(Representation r); |
| 3634 | 3646 |
| 3635 virtual bool IsDeletable() const { return true; } | 3647 virtual bool IsDeletable() const { return true; } |
| 3636 | 3648 |
| 3637 // If this is a numerical constant, handle_ either points to to the | 3649 // If this is a numerical constant, handle_ either points to to the |
| 3638 // HeapObject the constant originated from or is null. If the | 3650 // HeapObject the constant originated from or is null. If the |
| 3639 // constant is non-numeric, handle_ always points to a valid | 3651 // constant is non-numeric, handle_ always points to a valid |
| 3640 // constant HeapObject. | 3652 // constant HeapObject. |
| 3641 Handle<Object> handle_; | 3653 Handle<Object> handle_; |
| 3642 UniqueValueId unique_id_; | 3654 UniqueValueId unique_id_; |
| 3643 | 3655 |
| 3644 // We store the HConstant in the most specific form safely possible. | 3656 // We store the HConstant in the most specific form safely possible. |
| 3645 // The two flags, has_int32_value_ and has_double_value_ tell us if | 3657 // The two flags, has_int32_value_ and has_double_value_ tell us if |
| 3646 // int32_value_ and double_value_ hold valid, safe representations | 3658 // int32_value_ and double_value_ hold valid, safe representations |
| 3647 // of the constant. has_int32_value_ implies has_double_value_ but | 3659 // of the constant. has_int32_value_ implies has_double_value_ but |
| 3648 // not the converse. | 3660 // not the converse. |
| 3649 bool has_smi_value_ : 1; | 3661 bool has_smi_value_ : 1; |
| 3650 bool has_int32_value_ : 1; | 3662 bool has_int32_value_ : 1; |
| 3651 bool has_double_value_ : 1; | 3663 bool has_double_value_ : 1; |
| 3664 bool has_external_value_ : 1; | |
| 3652 bool is_internalized_string_ : 1; // TODO(yangguo): make this part of HType. | 3665 bool is_internalized_string_ : 1; // TODO(yangguo): make this part of HType. |
| 3653 bool is_not_in_new_space_ : 1; | 3666 bool is_not_in_new_space_ : 1; |
| 3654 bool is_cell_ : 1; | 3667 bool is_cell_ : 1; |
| 3655 bool boolean_value_ : 1; | 3668 bool boolean_value_ : 1; |
| 3656 int32_t int32_value_; | 3669 int32_t int32_value_; |
| 3657 double double_value_; | 3670 double double_value_; |
| 3671 ExternalReference external_value_; | |
| 3658 HType type_from_value_; | 3672 HType type_from_value_; |
| 3659 }; | 3673 }; |
| 3660 | 3674 |
| 3661 | 3675 |
| 3662 class HBinaryOperation: public HTemplateInstruction<3> { | 3676 class HBinaryOperation: public HTemplateInstruction<3> { |
| 3663 public: | 3677 public: |
| 3664 HBinaryOperation(HValue* context, HValue* left, HValue* right) | 3678 HBinaryOperation(HValue* context, HValue* left, HValue* right) |
| 3665 : observed_output_representation_(Representation::None()) { | 3679 : observed_output_representation_(Representation::None()) { |
| 3666 ASSERT(left != NULL && right != NULL); | 3680 ASSERT(left != NULL && right != NULL); |
| 3667 SetOperandAt(0, context); | 3681 SetOperandAt(0, context); |
| (...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5546 } | 5560 } |
| 5547 | 5561 |
| 5548 static HObjectAccess ForCellValue() { | 5562 static HObjectAccess ForCellValue() { |
| 5549 return HObjectAccess(kInobject, Cell::kValueOffset); | 5563 return HObjectAccess(kInobject, Cell::kValueOffset); |
| 5550 } | 5564 } |
| 5551 | 5565 |
| 5552 static HObjectAccess ForAllocationMementoSite() { | 5566 static HObjectAccess ForAllocationMementoSite() { |
| 5553 return HObjectAccess(kInobject, AllocationMemento::kAllocationSiteOffset); | 5567 return HObjectAccess(kInobject, AllocationMemento::kAllocationSiteOffset); |
| 5554 } | 5568 } |
| 5555 | 5569 |
| 5570 static HObjectAccess ForInteger32() { | |
|
titzer
2013/07/25 11:56:47
Would prefer this to be ForExternalReference() or
danno
2013/07/25 12:05:08
You need to change the kDependsOn/ChangesSpecializ
| |
| 5571 return HObjectAccess(kInobject, 0, Representation::Integer32()); | |
| 5572 } | |
| 5573 | |
| 5556 // Create an access to an offset in a fixed array header. | 5574 // Create an access to an offset in a fixed array header. |
| 5557 static HObjectAccess ForFixedArrayHeader(int offset); | 5575 static HObjectAccess ForFixedArrayHeader(int offset); |
| 5558 | 5576 |
| 5559 // Create an access to an in-object property in a JSObject. | 5577 // Create an access to an in-object property in a JSObject. |
| 5560 static HObjectAccess ForJSObjectOffset(int offset, | 5578 static HObjectAccess ForJSObjectOffset(int offset, |
| 5561 Representation representation = Representation::Tagged()); | 5579 Representation representation = Representation::Tagged()); |
| 5562 | 5580 |
| 5563 // Create an access to an in-object property in a JSArray. | 5581 // Create an access to an in-object property in a JSArray. |
| 5564 static HObjectAccess ForJSArrayOffset(int offset); | 5582 static HObjectAccess ForJSArrayOffset(int offset); |
| 5565 | 5583 |
| (...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6873 virtual bool IsDeletable() const { return true; } | 6891 virtual bool IsDeletable() const { return true; } |
| 6874 }; | 6892 }; |
| 6875 | 6893 |
| 6876 | 6894 |
| 6877 #undef DECLARE_INSTRUCTION | 6895 #undef DECLARE_INSTRUCTION |
| 6878 #undef DECLARE_CONCRETE_INSTRUCTION | 6896 #undef DECLARE_CONCRETE_INSTRUCTION |
| 6879 | 6897 |
| 6880 } } // namespace v8::internal | 6898 } } // namespace v8::internal |
| 6881 | 6899 |
| 6882 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6900 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |