| OLD | NEW |
| 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 "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 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2324 // --- Typed Data --- | 2324 // --- Typed Data --- |
| 2325 | 2325 |
| 2326 | 2326 |
| 2327 // Helper method to get the type of a TypedData object. | 2327 // Helper method to get the type of a TypedData object. |
| 2328 static Dart_TypedData_Type GetType(intptr_t class_id) { | 2328 static Dart_TypedData_Type GetType(intptr_t class_id) { |
| 2329 Dart_TypedData_Type type; | 2329 Dart_TypedData_Type type; |
| 2330 switch (class_id) { | 2330 switch (class_id) { |
| 2331 case kByteArrayCid : | 2331 case kByteArrayCid : |
| 2332 type = kByteData; | 2332 type = kByteData; |
| 2333 break; | 2333 break; |
| 2334 case kInt8ArrayCid : | 2334 case kTypedDataInt8ArrayCid : |
| 2335 case kExternalInt8ArrayCid : | 2335 case kExternalTypedDataInt8ArrayCid : |
| 2336 type = kInt8; | 2336 type = kInt8; |
| 2337 break; | 2337 break; |
| 2338 case kUint8ArrayCid : | 2338 case kTypedDataUint8ArrayCid : |
| 2339 case kExternalUint8ArrayCid : | 2339 case kExternalTypedDataUint8ArrayCid : |
| 2340 type = kUint8; | 2340 type = kUint8; |
| 2341 break; | 2341 break; |
| 2342 case kUint8ClampedArrayCid : | 2342 case kTypedDataUint8ClampedArrayCid : |
| 2343 case kExternalUint8ClampedArrayCid : | 2343 case kExternalTypedDataUint8ClampedArrayCid : |
| 2344 type = kUint8Clamped; | 2344 type = kUint8Clamped; |
| 2345 break; | 2345 break; |
| 2346 case kInt16ArrayCid : | 2346 case kTypedDataInt16ArrayCid : |
| 2347 case kExternalInt16ArrayCid : | 2347 case kExternalTypedDataInt16ArrayCid : |
| 2348 type = kInt16; | 2348 type = kInt16; |
| 2349 break; | 2349 break; |
| 2350 case kUint16ArrayCid : | 2350 case kTypedDataUint16ArrayCid : |
| 2351 case kExternalUint16ArrayCid : | 2351 case kExternalTypedDataUint16ArrayCid : |
| 2352 type = kUint16; | 2352 type = kUint16; |
| 2353 break; | 2353 break; |
| 2354 case kInt32ArrayCid : | 2354 case kTypedDataInt32ArrayCid : |
| 2355 case kExternalInt32ArrayCid : | 2355 case kExternalTypedDataInt32ArrayCid : |
| 2356 type = kInt32; | 2356 type = kInt32; |
| 2357 break; | 2357 break; |
| 2358 case kUint32ArrayCid : | 2358 case kTypedDataUint32ArrayCid : |
| 2359 case kExternalUint32ArrayCid : | 2359 case kExternalTypedDataUint32ArrayCid : |
| 2360 type = kUint32; | 2360 type = kUint32; |
| 2361 break; | 2361 break; |
| 2362 case kInt64ArrayCid : | 2362 case kTypedDataInt64ArrayCid : |
| 2363 case kExternalInt64ArrayCid : | 2363 case kExternalTypedDataInt64ArrayCid : |
| 2364 type = kInt64; | 2364 type = kInt64; |
| 2365 break; | 2365 break; |
| 2366 case kUint64ArrayCid : | 2366 case kTypedDataUint64ArrayCid : |
| 2367 case kExternalUint64ArrayCid : | 2367 case kExternalTypedDataUint64ArrayCid : |
| 2368 type = kUint64; | 2368 type = kUint64; |
| 2369 break; | 2369 break; |
| 2370 case kFloat32ArrayCid : | 2370 case kTypedDataFloat32ArrayCid : |
| 2371 case kExternalFloat32ArrayCid : | 2371 case kExternalTypedDataFloat32ArrayCid : |
| 2372 type = kFloat32; | 2372 type = kFloat32; |
| 2373 break; | 2373 break; |
| 2374 case kFloat64ArrayCid : | 2374 case kTypedDataFloat64ArrayCid : |
| 2375 case kExternalFloat64ArrayCid : | 2375 case kExternalTypedDataFloat64ArrayCid : |
| 2376 type = kFloat64; | 2376 type = kFloat64; |
| 2377 break; | 2377 break; |
| 2378 default: | 2378 default: |
| 2379 type = kInvalid; | 2379 type = kInvalid; |
| 2380 break; | 2380 break; |
| 2381 } | 2381 } |
| 2382 return type; | 2382 return type; |
| 2383 } | 2383 } |
| 2384 | 2384 |
| 2385 | 2385 |
| 2386 DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfTypedData(Dart_Handle object) { | 2386 DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfTypedData(Dart_Handle object) { |
| 2387 intptr_t class_id = Api::ClassId(object); | 2387 intptr_t class_id = Api::ClassId(object); |
| 2388 if (!RawObject::IsTypedDataClassId(class_id)) { |
| 2389 return kInvalid; |
| 2390 } |
| 2388 return GetType(class_id); | 2391 return GetType(class_id); |
| 2389 } | 2392 } |
| 2390 | 2393 |
| 2391 | 2394 |
| 2392 DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfExternalTypedData( | 2395 DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfExternalTypedData( |
| 2393 Dart_Handle object) { | 2396 Dart_Handle object) { |
| 2394 intptr_t class_id = Api::ClassId(object); | 2397 intptr_t class_id = Api::ClassId(object); |
| 2395 if (!RawObject::IsExternalByteArrayClassId(class_id)) { | 2398 if (!RawObject::IsExternalTypedDataClassId(class_id)) { |
| 2396 return kInvalid; | 2399 return kInvalid; |
| 2397 } | 2400 } |
| 2398 return GetType(class_id); | 2401 return GetType(class_id); |
| 2399 } | 2402 } |
| 2400 | 2403 |
| 2401 | 2404 |
| 2402 template<typename type> | 2405 static Dart_Handle NewTypedData(Isolate* isolate, |
| 2403 static Dart_Handle NewTypedData(Isolate* isolate, intptr_t length) { | 2406 intptr_t cid, |
| 2404 CHECK_LENGTH(length, type::kMaxElements); | 2407 intptr_t length) { |
| 2405 return Api::NewHandle(isolate, type::New(length)); | 2408 CHECK_LENGTH(length, TypedData::MaxElements(cid)); |
| 2409 return Api::NewHandle(isolate, TypedData::New(cid, length)); |
| 2406 } | 2410 } |
| 2407 | 2411 |
| 2408 | 2412 |
| 2409 template<typename type, typename datatype> | |
| 2410 static Dart_Handle NewExternalTypedData( | 2413 static Dart_Handle NewExternalTypedData( |
| 2414 intptr_t cid, |
| 2411 void* data, | 2415 void* data, |
| 2412 intptr_t length, | 2416 intptr_t length, |
| 2413 void* peer, | 2417 void* peer, |
| 2414 Dart_WeakPersistentHandleFinalizer callback) { | 2418 Dart_WeakPersistentHandleFinalizer callback) { |
| 2415 CHECK_LENGTH(length, type::kMaxElements); | 2419 CHECK_LENGTH(length, ExternalTypedData::MaxElements(cid)); |
| 2416 const type& obj = | 2420 const ExternalTypedData& obj = ExternalTypedData::Handle( |
| 2417 type::Handle(type::New(reinterpret_cast<datatype*>(data), length)); | 2421 ExternalTypedData::New(cid, |
| 2422 reinterpret_cast<uint8_t*>(data), |
| 2423 length)); |
| 2418 return reinterpret_cast<Dart_Handle>(obj.AddFinalizer(peer, callback)); | 2424 return reinterpret_cast<Dart_Handle>(obj.AddFinalizer(peer, callback)); |
| 2419 } | 2425 } |
| 2420 | 2426 |
| 2421 | 2427 |
| 2422 DART_EXPORT Dart_Handle Dart_NewTypedData(Dart_TypedData_Type type, | 2428 DART_EXPORT Dart_Handle Dart_NewTypedData(Dart_TypedData_Type type, |
| 2423 intptr_t length) { | 2429 intptr_t length) { |
| 2424 Isolate* isolate = Isolate::Current(); | 2430 Isolate* isolate = Isolate::Current(); |
| 2425 DARTSCOPE(isolate); | 2431 DARTSCOPE(isolate); |
| 2426 CHECK_CALLBACK_STATE(isolate); | 2432 CHECK_CALLBACK_STATE(isolate); |
| 2427 switch (type) { | 2433 switch (type) { |
| 2428 case kByteData : | 2434 case kByteData : |
| 2429 // TODO(asiva): Add a new ByteArray::New() method. | 2435 // TODO(asiva): Add a new ByteArray::New() method. |
| 2430 break; | 2436 break; |
| 2431 case kInt8 : | 2437 case kInt8 : |
| 2432 return NewTypedData<Int8Array>(isolate, length); | 2438 return NewTypedData(isolate, kTypedDataInt8ArrayCid, length); |
| 2433 case kUint8 : | 2439 case kUint8 : |
| 2434 return NewTypedData<Uint8Array>(isolate, length); | 2440 return NewTypedData(isolate, kTypedDataUint8ArrayCid, length); |
| 2435 case kUint8Clamped : | 2441 case kUint8Clamped : |
| 2436 return NewTypedData<Uint8ClampedArray>(isolate, length); | 2442 return NewTypedData(isolate, kTypedDataUint8ClampedArrayCid, length); |
| 2437 case kInt16 : | 2443 case kInt16 : |
| 2438 return NewTypedData<Int16Array>(isolate, length); | 2444 return NewTypedData(isolate, kTypedDataInt16ArrayCid, length); |
| 2439 case kUint16 : | 2445 case kUint16 : |
| 2440 return NewTypedData<Uint16Array>(isolate, length); | 2446 return NewTypedData(isolate, kTypedDataUint16ArrayCid, length); |
| 2441 case kInt32 : | 2447 case kInt32 : |
| 2442 return NewTypedData<Int32Array>(isolate, length); | 2448 return NewTypedData(isolate, kTypedDataInt32ArrayCid, length); |
| 2443 case kUint32 : | 2449 case kUint32 : |
| 2444 return NewTypedData<Uint32Array>(isolate, length); | 2450 return NewTypedData(isolate, kTypedDataUint32ArrayCid, length); |
| 2445 case kInt64 : | 2451 case kInt64 : |
| 2446 return NewTypedData<Int64Array>(isolate, length); | 2452 return NewTypedData(isolate, kTypedDataInt64ArrayCid, length); |
| 2447 case kUint64 : | 2453 case kUint64 : |
| 2448 return NewTypedData<Uint64Array>(isolate, length); | 2454 return NewTypedData(isolate, kTypedDataUint64ArrayCid, length); |
| 2449 case kFloat32 : | 2455 case kFloat32 : |
| 2450 return NewTypedData<Float32Array>(isolate, length); | 2456 return NewTypedData(isolate, kTypedDataFloat32ArrayCid, length); |
| 2451 case kFloat64 : | 2457 case kFloat64 : |
| 2452 return NewTypedData<Float64Array>(isolate, length); | 2458 return NewTypedData(isolate, kTypedDataFloat64ArrayCid, length); |
| 2453 default: | 2459 default: |
| 2454 return Api::NewError("%s expects argument 'type' to be of 'TypedData'", | 2460 return Api::NewError("%s expects argument 'type' to be of 'TypedData'", |
| 2455 CURRENT_FUNC); | 2461 CURRENT_FUNC); |
| 2456 } | 2462 } |
| 2457 UNREACHABLE(); | 2463 UNREACHABLE(); |
| 2458 return Api::Null(isolate); | 2464 return Api::Null(isolate); |
| 2459 } | 2465 } |
| 2460 | 2466 |
| 2461 | 2467 |
| 2462 DART_EXPORT Dart_Handle Dart_NewExternalTypedData( | 2468 DART_EXPORT Dart_Handle Dart_NewExternalTypedData( |
| 2463 Dart_TypedData_Type type, | 2469 Dart_TypedData_Type type, |
| 2464 void* data, | 2470 void* data, |
| 2465 intptr_t length, | 2471 intptr_t length, |
| 2466 void* peer, | 2472 void* peer, |
| 2467 Dart_WeakPersistentHandleFinalizer callback) { | 2473 Dart_WeakPersistentHandleFinalizer callback) { |
| 2468 Isolate* isolate = Isolate::Current(); | 2474 Isolate* isolate = Isolate::Current(); |
| 2469 DARTSCOPE(isolate); | 2475 DARTSCOPE(isolate); |
| 2470 if (data == NULL && length != 0) { | 2476 if (data == NULL && length != 0) { |
| 2471 RETURN_NULL_ERROR(data); | 2477 RETURN_NULL_ERROR(data); |
| 2472 } | 2478 } |
| 2473 CHECK_CALLBACK_STATE(isolate); | 2479 CHECK_CALLBACK_STATE(isolate); |
| 2474 switch (type) { | 2480 switch (type) { |
| 2475 case kByteData : | 2481 case kByteData : |
| 2476 // TODO(asiva): Allocate external ByteData object. | 2482 // TODO(asiva): Allocate external ByteData object. |
| 2477 break; | 2483 break; |
| 2478 case kInt8 : | 2484 case kInt8 : |
| 2479 return NewExternalTypedData<ExternalInt8Array, int8_t>(data, | 2485 return NewExternalTypedData(kExternalTypedDataInt8ArrayCid, |
| 2480 length, | 2486 data, |
| 2481 peer, | 2487 length, |
| 2482 callback); | 2488 peer, |
| 2489 callback); |
| 2483 case kUint8 : | 2490 case kUint8 : |
| 2484 return NewExternalTypedData<ExternalUint8Array, uint8_t>(data, | 2491 return NewExternalTypedData(kExternalTypedDataUint8ArrayCid, |
| 2485 length, | 2492 data, |
| 2486 peer, | 2493 length, |
| 2487 callback); | 2494 peer, |
| 2495 callback); |
| 2488 case kUint8Clamped : | 2496 case kUint8Clamped : |
| 2489 return NewExternalTypedData<ExternalUint8ClampedArray, uint8_t>(data, | 2497 return NewExternalTypedData(kExternalTypedDataUint8ClampedArrayCid, |
| 2490 length, | 2498 data, |
| 2491 peer, | 2499 length, |
| 2492 callback); | 2500 peer, |
| 2501 callback); |
| 2493 case kInt16 : | 2502 case kInt16 : |
| 2494 return NewExternalTypedData<ExternalInt16Array, int16_t>(data, | 2503 return NewExternalTypedData(kExternalTypedDataInt16ArrayCid, |
| 2495 length, | 2504 data, |
| 2496 peer, | 2505 length, |
| 2497 callback); | 2506 peer, |
| 2507 callback); |
| 2498 case kUint16 : | 2508 case kUint16 : |
| 2499 return NewExternalTypedData<ExternalUint16Array, uint16_t>(data, | 2509 return NewExternalTypedData(kExternalTypedDataUint16ArrayCid, |
| 2500 length, | 2510 data, |
| 2501 peer, | 2511 length, |
| 2502 callback); | 2512 peer, |
| 2513 callback); |
| 2503 case kInt32 : | 2514 case kInt32 : |
| 2504 return NewExternalTypedData<ExternalInt32Array, int32_t>(data, | 2515 return NewExternalTypedData(kExternalTypedDataInt32ArrayCid, |
| 2505 length, | 2516 data, |
| 2506 peer, | 2517 length, |
| 2507 callback); | 2518 peer, |
| 2519 callback); |
| 2508 case kUint32 : | 2520 case kUint32 : |
| 2509 return NewExternalTypedData<ExternalUint32Array, uint32_t>(data, | 2521 return NewExternalTypedData(kExternalTypedDataUint32ArrayCid, |
| 2510 length, | 2522 data, |
| 2511 peer, | 2523 length, |
| 2512 callback); | 2524 peer, |
| 2525 callback); |
| 2513 case kInt64 : | 2526 case kInt64 : |
| 2514 return NewExternalTypedData<ExternalInt64Array, int64_t>(data, | 2527 return NewExternalTypedData(kExternalTypedDataInt64ArrayCid, |
| 2515 length, | 2528 data, |
| 2516 peer, | 2529 length, |
| 2517 callback); | 2530 peer, |
| 2531 callback); |
| 2518 case kUint64 : | 2532 case kUint64 : |
| 2519 return NewExternalTypedData<ExternalUint64Array, uint64_t>(data, | 2533 return NewExternalTypedData(kExternalTypedDataUint64ArrayCid, |
| 2520 length, | 2534 data, |
| 2521 peer, | 2535 length, |
| 2522 callback); | 2536 peer, |
| 2537 callback); |
| 2523 case kFloat32 : | 2538 case kFloat32 : |
| 2524 return NewExternalTypedData<ExternalFloat32Array, float>(data, | 2539 return NewExternalTypedData(kExternalTypedDataFloat32ArrayCid, |
| 2525 length, | 2540 data, |
| 2526 peer, | 2541 length, |
| 2527 callback); | 2542 peer, |
| 2543 callback); |
| 2528 case kFloat64 : | 2544 case kFloat64 : |
| 2529 return NewExternalTypedData<ExternalFloat64Array, double>(data, | 2545 return NewExternalTypedData(kExternalTypedDataFloat64ArrayCid, |
| 2530 length, | 2546 data, |
| 2531 peer, | 2547 length, |
| 2532 callback); | 2548 peer, |
| 2549 callback); |
| 2533 default: | 2550 default: |
| 2534 return Api::NewError("%s expects argument 'type' to be of" | 2551 return Api::NewError("%s expects argument 'type' to be of" |
| 2535 " 'external TypedData'", CURRENT_FUNC); | 2552 " 'external TypedData'", CURRENT_FUNC); |
| 2536 } | 2553 } |
| 2537 UNREACHABLE(); | 2554 UNREACHABLE(); |
| 2538 return Api::Null(isolate); | 2555 return Api::Null(isolate); |
| 2539 } | 2556 } |
| 2540 | 2557 |
| 2541 | 2558 |
| 2542 DART_EXPORT Dart_Handle Dart_ExternalTypedDataGetPeer(Dart_Handle object, | 2559 DART_EXPORT Dart_Handle Dart_ExternalTypedDataGetPeer(Dart_Handle object, |
| 2543 void** peer) { | 2560 void** peer) { |
| 2544 Isolate* isolate = Isolate::Current(); | 2561 Isolate* isolate = Isolate::Current(); |
| 2545 DARTSCOPE(isolate); | 2562 DARTSCOPE(isolate); |
| 2546 const ByteArray& array = | 2563 const ExternalTypedData& array = |
| 2547 Api::UnwrapByteArrayHandle(isolate, object); | 2564 Api::UnwrapExternalTypedDataHandle(isolate, object); |
| 2548 if (array.IsNull()) { | 2565 if (array.IsNull()) { |
| 2549 RETURN_TYPE_ERROR(isolate, object, ByteArray); | 2566 RETURN_TYPE_ERROR(isolate, object, ExternalTypedData); |
| 2550 } | 2567 } |
| 2551 if (peer == NULL) { | 2568 if (peer == NULL) { |
| 2552 RETURN_NULL_ERROR(peer); | 2569 RETURN_NULL_ERROR(peer); |
| 2553 } | 2570 } |
| 2554 *peer = array.GetPeer(); | 2571 *peer = array.GetPeer(); |
| 2555 return Api::Success(isolate); | 2572 return Api::Success(isolate); |
| 2556 } | 2573 } |
| 2557 | 2574 |
| 2558 | 2575 |
| 2559 DART_EXPORT Dart_Handle Dart_TypedDataAcquireData(Dart_Handle object, | 2576 DART_EXPORT Dart_Handle Dart_TypedDataAcquireData(Dart_Handle object, |
| 2560 Dart_TypedData_Type* type, | 2577 Dart_TypedData_Type* type, |
| 2561 void** data, | 2578 void** data, |
| 2562 intptr_t* len) { | 2579 intptr_t* len) { |
| 2563 Isolate* isolate = Isolate::Current(); | 2580 Isolate* isolate = Isolate::Current(); |
| 2564 DARTSCOPE(isolate); | 2581 DARTSCOPE(isolate); |
| 2565 intptr_t class_id = Api::ClassId(object); | 2582 intptr_t class_id = Api::ClassId(object); |
| 2566 if (!RawObject::IsByteArrayClassId(class_id)) { | 2583 if (!RawObject::IsExternalTypedDataClassId(class_id) && |
| 2584 !RawObject::IsTypedDataClassId(class_id)) { |
| 2567 RETURN_TYPE_ERROR(isolate, object, 'TypedData'); | 2585 RETURN_TYPE_ERROR(isolate, object, 'TypedData'); |
| 2568 } | 2586 } |
| 2569 if (type == NULL) { | 2587 if (type == NULL) { |
| 2570 RETURN_NULL_ERROR(type); | 2588 RETURN_NULL_ERROR(type); |
| 2571 } | 2589 } |
| 2572 if (data == NULL) { | 2590 if (data == NULL) { |
| 2573 RETURN_NULL_ERROR(data); | 2591 RETURN_NULL_ERROR(data); |
| 2574 } | 2592 } |
| 2575 if (len == NULL) { | 2593 if (len == NULL) { |
| 2576 RETURN_NULL_ERROR(len); | 2594 RETURN_NULL_ERROR(len); |
| 2577 } | 2595 } |
| 2578 // Get the type of typed data object. | 2596 // Get the type of typed data object. |
| 2579 *type = GetType(class_id); | 2597 *type = GetType(class_id); |
| 2580 const ByteArray& obj = Api::UnwrapByteArrayHandle(isolate, object); | |
| 2581 ASSERT(!obj.IsNull()); | |
| 2582 *len = obj.Length(); | |
| 2583 // If it is an external typed data object just return the data field. | 2598 // If it is an external typed data object just return the data field. |
| 2584 if (RawObject::IsExternalByteArrayClassId(class_id)) { | 2599 if (RawObject::IsExternalTypedDataClassId(class_id)) { |
| 2585 *data = reinterpret_cast<void*>(obj.ByteAddr(0)); | 2600 const ExternalTypedData& obj = |
| 2601 Api::UnwrapExternalTypedDataHandle(isolate, object); |
| 2602 ASSERT(!obj.IsNull()); |
| 2603 *len = obj.Length(); |
| 2604 *data = reinterpret_cast<void*>(obj.DataAddr(0)); |
| 2586 } else { | 2605 } else { |
| 2587 // Regular typed data object, set up some GC and API callback guards. | 2606 // Regular typed data object, set up some GC and API callback guards. |
| 2607 const TypedData& obj = Api::UnwrapTypedDataHandle(isolate, object); |
| 2608 ASSERT(!obj.IsNull()); |
| 2609 *len = obj.Length(); |
| 2588 isolate->IncrementNoGCScopeDepth(); | 2610 isolate->IncrementNoGCScopeDepth(); |
| 2589 START_NO_CALLBACK_SCOPE(isolate); | 2611 START_NO_CALLBACK_SCOPE(isolate); |
| 2590 *data = reinterpret_cast<void*>(obj.ByteAddr(0)); | 2612 *data = reinterpret_cast<void*>(obj.DataAddr(0)); |
| 2591 } | 2613 } |
| 2592 return Api::Success(isolate); | 2614 return Api::Success(isolate); |
| 2593 } | 2615 } |
| 2594 | 2616 |
| 2595 | 2617 |
| 2596 DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle object) { | 2618 DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle object) { |
| 2597 Isolate* isolate = Isolate::Current(); | 2619 Isolate* isolate = Isolate::Current(); |
| 2598 DARTSCOPE(isolate); | 2620 DARTSCOPE(isolate); |
| 2599 intptr_t class_id = Api::ClassId(object); | 2621 intptr_t class_id = Api::ClassId(object); |
| 2600 if (!RawObject::IsByteArrayClassId(class_id)) { | 2622 if (!RawObject::IsExternalTypedDataClassId(class_id) && |
| 2623 !RawObject::IsTypedDataClassId(class_id)) { |
| 2601 RETURN_TYPE_ERROR(isolate, object, 'TypedData'); | 2624 RETURN_TYPE_ERROR(isolate, object, 'TypedData'); |
| 2602 } | 2625 } |
| 2603 if (!RawObject::IsExternalByteArrayClassId(class_id)) { | 2626 if (!RawObject::IsExternalTypedDataClassId(class_id)) { |
| 2604 isolate->DecrementNoGCScopeDepth(); | 2627 isolate->DecrementNoGCScopeDepth(); |
| 2605 END_NO_CALLBACK_SCOPE(isolate); | 2628 END_NO_CALLBACK_SCOPE(isolate); |
| 2606 } | 2629 } |
| 2607 return Api::Success(isolate); | 2630 return Api::Success(isolate); |
| 2608 } | 2631 } |
| 2609 | 2632 |
| 2610 | 2633 |
| 2611 // --- Closures --- | 2634 // --- Closures --- |
| 2612 | 2635 |
| 2613 | 2636 |
| (...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4686 } | 4709 } |
| 4687 { | 4710 { |
| 4688 NoGCScope no_gc; | 4711 NoGCScope no_gc; |
| 4689 RawObject* raw_obj = obj.raw(); | 4712 RawObject* raw_obj = obj.raw(); |
| 4690 isolate->heap()->SetPeer(raw_obj, peer); | 4713 isolate->heap()->SetPeer(raw_obj, peer); |
| 4691 } | 4714 } |
| 4692 return Api::Success(isolate); | 4715 return Api::Success(isolate); |
| 4693 } | 4716 } |
| 4694 | 4717 |
| 4695 } // namespace dart | 4718 } // namespace dart |
| OLD | NEW |