OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/exceptions.h" | 8 #include "vm/exceptions.h" |
9 #include "vm/native_entry.h" | 9 #include "vm/native_entry.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #define SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT) \ | 51 #define SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT) \ |
52 GET_NATIVE_ARGUMENT(ArrayT, array, arguments->At(0)); \ | 52 GET_NATIVE_ARGUMENT(ArrayT, array, arguments->At(0)); \ |
53 GET_NATIVE_ARGUMENT(Smi, index, arguments->At(1)); \ | 53 GET_NATIVE_ARGUMENT(Smi, index, arguments->At(1)); \ |
54 GET_NATIVE_ARGUMENT(ObjectT, value_object, arguments->At(2)); | 54 GET_NATIVE_ARGUMENT(ObjectT, value_object, arguments->At(2)); |
55 | 55 |
56 | 56 |
57 #define GETTER(ArrayT, ObjectT, ValueT) \ | 57 #define GETTER(ArrayT, ObjectT, ValueT) \ |
58 GETTER_ARGUMENTS(ArrayT, ValueT); \ | 58 GETTER_ARGUMENTS(ArrayT, ValueT); \ |
59 RangeCheck(array, index.Value() * sizeof(ValueT), sizeof(ValueT)); \ | 59 RangeCheck(array, index.Value() * sizeof(ValueT), sizeof(ValueT)); \ |
60 ValueT result = array.At(index.Value()); \ | 60 ValueT result = array.At(index.Value()); \ |
61 arguments->SetReturn(ObjectT::Handle(ObjectT::New(result))); | 61 return ObjectT::New(result); |
62 | 62 |
63 | 63 |
64 #define SETTER(ArrayT, ObjectT, Getter, ValueT) \ | 64 #define SETTER(ArrayT, ObjectT, Getter, ValueT) \ |
65 SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT); \ | 65 SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT); \ |
66 RangeCheck(array, index.Value() * sizeof(ValueT), sizeof(ValueT)); \ | 66 RangeCheck(array, index.Value() * sizeof(ValueT), sizeof(ValueT)); \ |
67 ValueT value = value_object.Getter(); \ | 67 ValueT value = value_object.Getter(); \ |
68 array.SetAt(index.Value(), value); | 68 array.SetAt(index.Value(), value); \ |
| 69 return Object::null(); |
69 | 70 |
70 | 71 |
71 #define UNALIGNED_GETTER(ArrayT, ObjectT, ValueT) \ | 72 #define UNALIGNED_GETTER(ArrayT, ObjectT, ValueT) \ |
72 GETTER_ARGUMENTS(ArrayT, ValueT); \ | 73 GETTER_ARGUMENTS(ArrayT, ValueT); \ |
73 RangeCheck(array, index.Value(), sizeof(ValueT)); \ | 74 RangeCheck(array, index.Value(), sizeof(ValueT)); \ |
74 ValueT result; \ | 75 ValueT result; \ |
75 ByteArray::Copy(&result, array, index.Value(), sizeof(ValueT)); \ | 76 ByteArray::Copy(&result, array, index.Value(), sizeof(ValueT)); \ |
76 arguments->SetReturn(ObjectT::Handle(ObjectT::New(result))); | 77 return ObjectT::New(result); |
77 | 78 |
78 | 79 |
79 #define UNALIGNED_SETTER(ArrayT, ObjectT, Getter, ValueT) \ | 80 #define UNALIGNED_SETTER(ArrayT, ObjectT, Getter, ValueT) \ |
80 SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT); \ | 81 SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT); \ |
81 RangeCheck(array, index.Value(), sizeof(ValueT)); \ | 82 RangeCheck(array, index.Value(), sizeof(ValueT)); \ |
82 ValueT src = value_object.Getter(); \ | 83 ValueT src = value_object.Getter(); \ |
83 ByteArray::Copy(array, index.Value(), &src, sizeof(ValueT)); \ | 84 ByteArray::Copy(array, index.Value(), &src, sizeof(ValueT)); \ |
84 Integer& result = Integer::Handle(); \ | 85 return Integer::New(index.Value() + sizeof(ValueT)); |
85 result ^= Integer::New(index.Value() + sizeof(ValueT)); \ | |
86 arguments->SetReturn(result); | |
87 | 86 |
88 | 87 |
89 #define UINT64_TO_INTEGER(value, integer) \ | 88 #define UINT64_TO_INTEGER(value, integer) \ |
90 if (value > static_cast<uint64_t>(Mint::kMaxValue)) { \ | 89 if (value > static_cast<uint64_t>(Mint::kMaxValue)) { \ |
91 result = BigintOperations::NewFromUint64(value); \ | 90 result = BigintOperations::NewFromUint64(value); \ |
92 } else if (value > static_cast<uint64_t>(Smi::kMaxValue)) { \ | 91 } else if (value > static_cast<uint64_t>(Smi::kMaxValue)) { \ |
93 result = Mint::New(value); \ | 92 result = Mint::New(value); \ |
94 } else { \ | 93 } else { \ |
95 result = Smi::New(value); \ | 94 result = Smi::New(value); \ |
96 } | 95 } |
97 | 96 |
98 | 97 |
99 #define GETTER_UINT64(ArrayT) \ | 98 #define GETTER_UINT64(ArrayT) \ |
100 GETTER_ARGUMENTS(ArrayT, uint64_t); \ | 99 GETTER_ARGUMENTS(ArrayT, uint64_t); \ |
101 intptr_t size = sizeof(uint64_t); \ | 100 intptr_t size = sizeof(uint64_t); \ |
102 RangeCheck(array, index.Value() * size, size); \ | 101 RangeCheck(array, index.Value() * size, size); \ |
103 uint64_t value = array.At(index.Value()); \ | 102 uint64_t value = array.At(index.Value()); \ |
104 Integer& result = Integer::Handle(); \ | 103 Integer& result = Integer::Handle(); \ |
105 UINT64_TO_INTEGER(value, result); \ | 104 UINT64_TO_INTEGER(value, result); \ |
106 arguments->SetReturn(result); | 105 return result.raw(); |
107 | 106 |
108 | 107 |
109 #define UNALIGNED_GETTER_UINT64(ArrayT) \ | 108 #define UNALIGNED_GETTER_UINT64(ArrayT) \ |
110 GETTER_ARGUMENTS(ArrayT, uint64_t); \ | 109 GETTER_ARGUMENTS(ArrayT, uint64_t); \ |
111 RangeCheck(array, index.Value(), sizeof(uint64_t)); \ | 110 RangeCheck(array, index.Value(), sizeof(uint64_t)); \ |
112 uint64_t value; \ | 111 uint64_t value; \ |
113 ByteArray::Copy(&value, array, index.Value(), sizeof(uint64_t)); \ | 112 ByteArray::Copy(&value, array, index.Value(), sizeof(uint64_t)); \ |
114 Integer& result = Integer::Handle(); \ | 113 Integer& result = Integer::Handle(); \ |
115 UINT64_TO_INTEGER(value, result); \ | 114 UINT64_TO_INTEGER(value, result); \ |
116 arguments->SetReturn(result); | 115 return result.raw(); |
117 | 116 |
118 | 117 |
119 #define INTEGER_TO_UINT64(integer, uint64) \ | 118 #define INTEGER_TO_UINT64(integer, uint64) \ |
120 if (integer.IsBigint()) { \ | 119 if (integer.IsBigint()) { \ |
121 Bigint& bigint = Bigint::Handle(); \ | 120 Bigint& bigint = Bigint::Handle(); \ |
122 bigint ^= integer.raw(); \ | 121 bigint ^= integer.raw(); \ |
123 ASSERT(BigintOperations::FitsIntoUint64(bigint)); \ | 122 ASSERT(BigintOperations::FitsIntoUint64(bigint)); \ |
124 value = BigintOperations::AbsToUint64(bigint); \ | 123 value = BigintOperations::AbsToUint64(bigint); \ |
125 } else { \ | 124 } else { \ |
126 ASSERT(integer.IsMint() || integer.IsSmi()); \ | 125 ASSERT(integer.IsMint() || integer.IsSmi()); \ |
127 value = integer.AsInt64Value(); \ | 126 value = integer.AsInt64Value(); \ |
128 } \ | 127 } \ |
129 | 128 |
130 | 129 |
131 #define SETTER_UINT64(ArrayT) \ | 130 #define SETTER_UINT64(ArrayT) \ |
132 SETTER_ARGUMENTS(ArrayT, Integer, uint64_t); \ | 131 SETTER_ARGUMENTS(ArrayT, Integer, uint64_t); \ |
133 intptr_t size = sizeof(uint64_t); \ | 132 intptr_t size = sizeof(uint64_t); \ |
134 RangeCheck(array, index.Value() * size, size); \ | 133 RangeCheck(array, index.Value() * size, size); \ |
135 uint64_t value; \ | 134 uint64_t value; \ |
136 INTEGER_TO_UINT64(value_object, value); \ | 135 INTEGER_TO_UINT64(value_object, value); \ |
137 array.SetAt(index.Value(), value); | 136 array.SetAt(index.Value(), value); \ |
| 137 return Object::null(); |
138 | 138 |
139 | 139 |
140 #define UNALIGNED_SETTER_UINT64(ArrayT) \ | 140 #define UNALIGNED_SETTER_UINT64(ArrayT) \ |
141 SETTER_ARGUMENTS(ArrayT, Integer, uint64_t); \ | 141 SETTER_ARGUMENTS(ArrayT, Integer, uint64_t); \ |
142 RangeCheck(array, index.Value(), sizeof(uint64_t)); \ | 142 RangeCheck(array, index.Value(), sizeof(uint64_t)); \ |
143 uint64_t value; \ | 143 uint64_t value; \ |
144 INTEGER_TO_UINT64(value_object, value); \ | 144 INTEGER_TO_UINT64(value_object, value); \ |
145 ByteArray::Copy(array, index.Value(), &value, sizeof(uint64_t)); \ | 145 ByteArray::Copy(array, index.Value(), &value, sizeof(uint64_t)); \ |
146 Integer& result = Integer::Handle(); \ | 146 return Integer::New(index.Value() + sizeof(uint64_t)); |
147 result ^= Integer::New(index.Value() + sizeof(uint64_t)); \ | |
148 arguments->SetReturn(result); | |
149 | 147 |
150 | 148 |
151 DEFINE_NATIVE_ENTRY(ByteArray_getLength, 1) { | 149 DEFINE_NATIVE_ENTRY(ByteArray_getLength, 1) { |
152 GET_NATIVE_ARGUMENT(ByteArray, array, arguments->At(0)); | 150 GET_NATIVE_ARGUMENT(ByteArray, array, arguments->At(0)); |
153 const Smi& length = Smi::Handle(Smi::New(array.Length())); | 151 return Smi::New(array.Length()); |
154 arguments->SetReturn(length); | |
155 } | 152 } |
156 | 153 |
157 | 154 |
158 DEFINE_NATIVE_ENTRY(ByteArray_getInt8, 2) { | 155 DEFINE_NATIVE_ENTRY(ByteArray_getInt8, 2) { |
159 UNALIGNED_GETTER(ByteArray, Smi, int8_t); | 156 UNALIGNED_GETTER(ByteArray, Smi, int8_t); |
160 } | 157 } |
161 | 158 |
162 | 159 |
163 DEFINE_NATIVE_ENTRY(ByteArray_setInt8, 3) { | 160 DEFINE_NATIVE_ENTRY(ByteArray_setInt8, 3) { |
164 UNALIGNED_SETTER(ByteArray, Smi, Value, int8_t); | 161 UNALIGNED_SETTER(ByteArray, Smi, Value, int8_t); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 if (length_value < 0) { | 264 if (length_value < 0) { |
268 const String& error = String::Handle(String::NewFormatted( | 265 const String& error = String::Handle(String::NewFormatted( |
269 "length (%ld) must be non-negative", length_value)); | 266 "length (%ld) must be non-negative", length_value)); |
270 GrowableArray<const Object*> args; | 267 GrowableArray<const Object*> args; |
271 args.Add(&error); | 268 args.Add(&error); |
272 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); | 269 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); |
273 } | 270 } |
274 RangeCheck(src, src_start_value, length_value); | 271 RangeCheck(src, src_start_value, length_value); |
275 RangeCheck(dst, dst_start_value, length_value); | 272 RangeCheck(dst, dst_start_value, length_value); |
276 ByteArray::Copy(dst, dst_start_value, src, src_start_value, length_value); | 273 ByteArray::Copy(dst, dst_start_value, src, src_start_value, length_value); |
| 274 return Object::null(); |
277 } | 275 } |
278 | 276 |
279 | 277 |
280 // Int8Array | 278 // Int8Array |
281 | 279 |
282 DEFINE_NATIVE_ENTRY(Int8Array_new, 1) { | 280 DEFINE_NATIVE_ENTRY(Int8Array_new, 1) { |
283 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); | 281 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); |
284 intptr_t len = length.Value(); | 282 intptr_t len = length.Value(); |
285 LengthCheck(len, Int8Array::kMaxElements); | 283 LengthCheck(len, Int8Array::kMaxElements); |
286 const Int8Array& new_array = Int8Array::Handle(Int8Array::New(len)); | 284 return Int8Array::New(len); |
287 arguments->SetReturn(new_array); | |
288 } | 285 } |
289 | 286 |
290 | 287 |
291 DEFINE_NATIVE_ENTRY(Int8Array_getIndexed, 2) { | 288 DEFINE_NATIVE_ENTRY(Int8Array_getIndexed, 2) { |
292 GETTER(Int8Array, Smi, int8_t); | 289 GETTER(Int8Array, Smi, int8_t); |
293 } | 290 } |
294 | 291 |
295 | 292 |
296 DEFINE_NATIVE_ENTRY(Int8Array_setIndexed, 3) { | 293 DEFINE_NATIVE_ENTRY(Int8Array_setIndexed, 3) { |
297 SETTER(Int8Array, Smi, Value, int8_t); | 294 SETTER(Int8Array, Smi, Value, int8_t); |
298 } | 295 } |
299 | 296 |
300 | 297 |
301 // Uint8Array | 298 // Uint8Array |
302 | 299 |
303 DEFINE_NATIVE_ENTRY(Uint8Array_new, 1) { | 300 DEFINE_NATIVE_ENTRY(Uint8Array_new, 1) { |
304 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); | 301 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); |
305 intptr_t len = length.Value(); | 302 intptr_t len = length.Value(); |
306 LengthCheck(len, Uint8Array::kMaxElements); | 303 LengthCheck(len, Uint8Array::kMaxElements); |
307 const Uint8Array& new_array = Uint8Array::Handle(Uint8Array::New(len)); | 304 return Uint8Array::New(len); |
308 arguments->SetReturn(new_array); | |
309 } | 305 } |
310 | 306 |
311 | 307 |
312 DEFINE_NATIVE_ENTRY(Uint8Array_getIndexed, 2) { | 308 DEFINE_NATIVE_ENTRY(Uint8Array_getIndexed, 2) { |
313 GETTER(Uint8Array, Smi, uint8_t); | 309 GETTER(Uint8Array, Smi, uint8_t); |
314 } | 310 } |
315 | 311 |
316 | 312 |
317 DEFINE_NATIVE_ENTRY(Uint8Array_setIndexed, 3) { | 313 DEFINE_NATIVE_ENTRY(Uint8Array_setIndexed, 3) { |
318 SETTER(Uint8Array, Smi, Value, uint8_t); | 314 SETTER(Uint8Array, Smi, Value, uint8_t); |
319 } | 315 } |
320 | 316 |
321 | 317 |
322 // Int16Array | 318 // Int16Array |
323 | 319 |
324 DEFINE_NATIVE_ENTRY(Int16Array_new, 1) { | 320 DEFINE_NATIVE_ENTRY(Int16Array_new, 1) { |
325 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); | 321 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); |
326 intptr_t len = length.Value(); | 322 intptr_t len = length.Value(); |
327 LengthCheck(len, Int16Array::kMaxElements); | 323 LengthCheck(len, Int16Array::kMaxElements); |
328 const Int16Array& new_array = Int16Array::Handle(Int16Array::New(len)); | 324 return Int16Array::New(len); |
329 arguments->SetReturn(new_array); | |
330 } | 325 } |
331 | 326 |
332 | 327 |
333 DEFINE_NATIVE_ENTRY(Int16Array_getIndexed, 2) { | 328 DEFINE_NATIVE_ENTRY(Int16Array_getIndexed, 2) { |
334 GETTER(Int16Array, Smi, int16_t); | 329 GETTER(Int16Array, Smi, int16_t); |
335 } | 330 } |
336 | 331 |
337 | 332 |
338 DEFINE_NATIVE_ENTRY(Int16Array_setIndexed, 3) { | 333 DEFINE_NATIVE_ENTRY(Int16Array_setIndexed, 3) { |
339 SETTER(Int16Array, Smi, Value, int16_t); | 334 SETTER(Int16Array, Smi, Value, int16_t); |
340 } | 335 } |
341 | 336 |
342 | 337 |
343 // Uint16Array | 338 // Uint16Array |
344 | 339 |
345 DEFINE_NATIVE_ENTRY(Uint16Array_new, 1) { | 340 DEFINE_NATIVE_ENTRY(Uint16Array_new, 1) { |
346 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); | 341 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); |
347 intptr_t len = length.Value(); | 342 intptr_t len = length.Value(); |
348 LengthCheck(len, Uint16Array::kMaxElements); | 343 LengthCheck(len, Uint16Array::kMaxElements); |
349 const Uint16Array& new_array = Uint16Array::Handle(Uint16Array::New(len)); | 344 return Uint16Array::New(len); |
350 arguments->SetReturn(new_array); | |
351 } | 345 } |
352 | 346 |
353 | 347 |
354 DEFINE_NATIVE_ENTRY(Uint16Array_getIndexed, 2) { | 348 DEFINE_NATIVE_ENTRY(Uint16Array_getIndexed, 2) { |
355 GETTER(Uint16Array, Smi, uint16_t); | 349 GETTER(Uint16Array, Smi, uint16_t); |
356 } | 350 } |
357 | 351 |
358 | 352 |
359 DEFINE_NATIVE_ENTRY(Uint16Array_setIndexed, 3) { | 353 DEFINE_NATIVE_ENTRY(Uint16Array_setIndexed, 3) { |
360 SETTER(Uint16Array, Smi, Value, uint16_t); | 354 SETTER(Uint16Array, Smi, Value, uint16_t); |
361 } | 355 } |
362 | 356 |
363 | 357 |
364 // Int32Array | 358 // Int32Array |
365 | 359 |
366 DEFINE_NATIVE_ENTRY(Int32Array_new, 1) { | 360 DEFINE_NATIVE_ENTRY(Int32Array_new, 1) { |
367 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); | 361 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); |
368 intptr_t len = length.Value(); | 362 intptr_t len = length.Value(); |
369 LengthCheck(len, Int32Array::kMaxElements); | 363 LengthCheck(len, Int32Array::kMaxElements); |
370 const Int32Array& new_array = Int32Array::Handle(Int32Array::New(len)); | 364 return Int32Array::New(len); |
371 arguments->SetReturn(new_array); | |
372 } | 365 } |
373 | 366 |
374 | 367 |
375 DEFINE_NATIVE_ENTRY(Int32Array_getIndexed, 2) { | 368 DEFINE_NATIVE_ENTRY(Int32Array_getIndexed, 2) { |
376 GETTER(Int32Array, Integer, int32_t); | 369 GETTER(Int32Array, Integer, int32_t); |
377 } | 370 } |
378 | 371 |
379 | 372 |
380 DEFINE_NATIVE_ENTRY(Int32Array_setIndexed, 3) { | 373 DEFINE_NATIVE_ENTRY(Int32Array_setIndexed, 3) { |
381 SETTER(Int32Array, Integer, AsInt64Value, int32_t); | 374 SETTER(Int32Array, Integer, AsInt64Value, int32_t); |
382 } | 375 } |
383 | 376 |
384 | 377 |
385 // Uint32Array | 378 // Uint32Array |
386 | 379 |
387 DEFINE_NATIVE_ENTRY(Uint32Array_new, 1) { | 380 DEFINE_NATIVE_ENTRY(Uint32Array_new, 1) { |
388 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); | 381 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); |
389 intptr_t len = length.Value(); | 382 intptr_t len = length.Value(); |
390 LengthCheck(len, Uint32Array::kMaxElements); | 383 LengthCheck(len, Uint32Array::kMaxElements); |
391 const Uint32Array& new_array = Uint32Array::Handle(Uint32Array::New(len)); | 384 return Uint32Array::New(len); |
392 arguments->SetReturn(new_array); | |
393 } | 385 } |
394 | 386 |
395 | 387 |
396 DEFINE_NATIVE_ENTRY(Uint32Array_getIndexed, 2) { | 388 DEFINE_NATIVE_ENTRY(Uint32Array_getIndexed, 2) { |
397 GETTER(Uint32Array, Integer, uint32_t); | 389 GETTER(Uint32Array, Integer, uint32_t); |
398 } | 390 } |
399 | 391 |
400 | 392 |
401 DEFINE_NATIVE_ENTRY(Uint32Array_setIndexed, 3) { | 393 DEFINE_NATIVE_ENTRY(Uint32Array_setIndexed, 3) { |
402 SETTER(Uint32Array, Integer, AsInt64Value, uint32_t); | 394 SETTER(Uint32Array, Integer, AsInt64Value, uint32_t); |
403 } | 395 } |
404 | 396 |
405 | 397 |
406 // Int64Array | 398 // Int64Array |
407 | 399 |
408 DEFINE_NATIVE_ENTRY(Int64Array_new, 1) { | 400 DEFINE_NATIVE_ENTRY(Int64Array_new, 1) { |
409 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); | 401 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); |
410 intptr_t len = length.Value(); | 402 intptr_t len = length.Value(); |
411 LengthCheck(len, Int64Array::kMaxElements); | 403 LengthCheck(len, Int64Array::kMaxElements); |
412 const Int64Array& new_array = Int64Array::Handle(Int64Array::New(len)); | 404 return Int64Array::New(len); |
413 arguments->SetReturn(new_array); | |
414 } | 405 } |
415 | 406 |
416 | 407 |
417 DEFINE_NATIVE_ENTRY(Int64Array_getIndexed, 2) { | 408 DEFINE_NATIVE_ENTRY(Int64Array_getIndexed, 2) { |
418 GETTER(Int64Array, Integer, int64_t); | 409 GETTER(Int64Array, Integer, int64_t); |
419 } | 410 } |
420 | 411 |
421 | 412 |
422 DEFINE_NATIVE_ENTRY(Int64Array_setIndexed, 3) { | 413 DEFINE_NATIVE_ENTRY(Int64Array_setIndexed, 3) { |
423 SETTER(Int64Array, Integer, AsInt64Value, int64_t); | 414 SETTER(Int64Array, Integer, AsInt64Value, int64_t); |
424 } | 415 } |
425 | 416 |
426 | 417 |
427 // Uint64Array | 418 // Uint64Array |
428 | 419 |
429 DEFINE_NATIVE_ENTRY(Uint64Array_new, 1) { | 420 DEFINE_NATIVE_ENTRY(Uint64Array_new, 1) { |
430 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); | 421 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); |
431 intptr_t len = length.Value(); | 422 intptr_t len = length.Value(); |
432 LengthCheck(len, Uint64Array::kMaxElements); | 423 LengthCheck(len, Uint64Array::kMaxElements); |
433 const Uint64Array& new_array = Uint64Array::Handle(Uint64Array::New(len)); | 424 return Uint64Array::New(len); |
434 arguments->SetReturn(new_array); | |
435 } | 425 } |
436 | 426 |
437 | 427 |
438 DEFINE_NATIVE_ENTRY(Uint64Array_getIndexed, 2) { | 428 DEFINE_NATIVE_ENTRY(Uint64Array_getIndexed, 2) { |
439 GETTER_UINT64(Uint64Array); | 429 GETTER_UINT64(Uint64Array); |
440 } | 430 } |
441 | 431 |
442 | 432 |
443 DEFINE_NATIVE_ENTRY(Uint64Array_setIndexed, 3) { | 433 DEFINE_NATIVE_ENTRY(Uint64Array_setIndexed, 3) { |
444 SETTER_UINT64(Uint64Array); | 434 SETTER_UINT64(Uint64Array); |
445 } | 435 } |
446 | 436 |
447 | 437 |
448 // Float32Array | 438 // Float32Array |
449 | 439 |
450 DEFINE_NATIVE_ENTRY(Float32Array_new, 1) { | 440 DEFINE_NATIVE_ENTRY(Float32Array_new, 1) { |
451 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); | 441 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); |
452 intptr_t len = length.Value(); | 442 intptr_t len = length.Value(); |
453 LengthCheck(len, Float32Array::kMaxElements); | 443 LengthCheck(len, Float32Array::kMaxElements); |
454 const Float32Array& new_array = Float32Array::Handle(Float32Array::New(len)); | 444 return Float32Array::New(len); |
455 arguments->SetReturn(new_array); | |
456 } | 445 } |
457 | 446 |
458 | 447 |
459 DEFINE_NATIVE_ENTRY(Float32Array_getIndexed, 2) { | 448 DEFINE_NATIVE_ENTRY(Float32Array_getIndexed, 2) { |
460 GETTER(Float32Array, Double, float); | 449 GETTER(Float32Array, Double, float); |
461 } | 450 } |
462 | 451 |
463 | 452 |
464 DEFINE_NATIVE_ENTRY(Float32Array_setIndexed, 3) { | 453 DEFINE_NATIVE_ENTRY(Float32Array_setIndexed, 3) { |
465 SETTER(Float32Array, Double, value, float); | 454 SETTER(Float32Array, Double, value, float); |
466 } | 455 } |
467 | 456 |
468 | 457 |
469 // Float64Array | 458 // Float64Array |
470 | 459 |
471 DEFINE_NATIVE_ENTRY(Float64Array_new, 1) { | 460 DEFINE_NATIVE_ENTRY(Float64Array_new, 1) { |
472 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); | 461 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(0)); |
473 intptr_t len = length.Value(); | 462 intptr_t len = length.Value(); |
474 LengthCheck(len, Float64Array::kMaxElements); | 463 LengthCheck(len, Float64Array::kMaxElements); |
475 const Float64Array& new_array = Float64Array::Handle(Float64Array::New(len)); | 464 return Float64Array::New(len); |
476 arguments->SetReturn(new_array); | |
477 } | 465 } |
478 | 466 |
479 | 467 |
480 DEFINE_NATIVE_ENTRY(Float64Array_getIndexed, 2) { | 468 DEFINE_NATIVE_ENTRY(Float64Array_getIndexed, 2) { |
481 GETTER(Float64Array, Double, double); | 469 GETTER(Float64Array, Double, double); |
482 } | 470 } |
483 | 471 |
484 | 472 |
485 DEFINE_NATIVE_ENTRY(Float64Array_setIndexed, 3) { | 473 DEFINE_NATIVE_ENTRY(Float64Array_setIndexed, 3) { |
486 SETTER(Float64Array, Double, value, double); | 474 SETTER(Float64Array, Double, value, double); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_getIndexed, 2) { | 588 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_getIndexed, 2) { |
601 GETTER(ExternalFloat64Array, Double, double); | 589 GETTER(ExternalFloat64Array, Double, double); |
602 } | 590 } |
603 | 591 |
604 | 592 |
605 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_setIndexed, 3) { | 593 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_setIndexed, 3) { |
606 SETTER(ExternalFloat64Array, Double, value, double); | 594 SETTER(ExternalFloat64Array, Double, value, double); |
607 } | 595 } |
608 | 596 |
609 } // namespace dart | 597 } // namespace dart |
OLD | NEW |