Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 | 6 |
| 7 #include "vm/exceptions.h" | 7 #include "vm/exceptions.h" |
| 8 #include "vm/native_entry.h" | 8 #include "vm/native_entry.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 } | 273 } |
| 274 float data[4] = { self.x(), self.y(), self.z(), self.w() }; | 274 float data[4] = { self.x(), self.y(), self.z(), self.w() }; |
| 275 float _x = data[m & 0x3]; | 275 float _x = data[m & 0x3]; |
| 276 float _y = data[(m >> 2) & 0x3]; | 276 float _y = data[(m >> 2) & 0x3]; |
| 277 float _z = data[(m >> 4) & 0x3]; | 277 float _z = data[(m >> 4) & 0x3]; |
| 278 float _w = data[(m >> 6) & 0x3]; | 278 float _w = data[(m >> 6) & 0x3]; |
| 279 return Float32x4::New(_x, _y, _z, _w); | 279 return Float32x4::New(_x, _y, _z, _w); |
| 280 } | 280 } |
| 281 | 281 |
| 282 | 282 |
| 283 DEFINE_NATIVE_ENTRY(Float32x4_withZWInXY, 2) { | 283 DEFINE_NATIVE_ENTRY(Float32x4_shuffleMix, 3) { |
| 284 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); | 284 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 285 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); | 285 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, zw, arguments->NativeArgAt(1)); |
|
zra
2013/10/30 17:39:27
Just a bit confused about naming, I think. This is
Cutch
2013/10/31 01:43:55
name of "zw" because the resulting ZW lanes will b
| |
| 286 float _x = other.z(); | 286 GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(2)); |
| 287 float _y = other.w(); | 287 int64_t m = mask.AsInt64Value(); |
| 288 float _z = self.z(); | 288 if (m < 0 || m > 255) { |
| 289 float _w = self.w(); | 289 const String& error = String::Handle( |
| 290 String::NewFormatted("mask (%" Pd64 ") must be in the range [0..256)", | |
| 291 m)); | |
| 292 const Array& args = Array::Handle(Array::New(1)); | |
| 293 args.SetAt(0, error); | |
| 294 Exceptions::ThrowByType(Exceptions::kRange, args); | |
| 295 } | |
| 296 float data[4] = { self.x(), self.y(), self.z(), self.w() }; | |
| 297 float zw_data[4] = { zw.x(), zw.y(), zw.z(), zw.w() }; | |
| 298 float _x = data[m & 0x3]; | |
| 299 float _y = data[(m >> 2) & 0x3]; | |
| 300 float _z = zw_data[(m >> 4) & 0x3]; | |
| 301 float _w = zw_data[(m >> 6) & 0x3]; | |
| 290 return Float32x4::New(_x, _y, _z, _w); | 302 return Float32x4::New(_x, _y, _z, _w); |
| 291 } | 303 } |
| 292 | 304 |
| 293 | |
| 294 DEFINE_NATIVE_ENTRY(Float32x4_interleaveXY, 2) { | |
| 295 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); | |
| 296 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); | |
| 297 float _x = self.x(); | |
| 298 float _y = other.x(); | |
| 299 float _z = self.y(); | |
| 300 float _w = other.y(); | |
| 301 return Float32x4::New(_x, _y, _z, _w); | |
| 302 } | |
| 303 | |
| 304 | |
| 305 DEFINE_NATIVE_ENTRY(Float32x4_interleaveZW, 2) { | |
| 306 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); | |
| 307 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); | |
| 308 float _x = self.z(); | |
| 309 float _y = other.z(); | |
| 310 float _z = self.w(); | |
| 311 float _w = other.w(); | |
| 312 return Float32x4::New(_x, _y, _z, _w); | |
| 313 } | |
| 314 | |
| 315 | |
| 316 DEFINE_NATIVE_ENTRY(Float32x4_interleaveXYPairs, 2) { | |
| 317 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); | |
| 318 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); | |
| 319 float _x = self.x(); | |
| 320 float _y = self.y(); | |
| 321 float _z = other.x(); | |
| 322 float _w = other.y(); | |
| 323 return Float32x4::New(_x, _y, _z, _w); | |
| 324 } | |
| 325 | |
| 326 | |
| 327 DEFINE_NATIVE_ENTRY(Float32x4_interleaveZWPairs, 2) { | |
| 328 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); | |
| 329 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); | |
| 330 float _x = self.z(); | |
| 331 float _y = self.w(); | |
| 332 float _z = other.z(); | |
| 333 float _w = other.w(); | |
| 334 return Float32x4::New(_x, _y, _z, _w); | |
| 335 } | |
| 336 | |
| 337 | 305 |
| 338 DEFINE_NATIVE_ENTRY(Float32x4_setX, 2) { | 306 DEFINE_NATIVE_ENTRY(Float32x4_setX, 2) { |
| 339 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); | 307 GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
| 340 GET_NON_NULL_NATIVE_ARGUMENT(Double, x, arguments->NativeArgAt(1)); | 308 GET_NON_NULL_NATIVE_ARGUMENT(Double, x, arguments->NativeArgAt(1)); |
| 341 float _x = static_cast<float>(x.value()); | 309 float _x = static_cast<float>(x.value()); |
| 342 float _y = self.y(); | 310 float _y = self.y(); |
| 343 float _z = self.z(); | 311 float _z = self.z(); |
| 344 float _w = self.w(); | 312 float _w = self.w(); |
| 345 return Float32x4::New(_x, _y, _z, _w); | 313 return Float32x4::New(_x, _y, _z, _w); |
| 346 } | 314 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 } | 513 } |
| 546 | 514 |
| 547 | 515 |
| 548 DEFINE_NATIVE_ENTRY(Uint32x4_getW, 1) { | 516 DEFINE_NATIVE_ENTRY(Uint32x4_getW, 1) { |
| 549 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); | 517 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 550 uint32_t value = self.w(); | 518 uint32_t value = self.w(); |
| 551 return Integer::New(value); | 519 return Integer::New(value); |
| 552 } | 520 } |
| 553 | 521 |
| 554 | 522 |
| 523 DEFINE_NATIVE_ENTRY(Uint32x4_shuffle, 2) { | |
| 524 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); | |
| 525 GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(1)); | |
| 526 int64_t m = mask.AsInt64Value(); | |
| 527 if (m < 0 || m > 255) { | |
| 528 const String& error = String::Handle( | |
| 529 String::NewFormatted("mask (%" Pd64 ") must be in the range [0..256)", | |
| 530 m)); | |
| 531 const Array& args = Array::Handle(Array::New(1)); | |
| 532 args.SetAt(0, error); | |
| 533 Exceptions::ThrowByType(Exceptions::kRange, args); | |
| 534 } | |
| 535 uint32_t data[4] = { self.x(), self.y(), self.z(), self.w() }; | |
| 536 uint32_t _x = data[m & 0x3]; | |
| 537 uint32_t _y = data[(m >> 2) & 0x3]; | |
| 538 uint32_t _z = data[(m >> 4) & 0x3]; | |
| 539 uint32_t _w = data[(m >> 6) & 0x3]; | |
| 540 return Uint32x4::New(_x, _y, _z, _w); | |
| 541 } | |
| 542 | |
| 543 | |
| 544 DEFINE_NATIVE_ENTRY(Uint32x4_shuffleMix, 3) { | |
| 545 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); | |
| 546 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, zw, arguments->NativeArgAt(1)); | |
|
zra
2013/10/30 17:39:27
Same question here.
Cutch
2013/10/31 01:43:55
Renamed to other.
| |
| 547 GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(2)); | |
| 548 int64_t m = mask.AsInt64Value(); | |
| 549 if (m < 0 || m > 255) { | |
| 550 const String& error = String::Handle( | |
| 551 String::NewFormatted("mask (%" Pd64 ") must be in the range [0..256)", | |
| 552 m)); | |
| 553 const Array& args = Array::Handle(Array::New(1)); | |
| 554 args.SetAt(0, error); | |
| 555 Exceptions::ThrowByType(Exceptions::kRange, args); | |
| 556 } | |
| 557 uint32_t data[4] = { self.x(), self.y(), self.z(), self.w() }; | |
| 558 uint32_t zw_data[4] = { zw.x(), zw.y(), zw.z(), zw.w() }; | |
| 559 uint32_t _x = data[m & 0x3]; | |
| 560 uint32_t _y = data[(m >> 2) & 0x3]; | |
| 561 uint32_t _z = zw_data[(m >> 4) & 0x3]; | |
| 562 uint32_t _w = zw_data[(m >> 6) & 0x3]; | |
| 563 return Uint32x4::New(_x, _y, _z, _w); | |
| 564 } | |
| 565 | |
| 566 | |
| 555 DEFINE_NATIVE_ENTRY(Uint32x4_setX, 2) { | 567 DEFINE_NATIVE_ENTRY(Uint32x4_setX, 2) { |
| 556 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); | 568 GET_NON_NULL_NATIVE_ARGUMENT(Uint32x4, self, arguments->NativeArgAt(0)); |
| 557 GET_NON_NULL_NATIVE_ARGUMENT(Integer, x, arguments->NativeArgAt(1)); | 569 GET_NON_NULL_NATIVE_ARGUMENT(Integer, x, arguments->NativeArgAt(1)); |
| 558 uint32_t _x = static_cast<uint32_t>(x.AsInt64Value() & 0xFFFFFFFF); | 570 uint32_t _x = static_cast<uint32_t>(x.AsInt64Value() & 0xFFFFFFFF); |
| 559 uint32_t _y = self.y(); | 571 uint32_t _y = self.y(); |
| 560 uint32_t _z = self.z(); | 572 uint32_t _z = self.z(); |
| 561 uint32_t _w = self.w(); | 573 uint32_t _w = self.w(); |
| 562 return Uint32x4::New(_x, _y, _z, _w); | 574 return Uint32x4::New(_x, _y, _z, _w); |
| 563 } | 575 } |
| 564 | 576 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 // Perform select. | 718 // Perform select. |
| 707 float32_uint32 tempX((_maskX & tvx.u) | (~_maskX & fvx.u)); | 719 float32_uint32 tempX((_maskX & tvx.u) | (~_maskX & fvx.u)); |
| 708 float32_uint32 tempY((_maskY & tvy.u) | (~_maskY & fvy.u)); | 720 float32_uint32 tempY((_maskY & tvy.u) | (~_maskY & fvy.u)); |
| 709 float32_uint32 tempZ((_maskZ & tvz.u) | (~_maskZ & fvz.u)); | 721 float32_uint32 tempZ((_maskZ & tvz.u) | (~_maskZ & fvz.u)); |
| 710 float32_uint32 tempW((_maskW & tvw.u) | (~_maskW & fvw.u)); | 722 float32_uint32 tempW((_maskW & tvw.u) | (~_maskW & fvw.u)); |
| 711 return Float32x4::New(tempX.f, tempY.f, tempZ.f, tempW.f); | 723 return Float32x4::New(tempX.f, tempY.f, tempZ.f, tempW.f); |
| 712 } | 724 } |
| 713 | 725 |
| 714 | 726 |
| 715 } // namespace dart | 727 } // namespace dart |
| OLD | NEW |