Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: runtime/lib/typeddata.cc

Issue 12547018: Add the allocator intrinsics for dart:typeddata implementation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/intrinsifier.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 // We check the length parameter against a possible maximum length for the 65 // We check the length parameter against a possible maximum length for the
66 // array based on available physical addressable memory on the system. The 66 // array based on available physical addressable memory on the system. The
67 // maximum possible length is a scaled value of kSmiMax which is set up based 67 // maximum possible length is a scaled value of kSmiMax which is set up based
68 // on whether the underlying architecture is 32-bit or 64-bit. 68 // on whether the underlying architecture is 32-bit or 64-bit.
69 #define TYPED_DATA_NEW(name) \ 69 #define TYPED_DATA_NEW(name) \
70 DEFINE_NATIVE_ENTRY(TypedData_##name##_new, 1) { \ 70 DEFINE_NATIVE_ENTRY(TypedData_##name##_new, 1) { \
71 GET_NON_NULL_NATIVE_ARGUMENT(Smi, length, arguments->NativeArgAt(0)); \ 71 GET_NON_NULL_NATIVE_ARGUMENT(Smi, length, arguments->NativeArgAt(0)); \
72 intptr_t cid = kTypedData##name##Cid; \ 72 intptr_t cid = kTypedData##name##Cid; \
73 intptr_t len = length.Value(); \ 73 intptr_t len = length.Value(); \
74 intptr_t max = (kSmiMax / TypedData::ElementSizeInBytes(cid)); \ 74 intptr_t max = TypedData::MaxElements(cid); \
75 LengthCheck(len, max); \ 75 LengthCheck(len, max); \
76 return TypedData::New(cid, len); \ 76 return TypedData::New(cid, len); \
77 } \ 77 } \
78 78
79 79
80 // We check the length parameter against a possible maximum length for the 80 // We check the length parameter against a possible maximum length for the
81 // array based on available physical addressable memory on the system. The 81 // array based on available physical addressable memory on the system. The
82 // maximum possible length is a scaled value of kSmiMax which is set up based 82 // maximum possible length is a scaled value of kSmiMax which is set up based
83 // on whether the underlying architecture is 32-bit or 64-bit. 83 // on whether the underlying architecture is 32-bit or 64-bit.
84 #define EXT_TYPED_DATA_NEW(name) \ 84 #define EXT_TYPED_DATA_NEW(name) \
85 DEFINE_NATIVE_ENTRY(ExternalTypedData_##name##_new, 1) { \ 85 DEFINE_NATIVE_ENTRY(ExternalTypedData_##name##_new, 1) { \
86 const int kAlignment = 16; \ 86 const int kAlignment = 16; \
87 GET_NON_NULL_NATIVE_ARGUMENT(Smi, length, arguments->NativeArgAt(0)); \ 87 GET_NON_NULL_NATIVE_ARGUMENT(Smi, length, arguments->NativeArgAt(0)); \
88 intptr_t cid = kExternalTypedData##name##Cid; \ 88 intptr_t cid = kExternalTypedData##name##Cid; \
89 intptr_t len = length.Value(); \ 89 intptr_t len = length.Value(); \
90 intptr_t max = (kSmiMax / ExternalTypedData::ElementSizeInBytes(cid)); \ 90 intptr_t max = ExternalTypedData::MaxElements(cid); \
91 LengthCheck(len, max); \ 91 LengthCheck(len, max); \
92 intptr_t len_bytes = len * ExternalTypedData::ElementSizeInBytes(cid); \ 92 intptr_t len_bytes = len * ExternalTypedData::ElementSizeInBytes(cid); \
93 uint8_t* data = OS::AllocateAlignedArray<uint8_t>(len_bytes, kAlignment); \ 93 uint8_t* data = OS::AllocateAlignedArray<uint8_t>(len_bytes, kAlignment); \
94 const ExternalTypedData& obj = \ 94 const ExternalTypedData& obj = \
95 ExternalTypedData::Handle(ExternalTypedData::New(cid, data, len)); \ 95 ExternalTypedData::Handle(ExternalTypedData::New(cid, data, len)); \
96 obj.AddFinalizer(data, PeerFinalizer); \ 96 obj.AddFinalizer(data, PeerFinalizer); \
97 return obj.raw(); \ 97 return obj.raw(); \
98 } \ 98 } \
99 99
100 100
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 TYPED_DATA_NATIVES(Int16Array, GetInt16, SetInt16, Smi, Value) 243 TYPED_DATA_NATIVES(Int16Array, GetInt16, SetInt16, Smi, Value)
244 TYPED_DATA_NATIVES(Uint16Array, GetUint16, SetUint16, Smi, Value) 244 TYPED_DATA_NATIVES(Uint16Array, GetUint16, SetUint16, Smi, Value)
245 TYPED_DATA_NATIVES(Int32Array, GetInt32, SetInt32, Integer, AsInt64Value) 245 TYPED_DATA_NATIVES(Int32Array, GetInt32, SetInt32, Integer, AsInt64Value)
246 TYPED_DATA_NATIVES(Uint32Array, GetUint32, SetUint32, Integer, AsInt64Value) 246 TYPED_DATA_NATIVES(Uint32Array, GetUint32, SetUint32, Integer, AsInt64Value)
247 TYPED_DATA_NATIVES(Int64Array, GetInt64, SetInt64, Integer, AsInt64Value) 247 TYPED_DATA_NATIVES(Int64Array, GetInt64, SetInt64, Integer, AsInt64Value)
248 TYPED_DATA_UINT64_NATIVES(Uint64Array, GetUint64, SetUint64, Integer) 248 TYPED_DATA_UINT64_NATIVES(Uint64Array, GetUint64, SetUint64, Integer)
249 TYPED_DATA_NATIVES(Float32Array, GetFloat32, SetFloat32, Double, value) 249 TYPED_DATA_NATIVES(Float32Array, GetFloat32, SetFloat32, Double, value)
250 TYPED_DATA_NATIVES(Float64Array, GetFloat64, SetFloat64, Double, value) 250 TYPED_DATA_NATIVES(Float64Array, GetFloat64, SetFloat64, Double, value)
251 251
252 } // namespace dart 252 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intrinsifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698