Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: src/hydrogen-instructions.cc

Issue 700963002: Replace C++ bitfields with our own BitFields (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fixed AST node field sizes; more scanner fixes; undid hydrogen.h/cc changes Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/profile-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/double.h" 8 #include "src/double.h"
9 #include "src/factory.h" 9 #include "src/factory.h"
10 #include "src/hydrogen-infer-representation.h" 10 #include "src/hydrogen-infer-representation.h"
(...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 : HValue::InferRange(zone); 1782 : HValue::InferRange(zone);
1783 result->set_can_be_minus_zero(!to().IsSmiOrInteger32() || 1783 result->set_can_be_minus_zero(!to().IsSmiOrInteger32() ||
1784 !(CheckFlag(kAllUsesTruncatingToInt32) || 1784 !(CheckFlag(kAllUsesTruncatingToInt32) ||
1785 CheckFlag(kAllUsesTruncatingToSmi))); 1785 CheckFlag(kAllUsesTruncatingToSmi)));
1786 if (to().IsSmi()) result->ClampToSmi(); 1786 if (to().IsSmi()) result->ClampToSmi();
1787 return result; 1787 return result;
1788 } 1788 }
1789 1789
1790 1790
1791 Range* HConstant::InferRange(Zone* zone) { 1791 Range* HConstant::InferRange(Zone* zone) {
1792 if (has_int32_value_) { 1792 if (HasInteger32Value()) {
1793 Range* result = new(zone) Range(int32_value_, int32_value_); 1793 Range* result = new(zone) Range(int32_value_, int32_value_);
1794 result->set_can_be_minus_zero(false); 1794 result->set_can_be_minus_zero(false);
1795 return result; 1795 return result;
1796 } 1796 }
1797 return HValue::InferRange(zone); 1797 return HValue::InferRange(zone);
1798 } 1798 }
1799 1799
1800 1800
1801 HSourcePosition HPhi::position() const { 1801 HSourcePosition HPhi::position() const {
1802 return block()->first()->position(); 1802 return block()->first()->position();
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
2599 } 2599 }
2600 os << NameOf(values_[i]); 2600 os << NameOf(values_[i]);
2601 if (i > 0) os << ","; 2601 if (i > 0) os << ",";
2602 } 2602 }
2603 } 2603 }
2604 return os; 2604 return os;
2605 } 2605 }
2606 2606
2607 2607
2608 void HSimulate::ReplayEnvironment(HEnvironment* env) { 2608 void HSimulate::ReplayEnvironment(HEnvironment* env) {
2609 if (done_with_replay_) return; 2609 if (is_done_with_replay()) return;
2610 DCHECK(env != NULL); 2610 DCHECK(env != NULL);
2611 env->set_ast_id(ast_id()); 2611 env->set_ast_id(ast_id());
2612 env->Drop(pop_count()); 2612 env->Drop(pop_count());
2613 for (int i = values()->length() - 1; i >= 0; --i) { 2613 for (int i = values()->length() - 1; i >= 0; --i) {
2614 HValue* value = values()->at(i); 2614 HValue* value = values()->at(i);
2615 if (HasAssignedIndexAt(i)) { 2615 if (HasAssignedIndexAt(i)) {
2616 env->Bind(GetAssignedIndexAt(i), value); 2616 env->Bind(GetAssignedIndexAt(i), value);
2617 } else { 2617 } else {
2618 env->Push(value); 2618 env->Push(value);
2619 } 2619 }
2620 } 2620 }
2621 done_with_replay_ = true; 2621 set_done_with_replay();
2622 } 2622 }
2623 2623
2624 2624
2625 static void ReplayEnvironmentNested(const ZoneList<HValue*>* values, 2625 static void ReplayEnvironmentNested(const ZoneList<HValue*>* values,
2626 HCapturedObject* other) { 2626 HCapturedObject* other) {
2627 for (int i = 0; i < values->length(); ++i) { 2627 for (int i = 0; i < values->length(); ++i) {
2628 HValue* value = values->at(i); 2628 HValue* value = values->at(i);
2629 if (value->IsCapturedObject()) { 2629 if (value->IsCapturedObject()) {
2630 if (HCapturedObject::cast(value)->capture_id() == other->capture_id()) { 2630 if (HCapturedObject::cast(value)->capture_id() == other->capture_id()) {
2631 values->at(i) = other; 2631 values->at(i) = other;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2667 } 2667 }
2668 2668
2669 2669
2670 static bool IsInteger32(double value) { 2670 static bool IsInteger32(double value) {
2671 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value)); 2671 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value));
2672 return bit_cast<int64_t>(roundtrip_value) == bit_cast<int64_t>(value); 2672 return bit_cast<int64_t>(roundtrip_value) == bit_cast<int64_t>(value);
2673 } 2673 }
2674 2674
2675 2675
2676 HConstant::HConstant(Handle<Object> object, Representation r) 2676 HConstant::HConstant(Handle<Object> object, Representation r)
2677 : HTemplateInstruction<0>(HType::FromValue(object)), 2677 : HTemplateInstruction<0>(HType::FromValue(object)),
2678 object_(Unique<Object>::CreateUninitialized(object)), 2678 object_(Unique<Object>::CreateUninitialized(object)),
2679 object_map_(Handle<Map>::null()), 2679 object_map_(Handle<Map>::null()),
2680 has_stable_map_value_(false), 2680 bit_field_(HasStableMapValueField::encode(false) |
2681 has_smi_value_(false), 2681 HasSmiValueField::encode(false) |
2682 has_int32_value_(false), 2682 HasInt32ValueField::encode(false) |
2683 has_double_value_(false), 2683 HasDoubleValueField::encode(false) |
2684 has_external_reference_value_(false), 2684 HasExternalReferenceValueField::encode(false) |
2685 is_not_in_new_space_(true), 2685 IsNotInNewSpaceField::encode(true) |
2686 boolean_value_(object->BooleanValue()), 2686 BooleanValueField::encode(object->BooleanValue()) |
2687 is_undetectable_(false), 2687 IsUndetectableField::encode(false) |
2688 instance_type_(kUnknownInstanceType) { 2688 InstanceTypeField::encode(kUnknownInstanceType)) {
2689 if (object->IsHeapObject()) { 2689 if (object->IsHeapObject()) {
2690 Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object); 2690 Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object);
2691 Isolate* isolate = heap_object->GetIsolate(); 2691 Isolate* isolate = heap_object->GetIsolate();
2692 Handle<Map> map(heap_object->map(), isolate); 2692 Handle<Map> map(heap_object->map(), isolate);
2693 is_not_in_new_space_ = !isolate->heap()->InNewSpace(*object); 2693 bit_field_ = IsNotInNewSpaceField::update(
2694 instance_type_ = map->instance_type(); 2694 bit_field_, !isolate->heap()->InNewSpace(*object));
2695 is_undetectable_ = map->is_undetectable(); 2695 bit_field_ = InstanceTypeField::update(bit_field_, map->instance_type());
2696 bit_field_ =
2697 IsUndetectableField::update(bit_field_, map->is_undetectable());
2696 if (map->is_stable()) object_map_ = Unique<Map>::CreateImmovable(map); 2698 if (map->is_stable()) object_map_ = Unique<Map>::CreateImmovable(map);
2697 has_stable_map_value_ = (instance_type_ == MAP_TYPE && 2699 bit_field_ = HasStableMapValueField::update(
2698 Handle<Map>::cast(heap_object)->is_stable()); 2700 bit_field_,
2701 HasMapValue() && Handle<Map>::cast(heap_object)->is_stable());
2699 } 2702 }
2700 if (object->IsNumber()) { 2703 if (object->IsNumber()) {
2701 double n = object->Number(); 2704 double n = object->Number();
2702 has_int32_value_ = IsInteger32(n); 2705 bool has_int32_value = IsInteger32(n);
2706 bit_field_ = HasInt32ValueField::update(bit_field_, has_int32_value);
2703 int32_value_ = DoubleToInt32(n); 2707 int32_value_ = DoubleToInt32(n);
2704 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); 2708 bit_field_ = HasSmiValueField::update(
2709 bit_field_, has_int32_value && Smi::IsValid(int32_value_));
2705 double_value_ = n; 2710 double_value_ = n;
2706 has_double_value_ = true; 2711 bit_field_ = HasDoubleValueField::update(bit_field_, true);
2707 // TODO(titzer): if this heap number is new space, tenure a new one. 2712 // TODO(titzer): if this heap number is new space, tenure a new one.
2708 } 2713 }
2709 2714
2710 Initialize(r); 2715 Initialize(r);
2711 } 2716 }
2712 2717
2713 2718
2714 HConstant::HConstant(Unique<Object> object, 2719 HConstant::HConstant(Unique<Object> object, Unique<Map> object_map,
2715 Unique<Map> object_map, 2720 bool has_stable_map_value, Representation r, HType type,
2716 bool has_stable_map_value, 2721 bool is_not_in_new_space, bool boolean_value,
2717 Representation r, 2722 bool is_undetectable, InstanceType instance_type)
2718 HType type, 2723 : HTemplateInstruction<0>(type),
2719 bool is_not_in_new_space, 2724 object_(object),
2720 bool boolean_value, 2725 object_map_(object_map),
2721 bool is_undetectable, 2726 bit_field_(HasStableMapValueField::encode(has_stable_map_value) |
2722 InstanceType instance_type) 2727 HasSmiValueField::encode(false) |
2723 : HTemplateInstruction<0>(type), 2728 HasInt32ValueField::encode(false) |
2724 object_(object), 2729 HasDoubleValueField::encode(false) |
2725 object_map_(object_map), 2730 HasExternalReferenceValueField::encode(false) |
2726 has_stable_map_value_(has_stable_map_value), 2731 IsNotInNewSpaceField::encode(is_not_in_new_space) |
2727 has_smi_value_(false), 2732 BooleanValueField::encode(boolean_value) |
2728 has_int32_value_(false), 2733 IsUndetectableField::encode(is_undetectable) |
2729 has_double_value_(false), 2734 InstanceTypeField::encode(instance_type)) {
2730 has_external_reference_value_(false),
2731 is_not_in_new_space_(is_not_in_new_space),
2732 boolean_value_(boolean_value),
2733 is_undetectable_(is_undetectable),
2734 instance_type_(instance_type) {
2735 DCHECK(!object.handle().is_null()); 2735 DCHECK(!object.handle().is_null());
2736 DCHECK(!type.IsTaggedNumber() || type.IsNone()); 2736 DCHECK(!type.IsTaggedNumber() || type.IsNone());
2737 Initialize(r); 2737 Initialize(r);
2738 } 2738 }
2739 2739
2740 2740
2741 HConstant::HConstant(int32_t integer_value, 2741 HConstant::HConstant(int32_t integer_value, Representation r,
2742 Representation r, 2742 bool is_not_in_new_space, Unique<Object> object)
2743 bool is_not_in_new_space, 2743 : object_(object),
2744 Unique<Object> object) 2744 object_map_(Handle<Map>::null()),
2745 : object_(object), 2745 bit_field_(HasStableMapValueField::encode(false) |
2746 object_map_(Handle<Map>::null()), 2746 HasSmiValueField::encode(Smi::IsValid(integer_value)) |
2747 has_stable_map_value_(false), 2747 HasInt32ValueField::encode(true) |
2748 has_smi_value_(Smi::IsValid(integer_value)), 2748 HasDoubleValueField::encode(true) |
2749 has_int32_value_(true), 2749 HasExternalReferenceValueField::encode(false) |
2750 has_double_value_(true), 2750 IsNotInNewSpaceField::encode(is_not_in_new_space) |
2751 has_external_reference_value_(false), 2751 BooleanValueField::encode(integer_value != 0) |
2752 is_not_in_new_space_(is_not_in_new_space), 2752 IsUndetectableField::encode(false) |
2753 boolean_value_(integer_value != 0), 2753 InstanceTypeField::encode(kUnknownInstanceType)),
2754 is_undetectable_(false), 2754 int32_value_(integer_value),
2755 int32_value_(integer_value), 2755 double_value_(FastI2D(integer_value)) {
2756 double_value_(FastI2D(integer_value)),
2757 instance_type_(kUnknownInstanceType) {
2758 // It's possible to create a constant with a value in Smi-range but stored 2756 // It's possible to create a constant with a value in Smi-range but stored
2759 // in a (pre-existing) HeapNumber. See crbug.com/349878. 2757 // in a (pre-existing) HeapNumber. See crbug.com/349878.
2760 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null(); 2758 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null();
2761 bool is_smi = has_smi_value_ && !could_be_heapobject; 2759 bool is_smi = HasSmiValue() && !could_be_heapobject;
2762 set_type(is_smi ? HType::Smi() : HType::TaggedNumber()); 2760 set_type(is_smi ? HType::Smi() : HType::TaggedNumber());
2763 Initialize(r); 2761 Initialize(r);
2764 } 2762 }
2765 2763
2766 2764
2767 HConstant::HConstant(double double_value, 2765 HConstant::HConstant(double double_value, Representation r,
2768 Representation r, 2766 bool is_not_in_new_space, Unique<Object> object)
2769 bool is_not_in_new_space, 2767 : object_(object),
2770 Unique<Object> object) 2768 object_map_(Handle<Map>::null()),
2771 : object_(object), 2769 bit_field_(HasStableMapValueField::encode(false) |
2772 object_map_(Handle<Map>::null()), 2770 HasInt32ValueField::encode(IsInteger32(double_value)) |
2773 has_stable_map_value_(false), 2771 HasDoubleValueField::encode(true) |
2774 has_int32_value_(IsInteger32(double_value)), 2772 HasExternalReferenceValueField::encode(false) |
2775 has_double_value_(true), 2773 IsNotInNewSpaceField::encode(is_not_in_new_space) |
2776 has_external_reference_value_(false), 2774 BooleanValueField::encode(double_value != 0 &&
2777 is_not_in_new_space_(is_not_in_new_space), 2775 !std::isnan(double_value)) |
2778 boolean_value_(double_value != 0 && !std::isnan(double_value)), 2776 IsUndetectableField::encode(false) |
2779 is_undetectable_(false), 2777 InstanceTypeField::encode(kUnknownInstanceType)),
2780 int32_value_(DoubleToInt32(double_value)), 2778 int32_value_(DoubleToInt32(double_value)),
2781 double_value_(double_value), 2779 double_value_(double_value) {
2782 instance_type_(kUnknownInstanceType) { 2780 bit_field_ = HasSmiValueField::update(
2783 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); 2781 bit_field_, HasInteger32Value() && Smi::IsValid(int32_value_));
2784 // It's possible to create a constant with a value in Smi-range but stored 2782 // It's possible to create a constant with a value in Smi-range but stored
2785 // in a (pre-existing) HeapNumber. See crbug.com/349878. 2783 // in a (pre-existing) HeapNumber. See crbug.com/349878.
2786 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null(); 2784 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null();
2787 bool is_smi = has_smi_value_ && !could_be_heapobject; 2785 bool is_smi = HasSmiValue() && !could_be_heapobject;
2788 set_type(is_smi ? HType::Smi() : HType::TaggedNumber()); 2786 set_type(is_smi ? HType::Smi() : HType::TaggedNumber());
2789 Initialize(r); 2787 Initialize(r);
2790 } 2788 }
2791 2789
2792 2790
2793 HConstant::HConstant(ExternalReference reference) 2791 HConstant::HConstant(ExternalReference reference)
2794 : HTemplateInstruction<0>(HType::Any()), 2792 : HTemplateInstruction<0>(HType::Any()),
2795 object_(Unique<Object>(Handle<Object>::null())), 2793 object_(Unique<Object>(Handle<Object>::null())),
2796 object_map_(Handle<Map>::null()), 2794 object_map_(Handle<Map>::null()),
2797 has_stable_map_value_(false), 2795 bit_field_(
2798 has_smi_value_(false), 2796 HasStableMapValueField::encode(false) |
2799 has_int32_value_(false), 2797 HasSmiValueField::encode(false) | HasInt32ValueField::encode(false) |
2800 has_double_value_(false), 2798 HasDoubleValueField::encode(false) |
2801 has_external_reference_value_(true), 2799 HasExternalReferenceValueField::encode(true) |
2802 is_not_in_new_space_(true), 2800 IsNotInNewSpaceField::encode(true) | BooleanValueField::encode(true) |
2803 boolean_value_(true), 2801 IsUndetectableField::encode(false) |
2804 is_undetectable_(false), 2802 InstanceTypeField::encode(kUnknownInstanceType)),
2805 external_reference_value_(reference), 2803 external_reference_value_(reference) {
2806 instance_type_(kUnknownInstanceType) {
2807 Initialize(Representation::External()); 2804 Initialize(Representation::External());
2808 } 2805 }
2809 2806
2810 2807
2811 void HConstant::Initialize(Representation r) { 2808 void HConstant::Initialize(Representation r) {
2812 if (r.IsNone()) { 2809 if (r.IsNone()) {
2813 if (has_smi_value_ && SmiValuesAre31Bits()) { 2810 if (HasSmiValue() && SmiValuesAre31Bits()) {
2814 r = Representation::Smi(); 2811 r = Representation::Smi();
2815 } else if (has_int32_value_) { 2812 } else if (HasInteger32Value()) {
2816 r = Representation::Integer32(); 2813 r = Representation::Integer32();
2817 } else if (has_double_value_) { 2814 } else if (HasDoubleValue()) {
2818 r = Representation::Double(); 2815 r = Representation::Double();
2819 } else if (has_external_reference_value_) { 2816 } else if (HasExternalReferenceValue()) {
2820 r = Representation::External(); 2817 r = Representation::External();
2821 } else { 2818 } else {
2822 Handle<Object> object = object_.handle(); 2819 Handle<Object> object = object_.handle();
2823 if (object->IsJSObject()) { 2820 if (object->IsJSObject()) {
2824 // Try to eagerly migrate JSObjects that have deprecated maps. 2821 // Try to eagerly migrate JSObjects that have deprecated maps.
2825 Handle<JSObject> js_object = Handle<JSObject>::cast(object); 2822 Handle<JSObject> js_object = Handle<JSObject>::cast(object);
2826 if (js_object->map()->is_deprecated()) { 2823 if (js_object->map()->is_deprecated()) {
2827 JSObject::TryMigrateInstance(js_object); 2824 JSObject::TryMigrateInstance(js_object);
2828 } 2825 }
2829 } 2826 }
2830 r = Representation::Tagged(); 2827 r = Representation::Tagged();
2831 } 2828 }
2832 } 2829 }
2833 if (r.IsSmi()) { 2830 if (r.IsSmi()) {
2834 // If we have an existing handle, zap it, because it might be a heap 2831 // If we have an existing handle, zap it, because it might be a heap
2835 // number which we must not re-use when copying this HConstant to 2832 // number which we must not re-use when copying this HConstant to
2836 // Tagged representation later, because having Smi representation now 2833 // Tagged representation later, because having Smi representation now
2837 // could cause heap object checks not to get emitted. 2834 // could cause heap object checks not to get emitted.
2838 object_ = Unique<Object>(Handle<Object>::null()); 2835 object_ = Unique<Object>(Handle<Object>::null());
2839 } 2836 }
2840 set_representation(r); 2837 set_representation(r);
2841 SetFlag(kUseGVN); 2838 SetFlag(kUseGVN);
2842 } 2839 }
2843 2840
2844 2841
2845 bool HConstant::ImmortalImmovable() const { 2842 bool HConstant::ImmortalImmovable() const {
2846 if (has_int32_value_) { 2843 if (HasInteger32Value()) {
2847 return false; 2844 return false;
2848 } 2845 }
2849 if (has_double_value_) { 2846 if (HasDoubleValue()) {
2850 if (IsSpecialDouble()) { 2847 if (IsSpecialDouble()) {
2851 return true; 2848 return true;
2852 } 2849 }
2853 return false; 2850 return false;
2854 } 2851 }
2855 if (has_external_reference_value_) { 2852 if (HasExternalReferenceValue()) {
2856 return false; 2853 return false;
2857 } 2854 }
2858 2855
2859 DCHECK(!object_.handle().is_null()); 2856 DCHECK(!object_.handle().is_null());
2860 Heap* heap = isolate()->heap(); 2857 Heap* heap = isolate()->heap();
2861 DCHECK(!object_.IsKnownGlobal(heap->minus_zero_value())); 2858 DCHECK(!object_.IsKnownGlobal(heap->minus_zero_value()));
2862 DCHECK(!object_.IsKnownGlobal(heap->nan_value())); 2859 DCHECK(!object_.IsKnownGlobal(heap->nan_value()));
2863 return 2860 return
2864 #define IMMORTAL_IMMOVABLE_ROOT(name) \ 2861 #define IMMORTAL_IMMOVABLE_ROOT(name) \
2865 object_.IsKnownGlobal(heap->root(Heap::k##name##RootIndex)) || 2862 object_.IsKnownGlobal(heap->root(Heap::k##name##RootIndex)) ||
(...skipping 20 matching lines...) Expand all
2886 } 2883 }
2887 if (HasNoUses()) return true; 2884 if (HasNoUses()) return true;
2888 if (IsCell()) return false; 2885 if (IsCell()) return false;
2889 if (representation().IsDouble()) return false; 2886 if (representation().IsDouble()) return false;
2890 if (representation().IsExternal()) return false; 2887 if (representation().IsExternal()) return false;
2891 return true; 2888 return true;
2892 } 2889 }
2893 2890
2894 2891
2895 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { 2892 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const {
2896 if (r.IsSmi() && !has_smi_value_) return NULL; 2893 if (r.IsSmi() && !HasSmiValue()) return NULL;
2897 if (r.IsInteger32() && !has_int32_value_) return NULL; 2894 if (r.IsInteger32() && !HasInteger32Value()) return NULL;
2898 if (r.IsDouble() && !has_double_value_) return NULL; 2895 if (r.IsDouble() && !HasDoubleValue()) return NULL;
2899 if (r.IsExternal() && !has_external_reference_value_) return NULL; 2896 if (r.IsExternal() && !HasExternalReferenceValue()) return NULL;
2900 if (has_int32_value_) { 2897 if (HasInteger32Value()) {
2901 return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, object_); 2898 return new (zone) HConstant(int32_value_, r, NotInNewSpace(), object_);
2902 } 2899 }
2903 if (has_double_value_) { 2900 if (HasDoubleValue()) {
2904 return new(zone) HConstant(double_value_, r, is_not_in_new_space_, object_); 2901 return new (zone) HConstant(double_value_, r, NotInNewSpace(), object_);
2905 } 2902 }
2906 if (has_external_reference_value_) { 2903 if (HasExternalReferenceValue()) {
2907 return new(zone) HConstant(external_reference_value_); 2904 return new(zone) HConstant(external_reference_value_);
2908 } 2905 }
2909 DCHECK(!object_.handle().is_null()); 2906 DCHECK(!object_.handle().is_null());
2910 return new(zone) HConstant(object_, 2907 return new (zone) HConstant(object_, object_map_, HasStableMapValue(), r,
2911 object_map_, 2908 type_, NotInNewSpace(), BooleanValue(),
2912 has_stable_map_value_, 2909 IsUndetectable(), GetInstanceType());
2913 r,
2914 type_,
2915 is_not_in_new_space_,
2916 boolean_value_,
2917 is_undetectable_,
2918 instance_type_);
2919 } 2910 }
2920 2911
2921 2912
2922 Maybe<HConstant*> HConstant::CopyToTruncatedInt32(Zone* zone) { 2913 Maybe<HConstant*> HConstant::CopyToTruncatedInt32(Zone* zone) {
2923 HConstant* res = NULL; 2914 HConstant* res = NULL;
2924 if (has_int32_value_) { 2915 if (HasInteger32Value()) {
2925 res = new(zone) HConstant(int32_value_, 2916 res = new (zone) HConstant(int32_value_, Representation::Integer32(),
2926 Representation::Integer32(), 2917 NotInNewSpace(), object_);
2927 is_not_in_new_space_, 2918 } else if (HasDoubleValue()) {
2928 object_); 2919 res = new (zone)
2929 } else if (has_double_value_) { 2920 HConstant(DoubleToInt32(double_value_), Representation::Integer32(),
2930 res = new(zone) HConstant(DoubleToInt32(double_value_), 2921 NotInNewSpace(), object_);
2931 Representation::Integer32(),
2932 is_not_in_new_space_,
2933 object_);
2934 } 2922 }
2935 return Maybe<HConstant*>(res != NULL, res); 2923 return Maybe<HConstant*>(res != NULL, res);
2936 } 2924 }
2937 2925
2938 2926
2939 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) { 2927 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) {
2940 HConstant* res = NULL; 2928 HConstant* res = NULL;
2941 Handle<Object> handle = this->handle(zone->isolate()); 2929 Handle<Object> handle = this->handle(zone->isolate());
2942 if (handle->IsBoolean()) { 2930 if (handle->IsBoolean()) {
2943 res = handle->BooleanValue() ? 2931 res = handle->BooleanValue() ?
2944 new(zone) HConstant(1) : new(zone) HConstant(0); 2932 new(zone) HConstant(1) : new(zone) HConstant(0);
2945 } else if (handle->IsUndefined()) { 2933 } else if (handle->IsUndefined()) {
2946 res = new(zone) HConstant(base::OS::nan_value()); 2934 res = new(zone) HConstant(base::OS::nan_value());
2947 } else if (handle->IsNull()) { 2935 } else if (handle->IsNull()) {
2948 res = new(zone) HConstant(0); 2936 res = new(zone) HConstant(0);
2949 } 2937 }
2950 return Maybe<HConstant*>(res != NULL, res); 2938 return Maybe<HConstant*>(res != NULL, res);
2951 } 2939 }
2952 2940
2953 2941
2954 std::ostream& HConstant::PrintDataTo(std::ostream& os) const { // NOLINT 2942 std::ostream& HConstant::PrintDataTo(std::ostream& os) const { // NOLINT
2955 if (has_int32_value_) { 2943 if (HasInteger32Value()) {
2956 os << int32_value_ << " "; 2944 os << int32_value_ << " ";
2957 } else if (has_double_value_) { 2945 } else if (HasDoubleValue()) {
2958 os << double_value_ << " "; 2946 os << double_value_ << " ";
2959 } else if (has_external_reference_value_) { 2947 } else if (HasExternalReferenceValue()) {
2960 os << reinterpret_cast<void*>(external_reference_value_.address()) << " "; 2948 os << reinterpret_cast<void*>(external_reference_value_.address()) << " ";
2961 } else { 2949 } else {
2962 // The handle() method is silently and lazily mutating the object. 2950 // The handle() method is silently and lazily mutating the object.
2963 Handle<Object> h = const_cast<HConstant*>(this)->handle(Isolate::Current()); 2951 Handle<Object> h = const_cast<HConstant*>(this)->handle(Isolate::Current());
2964 os << Brief(*h) << " "; 2952 os << Brief(*h) << " ";
2965 if (HasStableMapValue()) os << "[stable-map] "; 2953 if (HasStableMapValue()) os << "[stable-map] ";
2966 if (HasObjectMap()) os << "[map " << *ObjectMap().handle() << "] "; 2954 if (HasObjectMap()) os << "[map " << *ObjectMap().handle() << "] ";
2967 } 2955 }
2968 if (!is_not_in_new_space_) os << "[new space] "; 2956 if (!NotInNewSpace()) os << "[new space] ";
2969 return os; 2957 return os;
2970 } 2958 }
2971 2959
2972 2960
2973 std::ostream& HBinaryOperation::PrintDataTo(std::ostream& os) const { // NOLINT 2961 std::ostream& HBinaryOperation::PrintDataTo(std::ostream& os) const { // NOLINT
2974 os << NameOf(left()) << " " << NameOf(right()); 2962 os << NameOf(left()) << " " << NameOf(right());
2975 if (CheckFlag(kCanOverflow)) os << " !"; 2963 if (CheckFlag(kCanOverflow)) os << " !";
2976 if (CheckFlag(kBailoutOnMinusZero)) os << " -0?"; 2964 if (CheckFlag(kBailoutOnMinusZero)) os << " -0?";
2977 return os; 2965 return os;
2978 } 2966 }
(...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after
4801 break; 4789 break;
4802 case HObjectAccess::kExternalMemory: 4790 case HObjectAccess::kExternalMemory:
4803 os << "[external-memory]"; 4791 os << "[external-memory]";
4804 break; 4792 break;
4805 } 4793 }
4806 4794
4807 return os << "@" << access.offset(); 4795 return os << "@" << access.offset();
4808 } 4796 }
4809 4797
4810 } } // namespace v8::internal 4798 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698