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 | static void ThrowMaskRangeException(int64_t m) { |
15 | if ((m < 0) || (m > 255)) { |
16 | Exceptions::ThrowRangeError("mask" , Integer::Handle(Integer::New(m)), 0, |
17 | 255); |
18 | } |
19 | } |
20 | |
21 | DEFINE_NATIVE_ENTRY(Float32x4_fromDoubles, 0, 4) { |
22 | GET_NON_NULL_NATIVE_ARGUMENT(Double, x, arguments->NativeArgAt(0)); |
23 | GET_NON_NULL_NATIVE_ARGUMENT(Double, y, arguments->NativeArgAt(1)); |
24 | GET_NON_NULL_NATIVE_ARGUMENT(Double, z, arguments->NativeArgAt(2)); |
25 | GET_NON_NULL_NATIVE_ARGUMENT(Double, w, arguments->NativeArgAt(3)); |
26 | float _x = static_cast<float>(x.value()); |
27 | float _y = static_cast<float>(y.value()); |
28 | float _z = static_cast<float>(z.value()); |
29 | float _w = static_cast<float>(w.value()); |
30 | return Float32x4::New(_x, _y, _z, _w); |
31 | } |
32 | |
33 | DEFINE_NATIVE_ENTRY(Float32x4_splat, 0, 1) { |
34 | GET_NON_NULL_NATIVE_ARGUMENT(Double, v, arguments->NativeArgAt(0)); |
35 | float _v = v.value(); |
36 | return Float32x4::New(_v, _v, _v, _v); |
37 | } |
38 | |
39 | DEFINE_NATIVE_ENTRY(Float32x4_zero, 0, 1) { |
40 | ASSERT( |
41 | TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(0)).IsNull()); |
42 | return Float32x4::New(0.0f, 0.0f, 0.0f, 0.0f); |
43 | } |
44 | |
45 | DEFINE_NATIVE_ENTRY(Float32x4_fromInt32x4Bits, 0, 2) { |
46 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, v, arguments->NativeArgAt(1)); |
47 | return Float32x4::New(v.value()); |
48 | } |
49 | |
50 | DEFINE_NATIVE_ENTRY(Float32x4_fromFloat64x2, 0, 2) { |
51 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, v, arguments->NativeArgAt(1)); |
52 | float _x = static_cast<float>(v.x()); |
53 | float _y = static_cast<float>(v.y()); |
54 | return Float32x4::New(_x, _y, 0.0f, 0.0f); |
55 | } |
56 | |
57 | DEFINE_NATIVE_ENTRY(Float32x4_add, 0, 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 | DEFINE_NATIVE_ENTRY(Float32x4_negate, 0, 1) { |
68 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
69 | float _x = -self.x(); |
70 | float _y = -self.y(); |
71 | float _z = -self.z(); |
72 | float _w = -self.w(); |
73 | return Float32x4::New(_x, _y, _z, _w); |
74 | } |
75 | |
76 | DEFINE_NATIVE_ENTRY(Float32x4_sub, 0, 2) { |
77 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
78 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); |
79 | float _x = self.x() - other.x(); |
80 | float _y = self.y() - other.y(); |
81 | float _z = self.z() - other.z(); |
82 | float _w = self.w() - other.w(); |
83 | return Float32x4::New(_x, _y, _z, _w); |
84 | } |
85 | |
86 | DEFINE_NATIVE_ENTRY(Float32x4_mul, 0, 2) { |
87 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
88 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); |
89 | float _x = self.x() * other.x(); |
90 | float _y = self.y() * other.y(); |
91 | float _z = self.z() * other.z(); |
92 | float _w = self.w() * other.w(); |
93 | return Float32x4::New(_x, _y, _z, _w); |
94 | } |
95 | |
96 | DEFINE_NATIVE_ENTRY(Float32x4_div, 0, 2) { |
97 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
98 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); |
99 | float _x = self.x() / other.x(); |
100 | float _y = self.y() / other.y(); |
101 | float _z = self.z() / other.z(); |
102 | float _w = self.w() / other.w(); |
103 | return Float32x4::New(_x, _y, _z, _w); |
104 | } |
105 | |
106 | DEFINE_NATIVE_ENTRY(Float32x4_cmplt, 0, 2) { |
107 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, a, arguments->NativeArgAt(0)); |
108 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, b, arguments->NativeArgAt(1)); |
109 | uint32_t _x = a.x() < b.x() ? 0xFFFFFFFF : 0x0; |
110 | uint32_t _y = a.y() < b.y() ? 0xFFFFFFFF : 0x0; |
111 | uint32_t _z = a.z() < b.z() ? 0xFFFFFFFF : 0x0; |
112 | uint32_t _w = a.w() < b.w() ? 0xFFFFFFFF : 0x0; |
113 | return Int32x4::New(_x, _y, _z, _w); |
114 | } |
115 | |
116 | DEFINE_NATIVE_ENTRY(Float32x4_cmplte, 0, 2) { |
117 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, a, arguments->NativeArgAt(0)); |
118 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, b, arguments->NativeArgAt(1)); |
119 | uint32_t _x = a.x() <= b.x() ? 0xFFFFFFFF : 0x0; |
120 | uint32_t _y = a.y() <= b.y() ? 0xFFFFFFFF : 0x0; |
121 | uint32_t _z = a.z() <= b.z() ? 0xFFFFFFFF : 0x0; |
122 | uint32_t _w = a.w() <= b.w() ? 0xFFFFFFFF : 0x0; |
123 | return Int32x4::New(_x, _y, _z, _w); |
124 | } |
125 | |
126 | DEFINE_NATIVE_ENTRY(Float32x4_cmpgt, 0, 2) { |
127 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, a, arguments->NativeArgAt(0)); |
128 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, b, arguments->NativeArgAt(1)); |
129 | uint32_t _x = a.x() > b.x() ? 0xFFFFFFFF : 0x0; |
130 | uint32_t _y = a.y() > b.y() ? 0xFFFFFFFF : 0x0; |
131 | uint32_t _z = a.z() > b.z() ? 0xFFFFFFFF : 0x0; |
132 | uint32_t _w = a.w() > b.w() ? 0xFFFFFFFF : 0x0; |
133 | return Int32x4::New(_x, _y, _z, _w); |
134 | } |
135 | |
136 | DEFINE_NATIVE_ENTRY(Float32x4_cmpgte, 0, 2) { |
137 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, a, arguments->NativeArgAt(0)); |
138 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, b, arguments->NativeArgAt(1)); |
139 | uint32_t _x = a.x() >= b.x() ? 0xFFFFFFFF : 0x0; |
140 | uint32_t _y = a.y() >= b.y() ? 0xFFFFFFFF : 0x0; |
141 | uint32_t _z = a.z() >= b.z() ? 0xFFFFFFFF : 0x0; |
142 | uint32_t _w = a.w() >= b.w() ? 0xFFFFFFFF : 0x0; |
143 | return Int32x4::New(_x, _y, _z, _w); |
144 | } |
145 | |
146 | DEFINE_NATIVE_ENTRY(Float32x4_cmpequal, 0, 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 Int32x4::New(_x, _y, _z, _w); |
154 | } |
155 | |
156 | DEFINE_NATIVE_ENTRY(Float32x4_cmpnequal, 0, 2) { |
157 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, a, arguments->NativeArgAt(0)); |
158 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, b, arguments->NativeArgAt(1)); |
159 | uint32_t _x = a.x() != b.x() ? 0xFFFFFFFF : 0x0; |
160 | uint32_t _y = a.y() != b.y() ? 0xFFFFFFFF : 0x0; |
161 | uint32_t _z = a.z() != b.z() ? 0xFFFFFFFF : 0x0; |
162 | uint32_t _w = a.w() != b.w() ? 0xFFFFFFFF : 0x0; |
163 | return Int32x4::New(_x, _y, _z, _w); |
164 | } |
165 | |
166 | DEFINE_NATIVE_ENTRY(Float32x4_scale, 0, 2) { |
167 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
168 | GET_NON_NULL_NATIVE_ARGUMENT(Double, scale, arguments->NativeArgAt(1)); |
169 | float _s = static_cast<float>(scale.value()); |
170 | float _x = self.x() * _s; |
171 | float _y = self.y() * _s; |
172 | float _z = self.z() * _s; |
173 | float _w = self.w() * _s; |
174 | return Float32x4::New(_x, _y, _z, _w); |
175 | } |
176 | |
177 | DEFINE_NATIVE_ENTRY(Float32x4_abs, 0, 1) { |
178 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
179 | float _x = fabsf(self.x()); |
180 | float _y = fabsf(self.y()); |
181 | float _z = fabsf(self.z()); |
182 | float _w = fabsf(self.w()); |
183 | return Float32x4::New(_x, _y, _z, _w); |
184 | } |
185 | |
186 | DEFINE_NATIVE_ENTRY(Float32x4_clamp, 0, 3) { |
187 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
188 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, lo, arguments->NativeArgAt(1)); |
189 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, hi, arguments->NativeArgAt(2)); |
190 | // The order of the clamping must match the order of the optimized code: |
191 | // MAX(MIN(self, hi), lo). |
192 | float _x; |
193 | float _y; |
194 | float _z; |
195 | float _w; |
196 | // ARM semantics are different from X86/X64 at an instruction level. Ensure |
197 | // that we match the semantics of the architecture in the C version. |
198 | #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
199 | _x = self.x() < hi.x() ? self.x() : hi.x(); |
200 | _y = self.y() < hi.y() ? self.y() : hi.y(); |
201 | _z = self.z() < hi.z() ? self.z() : hi.z(); |
202 | _w = self.w() < hi.w() ? self.w() : hi.w(); |
203 | _x = lo.x() < _x ? _x : lo.x(); |
204 | _y = lo.y() < _y ? _y : lo.y(); |
205 | _z = lo.z() < _z ? _z : lo.z(); |
206 | _w = lo.w() < _w ? _w : lo.w(); |
207 | #else |
208 | _x = fminf(self.x(), hi.x()); |
209 | _y = fminf(self.y(), hi.y()); |
210 | _z = fminf(self.z(), hi.z()); |
211 | _w = fminf(self.w(), hi.w()); |
212 | _x = fmaxf(_x, lo.x()); |
213 | _y = fmaxf(_y, lo.y()); |
214 | _z = fmaxf(_z, lo.z()); |
215 | _w = fmaxf(_w, lo.w()); |
216 | #endif |
217 | return Float32x4::New(_x, _y, _z, _w); |
218 | } |
219 | |
220 | DEFINE_NATIVE_ENTRY(Float32x4_getX, 0, 1) { |
221 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
222 | double value = static_cast<double>(self.x()); |
223 | return Double::New(value); |
224 | } |
225 | |
226 | DEFINE_NATIVE_ENTRY(Float32x4_getY, 0, 1) { |
227 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
228 | double value = static_cast<double>(self.y()); |
229 | return Double::New(value); |
230 | } |
231 | |
232 | DEFINE_NATIVE_ENTRY(Float32x4_getZ, 0, 1) { |
233 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
234 | double value = static_cast<double>(self.z()); |
235 | return Double::New(value); |
236 | } |
237 | |
238 | DEFINE_NATIVE_ENTRY(Float32x4_getW, 0, 1) { |
239 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
240 | double value = static_cast<double>(self.w()); |
241 | return Double::New(value); |
242 | } |
243 | |
244 | DEFINE_NATIVE_ENTRY(Float32x4_getSignMask, 0, 1) { |
245 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
246 | uint32_t mx = (bit_cast<uint32_t>(self.x()) & 0x80000000) >> 31; |
247 | uint32_t my = (bit_cast<uint32_t>(self.y()) & 0x80000000) >> 31; |
248 | uint32_t mz = (bit_cast<uint32_t>(self.z()) & 0x80000000) >> 31; |
249 | uint32_t mw = (bit_cast<uint32_t>(self.w()) & 0x80000000) >> 31; |
250 | uint32_t value = mx | (my << 1) | (mz << 2) | (mw << 3); |
251 | return Integer::New(value); |
252 | } |
253 | |
254 | DEFINE_NATIVE_ENTRY(Int32x4_getSignMask, 0, 1) { |
255 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
256 | uint32_t mx = (self.x() & 0x80000000) >> 31; |
257 | uint32_t my = (self.y() & 0x80000000) >> 31; |
258 | uint32_t mz = (self.z() & 0x80000000) >> 31; |
259 | uint32_t mw = (self.w() & 0x80000000) >> 31; |
260 | uint32_t value = mx | (my << 1) | (mz << 2) | (mw << 3); |
261 | return Integer::New(value); |
262 | } |
263 | |
264 | DEFINE_NATIVE_ENTRY(Float32x4_shuffle, 0, 2) { |
265 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
266 | GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(1)); |
267 | int64_t m = mask.AsInt64Value(); |
268 | ThrowMaskRangeException(m); |
269 | float data[4] = {self.x(), self.y(), self.z(), self.w()}; |
270 | float _x = data[m & 0x3]; |
271 | float _y = data[(m >> 2) & 0x3]; |
272 | float _z = data[(m >> 4) & 0x3]; |
273 | float _w = data[(m >> 6) & 0x3]; |
274 | return Float32x4::New(_x, _y, _z, _w); |
275 | } |
276 | |
277 | DEFINE_NATIVE_ENTRY(Float32x4_shuffleMix, 0, 3) { |
278 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
279 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); |
280 | GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(2)); |
281 | int64_t m = mask.AsInt64Value(); |
282 | ThrowMaskRangeException(m); |
283 | float data[4] = {self.x(), self.y(), self.z(), self.w()}; |
284 | float other_data[4] = {other.x(), other.y(), other.z(), other.w()}; |
285 | float _x = data[m & 0x3]; |
286 | float _y = data[(m >> 2) & 0x3]; |
287 | float _z = other_data[(m >> 4) & 0x3]; |
288 | float _w = other_data[(m >> 6) & 0x3]; |
289 | return Float32x4::New(_x, _y, _z, _w); |
290 | } |
291 | |
292 | DEFINE_NATIVE_ENTRY(Float32x4_setX, 0, 2) { |
293 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
294 | GET_NON_NULL_NATIVE_ARGUMENT(Double, x, arguments->NativeArgAt(1)); |
295 | float _x = static_cast<float>(x.value()); |
296 | float _y = self.y(); |
297 | float _z = self.z(); |
298 | float _w = self.w(); |
299 | return Float32x4::New(_x, _y, _z, _w); |
300 | } |
301 | |
302 | DEFINE_NATIVE_ENTRY(Float32x4_setY, 0, 2) { |
303 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
304 | GET_NON_NULL_NATIVE_ARGUMENT(Double, y, arguments->NativeArgAt(1)); |
305 | float _x = self.x(); |
306 | float _y = static_cast<float>(y.value()); |
307 | float _z = self.z(); |
308 | float _w = self.w(); |
309 | return Float32x4::New(_x, _y, _z, _w); |
310 | } |
311 | |
312 | DEFINE_NATIVE_ENTRY(Float32x4_setZ, 0, 2) { |
313 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
314 | GET_NON_NULL_NATIVE_ARGUMENT(Double, z, arguments->NativeArgAt(1)); |
315 | float _x = self.x(); |
316 | float _y = self.y(); |
317 | float _z = static_cast<float>(z.value()); |
318 | float _w = self.w(); |
319 | return Float32x4::New(_x, _y, _z, _w); |
320 | } |
321 | |
322 | DEFINE_NATIVE_ENTRY(Float32x4_setW, 0, 2) { |
323 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
324 | GET_NON_NULL_NATIVE_ARGUMENT(Double, w, arguments->NativeArgAt(1)); |
325 | float _x = self.x(); |
326 | float _y = self.y(); |
327 | float _z = self.z(); |
328 | float _w = static_cast<float>(w.value()); |
329 | return Float32x4::New(_x, _y, _z, _w); |
330 | } |
331 | |
332 | DEFINE_NATIVE_ENTRY(Float32x4_min, 0, 2) { |
333 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
334 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); |
335 | float _x = self.x() < other.x() ? self.x() : other.x(); |
336 | float _y = self.y() < other.y() ? self.y() : other.y(); |
337 | float _z = self.z() < other.z() ? self.z() : other.z(); |
338 | float _w = self.w() < other.w() ? self.w() : other.w(); |
339 | return Float32x4::New(_x, _y, _z, _w); |
340 | } |
341 | |
342 | DEFINE_NATIVE_ENTRY(Float32x4_max, 0, 2) { |
343 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
344 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); |
345 | float _x = self.x() > other.x() ? self.x() : other.x(); |
346 | float _y = self.y() > other.y() ? self.y() : other.y(); |
347 | float _z = self.z() > other.z() ? self.z() : other.z(); |
348 | float _w = self.w() > other.w() ? self.w() : other.w(); |
349 | return Float32x4::New(_x, _y, _z, _w); |
350 | } |
351 | |
352 | DEFINE_NATIVE_ENTRY(Float32x4_sqrt, 0, 1) { |
353 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
354 | float _x = sqrtf(self.x()); |
355 | float _y = sqrtf(self.y()); |
356 | float _z = sqrtf(self.z()); |
357 | float _w = sqrtf(self.w()); |
358 | return Float32x4::New(_x, _y, _z, _w); |
359 | } |
360 | |
361 | DEFINE_NATIVE_ENTRY(Float32x4_reciprocal, 0, 1) { |
362 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
363 | float _x = 1.0f / self.x(); |
364 | float _y = 1.0f / self.y(); |
365 | float _z = 1.0f / self.z(); |
366 | float _w = 1.0f / self.w(); |
367 | return Float32x4::New(_x, _y, _z, _w); |
368 | } |
369 | |
370 | DEFINE_NATIVE_ENTRY(Float32x4_reciprocalSqrt, 0, 1) { |
371 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); |
372 | float _x = sqrtf(1.0f / self.x()); |
373 | float _y = sqrtf(1.0f / self.y()); |
374 | float _z = sqrtf(1.0f / self.z()); |
375 | float _w = sqrtf(1.0f / self.w()); |
376 | return Float32x4::New(_x, _y, _z, _w); |
377 | } |
378 | |
379 | DEFINE_NATIVE_ENTRY(Int32x4_fromInts, 0, 4) { |
380 | GET_NON_NULL_NATIVE_ARGUMENT(Integer, x, arguments->NativeArgAt(0)); |
381 | GET_NON_NULL_NATIVE_ARGUMENT(Integer, y, arguments->NativeArgAt(1)); |
382 | GET_NON_NULL_NATIVE_ARGUMENT(Integer, z, arguments->NativeArgAt(2)); |
383 | GET_NON_NULL_NATIVE_ARGUMENT(Integer, w, arguments->NativeArgAt(3)); |
384 | int32_t _x = static_cast<int32_t>(x.AsTruncatedUint32Value()); |
385 | int32_t _y = static_cast<int32_t>(y.AsTruncatedUint32Value()); |
386 | int32_t _z = static_cast<int32_t>(z.AsTruncatedUint32Value()); |
387 | int32_t _w = static_cast<int32_t>(w.AsTruncatedUint32Value()); |
388 | return Int32x4::New(_x, _y, _z, _w); |
389 | } |
390 | |
391 | DEFINE_NATIVE_ENTRY(Int32x4_fromBools, 0, 4) { |
392 | GET_NON_NULL_NATIVE_ARGUMENT(Bool, x, arguments->NativeArgAt(0)); |
393 | GET_NON_NULL_NATIVE_ARGUMENT(Bool, y, arguments->NativeArgAt(1)); |
394 | GET_NON_NULL_NATIVE_ARGUMENT(Bool, z, arguments->NativeArgAt(2)); |
395 | GET_NON_NULL_NATIVE_ARGUMENT(Bool, w, arguments->NativeArgAt(3)); |
396 | int32_t _x = x.value() ? 0xFFFFFFFF : 0x0; |
397 | int32_t _y = y.value() ? 0xFFFFFFFF : 0x0; |
398 | int32_t _z = z.value() ? 0xFFFFFFFF : 0x0; |
399 | int32_t _w = w.value() ? 0xFFFFFFFF : 0x0; |
400 | return Int32x4::New(_x, _y, _z, _w); |
401 | } |
402 | |
403 | DEFINE_NATIVE_ENTRY(Int32x4_fromFloat32x4Bits, 0, 2) { |
404 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, v, arguments->NativeArgAt(1)); |
405 | return Int32x4::New(v.value()); |
406 | } |
407 | |
408 | DEFINE_NATIVE_ENTRY(Int32x4_or, 0, 2) { |
409 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
410 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, other, arguments->NativeArgAt(1)); |
411 | int32_t _x = self.x() | other.x(); |
412 | int32_t _y = self.y() | other.y(); |
413 | int32_t _z = self.z() | other.z(); |
414 | int32_t _w = self.w() | other.w(); |
415 | return Int32x4::New(_x, _y, _z, _w); |
416 | } |
417 | |
418 | DEFINE_NATIVE_ENTRY(Int32x4_and, 0, 2) { |
419 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
420 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, other, arguments->NativeArgAt(1)); |
421 | int32_t _x = self.x() & other.x(); |
422 | int32_t _y = self.y() & other.y(); |
423 | int32_t _z = self.z() & other.z(); |
424 | int32_t _w = self.w() & other.w(); |
425 | return Int32x4::New(_x, _y, _z, _w); |
426 | } |
427 | |
428 | DEFINE_NATIVE_ENTRY(Int32x4_xor, 0, 2) { |
429 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
430 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, other, arguments->NativeArgAt(1)); |
431 | int32_t _x = self.x() ^ other.x(); |
432 | int32_t _y = self.y() ^ other.y(); |
433 | int32_t _z = self.z() ^ other.z(); |
434 | int32_t _w = self.w() ^ other.w(); |
435 | return Int32x4::New(_x, _y, _z, _w); |
436 | } |
437 | |
438 | DEFINE_NATIVE_ENTRY(Int32x4_add, 0, 2) { |
439 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
440 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, other, arguments->NativeArgAt(1)); |
441 | int32_t _x = self.x() + other.x(); |
442 | int32_t _y = self.y() + other.y(); |
443 | int32_t _z = self.z() + other.z(); |
444 | int32_t _w = self.w() + other.w(); |
445 | return Int32x4::New(_x, _y, _z, _w); |
446 | } |
447 | |
448 | DEFINE_NATIVE_ENTRY(Int32x4_sub, 0, 2) { |
449 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
450 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, other, arguments->NativeArgAt(1)); |
451 | int32_t _x = self.x() - other.x(); |
452 | int32_t _y = self.y() - other.y(); |
453 | int32_t _z = self.z() - other.z(); |
454 | int32_t _w = self.w() - other.w(); |
455 | return Int32x4::New(_x, _y, _z, _w); |
456 | } |
457 | |
458 | DEFINE_NATIVE_ENTRY(Int32x4_getX, 0, 1) { |
459 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
460 | int32_t value = self.x(); |
461 | return Integer::New(value); |
462 | } |
463 | |
464 | DEFINE_NATIVE_ENTRY(Int32x4_getY, 0, 1) { |
465 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
466 | int32_t value = self.y(); |
467 | return Integer::New(value); |
468 | } |
469 | |
470 | DEFINE_NATIVE_ENTRY(Int32x4_getZ, 0, 1) { |
471 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
472 | int32_t value = self.z(); |
473 | return Integer::New(value); |
474 | } |
475 | |
476 | DEFINE_NATIVE_ENTRY(Int32x4_getW, 0, 1) { |
477 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
478 | int32_t value = self.w(); |
479 | return Integer::New(value); |
480 | } |
481 | |
482 | DEFINE_NATIVE_ENTRY(Int32x4_shuffle, 0, 2) { |
483 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
484 | GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(1)); |
485 | int64_t m = mask.AsInt64Value(); |
486 | ThrowMaskRangeException(m); |
487 | int32_t data[4] = {self.x(), self.y(), self.z(), self.w()}; |
488 | int32_t _x = data[m & 0x3]; |
489 | int32_t _y = data[(m >> 2) & 0x3]; |
490 | int32_t _z = data[(m >> 4) & 0x3]; |
491 | int32_t _w = data[(m >> 6) & 0x3]; |
492 | return Int32x4::New(_x, _y, _z, _w); |
493 | } |
494 | |
495 | DEFINE_NATIVE_ENTRY(Int32x4_shuffleMix, 0, 3) { |
496 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
497 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, zw, arguments->NativeArgAt(1)); |
498 | GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(2)); |
499 | int64_t m = mask.AsInt64Value(); |
500 | ThrowMaskRangeException(m); |
501 | int32_t data[4] = {self.x(), self.y(), self.z(), self.w()}; |
502 | int32_t zw_data[4] = {zw.x(), zw.y(), zw.z(), zw.w()}; |
503 | int32_t _x = data[m & 0x3]; |
504 | int32_t _y = data[(m >> 2) & 0x3]; |
505 | int32_t _z = zw_data[(m >> 4) & 0x3]; |
506 | int32_t _w = zw_data[(m >> 6) & 0x3]; |
507 | return Int32x4::New(_x, _y, _z, _w); |
508 | } |
509 | |
510 | DEFINE_NATIVE_ENTRY(Int32x4_setX, 0, 2) { |
511 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
512 | GET_NON_NULL_NATIVE_ARGUMENT(Integer, x, arguments->NativeArgAt(1)); |
513 | int32_t _x = static_cast<int32_t>(x.AsInt64Value() & 0xFFFFFFFF); |
514 | int32_t _y = self.y(); |
515 | int32_t _z = self.z(); |
516 | int32_t _w = self.w(); |
517 | return Int32x4::New(_x, _y, _z, _w); |
518 | } |
519 | |
520 | DEFINE_NATIVE_ENTRY(Int32x4_setY, 0, 2) { |
521 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
522 | GET_NON_NULL_NATIVE_ARGUMENT(Integer, y, arguments->NativeArgAt(1)); |
523 | int32_t _x = self.x(); |
524 | int32_t _y = static_cast<int32_t>(y.AsInt64Value() & 0xFFFFFFFF); |
525 | int32_t _z = self.z(); |
526 | int32_t _w = self.w(); |
527 | return Int32x4::New(_x, _y, _z, _w); |
528 | } |
529 | |
530 | DEFINE_NATIVE_ENTRY(Int32x4_setZ, 0, 2) { |
531 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
532 | GET_NON_NULL_NATIVE_ARGUMENT(Integer, z, arguments->NativeArgAt(1)); |
533 | int32_t _x = self.x(); |
534 | int32_t _y = self.y(); |
535 | int32_t _z = static_cast<int32_t>(z.AsInt64Value() & 0xFFFFFFFF); |
536 | int32_t _w = self.w(); |
537 | return Int32x4::New(_x, _y, _z, _w); |
538 | } |
539 | |
540 | DEFINE_NATIVE_ENTRY(Int32x4_setW, 0, 2) { |
541 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
542 | GET_NON_NULL_NATIVE_ARGUMENT(Integer, w, arguments->NativeArgAt(1)); |
543 | int32_t _x = self.x(); |
544 | int32_t _y = self.y(); |
545 | int32_t _z = self.z(); |
546 | int32_t _w = static_cast<int32_t>(w.AsInt64Value() & 0xFFFFFFFF); |
547 | return Int32x4::New(_x, _y, _z, _w); |
548 | } |
549 | |
550 | DEFINE_NATIVE_ENTRY(Int32x4_getFlagX, 0, 1) { |
551 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
552 | int32_t value = self.x(); |
553 | return Bool::Get(value != 0).raw(); |
554 | } |
555 | |
556 | DEFINE_NATIVE_ENTRY(Int32x4_getFlagY, 0, 1) { |
557 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
558 | int32_t value = self.y(); |
559 | return Bool::Get(value != 0).raw(); |
560 | } |
561 | |
562 | DEFINE_NATIVE_ENTRY(Int32x4_getFlagZ, 0, 1) { |
563 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
564 | int32_t value = self.z(); |
565 | return Bool::Get(value != 0).raw(); |
566 | } |
567 | |
568 | DEFINE_NATIVE_ENTRY(Int32x4_getFlagW, 0, 1) { |
569 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
570 | int32_t value = self.w(); |
571 | return Bool::Get(value != 0).raw(); |
572 | } |
573 | |
574 | DEFINE_NATIVE_ENTRY(Int32x4_setFlagX, 0, 2) { |
575 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
576 | GET_NON_NULL_NATIVE_ARGUMENT(Bool, flagX, arguments->NativeArgAt(1)); |
577 | int32_t _x = self.x(); |
578 | int32_t _y = self.y(); |
579 | int32_t _z = self.z(); |
580 | int32_t _w = self.w(); |
581 | _x = flagX.raw() == Bool::True().raw() ? 0xFFFFFFFF : 0x0; |
582 | return Int32x4::New(_x, _y, _z, _w); |
583 | } |
584 | |
585 | DEFINE_NATIVE_ENTRY(Int32x4_setFlagY, 0, 2) { |
586 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
587 | GET_NON_NULL_NATIVE_ARGUMENT(Bool, flagY, arguments->NativeArgAt(1)); |
588 | int32_t _x = self.x(); |
589 | int32_t _y = self.y(); |
590 | int32_t _z = self.z(); |
591 | int32_t _w = self.w(); |
592 | _y = flagY.raw() == Bool::True().raw() ? 0xFFFFFFFF : 0x0; |
593 | return Int32x4::New(_x, _y, _z, _w); |
594 | } |
595 | |
596 | DEFINE_NATIVE_ENTRY(Int32x4_setFlagZ, 0, 2) { |
597 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
598 | GET_NON_NULL_NATIVE_ARGUMENT(Bool, flagZ, arguments->NativeArgAt(1)); |
599 | int32_t _x = self.x(); |
600 | int32_t _y = self.y(); |
601 | int32_t _z = self.z(); |
602 | int32_t _w = self.w(); |
603 | _z = flagZ.raw() == Bool::True().raw() ? 0xFFFFFFFF : 0x0; |
604 | return Int32x4::New(_x, _y, _z, _w); |
605 | } |
606 | |
607 | DEFINE_NATIVE_ENTRY(Int32x4_setFlagW, 0, 2) { |
608 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
609 | GET_NON_NULL_NATIVE_ARGUMENT(Bool, flagW, arguments->NativeArgAt(1)); |
610 | int32_t _x = self.x(); |
611 | int32_t _y = self.y(); |
612 | int32_t _z = self.z(); |
613 | int32_t _w = self.w(); |
614 | _w = flagW.raw() == Bool::True().raw() ? 0xFFFFFFFF : 0x0; |
615 | return Int32x4::New(_x, _y, _z, _w); |
616 | } |
617 | |
618 | // Used to convert between int32_t and float32 without breaking strict |
619 | // aliasing rules. |
620 | union float32_int32 { |
621 | float f; |
622 | int32_t u; |
623 | float32_int32(float v) { f = v; } |
624 | float32_int32(int32_t v) { u = v; } |
625 | }; |
626 | |
627 | DEFINE_NATIVE_ENTRY(Int32x4_select, 0, 3) { |
628 | GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); |
629 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, tv, arguments->NativeArgAt(1)); |
630 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, fv, arguments->NativeArgAt(2)); |
631 | int32_t _maskX = self.x(); |
632 | int32_t _maskY = self.y(); |
633 | int32_t _maskZ = self.z(); |
634 | int32_t _maskW = self.w(); |
635 | // Extract floats and interpret them as masks. |
636 | float32_int32 tvx(tv.x()); |
637 | float32_int32 tvy(tv.y()); |
638 | float32_int32 tvz(tv.z()); |
639 | float32_int32 tvw(tv.w()); |
640 | float32_int32 fvx(fv.x()); |
641 | float32_int32 fvy(fv.y()); |
642 | float32_int32 fvz(fv.z()); |
643 | float32_int32 fvw(fv.w()); |
644 | // Perform select. |
645 | float32_int32 tempX((_maskX & tvx.u) | (~_maskX & fvx.u)); |
646 | float32_int32 tempY((_maskY & tvy.u) | (~_maskY & fvy.u)); |
647 | float32_int32 tempZ((_maskZ & tvz.u) | (~_maskZ & fvz.u)); |
648 | float32_int32 tempW((_maskW & tvw.u) | (~_maskW & fvw.u)); |
649 | return Float32x4::New(tempX.f, tempY.f, tempZ.f, tempW.f); |
650 | } |
651 | |
652 | DEFINE_NATIVE_ENTRY(Float64x2_fromDoubles, 0, 2) { |
653 | GET_NON_NULL_NATIVE_ARGUMENT(Double, x, arguments->NativeArgAt(0)); |
654 | GET_NON_NULL_NATIVE_ARGUMENT(Double, y, arguments->NativeArgAt(1)); |
655 | return Float64x2::New(x.value(), y.value()); |
656 | } |
657 | |
658 | DEFINE_NATIVE_ENTRY(Float64x2_splat, 0, 1) { |
659 | GET_NON_NULL_NATIVE_ARGUMENT(Double, v, arguments->NativeArgAt(0)); |
660 | return Float64x2::New(v.value(), v.value()); |
661 | } |
662 | |
663 | DEFINE_NATIVE_ENTRY(Float64x2_zero, 0, 1) { |
664 | ASSERT( |
665 | TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(0)).IsNull()); |
666 | return Float64x2::New(0.0, 0.0); |
667 | } |
668 | |
669 | DEFINE_NATIVE_ENTRY(Float64x2_fromFloat32x4, 0, 2) { |
670 | ASSERT( |
671 | TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(0)).IsNull()); |
672 | GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, v, arguments->NativeArgAt(1)); |
673 | double _x = v.x(); |
674 | double _y = v.y(); |
675 | return Float64x2::New(_x, _y); |
676 | } |
677 | |
678 | DEFINE_NATIVE_ENTRY(Float64x2_add, 0, 2) { |
679 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
680 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, other, arguments->NativeArgAt(1)); |
681 | double _x = self.x() + other.x(); |
682 | double _y = self.y() + other.y(); |
683 | return Float64x2::New(_x, _y); |
684 | } |
685 | |
686 | DEFINE_NATIVE_ENTRY(Float64x2_negate, 0, 1) { |
687 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
688 | double _x = -self.x(); |
689 | double _y = -self.y(); |
690 | return Float64x2::New(_x, _y); |
691 | } |
692 | |
693 | DEFINE_NATIVE_ENTRY(Float64x2_sub, 0, 2) { |
694 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
695 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, other, arguments->NativeArgAt(1)); |
696 | double _x = self.x() - other.x(); |
697 | double _y = self.y() - other.y(); |
698 | return Float64x2::New(_x, _y); |
699 | } |
700 | |
701 | DEFINE_NATIVE_ENTRY(Float64x2_mul, 0, 2) { |
702 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
703 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, other, arguments->NativeArgAt(1)); |
704 | double _x = self.x() * other.x(); |
705 | double _y = self.y() * other.y(); |
706 | return Float64x2::New(_x, _y); |
707 | } |
708 | |
709 | DEFINE_NATIVE_ENTRY(Float64x2_div, 0, 2) { |
710 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
711 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, other, arguments->NativeArgAt(1)); |
712 | double _x = self.x() / other.x(); |
713 | double _y = self.y() / other.y(); |
714 | return Float64x2::New(_x, _y); |
715 | } |
716 | |
717 | DEFINE_NATIVE_ENTRY(Float64x2_scale, 0, 2) { |
718 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
719 | GET_NON_NULL_NATIVE_ARGUMENT(Double, scale, arguments->NativeArgAt(1)); |
720 | double _s = scale.value(); |
721 | double _x = self.x() * _s; |
722 | double _y = self.y() * _s; |
723 | return Float64x2::New(_x, _y); |
724 | } |
725 | |
726 | DEFINE_NATIVE_ENTRY(Float64x2_abs, 0, 1) { |
727 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
728 | double _x = fabs(self.x()); |
729 | double _y = fabs(self.y()); |
730 | return Float64x2::New(_x, _y); |
731 | } |
732 | |
733 | DEFINE_NATIVE_ENTRY(Float64x2_clamp, 0, 3) { |
734 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
735 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, lo, arguments->NativeArgAt(1)); |
736 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, hi, arguments->NativeArgAt(2)); |
737 | // The order of the clamping must match the order of the optimized code: |
738 | // MAX(MIN(self, hi), lo). |
739 | double _x; |
740 | double _y; |
741 | |
742 | // ARM semantics are different from X86/X64 at an instruction level. Ensure |
743 | // that we match the semantics of the architecture in the C version. |
744 | #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
745 | _x = self.x() < hi.x() ? self.x() : hi.x(); |
746 | _y = self.y() < hi.y() ? self.y() : hi.y(); |
747 | _x = lo.x() < _x ? _x : lo.x(); |
748 | _y = lo.y() < _y ? _y : lo.y(); |
749 | #else |
750 | _x = fmin(self.x(), hi.x()); |
751 | _y = fmin(self.y(), hi.y()); |
752 | _x = fmax(_x, lo.x()); |
753 | _y = fmax(_y, lo.y()); |
754 | #endif |
755 | return Float64x2::New(_x, _y); |
756 | } |
757 | |
758 | DEFINE_NATIVE_ENTRY(Float64x2_getX, 0, 1) { |
759 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
760 | return Double::New(self.x()); |
761 | } |
762 | |
763 | DEFINE_NATIVE_ENTRY(Float64x2_getY, 0, 1) { |
764 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
765 | return Double::New(self.y()); |
766 | } |
767 | |
768 | DEFINE_NATIVE_ENTRY(Float64x2_getSignMask, 0, 1) { |
769 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
770 | uint32_t mx = (bit_cast<uint64_t>(self.x()) & 0x8000000000000000LL) >> 63; |
771 | uint32_t my = (bit_cast<uint64_t>(self.y()) & 0x8000000000000000LL) >> 63; |
772 | uint32_t value = mx | (my << 1); |
773 | return Integer::New(value); |
774 | } |
775 | |
776 | DEFINE_NATIVE_ENTRY(Float64x2_setX, 0, 2) { |
777 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
778 | GET_NON_NULL_NATIVE_ARGUMENT(Double, x, arguments->NativeArgAt(1)); |
779 | double _x = x.value(); |
780 | double _y = self.y(); |
781 | return Float64x2::New(_x, _y); |
782 | } |
783 | |
784 | DEFINE_NATIVE_ENTRY(Float64x2_setY, 0, 2) { |
785 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
786 | GET_NON_NULL_NATIVE_ARGUMENT(Double, y, arguments->NativeArgAt(1)); |
787 | double _x = self.x(); |
788 | double _y = y.value(); |
789 | return Float64x2::New(_x, _y); |
790 | } |
791 | |
792 | DEFINE_NATIVE_ENTRY(Float64x2_min, 0, 2) { |
793 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
794 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, other, arguments->NativeArgAt(1)); |
795 | double _x = self.x() < other.x() ? self.x() : other.x(); |
796 | double _y = self.y() < other.y() ? self.y() : other.y(); |
797 | return Float64x2::New(_x, _y); |
798 | } |
799 | |
800 | DEFINE_NATIVE_ENTRY(Float64x2_max, 0, 2) { |
801 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
802 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, other, arguments->NativeArgAt(1)); |
803 | double _x = self.x() > other.x() ? self.x() : other.x(); |
804 | double _y = self.y() > other.y() ? self.y() : other.y(); |
805 | return Float64x2::New(_x, _y); |
806 | } |
807 | |
808 | DEFINE_NATIVE_ENTRY(Float64x2_sqrt, 0, 1) { |
809 | GET_NON_NULL_NATIVE_ARGUMENT(Float64x2, self, arguments->NativeArgAt(0)); |
810 | double _x = sqrt(self.x()); |
811 | double _y = sqrt(self.y()); |
812 | return Float64x2::New(_x, _y); |
813 | } |
814 | |
815 | } // namespace dart |
816 | |