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

Side by Side Diff: runtime/include/dart_api.h

Issue 187113003: Track external allocated memory for weak persistent handles. (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
« no previous file with comments | « runtime/bin/io_buffer.cc ('k') | runtime/vm/dart_api_impl.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 /* 1 /*
2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 * for details. All rights reserved. Use of this source code is governed by a 3 * for details. All rights reserved. Use of this source code is governed by a
4 * BSD-style license that can be found in the LICENSE file. 4 * BSD-style license that can be found in the LICENSE file.
5 */ 5 */
6 6
7 #ifndef INCLUDE_DART_API_H_ 7 #ifndef INCLUDE_DART_API_H_
8 #define INCLUDE_DART_API_H_ 8 #define INCLUDE_DART_API_H_
9 9
10 /** \mainpage Dart Embedding API Reference 10 /** \mainpage Dart Embedding API Reference
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 /** 435 /**
436 * Allocates a weak persistent handle for an object. 436 * Allocates a weak persistent handle for an object.
437 * 437 *
438 * This handle has the lifetime of the current isolate unless it is 438 * This handle has the lifetime of the current isolate unless it is
439 * explicitly deallocated by calling Dart_DeleteWeakPersistentHandle. 439 * explicitly deallocated by calling Dart_DeleteWeakPersistentHandle.
440 * 440 *
441 * If the object becomes unreachable the callback is invoked with the weak 441 * If the object becomes unreachable the callback is invoked with the weak
442 * persistent handle and the peer as arguments. This gives the native code the 442 * persistent handle and the peer as arguments. This gives the native code the
443 * ability to cleanup data associated with the object and to delete the weak 443 * ability to cleanup data associated with the object and to delete the weak
444 * persistent handle. It is illegal to call into the VM from the callback, 444 * persistent handle. It is illegal to call into the VM from the callback,
445 * except to delete the weak persistent handle. 445 * except to delete the weak persistent handle. If the handle is deleted before
446 * the object becomes unreachable, the callback is never invoked.
446 * 447 *
447 * Requires there to be a current isolate. 448 * Requires there to be a current isolate.
448 * 449 *
449 * \param object An object. 450 * \param object An object.
450 * \param peer A pointer to a native object or NULL. This value is 451 * \param peer A pointer to a native object or NULL. This value is
451 * provided to callback when it is invoked. 452 * provided to callback when it is invoked.
453 * \param external_allocation_size The number of externally allocated
454 * bytes for peer. Used to inform the garbage collector.
452 * \param callback A function pointer that will be invoked sometime 455 * \param callback A function pointer that will be invoked sometime
453 * after the object is garbage collected. 456 * after the object is garbage collected, unless the handle has been deleted.
454 * 457 *
455 * \return Success if the weak persistent handle was 458 * \return Success if the weak persistent handle was
456 * created. Otherwise, returns an error. 459 * created. Otherwise, returns an error.
457 */ 460 */
458 DART_EXPORT Dart_WeakPersistentHandle Dart_NewWeakPersistentHandle( 461 DART_EXPORT Dart_WeakPersistentHandle Dart_NewWeakPersistentHandle(
459 Dart_Handle object, 462 Dart_Handle object,
460 void* peer, 463 void* peer,
464 intptr_t external_allocation_size,
461 Dart_WeakPersistentHandleFinalizer callback); 465 Dart_WeakPersistentHandleFinalizer callback);
462 466
463 DART_EXPORT void Dart_DeleteWeakPersistentHandle( 467 DART_EXPORT void Dart_DeleteWeakPersistentHandle(
464 Dart_Isolate isolate, 468 Dart_Isolate isolate,
465 Dart_WeakPersistentHandle object); 469 Dart_WeakPersistentHandle object);
466 470
467 /** 471 /**
468 * Allocates a prologue weak persistent handle for an object. 472 * Allocates a prologue weak persistent handle for an object.
469 * 473 *
470 * Prologue weak persistent handles are similar to weak persistent 474 * Prologue weak persistent handles are similar to weak persistent
471 * handles but exhibit different behavior during garbage collections 475 * handles but exhibit different behavior during garbage collections
472 * that invoke the prologue and epilogue callbacks. While weak 476 * that invoke the prologue and epilogue callbacks. While weak
473 * persistent handles always weakly reference their referents, 477 * persistent handles always weakly reference their referents,
474 * prologue weak persistent handles weakly reference their referents 478 * prologue weak persistent handles weakly reference their referents
475 * only during a garbage collection that invokes the prologue and 479 * only during a garbage collection that invokes the prologue and
476 * epilogue callbacks. During all other garbage collections, prologue 480 * epilogue callbacks. During all other garbage collections, prologue
477 * weak persistent handles strongly reference their referents. 481 * weak persistent handles strongly reference their referents.
478 * 482 *
479 * This handle has the lifetime of the current isolate unless it is 483 * This handle has the lifetime of the current isolate unless it is
480 * explicitly deallocated by calling Dart_DeleteWeakPersistentHandle. 484 * explicitly deallocated by calling Dart_DeleteWeakPersistentHandle.
481 * 485 *
482 * Requires there to be a current isolate. 486 * Requires there to be a current isolate.
483 * 487 *
484 * \param object An object. 488 * \param object An object.
485 * \param peer A pointer to a native object or NULL. This value is 489 * \param peer A pointer to a native object or NULL. This value is
486 * provided to callback when it is invoked. 490 * provided to callback when it is invoked.
491 * \param external_allocation_size The number of externally allocated
492 * bytes for peer. Used to inform the garbage collector.
487 * \param callback A function pointer that will be invoked sometime 493 * \param callback A function pointer that will be invoked sometime
488 * after the object is garbage collected. 494 * after the object is garbage collected, unless the handle has been deleted.
489 * 495 *
490 * \return Success if the prologue weak persistent handle was created. 496 * \return Success if the prologue weak persistent handle was created.
491 * Otherwise, returns an error. 497 * Otherwise, returns an error.
492 */ 498 */
493 DART_EXPORT Dart_WeakPersistentHandle Dart_NewPrologueWeakPersistentHandle( 499 DART_EXPORT Dart_WeakPersistentHandle Dart_NewPrologueWeakPersistentHandle(
494 Dart_Handle object, 500 Dart_Handle object,
495 void* peer, 501 void* peer,
502 intptr_t external_allocation_size,
496 Dart_WeakPersistentHandleFinalizer callback); 503 Dart_WeakPersistentHandleFinalizer callback);
497 504
498 /** 505 /**
499 * Is this object a prologue weak persistent handle? 506 * Is this object a prologue weak persistent handle?
500 * 507 *
501 * Requires there to be a current isolate. 508 * Requires there to be a current isolate.
502 */ 509 */
503 DART_EXPORT bool Dart_IsPrologueWeakPersistentHandle( 510 DART_EXPORT bool Dart_IsPrologueWeakPersistentHandle(
504 Dart_WeakPersistentHandle object); 511 Dart_WeakPersistentHandle object);
505 512
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 */ 863 */
857 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri, 864 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri,
858 const char* main, 865 const char* main,
859 const uint8_t* snapshot, 866 const uint8_t* snapshot,
860 void* callback_data, 867 void* callback_data,
861 char** error); 868 char** error);
862 /* TODO(turnidge): Document behavior when there is already a current 869 /* TODO(turnidge): Document behavior when there is already a current
863 * isolate. */ 870 * isolate. */
864 871
865 /** 872 /**
866 * Shuts down the current isolate. After this call, the current 873 * Shuts down the current isolate. After this call, the current isolate
867 * isolate is NULL. 874 * is NULL. Invokes the shutdown callback and any callbacks of remaining
875 * weak persistent handles.
868 * 876 *
869 * Requires there to be a current isolate. 877 * Requires there to be a current isolate.
870 */ 878 */
871 DART_EXPORT void Dart_ShutdownIsolate(); 879 DART_EXPORT void Dart_ShutdownIsolate();
872 /* TODO(turnidge): Document behavior when there is no current isolate. */ 880 /* TODO(turnidge): Document behavior when there is no current isolate. */
873 881
874 /** 882 /**
875 * Returns the current isolate. Will return NULL if there is no 883 * Returns the current isolate. Will return NULL if there is no
876 * current isolate. 884 * current isolate.
877 */ 885 */
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 * NOTE: If multiple callbacks with the same name are registered, only the 2551 * NOTE: If multiple callbacks with the same name are registered, only the
2544 * last callback registered will be remembered. 2552 * last callback registered will be remembered.
2545 */ 2553 */
2546 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( 2554 DART_EXPORT void Dart_RegisterRootServiceRequestCallback(
2547 const char* name, 2555 const char* name,
2548 Dart_ServiceRequestCallback callback, 2556 Dart_ServiceRequestCallback callback,
2549 void* user_data); 2557 void* user_data);
2550 2558
2551 2559
2552 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ 2560 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */
OLDNEW
« no previous file with comments | « runtime/bin/io_buffer.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698