mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 12:57:42 +00:00
[build] Include FPESAN in UBSAN.
TEST=ubsan Bug: b/301044910 Change-Id: I608dd742a243bc1ab620c92da46e48270d6b060f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327041 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com>
This commit is contained in:
parent
2502e4e385
commit
8e6191c7f9
|
@ -133,8 +133,16 @@ config("compiler") {
|
|||
ldflags += [ "-fsanitize=thread" ]
|
||||
}
|
||||
if (is_ubsan) {
|
||||
cflags += [ "-fsanitize=undefined" ]
|
||||
ldflags += [ "-fsanitize=undefined" ]
|
||||
cflags += [
|
||||
"-fsanitize=undefined",
|
||||
"-fsanitize=float-divide-by-zero",
|
||||
"-fsanitize=float-cast-overflow",
|
||||
]
|
||||
ldflags += [
|
||||
"-fsanitize=undefined",
|
||||
"-fsanitize=float-divide-by-zero",
|
||||
"-fsanitize=float-cast-overflow",
|
||||
]
|
||||
}
|
||||
|
||||
if (use_custom_libcxx) {
|
||||
|
|
|
@ -33,7 +33,11 @@ config("sanitizer_options_link_helper") {
|
|||
ldflags += [ "-fsanitize=thread" ]
|
||||
}
|
||||
if (is_ubsan) {
|
||||
ldflags += [ "-fsanitize=undefined" ]
|
||||
ldflags += [
|
||||
"-fsanitize=undefined",
|
||||
"-fsanitize=float-divide-by-zero",
|
||||
"-fsanitize=float-cast-overflow",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ DEFINE_NATIVE_ENTRY(Double_div, 0, 2) {
|
|||
if (FLAG_trace_intrinsified_natives) {
|
||||
OS::PrintErr("Double_div %f / %f\n", left, right);
|
||||
}
|
||||
return Double::New(left / right);
|
||||
return Double::New(Utils::DivideAllowZero(left, right));
|
||||
}
|
||||
|
||||
DEFINE_NATIVE_ENTRY(Double_modulo, 0, 2) {
|
||||
|
|
|
@ -96,10 +96,10 @@ DEFINE_NATIVE_ENTRY(Float32x4_mul, 0, 2) {
|
|||
DEFINE_NATIVE_ENTRY(Float32x4_div, 0, 2) {
|
||||
GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0));
|
||||
GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1));
|
||||
float _x = self.x() / other.x();
|
||||
float _y = self.y() / other.y();
|
||||
float _z = self.z() / other.z();
|
||||
float _w = self.w() / other.w();
|
||||
float _x = Utils::DivideAllowZero(self.x(), other.x());
|
||||
float _y = Utils::DivideAllowZero(self.y(), other.y());
|
||||
float _z = Utils::DivideAllowZero(self.z(), other.z());
|
||||
float _w = Utils::DivideAllowZero(self.w(), other.w());
|
||||
return Float32x4::New(_x, _y, _z, _w);
|
||||
}
|
||||
|
||||
|
@ -361,19 +361,19 @@ DEFINE_NATIVE_ENTRY(Float32x4_sqrt, 0, 1) {
|
|||
|
||||
DEFINE_NATIVE_ENTRY(Float32x4_reciprocal, 0, 1) {
|
||||
GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0));
|
||||
float _x = 1.0f / self.x();
|
||||
float _y = 1.0f / self.y();
|
||||
float _z = 1.0f / self.z();
|
||||
float _w = 1.0f / self.w();
|
||||
float _x = Utils::DivideAllowZero(1.0f, self.x());
|
||||
float _y = Utils::DivideAllowZero(1.0f, self.y());
|
||||
float _z = Utils::DivideAllowZero(1.0f, self.z());
|
||||
float _w = Utils::DivideAllowZero(1.0f, self.w());
|
||||
return Float32x4::New(_x, _y, _z, _w);
|
||||
}
|
||||
|
||||
DEFINE_NATIVE_ENTRY(Float32x4_reciprocalSqrt, 0, 1) {
|
||||
GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0));
|
||||
float _x = sqrtf(1.0f / self.x());
|
||||
float _y = sqrtf(1.0f / self.y());
|
||||
float _z = sqrtf(1.0f / self.z());
|
||||
float _w = sqrtf(1.0f / self.w());
|
||||
float _x = sqrtf(Utils::DivideAllowZero(1.0f, self.x()));
|
||||
float _y = sqrtf(Utils::DivideAllowZero(1.0f, self.y()));
|
||||
float _z = sqrtf(Utils::DivideAllowZero(1.0f, self.z()));
|
||||
float _w = sqrtf(Utils::DivideAllowZero(1.0f, self.w()));
|
||||
return Float32x4::New(_x, _y, _z, _w);
|
||||
}
|
||||
|
||||
|
@ -710,8 +710,8 @@ DEFINE_NATIVE_ENTRY(Float64x2_mul, 0, 2) {
|
|||
DEFINE_NATIVE_ENTRY(Float64x2_div, 0, 2) {
|
||||
GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0));
|
||||
GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, other, arguments->NativeArgAt(1));
|
||||
double _x = self.x() / other.x();
|
||||
double _y = self.y() / other.y();
|
||||
double _x = Utils::DivideAllowZero(self.x(), other.x());
|
||||
double _y = Utils::DivideAllowZero(self.y(), other.y());
|
||||
return Float64x2::New(_x, _y);
|
||||
}
|
||||
|
||||
|
|
|
@ -474,6 +474,21 @@ class Utils {
|
|||
(static_cast<Unsigned>(value) << ((width - rotate) & (width - 1)));
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
__attribute__((no_sanitize("float-divide-by-zero")))
|
||||
#endif
|
||||
static inline float
|
||||
DivideAllowZero(float a, float b) {
|
||||
return a / b;
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
__attribute__((no_sanitize("float-divide-by-zero")))
|
||||
#endif
|
||||
static inline double
|
||||
DivideAllowZero(double a, double b) {
|
||||
return a / b;
|
||||
}
|
||||
|
||||
// Utility functions for converting values from host endianness to
|
||||
// big or little endian values.
|
||||
static uint16_t HostToBigEndian16(uint16_t host_value);
|
||||
|
|
|
@ -200,7 +200,7 @@ double Evaluator::EvaluateDoubleOp(const double left,
|
|||
case Token::kMUL:
|
||||
return left * right;
|
||||
case Token::kDIV:
|
||||
return left / right;
|
||||
return Utils::DivideAllowZero(left, right);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue