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 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 2179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2640 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); | 2641 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); |
| 2641 } | 2642 } |
| 2642 | 2643 |
| 2643 | 2644 |
| 2644 HConstant::HConstant(Handle<Object> handle, Representation r) | 2645 HConstant::HConstant(Handle<Object> handle, Representation r) |
| 2645 : handle_(handle), | 2646 : handle_(handle), |
| 2646 unique_id_(), | 2647 unique_id_(), |
| 2647 has_smi_value_(false), | 2648 has_smi_value_(false), |
| 2648 has_int32_value_(false), | 2649 has_int32_value_(false), |
| 2649 has_double_value_(false), | 2650 has_double_value_(false), |
| 2651 has_external_value_(false), | |
| 2650 is_internalized_string_(false), | 2652 is_internalized_string_(false), |
| 2651 is_not_in_new_space_(true), | 2653 is_not_in_new_space_(true), |
| 2652 is_cell_(false), | 2654 is_cell_(false), |
| 2653 boolean_value_(handle->BooleanValue()) { | 2655 boolean_value_(handle->BooleanValue()) { |
| 2654 if (handle_->IsHeapObject()) { | 2656 if (handle_->IsHeapObject()) { |
| 2655 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); | 2657 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); |
| 2656 is_not_in_new_space_ = !heap->InNewSpace(*handle); | 2658 is_not_in_new_space_ = !heap->InNewSpace(*handle); |
| 2657 } | 2659 } |
| 2658 if (handle_->IsNumber()) { | 2660 if (handle_->IsNumber()) { |
| 2659 double n = handle_->Number(); | 2661 double n = handle_->Number(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2674 | 2676 |
| 2675 | 2677 |
| 2676 HConstant::HConstant(Handle<Object> handle, | 2678 HConstant::HConstant(Handle<Object> handle, |
| 2677 UniqueValueId unique_id, | 2679 UniqueValueId unique_id, |
| 2678 Representation r, | 2680 Representation r, |
| 2679 HType type, | 2681 HType type, |
| 2680 bool is_internalize_string, | 2682 bool is_internalize_string, |
| 2681 bool is_not_in_new_space, | 2683 bool is_not_in_new_space, |
| 2682 bool is_cell, | 2684 bool is_cell, |
| 2683 bool boolean_value) | 2685 bool boolean_value) |
| 2684 : handle_(handle), | 2686 : handle_(handle), |
| 2685 unique_id_(unique_id), | 2687 unique_id_(unique_id), |
| 2686 has_smi_value_(false), | 2688 has_smi_value_(false), |
| 2687 has_int32_value_(false), | 2689 has_int32_value_(false), |
| 2688 has_double_value_(false), | 2690 has_double_value_(false), |
| 2689 is_internalized_string_(is_internalize_string), | 2691 has_external_value_(false), |
| 2690 is_not_in_new_space_(is_not_in_new_space), | 2692 is_internalized_string_(is_internalize_string), |
| 2691 is_cell_(is_cell), | 2693 is_not_in_new_space_(is_not_in_new_space), |
| 2692 boolean_value_(boolean_value), | 2694 is_cell_(is_cell), |
| 2693 type_from_value_(type) { | 2695 boolean_value_(boolean_value), |
| 2696 type_from_value_(type) { | |
| 2694 ASSERT(!handle.is_null()); | 2697 ASSERT(!handle.is_null()); |
| 2695 ASSERT(!type.IsUninitialized()); | 2698 ASSERT(!type.IsUninitialized()); |
| 2696 ASSERT(!type.IsTaggedNumber()); | 2699 ASSERT(!type.IsTaggedNumber()); |
| 2697 Initialize(r); | 2700 Initialize(r); |
| 2698 } | 2701 } |
| 2699 | 2702 |
| 2700 | 2703 |
| 2701 HConstant::HConstant(int32_t integer_value, | 2704 HConstant::HConstant(int32_t integer_value, |
| 2702 Representation r, | 2705 Representation r, |
| 2703 bool is_not_in_new_space, | 2706 bool is_not_in_new_space, |
| 2704 Handle<Object> optional_handle) | 2707 Handle<Object> optional_handle) |
| 2705 : handle_(optional_handle), | 2708 : handle_(optional_handle), |
| 2706 unique_id_(), | 2709 unique_id_(), |
| 2707 has_int32_value_(true), | 2710 has_int32_value_(true), |
| 2708 has_double_value_(true), | 2711 has_double_value_(true), |
| 2709 is_internalized_string_(false), | 2712 has_external_value_(false), |
| 2710 is_not_in_new_space_(is_not_in_new_space), | 2713 is_internalized_string_(false), |
| 2711 is_cell_(false), | 2714 is_not_in_new_space_(is_not_in_new_space), |
| 2712 boolean_value_(integer_value != 0), | 2715 is_cell_(false), |
| 2713 int32_value_(integer_value), | 2716 boolean_value_(integer_value != 0), |
| 2714 double_value_(FastI2D(integer_value)) { | 2717 int32_value_(integer_value), |
| 2718 double_value_(FastI2D(integer_value)) { | |
| 2715 has_smi_value_ = Smi::IsValid(int32_value_); | 2719 has_smi_value_ = Smi::IsValid(int32_value_); |
| 2716 Initialize(r); | 2720 Initialize(r); |
| 2717 } | 2721 } |
| 2718 | 2722 |
| 2719 | 2723 |
| 2720 HConstant::HConstant(double double_value, | 2724 HConstant::HConstant(double double_value, |
| 2721 Representation r, | 2725 Representation r, |
| 2722 bool is_not_in_new_space, | 2726 bool is_not_in_new_space, |
| 2723 Handle<Object> optional_handle) | 2727 Handle<Object> optional_handle) |
| 2724 : handle_(optional_handle), | 2728 : handle_(optional_handle), |
| 2725 unique_id_(), | 2729 unique_id_(), |
| 2726 has_int32_value_(IsInteger32(double_value)), | 2730 has_int32_value_(IsInteger32(double_value)), |
| 2727 has_double_value_(true), | 2731 has_double_value_(true), |
| 2728 is_internalized_string_(false), | 2732 has_external_value_(false), |
| 2729 is_not_in_new_space_(is_not_in_new_space), | 2733 is_internalized_string_(false), |
| 2730 is_cell_(false), | 2734 is_not_in_new_space_(is_not_in_new_space), |
| 2731 boolean_value_(double_value != 0 && !std::isnan(double_value)), | 2735 is_cell_(false), |
| 2732 int32_value_(DoubleToInt32(double_value)), | 2736 boolean_value_(double_value != 0 && !std::isnan(double_value)), |
| 2733 double_value_(double_value) { | 2737 int32_value_(DoubleToInt32(double_value)), |
| 2738 double_value_(double_value) { | |
| 2734 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); | 2739 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); |
| 2735 Initialize(r); | 2740 Initialize(r); |
| 2736 } | 2741 } |
| 2737 | 2742 |
| 2738 | 2743 |
| 2744 HConstant::HConstant(ExternalReference reference, Representation r) | |
| 2745 : has_smi_value_(false), | |
| 2746 has_int32_value_(false), | |
| 2747 has_double_value_(false), | |
| 2748 has_external_value_(true), | |
| 2749 is_internalized_string_(false), | |
| 2750 is_not_in_new_space_(true), | |
| 2751 is_cell_(false), | |
| 2752 boolean_value_(true), | |
| 2753 external_value_(reference) { | |
| 2754 Initialize(r); | |
| 2755 } | |
| 2756 | |
| 2757 | |
| 2739 void HConstant::Initialize(Representation r) { | 2758 void HConstant::Initialize(Representation r) { |
| 2740 if (r.IsNone()) { | 2759 if (r.IsNone()) { |
| 2741 if (has_smi_value_ && kSmiValueSize == 31) { | 2760 if (has_smi_value_ && kSmiValueSize == 31) { |
| 2742 r = Representation::Smi(); | 2761 r = Representation::Smi(); |
| 2743 } else if (has_int32_value_) { | 2762 } else if (has_int32_value_) { |
| 2744 r = Representation::Integer32(); | 2763 r = Representation::Integer32(); |
| 2745 } else if (has_double_value_) { | 2764 } else if (has_double_value_) { |
| 2746 r = Representation::Double(); | 2765 r = Representation::Double(); |
| 2766 } else if (has_external_value_) { | |
| 2767 r = Representation::External(); | |
| 2747 } else { | 2768 } else { |
| 2748 r = Representation::Tagged(); | 2769 r = Representation::Tagged(); |
| 2749 } | 2770 } |
| 2750 } | 2771 } |
| 2751 set_representation(r); | 2772 set_representation(r); |
| 2752 SetFlag(kUseGVN); | 2773 SetFlag(kUseGVN); |
| 2753 } | 2774 } |
| 2754 | 2775 |
| 2755 | 2776 |
| 2756 bool HConstant::EmitAtUses() { | 2777 bool HConstant::EmitAtUses() { |
| 2757 ASSERT(IsLinked()); | 2778 ASSERT(IsLinked()); |
| 2758 if (block()->graph()->has_osr()) { | 2779 if (block()->graph()->has_osr()) { |
| 2759 return block()->graph()->IsStandardConstant(this); | 2780 return block()->graph()->IsStandardConstant(this); |
| 2760 } | 2781 } |
| 2761 if (IsCell()) return false; | 2782 if (IsCell()) return false; |
| 2762 if (representation().IsDouble()) return false; | 2783 if (representation().IsDouble()) return false; |
| 2763 return true; | 2784 return true; |
| 2764 } | 2785 } |
| 2765 | 2786 |
| 2766 | 2787 |
| 2767 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { | 2788 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
| 2768 if (r.IsSmi() && !has_smi_value_) return NULL; | 2789 if (r.IsSmi() && !has_smi_value_) return NULL; |
| 2769 if (r.IsInteger32() && !has_int32_value_) return NULL; | 2790 if (r.IsInteger32() && !has_int32_value_) return NULL; |
| 2770 if (r.IsDouble() && !has_double_value_) return NULL; | 2791 if (r.IsDouble() && !has_double_value_) return NULL; |
| 2792 if (r.IsExternal() && !has_external_value_) return NULL; | |
| 2771 if (has_int32_value_) { | 2793 if (has_int32_value_) { |
| 2772 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_); |
| 2773 } | 2795 } |
| 2774 if (has_double_value_) { | 2796 if (has_double_value_) { |
| 2775 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_); |
| 2776 } | 2798 } |
| 2799 if (has_external_value_) { | |
| 2800 return new(zone) HConstant(external_value_, r); | |
| 2801 } | |
| 2777 ASSERT(!handle_.is_null()); | 2802 ASSERT(!handle_.is_null()); |
| 2778 return new(zone) HConstant(handle_, | 2803 return new(zone) HConstant(handle_, |
| 2779 unique_id_, | 2804 unique_id_, |
| 2780 r, | 2805 r, |
| 2781 type_from_value_, | 2806 type_from_value_, |
| 2782 is_internalized_string_, | 2807 is_internalized_string_, |
| 2783 is_not_in_new_space_, | 2808 is_not_in_new_space_, |
| 2784 is_cell_, | 2809 is_cell_, |
| 2785 boolean_value_); | 2810 boolean_value_); |
| 2786 } | 2811 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2819 } | 2844 } |
| 2820 return Maybe<HConstant*>(res != NULL, res); | 2845 return Maybe<HConstant*>(res != NULL, res); |
| 2821 } | 2846 } |
| 2822 | 2847 |
| 2823 | 2848 |
| 2824 void HConstant::PrintDataTo(StringStream* stream) { | 2849 void HConstant::PrintDataTo(StringStream* stream) { |
| 2825 if (has_int32_value_) { | 2850 if (has_int32_value_) { |
| 2826 stream->Add("%d ", int32_value_); | 2851 stream->Add("%d ", int32_value_); |
| 2827 } else if (has_double_value_) { | 2852 } else if (has_double_value_) { |
| 2828 stream->Add("%f ", FmtElm(double_value_)); | 2853 stream->Add("%f ", FmtElm(double_value_)); |
| 2854 } else if (has_external_value_) { | |
| 2855 stream->Add("%p ", reinterpret_cast<void*>(external_value_.address())); | |
| 2829 } else { | 2856 } else { |
| 2830 handle()->ShortPrint(stream); | 2857 handle()->ShortPrint(stream); |
| 2831 } | 2858 } |
| 2832 } | 2859 } |
| 2833 | 2860 |
| 2834 | 2861 |
| 2835 void HBinaryOperation::PrintDataTo(StringStream* stream) { | 2862 void HBinaryOperation::PrintDataTo(StringStream* stream) { |
| 2836 left()->PrintNameTo(stream); | 2863 left()->PrintNameTo(stream); |
| 2837 stream->Add(" "); | 2864 stream->Add(" "); |
| 2838 right()->PrintNameTo(stream); | 2865 right()->PrintNameTo(stream); |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3660 } | 3687 } |
| 3661 return result; | 3688 return result; |
| 3662 } | 3689 } |
| 3663 | 3690 |
| 3664 | 3691 |
| 3665 HType HConstant::CalculateInferredType() { | 3692 HType HConstant::CalculateInferredType() { |
| 3666 if (has_int32_value_) { | 3693 if (has_int32_value_) { |
| 3667 return Smi::IsValid(int32_value_) ? HType::Smi() : HType::HeapNumber(); | 3694 return Smi::IsValid(int32_value_) ? HType::Smi() : HType::HeapNumber(); |
| 3668 } | 3695 } |
| 3669 if (has_double_value_) return HType::HeapNumber(); | 3696 if (has_double_value_) return HType::HeapNumber(); |
| 3697 if (has_external_value_) return HType::None(); | |
|
danno
2013/07/25 18:35:57
You should also look in HLoadExternalArrayPointer
Benedikt Meurer
2013/07/25 21:09:11
Why? It's an external pointer, shouldn't it have R
danno
2013/07/25 22:22:05
HLoadExternalArrayPointer already does return Repr
| |
| 3670 ASSERT(!type_from_value_.IsUninitialized()); | 3698 ASSERT(!type_from_value_.IsUninitialized()); |
| 3671 return type_from_value_; | 3699 return type_from_value_; |
| 3672 } | 3700 } |
| 3673 | 3701 |
| 3674 | 3702 |
| 3675 HType HCompareGeneric::CalculateInferredType() { | 3703 HType HCompareGeneric::CalculateInferredType() { |
| 3676 return HType::Boolean(); | 3704 return HType::Boolean(); |
| 3677 } | 3705 } |
| 3678 | 3706 |
| 3679 | 3707 |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4513 ? kChangesBackingStoreFields : kDependsOnBackingStoreFields); | 4541 ? kChangesBackingStoreFields : kDependsOnBackingStoreFields); |
| 4514 break; | 4542 break; |
| 4515 case kElementsPointer: | 4543 case kElementsPointer: |
| 4516 instr->SetGVNFlag(is_store | 4544 instr->SetGVNFlag(is_store |
| 4517 ? kChangesElementsPointer : kDependsOnElementsPointer); | 4545 ? kChangesElementsPointer : kDependsOnElementsPointer); |
| 4518 break; | 4546 break; |
| 4519 case kMaps: | 4547 case kMaps: |
| 4520 instr->SetGVNFlag(is_store | 4548 instr->SetGVNFlag(is_store |
| 4521 ? kChangesMaps : kDependsOnMaps); | 4549 ? kChangesMaps : kDependsOnMaps); |
| 4522 break; | 4550 break; |
| 4551 case kExternalMemory: | |
| 4552 instr->SetGVNFlag(is_store | |
| 4553 ? kChangesExternalMemory : kDependsOnExternalMemory); | |
| 4554 break; | |
| 4523 } | 4555 } |
| 4524 } | 4556 } |
| 4525 | 4557 |
| 4526 | 4558 |
| 4527 void HObjectAccess::PrintTo(StringStream* stream) { | 4559 void HObjectAccess::PrintTo(StringStream* stream) { |
| 4528 stream->Add("."); | 4560 stream->Add("."); |
| 4529 | 4561 |
| 4530 switch (portion()) { | 4562 switch (portion()) { |
| 4531 case kArrayLengths: | 4563 case kArrayLengths: |
| 4532 stream->Add("%length"); | 4564 stream->Add("%length"); |
| 4533 break; | 4565 break; |
| 4534 case kElementsPointer: | 4566 case kElementsPointer: |
| 4535 stream->Add("%elements"); | 4567 stream->Add("%elements"); |
| 4536 break; | 4568 break; |
| 4537 case kMaps: | 4569 case kMaps: |
| 4538 stream->Add("%map"); | 4570 stream->Add("%map"); |
| 4539 break; | 4571 break; |
| 4540 case kDouble: // fall through | 4572 case kDouble: // fall through |
| 4541 case kInobject: | 4573 case kInobject: |
| 4542 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 4574 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
| 4543 stream->Add("[in-object]"); | 4575 stream->Add("[in-object]"); |
| 4544 break; | 4576 break; |
| 4545 case kBackingStore: | 4577 case kBackingStore: |
| 4546 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 4578 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
| 4547 stream->Add("[backing-store]"); | 4579 stream->Add("[backing-store]"); |
| 4548 break; | 4580 break; |
| 4581 case kExternalMemory: | |
| 4582 stream->Add("[external-memory]"); | |
| 4583 break; | |
| 4549 } | 4584 } |
| 4550 | 4585 |
| 4551 stream->Add("@%d", offset()); | 4586 stream->Add("@%d", offset()); |
| 4552 } | 4587 } |
| 4553 | 4588 |
| 4554 } } // namespace v8::internal | 4589 } } // namespace v8::internal |
| OLD | NEW |