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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 12093071: - Change the layout of external typed array objects to avoid the extra indirection when accessing e… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 | « runtime/lib/byte_array.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('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) 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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 2220
2221 2221
2222 DART_EXPORT Dart_Handle Dart_NewByteArray(intptr_t length) { 2222 DART_EXPORT Dart_Handle Dart_NewByteArray(intptr_t length) {
2223 Isolate* isolate = Isolate::Current(); 2223 Isolate* isolate = Isolate::Current();
2224 DARTSCOPE(isolate); 2224 DARTSCOPE(isolate);
2225 CHECK_LENGTH(length, Uint8Array::kMaxElements); 2225 CHECK_LENGTH(length, Uint8Array::kMaxElements);
2226 return Api::NewHandle(isolate, Uint8Array::New(length)); 2226 return Api::NewHandle(isolate, Uint8Array::New(length));
2227 } 2227 }
2228 2228
2229 2229
2230 DART_EXPORT Dart_Handle Dart_NewExternalByteArray(uint8_t* data, 2230 DART_EXPORT Dart_Handle Dart_NewExternalByteArray(
2231 intptr_t length, 2231 uint8_t* data,
2232 void* peer, 2232 intptr_t length,
2233 Dart_PeerFinalizer callback) { 2233 void* peer,
2234 Dart_WeakPersistentHandleFinalizer callback) {
2234 Isolate* isolate = Isolate::Current(); 2235 Isolate* isolate = Isolate::Current();
2235 DARTSCOPE(isolate); 2236 DARTSCOPE(isolate);
2236 if (data == NULL && length != 0) { 2237 if (data == NULL && length != 0) {
2237 RETURN_NULL_ERROR(data); 2238 RETURN_NULL_ERROR(data);
2238 } 2239 }
2239 CHECK_LENGTH(length, ExternalUint8Array::kMaxElements); 2240 CHECK_LENGTH(length, ExternalUint8Array::kMaxElements);
2240 return Api::NewHandle( 2241 const ExternalUint8Array& obj = ExternalUint8Array::Handle(
2241 isolate, ExternalUint8Array::New(data, length, peer, callback)); 2242 ExternalUint8Array::New(data, length));
2243 return reinterpret_cast<Dart_Handle>(obj.AddFinalizer(peer, callback));
2242 } 2244 }
2243 2245
2244 2246
2245 DART_EXPORT Dart_Handle Dart_NewExternalClampedByteArray( 2247 DART_EXPORT Dart_Handle Dart_NewExternalClampedByteArray(
2246 uint8_t* data, 2248 uint8_t* data,
2247 intptr_t length, 2249 intptr_t length,
2248 void* peer, 2250 void* peer,
2249 Dart_PeerFinalizer callback) { 2251 Dart_WeakPersistentHandleFinalizer callback) {
2250 Isolate* isolate = Isolate::Current(); 2252 Isolate* isolate = Isolate::Current();
2251 DARTSCOPE(isolate); 2253 DARTSCOPE(isolate);
2252 if (data == NULL && length != 0) { 2254 if (data == NULL && length != 0) {
2253 RETURN_NULL_ERROR(data); 2255 RETURN_NULL_ERROR(data);
2254 } 2256 }
2255 CHECK_LENGTH(length, ExternalUint8ClampedArray::kMaxElements); 2257 CHECK_LENGTH(length, ExternalUint8ClampedArray::kMaxElements);
2256 return Api::NewHandle( 2258 const ExternalUint8ClampedArray& obj = ExternalUint8ClampedArray::Handle(
2257 isolate, ExternalUint8ClampedArray::New(data, length, peer, callback)); 2259 ExternalUint8ClampedArray::New(data, length));
2260 return reinterpret_cast<Dart_Handle>(obj.AddFinalizer(peer, callback));
2258 } 2261 }
2259 2262
2260 2263
2261 DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetData(Dart_Handle object, 2264 DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetData(Dart_Handle object,
2262 void** data) { 2265 void** data) {
2263 Isolate* isolate = Isolate::Current(); 2266 Isolate* isolate = Isolate::Current();
2264 DARTSCOPE(isolate); 2267 DARTSCOPE(isolate);
2265 const ExternalUint8Array& array = 2268 const ExternalUint8Array& array =
2266 Api::UnwrapExternalUint8ArrayHandle(isolate, object); 2269 Api::UnwrapExternalUint8ArrayHandle(isolate, object);
2267 if (array.IsNull()) { 2270 if (array.IsNull()) {
(...skipping 2254 matching lines...) Expand 10 before | Expand all | Expand 10 after
4522 } 4525 }
4523 { 4526 {
4524 NoGCScope no_gc; 4527 NoGCScope no_gc;
4525 RawObject* raw_obj = obj.raw(); 4528 RawObject* raw_obj = obj.raw();
4526 isolate->heap()->SetPeer(raw_obj, peer); 4529 isolate->heap()->SetPeer(raw_obj, peer);
4527 } 4530 }
4528 return Api::Success(isolate); 4531 return Api::Success(isolate);
4529 } 4532 }
4530 4533
4531 } // namespace dart 4534 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/byte_array.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698