[dart2js/ddc] Add null checks to with<X|Y|Z|W> methods

Fixes test failures in lib/typed_data/simd_type_null_params_weak_test.

It appears that these methods are intended to retain the null checks
and failures in weak mode based on the discussion in the migration
https://dart-review.googlesource.com/c/sdk/+/132341.

Change-Id: Ieeb1730059a57b2edf1b5d235cd7a4133d4844df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152909
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
This commit is contained in:
Nicholas Shahan 2020-07-06 22:06:42 +00:00 committed by commit-bot@chromium.org
parent 0d44449aaa
commit 4140853675
2 changed files with 21 additions and 8 deletions

View file

@ -1361,21 +1361,25 @@ class NativeFloat32x4 implements Float32x4 {
/// Copy [this] and replace the [x] lane.
Float32x4 withX(double newX) {
ArgumentError.checkNotNull(newX);
return NativeFloat32x4._truncated(_truncate(newX), y, z, w);
}
/// Copy [this] and replace the [y] lane.
Float32x4 withY(double newY) {
ArgumentError.checkNotNull(newY);
return NativeFloat32x4._truncated(x, _truncate(newY), z, w);
}
/// Copy [this] and replace the [z] lane.
Float32x4 withZ(double newZ) {
ArgumentError.checkNotNull(newZ);
return NativeFloat32x4._truncated(x, y, _truncate(newZ), w);
}
/// Copy [this] and replace the [w] lane.
Float32x4 withW(double newW) {
ArgumentError.checkNotNull(newW);
return NativeFloat32x4._truncated(x, y, z, _truncate(newW));
}
@ -1583,24 +1587,28 @@ class NativeInt32x4 implements Int32x4 {
/// Returns a new [Int32x4] copied from [this] with a new x value.
Int32x4 withX(int x) {
ArgumentError.checkNotNull(x);
int _x = _truncate(x);
return NativeInt32x4._truncated(_x, y, z, w);
}
/// Returns a new [Int32x4] copied from [this] with a new y value.
Int32x4 withY(int y) {
ArgumentError.checkNotNull(y);
int _y = _truncate(y);
return NativeInt32x4._truncated(x, _y, z, w);
}
/// Returns a new [Int32x4] copied from [this] with a new z value.
Int32x4 withZ(int z) {
ArgumentError.checkNotNull(z);
int _z = _truncate(z);
return NativeInt32x4._truncated(x, y, _z, w);
}
/// Returns a new [Int32x4] copied from [this] with a new w value.
Int32x4 withW(int w) {
ArgumentError.checkNotNull(w);
int _w = _truncate(w);
return NativeInt32x4._truncated(x, y, z, _w);
}

View file

@ -11,6 +11,7 @@ import 'dart:_internal' show FixedLengthListMixin hide Symbol;
import 'dart:_interceptors' show JSIndexable, JSUInt32, JSUInt31;
import 'dart:_js_helper'
show
checkNum,
Creates,
JavaScriptIndexingBehavior,
JSName,
@ -1351,22 +1352,26 @@ class NativeFloat32x4 implements Float32x4 {
/// Copy [this] and replace the [x] lane.
Float32x4 withX(double newX) {
return NativeFloat32x4._truncated(_truncate(newX), y, z, w);
double _newX = _truncate(checkNum(newX));
return NativeFloat32x4._truncated(_newX, y, z, w);
}
/// Copy [this] and replace the [y] lane.
Float32x4 withY(double newY) {
return NativeFloat32x4._truncated(x, _truncate(newY), z, w);
double _newY = _truncate(checkNum(newY));
return NativeFloat32x4._truncated(x, _newY, z, w);
}
/// Copy [this] and replace the [z] lane.
Float32x4 withZ(double newZ) {
return NativeFloat32x4._truncated(x, y, _truncate(newZ), w);
double _newZ = _truncate(checkNum(newZ));
return NativeFloat32x4._truncated(x, y, _newZ, w);
}
/// Copy [this] and replace the [w] lane.
Float32x4 withW(double newW) {
return NativeFloat32x4._truncated(x, y, z, _truncate(newW));
double _newW = _truncate(checkNum(newW));
return NativeFloat32x4._truncated(x, y, z, _newW);
}
/// Returns the lane-wise minimum value in [this] or [other].
@ -1573,25 +1578,25 @@ class NativeInt32x4 implements Int32x4 {
/// Returns a new [Int32x4] copied from [this] with a new x value.
Int32x4 withX(int x) {
int _x = _truncate(x);
int _x = _truncate(checkNum(x));
return NativeInt32x4._truncated(_x, y, z, w);
}
/// Returns a new [Int32x4] copied from [this] with a new y value.
Int32x4 withY(int y) {
int _y = _truncate(y);
int _y = _truncate(checkNum(y));
return NativeInt32x4._truncated(x, _y, z, w);
}
/// Returns a new [Int32x4] copied from [this] with a new z value.
Int32x4 withZ(int z) {
int _z = _truncate(z);
int _z = _truncate(checkNum(z));
return NativeInt32x4._truncated(x, y, _z, w);
}
/// Returns a new [Int32x4] copied from [this] with a new w value.
Int32x4 withW(int w) {
int _w = _truncate(w);
int _w = _truncate(checkNum(w));
return NativeInt32x4._truncated(x, y, z, _w);
}