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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 Verify(); | 441 Verify(); |
442 #endif | 442 #endif |
443 return may_overflow; | 443 return may_overflow; |
444 } | 444 } |
445 | 445 |
446 | 446 |
447 const char* HType::ToString() { | 447 const char* HType::ToString() { |
448 // Note: The c1visualizer syntax for locals allows only a sequence of the | 448 // Note: The c1visualizer syntax for locals allows only a sequence of the |
449 // following characters: A-Za-z0-9_-|: | 449 // following characters: A-Za-z0-9_-|: |
450 switch (type_) { | 450 switch (type_) { |
| 451 case kNone: return "none"; |
451 case kTagged: return "tagged"; | 452 case kTagged: return "tagged"; |
452 case kTaggedPrimitive: return "primitive"; | 453 case kTaggedPrimitive: return "primitive"; |
453 case kTaggedNumber: return "number"; | 454 case kTaggedNumber: return "number"; |
454 case kSmi: return "smi"; | 455 case kSmi: return "smi"; |
455 case kHeapNumber: return "heap-number"; | 456 case kHeapNumber: return "heap-number"; |
456 case kString: return "string"; | 457 case kString: return "string"; |
457 case kBoolean: return "boolean"; | 458 case kBoolean: return "boolean"; |
458 case kNonPrimitive: return "non-primitive"; | 459 case kNonPrimitive: return "non-primitive"; |
459 case kJSArray: return "array"; | 460 case kJSArray: return "array"; |
460 case kJSObject: return "object"; | 461 case kJSObject: return "object"; |
(...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2637 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); | 2638 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); |
2638 } | 2639 } |
2639 | 2640 |
2640 | 2641 |
2641 HConstant::HConstant(Handle<Object> handle, Representation r) | 2642 HConstant::HConstant(Handle<Object> handle, Representation r) |
2642 : handle_(handle), | 2643 : handle_(handle), |
2643 unique_id_(), | 2644 unique_id_(), |
2644 has_smi_value_(false), | 2645 has_smi_value_(false), |
2645 has_int32_value_(false), | 2646 has_int32_value_(false), |
2646 has_double_value_(false), | 2647 has_double_value_(false), |
| 2648 has_external_reference_value_(false), |
2647 is_internalized_string_(false), | 2649 is_internalized_string_(false), |
2648 is_not_in_new_space_(true), | 2650 is_not_in_new_space_(true), |
2649 is_cell_(false), | 2651 is_cell_(false), |
2650 boolean_value_(handle->BooleanValue()) { | 2652 boolean_value_(handle->BooleanValue()) { |
2651 set_type(HType::TypeFromValue(handle)); | 2653 set_type(HType::TypeFromValue(handle)); |
2652 | 2654 |
2653 if (handle_->IsHeapObject()) { | 2655 if (handle_->IsHeapObject()) { |
2654 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); | 2656 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); |
2655 is_not_in_new_space_ = !heap->InNewSpace(*handle); | 2657 is_not_in_new_space_ = !heap->InNewSpace(*handle); |
2656 } | 2658 } |
(...skipping 15 matching lines...) Expand all Loading... |
2672 | 2674 |
2673 | 2675 |
2674 HConstant::HConstant(Handle<Object> handle, | 2676 HConstant::HConstant(Handle<Object> handle, |
2675 UniqueValueId unique_id, | 2677 UniqueValueId unique_id, |
2676 Representation r, | 2678 Representation r, |
2677 HType type, | 2679 HType type, |
2678 bool is_internalize_string, | 2680 bool is_internalize_string, |
2679 bool is_not_in_new_space, | 2681 bool is_not_in_new_space, |
2680 bool is_cell, | 2682 bool is_cell, |
2681 bool boolean_value) | 2683 bool boolean_value) |
2682 : handle_(handle), | 2684 : handle_(handle), |
2683 unique_id_(unique_id), | 2685 unique_id_(unique_id), |
2684 has_smi_value_(false), | 2686 has_smi_value_(false), |
2685 has_int32_value_(false), | 2687 has_int32_value_(false), |
2686 has_double_value_(false), | 2688 has_double_value_(false), |
2687 is_internalized_string_(is_internalize_string), | 2689 has_external_reference_value_(false), |
2688 is_not_in_new_space_(is_not_in_new_space), | 2690 is_internalized_string_(is_internalize_string), |
2689 is_cell_(is_cell), | 2691 is_not_in_new_space_(is_not_in_new_space), |
2690 boolean_value_(boolean_value) { | 2692 is_cell_(is_cell), |
| 2693 boolean_value_(boolean_value) { |
2691 ASSERT(!handle.is_null()); | 2694 ASSERT(!handle.is_null()); |
2692 ASSERT(!type.IsTaggedNumber()); | 2695 ASSERT(!type.IsTaggedNumber()); |
2693 set_type(type); | 2696 set_type(type); |
2694 Initialize(r); | 2697 Initialize(r); |
2695 } | 2698 } |
2696 | 2699 |
2697 | 2700 |
2698 HConstant::HConstant(int32_t integer_value, | 2701 HConstant::HConstant(int32_t integer_value, |
2699 Representation r, | 2702 Representation r, |
2700 bool is_not_in_new_space, | 2703 bool is_not_in_new_space, |
2701 Handle<Object> optional_handle) | 2704 Handle<Object> optional_handle) |
2702 : handle_(optional_handle), | 2705 : handle_(optional_handle), |
2703 unique_id_(), | 2706 unique_id_(), |
2704 has_smi_value_(Smi::IsValid(integer_value)), | 2707 has_smi_value_(Smi::IsValid(integer_value)), |
2705 has_int32_value_(true), | 2708 has_int32_value_(true), |
2706 has_double_value_(true), | 2709 has_double_value_(true), |
2707 is_internalized_string_(false), | 2710 has_external_reference_value_(false), |
2708 is_not_in_new_space_(is_not_in_new_space), | 2711 is_internalized_string_(false), |
2709 is_cell_(false), | 2712 is_not_in_new_space_(is_not_in_new_space), |
2710 boolean_value_(integer_value != 0), | 2713 is_cell_(false), |
2711 int32_value_(integer_value), | 2714 boolean_value_(integer_value != 0), |
2712 double_value_(FastI2D(integer_value)) { | 2715 int32_value_(integer_value), |
| 2716 double_value_(FastI2D(integer_value)) { |
2713 set_type(has_smi_value_ ? HType::Smi() : HType::TaggedNumber()); | 2717 set_type(has_smi_value_ ? HType::Smi() : HType::TaggedNumber()); |
2714 Initialize(r); | 2718 Initialize(r); |
2715 } | 2719 } |
2716 | 2720 |
2717 | 2721 |
2718 HConstant::HConstant(double double_value, | 2722 HConstant::HConstant(double double_value, |
2719 Representation r, | 2723 Representation r, |
2720 bool is_not_in_new_space, | 2724 bool is_not_in_new_space, |
2721 Handle<Object> optional_handle) | 2725 Handle<Object> optional_handle) |
2722 : handle_(optional_handle), | 2726 : handle_(optional_handle), |
2723 unique_id_(), | 2727 unique_id_(), |
2724 has_int32_value_(IsInteger32(double_value)), | 2728 has_int32_value_(IsInteger32(double_value)), |
2725 has_double_value_(true), | 2729 has_double_value_(true), |
2726 is_internalized_string_(false), | 2730 has_external_reference_value_(false), |
2727 is_not_in_new_space_(is_not_in_new_space), | 2731 is_internalized_string_(false), |
2728 is_cell_(false), | 2732 is_not_in_new_space_(is_not_in_new_space), |
2729 boolean_value_(double_value != 0 && !std::isnan(double_value)), | 2733 is_cell_(false), |
2730 int32_value_(DoubleToInt32(double_value)), | 2734 boolean_value_(double_value != 0 && !std::isnan(double_value)), |
2731 double_value_(double_value) { | 2735 int32_value_(DoubleToInt32(double_value)), |
| 2736 double_value_(double_value) { |
2732 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); | 2737 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); |
2733 set_type(has_smi_value_ ? HType::Smi() : HType::TaggedNumber()); | 2738 set_type(has_smi_value_ ? HType::Smi() : HType::TaggedNumber()); |
2734 Initialize(r); | 2739 Initialize(r); |
2735 } | 2740 } |
2736 | 2741 |
2737 | 2742 |
| 2743 HConstant::HConstant(ExternalReference reference) |
| 2744 : has_smi_value_(false), |
| 2745 has_int32_value_(false), |
| 2746 has_double_value_(false), |
| 2747 has_external_reference_value_(true), |
| 2748 is_internalized_string_(false), |
| 2749 is_not_in_new_space_(true), |
| 2750 is_cell_(false), |
| 2751 boolean_value_(true), |
| 2752 external_reference_value_(reference) { |
| 2753 set_type(HType::None()); |
| 2754 Initialize(Representation::External()); |
| 2755 } |
| 2756 |
| 2757 |
2738 void HConstant::Initialize(Representation r) { | 2758 void HConstant::Initialize(Representation r) { |
2739 if (r.IsNone()) { | 2759 if (r.IsNone()) { |
2740 if (has_smi_value_ && kSmiValueSize == 31) { | 2760 if (has_smi_value_ && kSmiValueSize == 31) { |
2741 r = Representation::Smi(); | 2761 r = Representation::Smi(); |
2742 } else if (has_int32_value_) { | 2762 } else if (has_int32_value_) { |
2743 r = Representation::Integer32(); | 2763 r = Representation::Integer32(); |
2744 } else if (has_double_value_) { | 2764 } else if (has_double_value_) { |
2745 r = Representation::Double(); | 2765 r = Representation::Double(); |
| 2766 } else if (has_external_reference_value_) { |
| 2767 r = Representation::External(); |
2746 } else { | 2768 } else { |
2747 r = Representation::Tagged(); | 2769 r = Representation::Tagged(); |
2748 } | 2770 } |
2749 } | 2771 } |
2750 set_representation(r); | 2772 set_representation(r); |
2751 SetFlag(kUseGVN); | 2773 SetFlag(kUseGVN); |
2752 } | 2774 } |
2753 | 2775 |
2754 | 2776 |
2755 bool HConstant::EmitAtUses() { | 2777 bool HConstant::EmitAtUses() { |
2756 ASSERT(IsLinked()); | 2778 ASSERT(IsLinked()); |
2757 if (block()->graph()->has_osr()) { | 2779 if (block()->graph()->has_osr()) { |
2758 return block()->graph()->IsStandardConstant(this); | 2780 return block()->graph()->IsStandardConstant(this); |
2759 } | 2781 } |
2760 if (IsCell()) return false; | 2782 if (IsCell()) return false; |
2761 if (representation().IsDouble()) return false; | 2783 if (representation().IsDouble()) return false; |
2762 return true; | 2784 return true; |
2763 } | 2785 } |
2764 | 2786 |
2765 | 2787 |
2766 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { | 2788 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
2767 if (r.IsSmi() && !has_smi_value_) return NULL; | 2789 if (r.IsSmi() && !has_smi_value_) return NULL; |
2768 if (r.IsInteger32() && !has_int32_value_) return NULL; | 2790 if (r.IsInteger32() && !has_int32_value_) return NULL; |
2769 if (r.IsDouble() && !has_double_value_) return NULL; | 2791 if (r.IsDouble() && !has_double_value_) return NULL; |
| 2792 if (r.IsExternal() && !has_external_reference_value_) return NULL; |
2770 if (has_int32_value_) { | 2793 if (has_int32_value_) { |
2771 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_); | 2794 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_); |
2772 } | 2795 } |
2773 if (has_double_value_) { | 2796 if (has_double_value_) { |
2774 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_); | 2797 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_); |
2775 } | 2798 } |
| 2799 if (has_external_reference_value_) { |
| 2800 return new(zone) HConstant(external_reference_value_); |
| 2801 } |
2776 ASSERT(!handle_.is_null()); | 2802 ASSERT(!handle_.is_null()); |
2777 return new(zone) HConstant(handle_, | 2803 return new(zone) HConstant(handle_, |
2778 unique_id_, | 2804 unique_id_, |
2779 r, | 2805 r, |
2780 type_, | 2806 type_, |
2781 is_internalized_string_, | 2807 is_internalized_string_, |
2782 is_not_in_new_space_, | 2808 is_not_in_new_space_, |
2783 is_cell_, | 2809 is_cell_, |
2784 boolean_value_); | 2810 boolean_value_); |
2785 } | 2811 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2818 } | 2844 } |
2819 return Maybe<HConstant*>(res != NULL, res); | 2845 return Maybe<HConstant*>(res != NULL, res); |
2820 } | 2846 } |
2821 | 2847 |
2822 | 2848 |
2823 void HConstant::PrintDataTo(StringStream* stream) { | 2849 void HConstant::PrintDataTo(StringStream* stream) { |
2824 if (has_int32_value_) { | 2850 if (has_int32_value_) { |
2825 stream->Add("%d ", int32_value_); | 2851 stream->Add("%d ", int32_value_); |
2826 } else if (has_double_value_) { | 2852 } else if (has_double_value_) { |
2827 stream->Add("%f ", FmtElm(double_value_)); | 2853 stream->Add("%f ", FmtElm(double_value_)); |
| 2854 } else if (has_external_reference_value_) { |
| 2855 stream->Add("%p ", reinterpret_cast<void*>( |
| 2856 external_reference_value_.address())); |
2828 } else { | 2857 } else { |
2829 handle()->ShortPrint(stream); | 2858 handle()->ShortPrint(stream); |
2830 } | 2859 } |
2831 } | 2860 } |
2832 | 2861 |
2833 | 2862 |
2834 void HBinaryOperation::PrintDataTo(StringStream* stream) { | 2863 void HBinaryOperation::PrintDataTo(StringStream* stream) { |
2835 left()->PrintNameTo(stream); | 2864 left()->PrintNameTo(stream); |
2836 stream->Add(" "); | 2865 stream->Add(" "); |
2837 right()->PrintNameTo(stream); | 2866 right()->PrintNameTo(stream); |
(...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4498 ? kChangesBackingStoreFields : kDependsOnBackingStoreFields); | 4527 ? kChangesBackingStoreFields : kDependsOnBackingStoreFields); |
4499 break; | 4528 break; |
4500 case kElementsPointer: | 4529 case kElementsPointer: |
4501 instr->SetGVNFlag(is_store | 4530 instr->SetGVNFlag(is_store |
4502 ? kChangesElementsPointer : kDependsOnElementsPointer); | 4531 ? kChangesElementsPointer : kDependsOnElementsPointer); |
4503 break; | 4532 break; |
4504 case kMaps: | 4533 case kMaps: |
4505 instr->SetGVNFlag(is_store | 4534 instr->SetGVNFlag(is_store |
4506 ? kChangesMaps : kDependsOnMaps); | 4535 ? kChangesMaps : kDependsOnMaps); |
4507 break; | 4536 break; |
| 4537 case kExternalMemory: |
| 4538 instr->SetGVNFlag(is_store |
| 4539 ? kChangesExternalMemory : kDependsOnExternalMemory); |
| 4540 break; |
4508 } | 4541 } |
4509 } | 4542 } |
4510 | 4543 |
4511 | 4544 |
4512 void HObjectAccess::PrintTo(StringStream* stream) { | 4545 void HObjectAccess::PrintTo(StringStream* stream) { |
4513 stream->Add("."); | 4546 stream->Add("."); |
4514 | 4547 |
4515 switch (portion()) { | 4548 switch (portion()) { |
4516 case kArrayLengths: | 4549 case kArrayLengths: |
4517 stream->Add("%length"); | 4550 stream->Add("%length"); |
4518 break; | 4551 break; |
4519 case kElementsPointer: | 4552 case kElementsPointer: |
4520 stream->Add("%elements"); | 4553 stream->Add("%elements"); |
4521 break; | 4554 break; |
4522 case kMaps: | 4555 case kMaps: |
4523 stream->Add("%map"); | 4556 stream->Add("%map"); |
4524 break; | 4557 break; |
4525 case kDouble: // fall through | 4558 case kDouble: // fall through |
4526 case kInobject: | 4559 case kInobject: |
4527 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 4560 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
4528 stream->Add("[in-object]"); | 4561 stream->Add("[in-object]"); |
4529 break; | 4562 break; |
4530 case kBackingStore: | 4563 case kBackingStore: |
4531 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 4564 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
4532 stream->Add("[backing-store]"); | 4565 stream->Add("[backing-store]"); |
4533 break; | 4566 break; |
| 4567 case kExternalMemory: |
| 4568 stream->Add("[external-memory]"); |
| 4569 break; |
4534 } | 4570 } |
4535 | 4571 |
4536 stream->Add("@%d", offset()); | 4572 stream->Add("@%d", offset()); |
4537 } | 4573 } |
4538 | 4574 |
4539 } } // namespace v8::internal | 4575 } } // namespace v8::internal |
OLD | NEW |