Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 39 #define GETTER(ArrayT, ObjectT, ValueT) \ | 39 #define GETTER(ArrayT, ObjectT, ValueT) \ |
| 40 GETTER_ARGUMENTS(ArrayT, ValueT); \ | 40 GETTER_ARGUMENTS(ArrayT, ValueT); \ |
| 41 RangeCheck(array, index.Value() * sizeof(ValueT), sizeof(ValueT)); \ | 41 RangeCheck(array, index.Value() * sizeof(ValueT), sizeof(ValueT)); \ |
| 42 ValueT result = array.At(index.Value()); \ | 42 ValueT result = array.At(index.Value()); \ |
| 43 arguments->SetReturn(ObjectT::Handle(ObjectT::New(result))); | 43 arguments->SetReturn(ObjectT::Handle(ObjectT::New(result))); |
| 44 | 44 |
| 45 | 45 |
| 46 #define SETTER(ArrayT, ObjectT, Getter, ValueT) \ | 46 #define SETTER(ArrayT, ObjectT, Getter, ValueT) \ |
| 47 SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT); \ | 47 SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT); \ |
| 48 RangeCheck(array, index.Value() * sizeof(ValueT), sizeof(ValueT)); \ | 48 RangeCheck(array, index.Value() * sizeof(ValueT), sizeof(ValueT)); \ |
| 49 ValueT value = value_object.Getter(); \ | 49 ValueT value = value_object.Getter(); \ |
| 50 array.SetAt(index.Value(), value); | 50 array.SetAt(index.Value(), value); |
| 51 | 51 |
| 52 | 52 |
| 53 #define UNALIGNED_GETTER(ArrayT, ObjectT, ValueT) \ | 53 #define UNALIGNED_GETTER(ArrayT, ObjectT, ValueT) \ |
| 54 GETTER_ARGUMENTS(ArrayT, ValueT); \ | 54 GETTER_ARGUMENTS(ArrayT, ValueT); \ |
| 55 RangeCheck(array, index.Value(), sizeof(ValueT)); \ | 55 RangeCheck(array, index.Value(), sizeof(ValueT)); \ |
| 56 ValueT result; \ | 56 ValueT result; \ |
| 57 ByteArray::Copy(&result, array, index.Value(), sizeof(ValueT)); \ | 57 ByteArray::Copy(&result, array, index.Value(), sizeof(ValueT)); \ |
| 58 arguments->SetReturn(ObjectT::Handle(ObjectT::New(result))); | 58 arguments->SetReturn(ObjectT::Handle(ObjectT::New(result))); |
| 59 | 59 |
| 60 | 60 |
| 61 #define UNALIGNED_SETTER(ArrayT, ObjectT, Getter, ValueT) \ | 61 #define UNALIGNED_SETTER(ArrayT, ObjectT, Getter, ValueT) \ |
| 62 SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT); \ | 62 SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT); \ |
| 63 RangeCheck(array, index.Value(), sizeof(ValueT)); \ | 63 RangeCheck(array, index.Value(), sizeof(ValueT)); \ |
| 64 ValueT src = value_object.Getter(); \ | 64 ValueT src = value_object.Getter(); \ |
| 65 ByteArray::Copy(array, index.Value(), &src, sizeof(ValueT)); \ | 65 ByteArray::Copy(array, index.Value(), &src, sizeof(ValueT)); |
|
siva
2012/07/16 16:41:33
I think the setter methods of byte array need to r
regis
2012/07/16 18:05:34
Good point! I reverted the change here and instead
| |
| 66 Integer& result = Integer::Handle(); \ | |
| 67 result ^= Integer::New(index.Value() + sizeof(ValueT)); \ | |
| 68 arguments->SetReturn(result); | |
| 69 | 66 |
| 70 | 67 |
| 71 #define UINT64_TO_INTEGER(value, integer) \ | 68 #define UINT64_TO_INTEGER(value, integer) \ |
| 72 if (value > static_cast<uint64_t>(Mint::kMaxValue)) { \ | 69 if (value > static_cast<uint64_t>(Mint::kMaxValue)) { \ |
| 73 result = BigintOperations::NewFromUint64(value); \ | 70 result = BigintOperations::NewFromUint64(value); \ |
| 74 } else if (value > static_cast<uint64_t>(Smi::kMaxValue)) { \ | 71 } else if (value > static_cast<uint64_t>(Smi::kMaxValue)) { \ |
| 75 result = Mint::New(value); \ | 72 result = Mint::New(value); \ |
| 76 } else { \ | 73 } else { \ |
| 77 result = Smi::New(value); \ | 74 result = Smi::New(value); \ |
| 78 } | 75 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 uint64_t value; \ | 114 uint64_t value; \ |
| 118 INTEGER_TO_UINT64(value_object, value); \ | 115 INTEGER_TO_UINT64(value_object, value); \ |
| 119 array.SetAt(index.Value(), value); | 116 array.SetAt(index.Value(), value); |
| 120 | 117 |
| 121 | 118 |
| 122 #define UNALIGNED_SETTER_UINT64(ArrayT) \ | 119 #define UNALIGNED_SETTER_UINT64(ArrayT) \ |
| 123 SETTER_ARGUMENTS(ArrayT, Integer, uint64_t); \ | 120 SETTER_ARGUMENTS(ArrayT, Integer, uint64_t); \ |
| 124 RangeCheck(array, index.Value(), sizeof(uint64_t)); \ | 121 RangeCheck(array, index.Value(), sizeof(uint64_t)); \ |
| 125 uint64_t value; \ | 122 uint64_t value; \ |
| 126 INTEGER_TO_UINT64(value_object, value); \ | 123 INTEGER_TO_UINT64(value_object, value); \ |
| 127 ByteArray::Copy(array, index.Value(), &value, sizeof(uint64_t)); \ | 124 ByteArray::Copy(array, index.Value(), &value, sizeof(uint64_t)); |
|
siva
2012/07/16 16:41:33
Ditto.
regis
2012/07/16 18:05:34
Done.
| |
| 128 Integer& result = Integer::Handle(); \ | |
| 129 result ^= Integer::New(index.Value() + sizeof(uint64_t)); \ | |
| 130 arguments->SetReturn(result); | |
| 131 | 125 |
| 132 | 126 |
| 133 DEFINE_NATIVE_ENTRY(ByteArray_getLength, 1) { | 127 DEFINE_NATIVE_ENTRY(ByteArray_getLength, 1) { |
| 134 GET_NATIVE_ARGUMENT(ByteArray, array, arguments->At(0)); | 128 GET_NATIVE_ARGUMENT(ByteArray, array, arguments->At(0)); |
| 135 const Smi& length = Smi::Handle(Smi::New(array.Length())); | 129 const Smi& length = Smi::Handle(Smi::New(array.Length())); |
| 136 arguments->SetReturn(length); | 130 arguments->SetReturn(length); |
| 137 } | 131 } |
| 138 | 132 |
| 139 | 133 |
| 140 DEFINE_NATIVE_ENTRY(ByteArray_getInt8, 2) { | 134 DEFINE_NATIVE_ENTRY(ByteArray_getInt8, 2) { |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 619 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_getIndexed, 2) { | 613 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_getIndexed, 2) { |
| 620 GETTER(ExternalFloat64Array, Double, double); | 614 GETTER(ExternalFloat64Array, Double, double); |
| 621 } | 615 } |
| 622 | 616 |
| 623 | 617 |
| 624 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_setIndexed, 3) { | 618 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_setIndexed, 3) { |
| 625 SETTER(ExternalFloat64Array, Double, value, double); | 619 SETTER(ExternalFloat64Array, Double, value, double); |
| 626 } | 620 } |
| 627 | 621 |
| 628 } // namespace dart | 622 } // namespace dart |
| OLD | NEW |