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

Side by Side Diff: include/v8.h

Issue 11190011: Add an API for enumerating persistent handles (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 2 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 | « no previous file | src/api.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 inline void Dispose(); 383 inline void Dispose();
384 384
385 /** 385 /**
386 * Make the reference to this object weak. When only weak handles 386 * Make the reference to this object weak. When only weak handles
387 * refer to the object, the garbage collector will perform a 387 * refer to the object, the garbage collector will perform a
388 * callback to the given V8::WeakReferenceCallback function, passing 388 * callback to the given V8::WeakReferenceCallback function, passing
389 * it the object reference and the given parameters. 389 * it the object reference and the given parameters.
390 */ 390 */
391 inline void MakeWeak(void* parameters, WeakReferenceCallback callback); 391 inline void MakeWeak(void* parameters, WeakReferenceCallback callback);
392 392
393 /** Clears the weak reference to this object.*/ 393 /** Clears the weak reference to this object. */
394 inline void ClearWeak(); 394 inline void ClearWeak();
395 395
396 /** 396 /**
397 * Marks the reference to this object independent. Garbage collector 397 * Marks the reference to this object independent. Garbage collector
398 * is free to ignore any object groups containing this object. 398 * is free to ignore any object groups containing this object.
399 * Weak callback for an independent handle should not 399 * Weak callback for an independent handle should not
400 * assume that it will be preceded by a global GC prologue callback 400 * assume that it will be preceded by a global GC prologue callback
401 * or followed by a global GC epilogue callback. 401 * or followed by a global GC epilogue callback.
402 */ 402 */
403 inline void MarkIndependent(); 403 inline void MarkIndependent();
404 404
405 /** 405 /** Returns true if this handle was previously marked as independent. */
406 *Checks if the handle holds the only reference to an object. 406 inline bool IsIndependent() const;
407 */ 407
408 /** Checks if the handle holds the only reference to an object. */
408 inline bool IsNearDeath() const; 409 inline bool IsNearDeath() const;
409 410
410 /** 411 /** Returns true if the handle's reference is weak. */
411 * Returns true if the handle's reference is weak.
412 */
413 inline bool IsWeak() const; 412 inline bool IsWeak() const;
414 413
415 /** 414 /**
416 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo 415 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo
417 * interface description in v8-profiler.h for details. 416 * interface description in v8-profiler.h for details.
418 */ 417 */
419 inline void SetWrapperClassId(uint16_t class_id); 418 inline void SetWrapperClassId(uint16_t class_id);
420 419
420 /**
421 * Returns the class ID previously assigned to this handle or 0 if no class
422 * ID was previously assigned.
423 */
424 inline uint16_t WrapperClassId() const;
425
421 private: 426 private:
422 friend class ImplementationUtilities; 427 friend class ImplementationUtilities;
423 friend class ObjectTemplate; 428 friend class ObjectTemplate;
424 }; 429 };
425 430
426 431
427 /** 432 /**
428 * A stack-allocated class that governs a number of local handles. 433 * A stack-allocated class that governs a number of local handles.
429 * After a handle scope has been created, all local handles will be 434 * After a handle scope has been created, all local handles will be
430 * allocated within that handle scope until either the handle scope is 435 * allocated within that handle scope until either the handle scope is
(...skipping 2573 matching lines...) Expand 10 before | Expand all | Expand 10 after
3004 3009
3005 /** 3010 /**
3006 * Callback function passed to SetJitCodeEventHandler. 3011 * Callback function passed to SetJitCodeEventHandler.
3007 * 3012 *
3008 * \param event code add, move or removal event. 3013 * \param event code add, move or removal event.
3009 */ 3014 */
3010 typedef void (*JitCodeEventHandler)(const JitCodeEvent* event); 3015 typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
3011 3016
3012 3017
3013 /** 3018 /**
3014 * Interface for iterating though all external resources in the heap. 3019 * Interface for iterating through all external resources in the heap.
3015 */ 3020 */
3016 class V8EXPORT ExternalResourceVisitor { // NOLINT 3021 class V8EXPORT ExternalResourceVisitor { // NOLINT
3017 public: 3022 public:
3018 virtual ~ExternalResourceVisitor() {} 3023 virtual ~ExternalResourceVisitor() {}
3019 virtual void VisitExternalString(Handle<String> string) {} 3024 virtual void VisitExternalString(Handle<String> string) {}
3020 }; 3025 };
3021 3026
3022 3027
3023 /** 3028 /**
3029 * Interface for iterating through all the persistent handles in the heap.
3030 */
3031 class V8EXPORT PersistentHandleVisitor { // NOLINT
3032 public:
3033 virtual ~PersistentHandleVisitor() {}
3034 virtual void VisitPersistentHandle(Persistent<Value> value,
3035 uint16_t class_id) {}
3036 };
3037
3038
3039 /**
3024 * Container class for static utility functions. 3040 * Container class for static utility functions.
3025 */ 3041 */
3026 class V8EXPORT V8 { 3042 class V8EXPORT V8 {
3027 public: 3043 public:
3028 /** Set the callback to invoke in case of fatal errors. */ 3044 /** Set the callback to invoke in case of fatal errors. */
3029 static void SetFatalErrorHandler(FatalErrorCallback that); 3045 static void SetFatalErrorHandler(FatalErrorCallback that);
3030 3046
3031 /** 3047 /**
3032 * Set the callback to invoke to check if code generation from 3048 * Set the callback to invoke to check if code generation from
3033 * strings should be allowed. 3049 * strings should be allowed.
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
3421 static void GetHeapStatistics(HeapStatistics* heap_statistics); 3437 static void GetHeapStatistics(HeapStatistics* heap_statistics);
3422 3438
3423 /** 3439 /**
3424 * Iterates through all external resources referenced from current isolate 3440 * Iterates through all external resources referenced from current isolate
3425 * heap. This method is not expected to be used except for debugging purposes 3441 * heap. This method is not expected to be used except for debugging purposes
3426 * and may be quite slow. 3442 * and may be quite slow.
3427 */ 3443 */
3428 static void VisitExternalResources(ExternalResourceVisitor* visitor); 3444 static void VisitExternalResources(ExternalResourceVisitor* visitor);
3429 3445
3430 /** 3446 /**
3447 * Iterates through all the persistent handles in the current isolate's heap
3448 * that have class_ids.
3449 */
3450 static void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
3451
3452 /**
3431 * Optional notification that the embedder is idle. 3453 * Optional notification that the embedder is idle.
3432 * V8 uses the notification to reduce memory footprint. 3454 * V8 uses the notification to reduce memory footprint.
3433 * This call can be used repeatedly if the embedder remains idle. 3455 * This call can be used repeatedly if the embedder remains idle.
3434 * Returns true if the embedder should stop calling IdleNotification 3456 * Returns true if the embedder should stop calling IdleNotification
3435 * until real work has been done. This indicates that V8 has done 3457 * until real work has been done. This indicates that V8 has done
3436 * as much cleanup as it will be able to do. 3458 * as much cleanup as it will be able to do.
3437 * 3459 *
3438 * The hint argument specifies the amount of work to be done in the function 3460 * The hint argument specifies the amount of work to be done in the function
3439 * on scale from 1 to 1000. There is no guarantee that the actual work will 3461 * on scale from 1 to 1000. There is no guarantee that the actual work will
3440 * match the hint. 3462 * match the hint.
(...skipping 17 matching lines...) Expand all
3458 private: 3480 private:
3459 V8(); 3481 V8();
3460 3482
3461 static internal::Object** GlobalizeReference(internal::Object** handle); 3483 static internal::Object** GlobalizeReference(internal::Object** handle);
3462 static void DisposeGlobal(internal::Object** global_handle); 3484 static void DisposeGlobal(internal::Object** global_handle);
3463 static void MakeWeak(internal::Object** global_handle, 3485 static void MakeWeak(internal::Object** global_handle,
3464 void* data, 3486 void* data,
3465 WeakReferenceCallback); 3487 WeakReferenceCallback);
3466 static void ClearWeak(internal::Object** global_handle); 3488 static void ClearWeak(internal::Object** global_handle);
3467 static void MarkIndependent(internal::Object** global_handle); 3489 static void MarkIndependent(internal::Object** global_handle);
3490 static bool IsGlobalIndependent(internal::Object** global_handle);
3468 static bool IsGlobalNearDeath(internal::Object** global_handle); 3491 static bool IsGlobalNearDeath(internal::Object** global_handle);
3469 static bool IsGlobalWeak(internal::Object** global_handle); 3492 static bool IsGlobalWeak(internal::Object** global_handle);
3470 static void SetWrapperClassId(internal::Object** global_handle, 3493 static void SetWrapperClassId(internal::Object** global_handle,
3471 uint16_t class_id); 3494 uint16_t class_id);
3495 static uint16_t GetWrapperClassId(internal::Object** global_handle);
3472 3496
3473 template <class T> friend class Handle; 3497 template <class T> friend class Handle;
3474 template <class T> friend class Local; 3498 template <class T> friend class Local;
3475 template <class T> friend class Persistent; 3499 template <class T> friend class Persistent;
3476 friend class Context; 3500 friend class Context;
3477 }; 3501 };
3478 3502
3479 3503
3480 /** 3504 /**
3481 * An external exception handler. 3505 * An external exception handler.
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
4179 4203
4180 template <class T> 4204 template <class T>
4181 Persistent<T> Persistent<T>::New(Handle<T> that) { 4205 Persistent<T> Persistent<T>::New(Handle<T> that) {
4182 if (that.IsEmpty()) return Persistent<T>(); 4206 if (that.IsEmpty()) return Persistent<T>();
4183 internal::Object** p = reinterpret_cast<internal::Object**>(*that); 4207 internal::Object** p = reinterpret_cast<internal::Object**>(*that);
4184 return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); 4208 return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p)));
4185 } 4209 }
4186 4210
4187 4211
4188 template <class T> 4212 template <class T>
4213 bool Persistent<T>::IsIndependent() const {
4214 if (this->IsEmpty()) return false;
4215 return V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**this));
4216 }
4217
4218
4219 template <class T>
4189 bool Persistent<T>::IsNearDeath() const { 4220 bool Persistent<T>::IsNearDeath() const {
4190 if (this->IsEmpty()) return false; 4221 if (this->IsEmpty()) return false;
4191 return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this)); 4222 return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this));
4192 } 4223 }
4193 4224
4194 4225
4195 template <class T> 4226 template <class T>
4196 bool Persistent<T>::IsWeak() const { 4227 bool Persistent<T>::IsWeak() const {
4197 if (this->IsEmpty()) return false; 4228 if (this->IsEmpty()) return false;
4198 return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this)); 4229 return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this));
(...skipping 25 matching lines...) Expand all
4224 template <class T> 4255 template <class T>
4225 void Persistent<T>::MarkIndependent() { 4256 void Persistent<T>::MarkIndependent() {
4226 V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); 4257 V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this));
4227 } 4258 }
4228 4259
4229 template <class T> 4260 template <class T>
4230 void Persistent<T>::SetWrapperClassId(uint16_t class_id) { 4261 void Persistent<T>::SetWrapperClassId(uint16_t class_id) {
4231 V8::SetWrapperClassId(reinterpret_cast<internal::Object**>(**this), class_id); 4262 V8::SetWrapperClassId(reinterpret_cast<internal::Object**>(**this), class_id);
4232 } 4263 }
4233 4264
4265 template <class T>
4266 uint16_t Persistent<T>::WrapperClassId() const {
4267 return V8::GetWrapperClassId(reinterpret_cast<internal::Object**>(**this));
4268 }
4269
4234 Arguments::Arguments(internal::Object** implicit_args, 4270 Arguments::Arguments(internal::Object** implicit_args,
4235 internal::Object** values, int length, 4271 internal::Object** values, int length,
4236 bool is_construct_call) 4272 bool is_construct_call)
4237 : implicit_args_(implicit_args), 4273 : implicit_args_(implicit_args),
4238 values_(values), 4274 values_(values),
4239 length_(length), 4275 length_(length),
4240 is_construct_call_(is_construct_call) { } 4276 is_construct_call_(is_construct_call) { }
4241 4277
4242 4278
4243 Local<Value> Arguments::operator[](int i) const { 4279 Local<Value> Arguments::operator[](int i) const {
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
4654 4690
4655 4691
4656 } // namespace v8 4692 } // namespace v8
4657 4693
4658 4694
4659 #undef V8EXPORT 4695 #undef V8EXPORT
4660 #undef TYPE_CHECK 4696 #undef TYPE_CHECK
4661 4697
4662 4698
4663 #endif // V8_H_ 4699 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698