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

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

Issue 15772005: - Add different types for persistent and weak persistent handles (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/object.h ('k') | no next file » | 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 "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } else if (value == '\\') { 289 } else if (value == '\\') {
290 return '\\'; 290 return '\\';
291 } else if (value == '$') { 291 } else if (value == '$') {
292 return '$'; 292 return '$';
293 } 293 }
294 UNREACHABLE(); 294 UNREACHABLE();
295 return '\0'; 295 return '\0';
296 } 296 }
297 297
298 298
299 static void DeleteWeakPersistentHandle(Dart_Handle handle) { 299 static void DeleteWeakPersistentHandle(Dart_WeakPersistentHandle handle) {
300 ApiState* state = Isolate::Current()->api_state(); 300 ApiState* state = Isolate::Current()->api_state();
301 ASSERT(state != NULL); 301 ASSERT(state != NULL);
302 FinalizablePersistentHandle* weak_ref = 302 FinalizablePersistentHandle* weak_ref =
303 reinterpret_cast<FinalizablePersistentHandle*>(handle); 303 reinterpret_cast<FinalizablePersistentHandle*>(handle);
304 ASSERT(state->IsValidWeakPersistentHandle(handle)); 304 ASSERT(state->IsValidWeakPersistentHandle(handle));
305 state->weak_persistent_handles().FreeHandle(weak_ref); 305 state->weak_persistent_handles().FreeHandle(weak_ref);
306 } 306 }
307 307
308 308
309 void Object::InitOnce() { 309 void Object::InitOnce() {
(...skipping 4791 matching lines...) Expand 10 before | Expand all | Expand 10 after
5101 RawExternalTypedData* TokenStream::GetStream() const { 5101 RawExternalTypedData* TokenStream::GetStream() const {
5102 return raw_ptr()->stream_; 5102 return raw_ptr()->stream_;
5103 } 5103 }
5104 5104
5105 5105
5106 void TokenStream::SetStream(const ExternalTypedData& value) const { 5106 void TokenStream::SetStream(const ExternalTypedData& value) const {
5107 StorePointer(&raw_ptr()->stream_, value.raw()); 5107 StorePointer(&raw_ptr()->stream_, value.raw());
5108 } 5108 }
5109 5109
5110 5110
5111 void TokenStream::DataFinalizer(Dart_Handle handle, void *peer) { 5111 void TokenStream::DataFinalizer(Dart_WeakPersistentHandle handle, void *peer) {
5112 ASSERT(peer != NULL); 5112 ASSERT(peer != NULL);
5113 ::free(peer); 5113 ::free(peer);
5114 DeleteWeakPersistentHandle(handle); 5114 DeleteWeakPersistentHandle(handle);
5115 } 5115 }
5116 5116
5117 5117
5118 RawString* TokenStream::PrivateKey() const { 5118 RawString* TokenStream::PrivateKey() const {
5119 return raw_ptr()->private_key_; 5119 return raw_ptr()->private_key_;
5120 } 5120 }
5121 5121
(...skipping 7208 matching lines...) Expand 10 before | Expand all | Expand 10 after
12330 result ^= raw; 12330 result ^= raw;
12331 result.SetLength(len); 12331 result.SetLength(len);
12332 result.SetHash(0); 12332 result.SetHash(0);
12333 SetExternalData(result, external_data); 12333 SetExternalData(result, external_data);
12334 } 12334 }
12335 AddFinalizer(result, external_data, ExternalOneByteString::Finalize); 12335 AddFinalizer(result, external_data, ExternalOneByteString::Finalize);
12336 return ExternalOneByteString::raw(result); 12336 return ExternalOneByteString::raw(result);
12337 } 12337 }
12338 12338
12339 12339
12340 void ExternalOneByteString::Finalize(Dart_Handle handle, void* peer) { 12340 void ExternalOneByteString::Finalize(Dart_WeakPersistentHandle handle, void* pee r) {
12341 delete reinterpret_cast<ExternalStringData<uint8_t>*>(peer); 12341 delete reinterpret_cast<ExternalStringData<uint8_t>*>(peer);
12342 DeleteWeakPersistentHandle(handle); 12342 DeleteWeakPersistentHandle(handle);
12343 } 12343 }
12344 12344
12345 12345
12346 RawExternalTwoByteString* ExternalTwoByteString::New( 12346 RawExternalTwoByteString* ExternalTwoByteString::New(
12347 const uint16_t* data, 12347 const uint16_t* data,
12348 intptr_t len, 12348 intptr_t len,
12349 void* peer, 12349 void* peer,
12350 Dart_PeerFinalizer callback, 12350 Dart_PeerFinalizer callback,
(...skipping 16 matching lines...) Expand all
12367 result ^= raw; 12367 result ^= raw;
12368 result.SetLength(len); 12368 result.SetLength(len);
12369 result.SetHash(0); 12369 result.SetHash(0);
12370 SetExternalData(result, external_data); 12370 SetExternalData(result, external_data);
12371 } 12371 }
12372 AddFinalizer(result, external_data, ExternalTwoByteString::Finalize); 12372 AddFinalizer(result, external_data, ExternalTwoByteString::Finalize);
12373 return ExternalTwoByteString::raw(result); 12373 return ExternalTwoByteString::raw(result);
12374 } 12374 }
12375 12375
12376 12376
12377 void ExternalTwoByteString::Finalize(Dart_Handle handle, void* peer) { 12377 void ExternalTwoByteString::Finalize(Dart_WeakPersistentHandle handle, void* pee r) {
12378 delete reinterpret_cast<ExternalStringData<uint16_t>*>(peer); 12378 delete reinterpret_cast<ExternalStringData<uint16_t>*>(peer);
12379 DeleteWeakPersistentHandle(handle); 12379 DeleteWeakPersistentHandle(handle);
12380 } 12380 }
12381 12381
12382 12382
12383 RawBool* Bool::New(bool value) { 12383 RawBool* Bool::New(bool value) {
12384 ASSERT(Isolate::Current()->object_store()->bool_class() != Class::null()); 12384 ASSERT(Isolate::Current()->object_store()->bool_class() != Class::null());
12385 Bool& result = Bool::Handle(); 12385 Bool& result = Bool::Handle();
12386 { 12386 {
12387 // Since the two boolean instances are singletons we allocate them straight 12387 // Since the two boolean instances are singletons we allocate them straight
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
13330 } 13330 }
13331 return result.raw(); 13331 return result.raw();
13332 } 13332 }
13333 13333
13334 13334
13335 const char* WeakProperty::ToCString() const { 13335 const char* WeakProperty::ToCString() const {
13336 return "_WeakProperty"; 13336 return "_WeakProperty";
13337 } 13337 }
13338 13338
13339 } // namespace dart 13339 } // namespace dart
OLDNEW
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698