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

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

Issue 809293003: Fixed -fsanitize=float-cast-overflow problems. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « src/factory.cc ('k') | no next file » | 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 2654 matching lines...) Expand 10 before | Expand all | Expand 10 after
2665 return_targets_.Add(return_target, zone); 2665 return_targets_.Add(return_target, zone);
2666 } 2666 }
2667 2667
2668 2668
2669 std::ostream& HEnterInlined::PrintDataTo(std::ostream& os) const { // NOLINT 2669 std::ostream& HEnterInlined::PrintDataTo(std::ostream& os) const { // NOLINT
2670 return os << function()->debug_name()->ToCString().get(); 2670 return os << function()->debug_name()->ToCString().get();
2671 } 2671 }
2672 2672
2673 2673
2674 static bool IsInteger32(double value) { 2674 static bool IsInteger32(double value) {
2675 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value)); 2675 if (value >= std::numeric_limits<int32_t>::min() &&
2676 return bit_cast<int64_t>(roundtrip_value) == bit_cast<int64_t>(value); 2676 value <= std::numeric_limits<int32_t>::max()) {
2677 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value));
2678 return bit_cast<int64_t>(roundtrip_value) == bit_cast<int64_t>(value);
2679 }
2680 return false;
2677 } 2681 }
2678 2682
2679 2683
2680 HConstant::HConstant(Handle<Object> object, Representation r) 2684 HConstant::HConstant(Handle<Object> object, Representation r)
2681 : HTemplateInstruction<0>(HType::FromValue(object)), 2685 : HTemplateInstruction<0>(HType::FromValue(object)),
2682 object_(Unique<Object>::CreateUninitialized(object)), 2686 object_(Unique<Object>::CreateUninitialized(object)),
2683 object_map_(Handle<Map>::null()), 2687 object_map_(Handle<Map>::null()),
2684 bit_field_(HasStableMapValueField::encode(false) | 2688 bit_field_(HasStableMapValueField::encode(false) |
2685 HasSmiValueField::encode(false) | 2689 HasSmiValueField::encode(false) |
2686 HasInt32ValueField::encode(false) | 2690 HasInt32ValueField::encode(false) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2772 object_map_(Handle<Map>::null()), 2776 object_map_(Handle<Map>::null()),
2773 bit_field_(HasStableMapValueField::encode(false) | 2777 bit_field_(HasStableMapValueField::encode(false) |
2774 HasInt32ValueField::encode(IsInteger32(double_value)) | 2778 HasInt32ValueField::encode(IsInteger32(double_value)) |
2775 HasDoubleValueField::encode(true) | 2779 HasDoubleValueField::encode(true) |
2776 HasExternalReferenceValueField::encode(false) | 2780 HasExternalReferenceValueField::encode(false) |
2777 IsNotInNewSpaceField::encode(is_not_in_new_space) | 2781 IsNotInNewSpaceField::encode(is_not_in_new_space) |
2778 BooleanValueField::encode(double_value != 0 && 2782 BooleanValueField::encode(double_value != 0 &&
2779 !std::isnan(double_value)) | 2783 !std::isnan(double_value)) |
2780 IsUndetectableField::encode(false) | 2784 IsUndetectableField::encode(false) |
2781 InstanceTypeField::encode(kUnknownInstanceType)), 2785 InstanceTypeField::encode(kUnknownInstanceType)),
2782 int32_value_(DoubleToInt32(double_value)), 2786 int32_value_(HasInteger32Value() ? DoubleToInt32(double_value) : 0),
2783 double_value_(double_value) { 2787 double_value_(double_value) {
2784 bit_field_ = HasSmiValueField::update( 2788 bit_field_ = HasSmiValueField::update(
2785 bit_field_, HasInteger32Value() && Smi::IsValid(int32_value_)); 2789 bit_field_, HasInteger32Value() && Smi::IsValid(int32_value_));
2786 // It's possible to create a constant with a value in Smi-range but stored 2790 // It's possible to create a constant with a value in Smi-range but stored
2787 // in a (pre-existing) HeapNumber. See crbug.com/349878. 2791 // in a (pre-existing) HeapNumber. See crbug.com/349878.
2788 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null(); 2792 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null();
2789 bool is_smi = HasSmiValue() && !could_be_heapobject; 2793 bool is_smi = HasSmiValue() && !could_be_heapobject;
2790 set_type(is_smi ? HType::Smi() : HType::TaggedNumber()); 2794 set_type(is_smi ? HType::Smi() : HType::TaggedNumber());
2791 Initialize(r); 2795 Initialize(r);
2792 } 2796 }
(...skipping 2012 matching lines...) Expand 10 before | Expand all | Expand 10 after
4805 break; 4809 break;
4806 case HObjectAccess::kExternalMemory: 4810 case HObjectAccess::kExternalMemory:
4807 os << "[external-memory]"; 4811 os << "[external-memory]";
4808 break; 4812 break;
4809 } 4813 }
4810 4814
4811 return os << "@" << access.offset(); 4815 return os << "@" << access.offset();
4812 } 4816 }
4813 4817
4814 } } // namespace v8::internal 4818 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698