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

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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/unit_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 "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 7203 matching lines...) Expand 10 before | Expand all | Expand 10 after
12325 result ^= raw; 12325 result ^= raw;
12326 result.SetLength(len); 12326 result.SetLength(len);
12327 result.SetHash(0); 12327 result.SetHash(0);
12328 SetExternalData(result, external_data); 12328 SetExternalData(result, external_data);
12329 } 12329 }
12330 AddFinalizer(result, external_data, ExternalOneByteString::Finalize); 12330 AddFinalizer(result, external_data, ExternalOneByteString::Finalize);
12331 return ExternalOneByteString::raw(result); 12331 return ExternalOneByteString::raw(result);
12332 } 12332 }
12333 12333
12334 12334
12335 void ExternalOneByteString::Finalize(Dart_Handle handle, void* peer) { 12335 void ExternalOneByteString::Finalize(Dart_WeakPersistentHandle handle,
12336 void* peer) {
12336 delete reinterpret_cast<ExternalStringData<uint8_t>*>(peer); 12337 delete reinterpret_cast<ExternalStringData<uint8_t>*>(peer);
12337 DeleteWeakPersistentHandle(handle); 12338 DeleteWeakPersistentHandle(handle);
12338 } 12339 }
12339 12340
12340 12341
12341 RawExternalTwoByteString* ExternalTwoByteString::New( 12342 RawExternalTwoByteString* ExternalTwoByteString::New(
12342 const uint16_t* data, 12343 const uint16_t* data,
12343 intptr_t len, 12344 intptr_t len,
12344 void* peer, 12345 void* peer,
12345 Dart_PeerFinalizer callback, 12346 Dart_PeerFinalizer callback,
(...skipping 16 matching lines...) Expand all
12362 result ^= raw; 12363 result ^= raw;
12363 result.SetLength(len); 12364 result.SetLength(len);
12364 result.SetHash(0); 12365 result.SetHash(0);
12365 SetExternalData(result, external_data); 12366 SetExternalData(result, external_data);
12366 } 12367 }
12367 AddFinalizer(result, external_data, ExternalTwoByteString::Finalize); 12368 AddFinalizer(result, external_data, ExternalTwoByteString::Finalize);
12368 return ExternalTwoByteString::raw(result); 12369 return ExternalTwoByteString::raw(result);
12369 } 12370 }
12370 12371
12371 12372
12372 void ExternalTwoByteString::Finalize(Dart_Handle handle, void* peer) { 12373 void ExternalTwoByteString::Finalize(Dart_WeakPersistentHandle handle,
12374 void* peer) {
12373 delete reinterpret_cast<ExternalStringData<uint16_t>*>(peer); 12375 delete reinterpret_cast<ExternalStringData<uint16_t>*>(peer);
12374 DeleteWeakPersistentHandle(handle); 12376 DeleteWeakPersistentHandle(handle);
12375 } 12377 }
12376 12378
12377 12379
12378 RawBool* Bool::New(bool value) { 12380 RawBool* Bool::New(bool value) {
12379 ASSERT(Isolate::Current()->object_store()->bool_class() != Class::null()); 12381 ASSERT(Isolate::Current()->object_store()->bool_class() != Class::null());
12380 Bool& result = Bool::Handle(); 12382 Bool& result = Bool::Handle();
12381 { 12383 {
12382 // Since the two boolean instances are singletons we allocate them straight 12384 // Since the two boolean instances are singletons we allocate them straight
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
13325 } 13327 }
13326 return result.raw(); 13328 return result.raw();
13327 } 13329 }
13328 13330
13329 13331
13330 const char* WeakProperty::ToCString() const { 13332 const char* WeakProperty::ToCString() const {
13331 return "_WeakProperty"; 13333 return "_WeakProperty";
13332 } 13334 }
13333 13335
13334 } // namespace dart 13336 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/unit_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698