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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 Verify(); | 418 Verify(); |
419 #endif | 419 #endif |
420 return may_overflow; | 420 return may_overflow; |
421 } | 421 } |
422 | 422 |
423 | 423 |
424 const char* HType::ToString() { | 424 const char* HType::ToString() { |
425 // Note: The c1visualizer syntax for locals allows only a sequence of the | 425 // Note: The c1visualizer syntax for locals allows only a sequence of the |
426 // following characters: A-Za-z0-9_-|: | 426 // following characters: A-Za-z0-9_-|: |
427 switch (type_) { | 427 switch (type_) { |
| 428 case kNone: return "none"; |
428 case kTagged: return "tagged"; | 429 case kTagged: return "tagged"; |
429 case kTaggedPrimitive: return "primitive"; | 430 case kTaggedPrimitive: return "primitive"; |
430 case kTaggedNumber: return "number"; | 431 case kTaggedNumber: return "number"; |
431 case kSmi: return "smi"; | 432 case kSmi: return "smi"; |
432 case kHeapNumber: return "heap-number"; | 433 case kHeapNumber: return "heap-number"; |
433 case kString: return "string"; | 434 case kString: return "string"; |
434 case kBoolean: return "boolean"; | 435 case kBoolean: return "boolean"; |
435 case kNonPrimitive: return "non-primitive"; | 436 case kNonPrimitive: return "non-primitive"; |
436 case kJSArray: return "array"; | 437 case kJSArray: return "array"; |
437 case kJSObject: return "object"; | 438 case kJSObject: return "object"; |
(...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2600 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); | 2601 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); |
2601 } | 2602 } |
2602 | 2603 |
2603 | 2604 |
2604 HConstant::HConstant(Handle<Object> handle, Representation r) | 2605 HConstant::HConstant(Handle<Object> handle, Representation r) |
2605 : handle_(handle), | 2606 : handle_(handle), |
2606 unique_id_(), | 2607 unique_id_(), |
2607 has_smi_value_(false), | 2608 has_smi_value_(false), |
2608 has_int32_value_(false), | 2609 has_int32_value_(false), |
2609 has_double_value_(false), | 2610 has_double_value_(false), |
| 2611 has_external_value_(false), |
2610 is_internalized_string_(false), | 2612 is_internalized_string_(false), |
2611 is_not_in_new_space_(true), | 2613 is_not_in_new_space_(true), |
2612 is_cell_(false), | 2614 is_cell_(false), |
2613 boolean_value_(handle->BooleanValue()) { | 2615 boolean_value_(handle->BooleanValue()) { |
2614 if (handle_->IsHeapObject()) { | 2616 if (handle_->IsHeapObject()) { |
2615 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); | 2617 Heap* heap = Handle<HeapObject>::cast(handle)->GetHeap(); |
2616 is_not_in_new_space_ = !heap->InNewSpace(*handle); | 2618 is_not_in_new_space_ = !heap->InNewSpace(*handle); |
2617 } | 2619 } |
2618 if (handle_->IsNumber()) { | 2620 if (handle_->IsNumber()) { |
2619 double n = handle_->Number(); | 2621 double n = handle_->Number(); |
(...skipping 14 matching lines...) Expand all Loading... |
2634 | 2636 |
2635 | 2637 |
2636 HConstant::HConstant(Handle<Object> handle, | 2638 HConstant::HConstant(Handle<Object> handle, |
2637 UniqueValueId unique_id, | 2639 UniqueValueId unique_id, |
2638 Representation r, | 2640 Representation r, |
2639 HType type, | 2641 HType type, |
2640 bool is_internalize_string, | 2642 bool is_internalize_string, |
2641 bool is_not_in_new_space, | 2643 bool is_not_in_new_space, |
2642 bool is_cell, | 2644 bool is_cell, |
2643 bool boolean_value) | 2645 bool boolean_value) |
2644 : handle_(handle), | 2646 : handle_(handle), |
2645 unique_id_(unique_id), | 2647 unique_id_(unique_id), |
2646 has_smi_value_(false), | 2648 has_smi_value_(false), |
2647 has_int32_value_(false), | 2649 has_int32_value_(false), |
2648 has_double_value_(false), | 2650 has_double_value_(false), |
2649 is_internalized_string_(is_internalize_string), | 2651 has_external_value_(false), |
2650 is_not_in_new_space_(is_not_in_new_space), | 2652 is_internalized_string_(is_internalize_string), |
2651 is_cell_(is_cell), | 2653 is_not_in_new_space_(is_not_in_new_space), |
2652 boolean_value_(boolean_value), | 2654 is_cell_(is_cell), |
2653 type_from_value_(type) { | 2655 boolean_value_(boolean_value), |
| 2656 type_from_value_(type) { |
2654 ASSERT(!handle.is_null()); | 2657 ASSERT(!handle.is_null()); |
2655 ASSERT(!type.IsUninitialized()); | 2658 ASSERT(!type.IsUninitialized()); |
2656 ASSERT(!type.IsTaggedNumber()); | 2659 ASSERT(!type.IsTaggedNumber()); |
2657 Initialize(r); | 2660 Initialize(r); |
2658 } | 2661 } |
2659 | 2662 |
2660 | 2663 |
2661 HConstant::HConstant(int32_t integer_value, | 2664 HConstant::HConstant(int32_t integer_value, |
2662 Representation r, | 2665 Representation r, |
2663 bool is_not_in_new_space, | 2666 bool is_not_in_new_space, |
2664 Handle<Object> optional_handle) | 2667 Handle<Object> optional_handle) |
2665 : handle_(optional_handle), | 2668 : handle_(optional_handle), |
2666 unique_id_(), | 2669 unique_id_(), |
2667 has_int32_value_(true), | 2670 has_int32_value_(true), |
2668 has_double_value_(true), | 2671 has_double_value_(true), |
2669 is_internalized_string_(false), | 2672 has_external_value_(false), |
2670 is_not_in_new_space_(is_not_in_new_space), | 2673 is_internalized_string_(false), |
2671 is_cell_(false), | 2674 is_not_in_new_space_(is_not_in_new_space), |
2672 boolean_value_(integer_value != 0), | 2675 is_cell_(false), |
2673 int32_value_(integer_value), | 2676 boolean_value_(integer_value != 0), |
2674 double_value_(FastI2D(integer_value)) { | 2677 int32_value_(integer_value), |
| 2678 double_value_(FastI2D(integer_value)) { |
2675 has_smi_value_ = Smi::IsValid(int32_value_); | 2679 has_smi_value_ = Smi::IsValid(int32_value_); |
2676 Initialize(r); | 2680 Initialize(r); |
2677 } | 2681 } |
2678 | 2682 |
2679 | 2683 |
2680 HConstant::HConstant(double double_value, | 2684 HConstant::HConstant(double double_value, |
2681 Representation r, | 2685 Representation r, |
2682 bool is_not_in_new_space, | 2686 bool is_not_in_new_space, |
2683 Handle<Object> optional_handle) | 2687 Handle<Object> optional_handle) |
2684 : handle_(optional_handle), | 2688 : handle_(optional_handle), |
2685 unique_id_(), | 2689 unique_id_(), |
2686 has_int32_value_(IsInteger32(double_value)), | 2690 has_int32_value_(IsInteger32(double_value)), |
2687 has_double_value_(true), | 2691 has_double_value_(true), |
2688 is_internalized_string_(false), | 2692 has_external_value_(false), |
2689 is_not_in_new_space_(is_not_in_new_space), | 2693 is_internalized_string_(false), |
2690 is_cell_(false), | 2694 is_not_in_new_space_(is_not_in_new_space), |
2691 boolean_value_(double_value != 0 && !std::isnan(double_value)), | 2695 is_cell_(false), |
2692 int32_value_(DoubleToInt32(double_value)), | 2696 boolean_value_(double_value != 0 && !std::isnan(double_value)), |
2693 double_value_(double_value) { | 2697 int32_value_(DoubleToInt32(double_value)), |
| 2698 double_value_(double_value) { |
2694 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); | 2699 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); |
2695 Initialize(r); | 2700 Initialize(r); |
2696 } | 2701 } |
2697 | 2702 |
2698 | 2703 |
| 2704 HConstant::HConstant(ExternalReference reference, Representation r) |
| 2705 : has_smi_value_(false), |
| 2706 has_int32_value_(false), |
| 2707 has_double_value_(false), |
| 2708 has_external_value_(true), |
| 2709 is_internalized_string_(false), |
| 2710 is_not_in_new_space_(true), |
| 2711 is_cell_(false), |
| 2712 boolean_value_(true), |
| 2713 external_value_(reference) { |
| 2714 Initialize(r); |
| 2715 } |
| 2716 |
| 2717 |
2699 void HConstant::Initialize(Representation r) { | 2718 void HConstant::Initialize(Representation r) { |
2700 if (r.IsNone()) { | 2719 if (r.IsNone()) { |
2701 if (has_smi_value_) { | 2720 if (has_smi_value_) { |
2702 r = Representation::Smi(); | 2721 r = Representation::Smi(); |
2703 } else if (has_int32_value_) { | 2722 } else if (has_int32_value_) { |
2704 r = Representation::Integer32(); | 2723 r = Representation::Integer32(); |
2705 } else if (has_double_value_) { | 2724 } else if (has_double_value_) { |
2706 r = Representation::Double(); | 2725 r = Representation::Double(); |
| 2726 } else if (has_external_value_) { |
| 2727 r = Representation::External(); |
2707 } else { | 2728 } else { |
2708 r = Representation::Tagged(); | 2729 r = Representation::Tagged(); |
2709 } | 2730 } |
2710 } | 2731 } |
2711 set_representation(r); | 2732 set_representation(r); |
2712 SetFlag(kUseGVN); | 2733 SetFlag(kUseGVN); |
2713 } | 2734 } |
2714 | 2735 |
2715 | 2736 |
2716 bool HConstant::EmitAtUses() { | 2737 bool HConstant::EmitAtUses() { |
2717 ASSERT(IsLinked()); | 2738 ASSERT(IsLinked()); |
2718 if (block()->graph()->has_osr()) { | 2739 if (block()->graph()->has_osr()) { |
2719 return block()->graph()->IsStandardConstant(this); | 2740 return block()->graph()->IsStandardConstant(this); |
2720 } | 2741 } |
2721 if (IsCell()) return false; | 2742 if (IsCell()) return false; |
2722 if (representation().IsDouble()) return false; | 2743 if (representation().IsDouble()) return false; |
2723 return true; | 2744 return true; |
2724 } | 2745 } |
2725 | 2746 |
2726 | 2747 |
2727 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { | 2748 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
2728 if (r.IsSmi() && !has_smi_value_) return NULL; | 2749 if (r.IsSmi() && !has_smi_value_) return NULL; |
2729 if (r.IsInteger32() && !has_int32_value_) return NULL; | 2750 if (r.IsInteger32() && !has_int32_value_) return NULL; |
2730 if (r.IsDouble() && !has_double_value_) return NULL; | 2751 if (r.IsDouble() && !has_double_value_) return NULL; |
| 2752 if (r.IsExternal() && !has_external_value_) return NULL; |
2731 if (has_int32_value_) { | 2753 if (has_int32_value_) { |
2732 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_); | 2754 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, handle_); |
2733 } | 2755 } |
2734 if (has_double_value_) { | 2756 if (has_double_value_) { |
2735 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_); | 2757 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, handle_); |
2736 } | 2758 } |
| 2759 if (has_external_value_) { |
| 2760 return new(zone) HConstant(external_value_, r); |
| 2761 } |
2737 ASSERT(!handle_.is_null()); | 2762 ASSERT(!handle_.is_null()); |
2738 return new(zone) HConstant(handle_, | 2763 return new(zone) HConstant(handle_, |
2739 unique_id_, | 2764 unique_id_, |
2740 r, | 2765 r, |
2741 type_from_value_, | 2766 type_from_value_, |
2742 is_internalized_string_, | 2767 is_internalized_string_, |
2743 is_not_in_new_space_, | 2768 is_not_in_new_space_, |
2744 is_cell_, | 2769 is_cell_, |
2745 boolean_value_); | 2770 boolean_value_); |
2746 } | 2771 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2779 } | 2804 } |
2780 return Maybe<HConstant*>(res != NULL, res); | 2805 return Maybe<HConstant*>(res != NULL, res); |
2781 } | 2806 } |
2782 | 2807 |
2783 | 2808 |
2784 void HConstant::PrintDataTo(StringStream* stream) { | 2809 void HConstant::PrintDataTo(StringStream* stream) { |
2785 if (has_int32_value_) { | 2810 if (has_int32_value_) { |
2786 stream->Add("%d ", int32_value_); | 2811 stream->Add("%d ", int32_value_); |
2787 } else if (has_double_value_) { | 2812 } else if (has_double_value_) { |
2788 stream->Add("%f ", FmtElm(double_value_)); | 2813 stream->Add("%f ", FmtElm(double_value_)); |
| 2814 } else if (has_external_value_) { |
| 2815 stream->Add("%p ", reinterpret_cast<void*>(external_value_.address())); |
2789 } else { | 2816 } else { |
2790 handle()->ShortPrint(stream); | 2817 handle()->ShortPrint(stream); |
2791 } | 2818 } |
2792 } | 2819 } |
2793 | 2820 |
2794 | 2821 |
2795 void HBinaryOperation::PrintDataTo(StringStream* stream) { | 2822 void HBinaryOperation::PrintDataTo(StringStream* stream) { |
2796 left()->PrintNameTo(stream); | 2823 left()->PrintNameTo(stream); |
2797 stream->Add(" "); | 2824 stream->Add(" "); |
2798 right()->PrintNameTo(stream); | 2825 right()->PrintNameTo(stream); |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3617 } | 3644 } |
3618 return result; | 3645 return result; |
3619 } | 3646 } |
3620 | 3647 |
3621 | 3648 |
3622 HType HConstant::CalculateInferredType() { | 3649 HType HConstant::CalculateInferredType() { |
3623 if (has_int32_value_) { | 3650 if (has_int32_value_) { |
3624 return Smi::IsValid(int32_value_) ? HType::Smi() : HType::HeapNumber(); | 3651 return Smi::IsValid(int32_value_) ? HType::Smi() : HType::HeapNumber(); |
3625 } | 3652 } |
3626 if (has_double_value_) return HType::HeapNumber(); | 3653 if (has_double_value_) return HType::HeapNumber(); |
| 3654 if (has_external_value_) return HType::None(); |
3627 ASSERT(!type_from_value_.IsUninitialized()); | 3655 ASSERT(!type_from_value_.IsUninitialized()); |
3628 return type_from_value_; | 3656 return type_from_value_; |
3629 } | 3657 } |
3630 | 3658 |
3631 | 3659 |
3632 HType HCompareGeneric::CalculateInferredType() { | 3660 HType HCompareGeneric::CalculateInferredType() { |
3633 return HType::Boolean(); | 3661 return HType::Boolean(); |
3634 } | 3662 } |
3635 | 3663 |
3636 | 3664 |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4493 case kBackingStore: | 4521 case kBackingStore: |
4494 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 4522 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
4495 stream->Add("[backing-store]"); | 4523 stream->Add("[backing-store]"); |
4496 break; | 4524 break; |
4497 } | 4525 } |
4498 | 4526 |
4499 stream->Add("@%d", offset()); | 4527 stream->Add("@%d", offset()); |
4500 } | 4528 } |
4501 | 4529 |
4502 } } // namespace v8::internal | 4530 } } // namespace v8::internal |
OLD | NEW |