OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #include "vm/bootstrap_natives.h" |
| 6 |
| 7 #include "vm/exceptions.h" |
| 8 #include "vm/native_entry.h" |
| 9 #include "vm/object.h" |
| 10 #include "vm/symbols.h" |
| 11 |
| 12 namespace dart { |
| 13 |
| 14 DEFINE_NATIVE_ENTRY(Float32x4_fromDoubles, 5) { |
| 15 ASSERT(AbstractTypeArguments::CheckedHandle( |
| 16 arguments->NativeArgAt(0)).IsNull()); |
| 17 GET_NON_NULL_NATIVE_ARGUMENT(Double, x, arguments->NativeArgAt(1)); |
| 18 GET_NON_NULL_NATIVE_ARGUMENT(Double, y, arguments->NativeArgAt(2)); |
| 19 GET_NON_NULL_NATIVE_ARGUMENT(Double, z, arguments->NativeArgAt(3)); |
| 20 GET_NON_NULL_NATIVE_ARGUMENT(Double, w, arguments->NativeArgAt(4)); |
| 21 float _x = x.value(); |
| 22 float _y = y.value(); |
| 23 float _z = z.value(); |
| 24 float _w = w.value(); |
| 25 return Float32x4::New(_x, _y, _z, _w); |
| 26 } |
| 27 |
| 28 |
| 29 DEFINE_NATIVE_ENTRY(Float32x4_zero, 1) { |
| 30 ASSERT(AbstractTypeArguments::CheckedHandle( |
| 31 arguments->NativeArgAt(0)).IsNull()); |
| 32 return Float32x4::New(0.0f, 0.0f, 0.0f, 0.0f); |
| 33 } |
| 34 |
| 35 |
| 36 DEFINE_NATIVE_ENTRY(Float32x4_add, 2) { |
| 37 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 38 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); |
| 39 float _x = self.x() + other.x(); |
| 40 float _y = self.y() + other.y(); |
| 41 float _z = self.z() + other.z(); |
| 42 float _w = self.w() + other.w(); |
| 43 return Float32x4::New(_x, _y, _z, _w); |
| 44 } |
| 45 |
| 46 |
| 47 DEFINE_NATIVE_ENTRY(Float32x4_negate, 1) { |
| 48 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 49 float _x = -self.x(); |
| 50 float _y = -self.y(); |
| 51 float _z = -self.z(); |
| 52 float _w = -self.w(); |
| 53 return Float32x4::New(_x, _y, _z, _w); |
| 54 } |
| 55 |
| 56 |
| 57 DEFINE_NATIVE_ENTRY(Float32x4_sub, 2) { |
| 58 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 59 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); |
| 60 float _x = self.x() - other.x(); |
| 61 float _y = self.y() - other.y(); |
| 62 float _z = self.z() - other.z(); |
| 63 float _w = self.w() - other.w(); |
| 64 return Float32x4::New(_x, _y, _z, _w); |
| 65 } |
| 66 |
| 67 |
| 68 DEFINE_NATIVE_ENTRY(Float32x4_mul, 2) { |
| 69 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 70 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, |
| 71 arguments->NativeArgAt(1)); |
| 72 float _x = self.x() * other.x(); |
| 73 float _y = self.y() * other.y(); |
| 74 float _z = self.z() * other.z(); |
| 75 float _w = self.w() * other.w(); |
| 76 return Float32x4::New(_x, _y, _z, _w); |
| 77 } |
| 78 |
| 79 |
| 80 DEFINE_NATIVE_ENTRY(Float32x4_div, 2) { |
| 81 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 82 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); |
| 83 float _x = self.x() / other.x(); |
| 84 float _y = self.y() / other.y(); |
| 85 float _z = self.z() / other.z(); |
| 86 float _w = self.w() / other.w(); |
| 87 return Float32x4::New(_x, _y, _z, _w); |
| 88 } |
| 89 |
| 90 |
| 91 DEFINE_NATIVE_ENTRY(Float32x4_cmplt, 2) { |
| 92 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, a, arguments->NativeArgAt(0)); |
| 93 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, b, arguments->NativeArgAt(1)); |
| 94 uint32_t _x = a.x() < b.x() ? 0xFFFFFFFF : 0x0; |
| 95 uint32_t _y = a.y() < b.y() ? 0xFFFFFFFF : 0x0; |
| 96 uint32_t _z = a.z() < b.z() ? 0xFFFFFFFF : 0x0; |
| 97 uint32_t _w = a.w() < b.w() ? 0xFFFFFFFF : 0x0; |
| 98 return Uint32x4::New(_x, _y, _z, _w); |
| 99 } |
| 100 |
| 101 |
| 102 DEFINE_NATIVE_ENTRY(Float32x4_cmplte, 2) { |
| 103 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, a, arguments->NativeArgAt(0)); |
| 104 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, b, arguments->NativeArgAt(1)); |
| 105 uint32_t _x = a.x() <= b.x() ? 0xFFFFFFFF : 0x0; |
| 106 uint32_t _y = a.y() <= b.y() ? 0xFFFFFFFF : 0x0; |
| 107 uint32_t _z = a.z() <= b.z() ? 0xFFFFFFFF : 0x0; |
| 108 uint32_t _w = a.w() <= b.w() ? 0xFFFFFFFF : 0x0; |
| 109 return Uint32x4::New(_x, _y, _z, _w); |
| 110 } |
| 111 |
| 112 |
| 113 DEFINE_NATIVE_ENTRY(Float32x4_cmpgt, 2) { |
| 114 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, a, arguments->NativeArgAt(0)); |
| 115 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, b, arguments->NativeArgAt(1)); |
| 116 uint32_t _x = a.x() > b.x() ? 0xFFFFFFFF : 0x0; |
| 117 uint32_t _y = a.y() > b.y() ? 0xFFFFFFFF : 0x0; |
| 118 uint32_t _z = a.z() > b.z() ? 0xFFFFFFFF : 0x0; |
| 119 uint32_t _w = a.w() > b.w() ? 0xFFFFFFFF : 0x0; |
| 120 return Uint32x4::New(_x, _y, _z, _w); |
| 121 } |
| 122 |
| 123 |
| 124 DEFINE_NATIVE_ENTRY(Float32x4_cmpgte, 2) { |
| 125 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, a, arguments->NativeArgAt(0)); |
| 126 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, b, arguments->NativeArgAt(1)); |
| 127 uint32_t _x = a.x() >= b.x() ? 0xFFFFFFFF : 0x0; |
| 128 uint32_t _y = a.y() >= b.y() ? 0xFFFFFFFF : 0x0; |
| 129 uint32_t _z = a.z() >= b.z() ? 0xFFFFFFFF : 0x0; |
| 130 uint32_t _w = a.w() >= b.w() ? 0xFFFFFFFF : 0x0; |
| 131 return Uint32x4::New(_x, _y, _z, _w); |
| 132 } |
| 133 |
| 134 |
| 135 DEFINE_NATIVE_ENTRY(Float32x4_cmpequal, 2) { |
| 136 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, a, arguments->NativeArgAt(0)); |
| 137 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, b, arguments->NativeArgAt(1)); |
| 138 uint32_t _x = a.x() == b.x() ? 0xFFFFFFFF : 0x0; |
| 139 uint32_t _y = a.y() == b.y() ? 0xFFFFFFFF : 0x0; |
| 140 uint32_t _z = a.z() == b.z() ? 0xFFFFFFFF : 0x0; |
| 141 uint32_t _w = a.w() == b.w() ? 0xFFFFFFFF : 0x0; |
| 142 return Uint32x4::New(_x, _y, _z, _w); |
| 143 } |
| 144 |
| 145 |
| 146 DEFINE_NATIVE_ENTRY(Float32x4_cmpnequal, 2) { |
| 147 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, a, arguments->NativeArgAt(0)); |
| 148 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, b, arguments->NativeArgAt(1)); |
| 149 uint32_t _x = a.x() != b.x() ? 0xFFFFFFFF : 0x0; |
| 150 uint32_t _y = a.y() != b.y() ? 0xFFFFFFFF : 0x0; |
| 151 uint32_t _z = a.z() != b.z() ? 0xFFFFFFFF : 0x0; |
| 152 uint32_t _w = a.w() != b.w() ? 0xFFFFFFFF : 0x0; |
| 153 return Uint32x4::New(_x, _y, _z, _w); |
| 154 } |
| 155 |
| 156 |
| 157 DEFINE_NATIVE_ENTRY(Float32x4_scale, 2) { |
| 158 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 159 GET_NON_NULL_NATIVE_ARGUMENT(Double, scale, arguments->NativeArgAt(1)); |
| 160 float _s = static_cast<float>(scale.value()); |
| 161 float _x = self.x() * _s; |
| 162 float _y = self.y() * _s; |
| 163 float _z = self.z() * _s; |
| 164 float _w = self.w() * _s; |
| 165 return Float32x4::New(_x, _y, _z, _w); |
| 166 } |
| 167 |
| 168 |
| 169 DEFINE_NATIVE_ENTRY(Float32x4_abs, 1) { |
| 170 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 171 float _x = fabsf(self.x()); |
| 172 float _y = fabsf(self.y()); |
| 173 float _z = fabsf(self.z()); |
| 174 float _w = fabsf(self.w()); |
| 175 return Float32x4::New(_x, _y, _z, _w); |
| 176 } |
| 177 |
| 178 |
| 179 DEFINE_NATIVE_ENTRY(Float32x4_clamp, 3) { |
| 180 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 181 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, lo, arguments->NativeArgAt(1)); |
| 182 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, hi, arguments->NativeArgAt(2)); |
| 183 float _x = self.x() > lo.x() ? self.x() : lo.x(); |
| 184 float _y = self.y() > lo.y() ? self.y() : lo.y(); |
| 185 float _z = self.z() > lo.z() ? self.z() : lo.z(); |
| 186 float _w = self.w() > lo.w() ? self.w() : lo.w(); |
| 187 _x = _x > hi.x() ? hi.x() : _x; |
| 188 _y = _y > hi.y() ? hi.y() : _y; |
| 189 _z = _z > hi.z() ? hi.z() : _z; |
| 190 _w = _w > hi.w() ? hi.w() : _w; |
| 191 return Float32x4::New(_x, _y, _z, _w); |
| 192 } |
| 193 |
| 194 |
| 195 DEFINE_NATIVE_ENTRY(Float32x4_getX, 1) { |
| 196 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 197 double value = static_cast<double>(self.x()); |
| 198 return Double::New(value); |
| 199 } |
| 200 |
| 201 |
| 202 DEFINE_NATIVE_ENTRY(Float32x4_getY, 1) { |
| 203 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 204 double value = static_cast<double>(self.y()); |
| 205 return Double::New(value); |
| 206 } |
| 207 |
| 208 |
| 209 DEFINE_NATIVE_ENTRY(Float32x4_getZ, 1) { |
| 210 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 211 double value = static_cast<double>(self.z()); |
| 212 return Double::New(value); |
| 213 } |
| 214 |
| 215 |
| 216 DEFINE_NATIVE_ENTRY(Float32x4_getW, 1) { |
| 217 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 218 double value = static_cast<double>(self.w()); |
| 219 return Double::New(value); |
| 220 } |
| 221 |
| 222 |
| 223 DEFINE_NATIVE_ENTRY(Float32x4_getXXXX, 1) { |
| 224 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 225 float value = self.x(); |
| 226 return Float32x4::New(value, value, value, value); |
| 227 } |
| 228 |
| 229 |
| 230 DEFINE_NATIVE_ENTRY(Float32x4_getYYYY, 1) { |
| 231 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 232 float value = self.y(); |
| 233 return Float32x4::New(value, value, value, value); |
| 234 } |
| 235 |
| 236 |
| 237 DEFINE_NATIVE_ENTRY(Float32x4_getZZZZ, 1) { |
| 238 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 239 float value = self.z(); |
| 240 return Float32x4::New(value, value, value, value); |
| 241 } |
| 242 |
| 243 |
| 244 DEFINE_NATIVE_ENTRY(Float32x4_getWWWW, 1) { |
| 245 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 246 float value = self.w(); |
| 247 return Float32x4::New(value, value, value, value); |
| 248 } |
| 249 |
| 250 |
| 251 DEFINE_NATIVE_ENTRY(Float32x4_setX, 2) { |
| 252 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 253 GET_NON_NULL_NATIVE_ARGUMENT(Double, x, arguments->NativeArgAt(1)); |
| 254 float _x = static_cast<float>(x.value()); |
| 255 float _y = self.y(); |
| 256 float _z = self.z(); |
| 257 float _w = self.w(); |
| 258 return Float32x4::New(_x, _y, _z, _w); |
| 259 } |
| 260 |
| 261 |
| 262 DEFINE_NATIVE_ENTRY(Float32x4_setY, 2) { |
| 263 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 264 GET_NON_NULL_NATIVE_ARGUMENT(Double, y, arguments->NativeArgAt(1)); |
| 265 float _x = self.x(); |
| 266 float _y = static_cast<float>(y.value()); |
| 267 float _z = self.z(); |
| 268 float _w = self.w(); |
| 269 return Float32x4::New(_x, _y, _z, _w); |
| 270 } |
| 271 |
| 272 |
| 273 DEFINE_NATIVE_ENTRY(Float32x4_setZ, 2) { |
| 274 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 275 GET_NON_NULL_NATIVE_ARGUMENT(Double, z, arguments->NativeArgAt(1)); |
| 276 float _x = self.x(); |
| 277 float _y = self.y(); |
| 278 float _z = static_cast<float>(z.value()); |
| 279 float _w = self.w(); |
| 280 return Float32x4::New(_x, _y, _z, _w); |
| 281 } |
| 282 |
| 283 |
| 284 DEFINE_NATIVE_ENTRY(Float32x4_setW, 2) { |
| 285 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 286 GET_NON_NULL_NATIVE_ARGUMENT(Double, w, arguments->NativeArgAt(1)); |
| 287 float _x = self.x(); |
| 288 float _y = self.y(); |
| 289 float _z = self.z(); |
| 290 float _w = static_cast<float>(w.value()); |
| 291 return Float32x4::New(_x, _y, _z, _w); |
| 292 } |
| 293 |
| 294 |
| 295 DEFINE_NATIVE_ENTRY(Float32x4_min, 2) { |
| 296 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 297 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, |
| 298 arguments->NativeArgAt(1)); |
| 299 float _x = self.x() < other.x() ? self.x() : other.x(); |
| 300 float _y = self.y() < other.y() ? self.y() : other.y(); |
| 301 float _z = self.z() < other.z() ? self.z() : other.z(); |
| 302 float _w = self.w() < other.w() ? self.w() : other.w(); |
| 303 return Float32x4::New(_x, _y, _z, _w); |
| 304 } |
| 305 |
| 306 |
| 307 DEFINE_NATIVE_ENTRY(Float32x4_max, 2) { |
| 308 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 309 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, |
| 310 arguments->NativeArgAt(1)); |
| 311 float _x = self.x() > other.x() ? self.x() : other.x(); |
| 312 float _y = self.y() > other.y() ? self.y() : other.y(); |
| 313 float _z = self.z() > other.z() ? self.z() : other.z(); |
| 314 float _w = self.w() > other.w() ? self.w() : other.w(); |
| 315 return Float32x4::New(_x, _y, _z, _w); |
| 316 } |
| 317 |
| 318 |
| 319 DEFINE_NATIVE_ENTRY(Float32x4_sqrt, 1) { |
| 320 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 321 float _x = sqrtf(self.x()); |
| 322 float _y = sqrtf(self.y()); |
| 323 float _z = sqrtf(self.z()); |
| 324 float _w = sqrtf(self.w()); |
| 325 return Float32x4::New(_x, _y, _z, _w); |
| 326 } |
| 327 |
| 328 |
| 329 DEFINE_NATIVE_ENTRY(Float32x4_reciprocal, 1) { |
| 330 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 331 float _x = 1.0f / self.x(); |
| 332 float _y = 1.0f / self.y(); |
| 333 float _z = 1.0f / self.z(); |
| 334 float _w = 1.0f / self.w(); |
| 335 return Float32x4::New(_x, _y, _z, _w); |
| 336 } |
| 337 |
| 338 |
| 339 DEFINE_NATIVE_ENTRY(Float32x4_reciprocalSqrt, 1) { |
| 340 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 341 float _x = sqrtf(1.0f / self.x()); |
| 342 float _y = sqrtf(1.0f / self.y()); |
| 343 float _z = sqrtf(1.0f / self.z()); |
| 344 float _w = sqrtf(1.0f / self.w()); |
| 345 return Float32x4::New(_x, _y, _z, _w); |
| 346 } |
| 347 |
| 348 |
| 349 DEFINE_NATIVE_ENTRY(Float32x4_toUint32x4, 1) { |
| 350 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, v, arguments->NativeArgAt(0)); |
| 351 return Uint32x4::New(v.value()); |
| 352 } |
| 353 |
| 354 |
| 355 DEFINE_NATIVE_ENTRY(Uint32x4_fromInts, 5) { |
| 356 ASSERT(AbstractTypeArguments::CheckedHandle( |
| 357 arguments->NativeArgAt(0)).IsNull()); |
| 358 GET_NON_NULL_NATIVE_ARGUMENT(Integer, x, arguments->NativeArgAt(1)); |
| 359 GET_NON_NULL_NATIVE_ARGUMENT(Integer, y, arguments->NativeArgAt(2)); |
| 360 GET_NON_NULL_NATIVE_ARGUMENT(Integer, z, arguments->NativeArgAt(3)); |
| 361 GET_NON_NULL_NATIVE_ARGUMENT(Integer, w, arguments->NativeArgAt(4)); |
| 362 uint32_t _x = static_cast<uint32_t>(x.AsInt64Value() & 0xFFFFFFFF); |
| 363 uint32_t _y = static_cast<uint32_t>(y.AsInt64Value() & 0xFFFFFFFF); |
| 364 uint32_t _z = static_cast<uint32_t>(z.AsInt64Value() & 0xFFFFFFFF); |
| 365 uint32_t _w = static_cast<uint32_t>(w.AsInt64Value() & 0xFFFFFFFF); |
| 366 return Uint32x4::New(_x, _y, _z, _w); |
| 367 } |
| 368 |
| 369 |
| 370 DEFINE_NATIVE_ENTRY(Uint32x4_fromBools, 5) { |
| 371 ASSERT(AbstractTypeArguments::CheckedHandle( |
| 372 arguments->NativeArgAt(0)).IsNull()); |
| 373 GET_NON_NULL_NATIVE_ARGUMENT(Bool, x, arguments->NativeArgAt(1)); |
| 374 GET_NON_NULL_NATIVE_ARGUMENT(Bool, y, arguments->NativeArgAt(2)); |
| 375 GET_NON_NULL_NATIVE_ARGUMENT(Bool, z, arguments->NativeArgAt(3)); |
| 376 GET_NON_NULL_NATIVE_ARGUMENT(Bool, w, arguments->NativeArgAt(4)); |
| 377 uint32_t _x = x.value() ? 0xFFFFFFFF : 0x0; |
| 378 uint32_t _y = y.value() ? 0xFFFFFFFF : 0x0; |
| 379 uint32_t _z = z.value() ? 0xFFFFFFFF : 0x0; |
| 380 uint32_t _w = w.value() ? 0xFFFFFFFF : 0x0; |
| 381 return Uint32x4::New(_x, _y, _z, _w); |
| 382 } |
| 383 |
| 384 |
| 385 DEFINE_NATIVE_ENTRY(Uint32x4_or, 2) { |
| 386 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 387 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, other, arguments->NativeArgAt(1)); |
| 388 uint32_t _x = self.x() | other.x(); |
| 389 uint32_t _y = self.y() | other.y(); |
| 390 uint32_t _z = self.z() | other.z(); |
| 391 uint32_t _w = self.w() | other.w(); |
| 392 return Uint32x4::New(_x, _y, _z, _w); |
| 393 } |
| 394 |
| 395 |
| 396 DEFINE_NATIVE_ENTRY(Uint32x4_and, 2) { |
| 397 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 398 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, other, arguments->NativeArgAt(1)); |
| 399 uint32_t _x = self.x() & other.x(); |
| 400 uint32_t _y = self.y() & other.y(); |
| 401 uint32_t _z = self.z() & other.z(); |
| 402 uint32_t _w = self.w() & other.w(); |
| 403 return Uint32x4::New(_x, _y, _z, _w); |
| 404 } |
| 405 |
| 406 |
| 407 DEFINE_NATIVE_ENTRY(Uint32x4_xor, 2) { |
| 408 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 409 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, other, arguments->NativeArgAt(1)); |
| 410 uint32_t _x = self.x() ^ other.x(); |
| 411 uint32_t _y = self.y() ^ other.y(); |
| 412 uint32_t _z = self.z() ^ other.z(); |
| 413 uint32_t _w = self.w() ^ other.w(); |
| 414 return Uint32x4::New(_x, _y, _z, _w); |
| 415 } |
| 416 |
| 417 |
| 418 DEFINE_NATIVE_ENTRY(Uint32x4_getX, 1) { |
| 419 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 420 uint32_t value = self.x(); |
| 421 return Integer::New(value); |
| 422 } |
| 423 |
| 424 |
| 425 DEFINE_NATIVE_ENTRY(Uint32x4_getY, 1) { |
| 426 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 427 uint32_t value = self.y(); |
| 428 return Integer::New(value); |
| 429 } |
| 430 |
| 431 |
| 432 DEFINE_NATIVE_ENTRY(Uint32x4_getZ, 1) { |
| 433 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 434 uint32_t value = self.z(); |
| 435 return Integer::New(value); |
| 436 } |
| 437 |
| 438 |
| 439 DEFINE_NATIVE_ENTRY(Uint32x4_getW, 1) { |
| 440 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 441 uint32_t value = self.w(); |
| 442 return Integer::New(value); |
| 443 } |
| 444 |
| 445 |
| 446 DEFINE_NATIVE_ENTRY(Uint32x4_setX, 2) { |
| 447 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 448 GET_NON_NULL_NATIVE_ARGUMENT(Integer, x, arguments->NativeArgAt(1)); |
| 449 uint32_t _x = static_cast<uint32_t>(x.AsInt64Value() & 0xFFFFFFFF); |
| 450 uint32_t _y = self.y(); |
| 451 uint32_t _z = self.z(); |
| 452 uint32_t _w = self.w(); |
| 453 return Uint32x4::New(_x, _y, _z, _w); |
| 454 } |
| 455 |
| 456 |
| 457 DEFINE_NATIVE_ENTRY(Uint32x4_setY, 2) { |
| 458 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 459 GET_NON_NULL_NATIVE_ARGUMENT(Integer, y, arguments->NativeArgAt(1)); |
| 460 uint32_t _x = self.x(); |
| 461 uint32_t _y = static_cast<uint32_t>(y.AsInt64Value() & 0xFFFFFFFF); |
| 462 uint32_t _z = self.z(); |
| 463 uint32_t _w = self.w(); |
| 464 return Uint32x4::New(_x, _y, _z, _w); |
| 465 } |
| 466 |
| 467 |
| 468 DEFINE_NATIVE_ENTRY(Uint32x4_setZ, 2) { |
| 469 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 470 GET_NON_NULL_NATIVE_ARGUMENT(Integer, z, arguments->NativeArgAt(1)); |
| 471 uint32_t _x = self.x(); |
| 472 uint32_t _y = self.y(); |
| 473 uint32_t _z = static_cast<uint32_t>(z.AsInt64Value() & 0xFFFFFFFF); |
| 474 uint32_t _w = self.w(); |
| 475 return Uint32x4::New(_x, _y, _z, _w); |
| 476 } |
| 477 |
| 478 |
| 479 DEFINE_NATIVE_ENTRY(Uint32x4_setW, 2) { |
| 480 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 481 GET_NON_NULL_NATIVE_ARGUMENT(Integer, w, arguments->NativeArgAt(1)); |
| 482 uint32_t _x = self.x(); |
| 483 uint32_t _y = self.y(); |
| 484 uint32_t _z = self.z(); |
| 485 uint32_t _w = static_cast<uint32_t>(w.AsInt64Value() & 0xFFFFFFFF); |
| 486 return Uint32x4::New(_x, _y, _z, _w); |
| 487 } |
| 488 |
| 489 |
| 490 DEFINE_NATIVE_ENTRY(Uint32x4_getFlagX, 1) { |
| 491 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 492 uint32_t value = self.x(); |
| 493 return value != 0 ? Bool::True().raw() : Bool::False().raw(); |
| 494 } |
| 495 |
| 496 |
| 497 DEFINE_NATIVE_ENTRY(Uint32x4_getFlagY, 1) { |
| 498 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 499 uint32_t value = self.y(); |
| 500 return value != 0 ? Bool::True().raw() : Bool::False().raw(); |
| 501 } |
| 502 |
| 503 |
| 504 DEFINE_NATIVE_ENTRY(Uint32x4_getFlagZ, 1) { |
| 505 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 506 uint32_t value = self.z(); |
| 507 return value != 0 ? Bool::True().raw() : Bool::False().raw(); |
| 508 } |
| 509 |
| 510 |
| 511 DEFINE_NATIVE_ENTRY(Uint32x4_getFlagW, 1) { |
| 512 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 513 uint32_t value = self.w(); |
| 514 return value != 0 ? Bool::True().raw() : Bool::False().raw(); |
| 515 } |
| 516 |
| 517 |
| 518 DEFINE_NATIVE_ENTRY(Uint32x4_setFlagX, 2) { |
| 519 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 520 GET_NON_NULL_NATIVE_ARGUMENT(Bool, flagX, arguments->NativeArgAt(1)); |
| 521 uint32_t _x = self.x(); |
| 522 uint32_t _y = self.y(); |
| 523 uint32_t _z = self.z(); |
| 524 uint32_t _w = self.w(); |
| 525 _x = flagX.raw() == Bool::True().raw() ? 0xFFFFFFFF : 0x0; |
| 526 return Uint32x4::New(_x, _y, _z, _w); |
| 527 } |
| 528 |
| 529 |
| 530 DEFINE_NATIVE_ENTRY(Uint32x4_setFlagY, 2) { |
| 531 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 532 GET_NON_NULL_NATIVE_ARGUMENT(Bool, flagY, arguments->NativeArgAt(1)); |
| 533 uint32_t _x = self.x(); |
| 534 uint32_t _y = self.y(); |
| 535 uint32_t _z = self.z(); |
| 536 uint32_t _w = self.w(); |
| 537 _y = flagY.raw() == Bool::True().raw() ? 0xFFFFFFFF : 0x0; |
| 538 return Uint32x4::New(_x, _y, _z, _w); |
| 539 } |
| 540 |
| 541 |
| 542 DEFINE_NATIVE_ENTRY(Uint32x4_setFlagZ, 2) { |
| 543 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 544 GET_NON_NULL_NATIVE_ARGUMENT(Bool, flagZ, arguments->NativeArgAt(1)); |
| 545 uint32_t _x = self.x(); |
| 546 uint32_t _y = self.y(); |
| 547 uint32_t _z = self.z(); |
| 548 uint32_t _w = self.w(); |
| 549 _z = flagZ.raw() == Bool::True().raw() ? 0xFFFFFFFF : 0x0; |
| 550 return Uint32x4::New(_x, _y, _z, _w); |
| 551 } |
| 552 |
| 553 |
| 554 DEFINE_NATIVE_ENTRY(Uint32x4_setFlagW, 2) { |
| 555 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 556 GET_NON_NULL_NATIVE_ARGUMENT(Bool, flagW, arguments->NativeArgAt(1)); |
| 557 uint32_t _x = self.x(); |
| 558 uint32_t _y = self.y(); |
| 559 uint32_t _z = self.z(); |
| 560 uint32_t _w = self.w(); |
| 561 _w = flagW.raw() == Bool::True().raw() ? 0xFFFFFFFF : 0x0; |
| 562 return Uint32x4::New(_x, _y, _z, _w); |
| 563 } |
| 564 |
| 565 |
| 566 // Used to convert between uint32_t and float32 without breaking strict |
| 567 // aliasing rules. |
| 568 union float32_uint32 { |
| 569 float f; |
| 570 uint32_t u; |
| 571 float32_uint32(float v) { |
| 572 f = v; |
| 573 } |
| 574 float32_uint32(uint32_t v) { |
| 575 u = v; |
| 576 } |
| 577 }; |
| 578 |
| 579 |
| 580 DEFINE_NATIVE_ENTRY(Uint32x4_select, 3) { |
| 581 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 582 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, tv, arguments->NativeArgAt(1)); |
| 583 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, fv, arguments->NativeArgAt(2)); |
| 584 uint32_t _maskX = self.x(); |
| 585 uint32_t _maskY = self.y(); |
| 586 uint32_t _maskZ = self.z(); |
| 587 uint32_t _maskW = self.w(); |
| 588 // Extract floats and interpret them as masks. |
| 589 float32_uint32 tvx(tv.x()); |
| 590 float32_uint32 tvy(tv.y()); |
| 591 float32_uint32 tvz(tv.z()); |
| 592 float32_uint32 tvw(tv.w()); |
| 593 float32_uint32 fvx(fv.x()); |
| 594 float32_uint32 fvy(fv.y()); |
| 595 float32_uint32 fvz(fv.z()); |
| 596 float32_uint32 fvw(fv.w()); |
| 597 // Perform select. |
| 598 float32_uint32 tempX((_maskX & tvx.u) | (~_maskX & fvx.u)); |
| 599 float32_uint32 tempY((_maskY & tvy.u) | (~_maskY & fvy.u)); |
| 600 float32_uint32 tempZ((_maskZ & tvz.u) | (~_maskZ & fvz.u)); |
| 601 float32_uint32 tempW((_maskW & tvw.u) | (~_maskW & fvw.u)); |
| 602 return Float32x4::New(tempX.f, tempY.f, tempZ.f, tempW.f); |
| 603 } |
| 604 |
| 605 |
| 606 DEFINE_NATIVE_ENTRY(Uint32x4_toFloat32x4, 1) { |
| 607 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, v, arguments->NativeArgAt(0)); |
| 608 return Float32x4::New(v.value()); |
| 609 } |
| 610 |
| 611 |
| 612 } // namespace dart |
OLD | NEW |