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

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

Issue 205153002: Auto delete persistent weak handles during finalization after invoking the callback associated with… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
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 25 matching lines...) Expand all
36 static void LengthCheck(intptr_t len, intptr_t max) { 36 static void LengthCheck(intptr_t len, intptr_t max) {
37 if (len < 0 || len > max) { 37 if (len < 0 || len > max) {
38 const String& error = String::Handle(String::NewFormatted( 38 const String& error = String::Handle(String::NewFormatted(
39 "Length (%" Pd ") of object must be in range [0..%" Pd "]", 39 "Length (%" Pd ") of object must be in range [0..%" Pd "]",
40 len, max)); 40 len, max));
41 Exceptions::ThrowArgumentError(error); 41 Exceptions::ThrowArgumentError(error);
42 } 42 }
43 } 43 }
44 44
45 45
46 static void PeerFinalizer(Dart_Isolate isolate, 46 static void PeerFinalizer(void* isolate_callback_data,
47 Dart_WeakPersistentHandle handle, 47 Dart_WeakPersistentHandle handle,
48 void* peer) { 48 void* peer) {
49 Dart_DeleteWeakPersistentHandle(isolate, handle);
50 OS::AlignedFree(peer); 49 OS::AlignedFree(peer);
51 } 50 }
52 51
53 52
54 DEFINE_NATIVE_ENTRY(TypedData_length, 1) { 53 DEFINE_NATIVE_ENTRY(TypedData_length, 1) {
55 GET_NON_NULL_NATIVE_ARGUMENT(Instance, instance, arguments->NativeArgAt(0)); 54 GET_NON_NULL_NATIVE_ARGUMENT(Instance, instance, arguments->NativeArgAt(0));
56 if (instance.IsTypedData()) { 55 if (instance.IsTypedData()) {
57 const TypedData& array = TypedData::Cast(instance); 56 const TypedData& array = TypedData::Cast(instance);
58 return Smi::New(array.Length()); 57 return Smi::New(array.Length());
59 } 58 }
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 value = bit_cast<double>( 454 value = bit_cast<double>(
456 Utils::HostToLittleEndian64(bit_cast<uint64_t>(value))); 455 Utils::HostToLittleEndian64(bit_cast<uint64_t>(value)));
457 } else { 456 } else {
458 value = bit_cast<double>( 457 value = bit_cast<double>(
459 Utils::HostToBigEndian64(bit_cast<uint64_t>(value))); 458 Utils::HostToBigEndian64(bit_cast<uint64_t>(value)));
460 } 459 }
461 return Double::New(value); 460 return Double::New(value);
462 } 461 }
463 462
464 } // namespace dart 463 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698