OLD | NEW |
---|---|
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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 inline bool IsIndependent() const; | |
Michael Starzinger
2012/10/17 08:47:47
Add short one-liner comment about this function.
| |
406 | |
405 /** | 407 /** |
406 *Checks if the handle holds the only reference to an object. | 408 *Checks if the handle holds the only reference to an object. |
407 */ | 409 */ |
408 inline bool IsNearDeath() const; | 410 inline bool IsNearDeath() const; |
409 | 411 |
410 /** | 412 /** |
411 * Returns true if the handle's reference is weak. | 413 * Returns true if the handle's reference is weak. |
412 */ | 414 */ |
413 inline bool IsWeak() const; | 415 inline bool IsWeak() const; |
414 | 416 |
415 /** | 417 /** |
416 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo | 418 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo |
417 * interface description in v8-profiler.h for details. | 419 * interface description in v8-profiler.h for details. |
418 */ | 420 */ |
419 inline void SetWrapperClassId(uint16_t class_id); | 421 inline void SetWrapperClassId(uint16_t class_id); |
422 inline uint16_t WrapperClassId() const; | |
Michael Starzinger
2012/10/17 08:47:47
Either adapt the above comment to cover both funct
| |
420 | 423 |
421 private: | 424 private: |
422 friend class ImplementationUtilities; | 425 friend class ImplementationUtilities; |
423 friend class ObjectTemplate; | 426 friend class ObjectTemplate; |
424 }; | 427 }; |
425 | 428 |
426 | 429 |
427 /** | 430 /** |
428 * A stack-allocated class that governs a number of local handles. | 431 * A stack-allocated class that governs a number of local handles. |
429 * After a handle scope has been created, all local handles will be | 432 * After a handle scope has been created, all local handles will be |
(...skipping 2574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3004 | 3007 |
3005 /** | 3008 /** |
3006 * Callback function passed to SetJitCodeEventHandler. | 3009 * Callback function passed to SetJitCodeEventHandler. |
3007 * | 3010 * |
3008 * \param event code add, move or removal event. | 3011 * \param event code add, move or removal event. |
3009 */ | 3012 */ |
3010 typedef void (*JitCodeEventHandler)(const JitCodeEvent* event); | 3013 typedef void (*JitCodeEventHandler)(const JitCodeEvent* event); |
3011 | 3014 |
3012 | 3015 |
3013 /** | 3016 /** |
3014 * Interface for iterating though all external resources in the heap. | 3017 * Interface for iterating though all external resources in the heap. |
Michael Starzinger
2012/10/17 08:47:47
s/though/through/
| |
3015 */ | 3018 */ |
3016 class V8EXPORT ExternalResourceVisitor { // NOLINT | 3019 class V8EXPORT ExternalResourceVisitor { // NOLINT |
3017 public: | 3020 public: |
3018 virtual ~ExternalResourceVisitor() {} | 3021 virtual ~ExternalResourceVisitor() {} |
3019 virtual void VisitExternalString(Handle<String> string) {} | 3022 virtual void VisitExternalString(Handle<String> string) {} |
3020 }; | 3023 }; |
3021 | 3024 |
3022 | 3025 |
3023 /** | 3026 /** |
3027 * Interface for iterating though the persistent handles in the heap. | |
Michael Starzinger
2012/10/17 08:47:47
s/though the/through all/
| |
3028 */ | |
3029 class V8EXPORT PersistentHandleVisitor { // NOLINT | |
3030 public: | |
3031 virtual ~PersistentHandleVisitor() {} | |
3032 virtual void VisitPersistentHandle(Persistent<Value> value, | |
3033 uint16_t class_id) {} | |
3034 }; | |
3035 | |
3036 | |
3037 /** | |
3024 * Container class for static utility functions. | 3038 * Container class for static utility functions. |
3025 */ | 3039 */ |
3026 class V8EXPORT V8 { | 3040 class V8EXPORT V8 { |
3027 public: | 3041 public: |
3028 /** Set the callback to invoke in case of fatal errors. */ | 3042 /** Set the callback to invoke in case of fatal errors. */ |
3029 static void SetFatalErrorHandler(FatalErrorCallback that); | 3043 static void SetFatalErrorHandler(FatalErrorCallback that); |
3030 | 3044 |
3031 /** | 3045 /** |
3032 * Set the callback to invoke to check if code generation from | 3046 * Set the callback to invoke to check if code generation from |
3033 * strings should be allowed. | 3047 * strings should be allowed. |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3421 static void GetHeapStatistics(HeapStatistics* heap_statistics); | 3435 static void GetHeapStatistics(HeapStatistics* heap_statistics); |
3422 | 3436 |
3423 /** | 3437 /** |
3424 * Iterates through all external resources referenced from current isolate | 3438 * Iterates through all external resources referenced from current isolate |
3425 * heap. This method is not expected to be used except for debugging purposes | 3439 * heap. This method is not expected to be used except for debugging purposes |
3426 * and may be quite slow. | 3440 * and may be quite slow. |
3427 */ | 3441 */ |
3428 static void VisitExternalResources(ExternalResourceVisitor* visitor); | 3442 static void VisitExternalResources(ExternalResourceVisitor* visitor); |
3429 | 3443 |
3430 /** | 3444 /** |
3445 * Iterates through all the persistent handles in the current isolate's heap | |
3446 * that have class_ids. | |
3447 */ | |
3448 static void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor); | |
3449 | |
3450 /** | |
3431 * Optional notification that the embedder is idle. | 3451 * Optional notification that the embedder is idle. |
3432 * V8 uses the notification to reduce memory footprint. | 3452 * V8 uses the notification to reduce memory footprint. |
3433 * This call can be used repeatedly if the embedder remains idle. | 3453 * This call can be used repeatedly if the embedder remains idle. |
3434 * Returns true if the embedder should stop calling IdleNotification | 3454 * Returns true if the embedder should stop calling IdleNotification |
3435 * until real work has been done. This indicates that V8 has done | 3455 * until real work has been done. This indicates that V8 has done |
3436 * as much cleanup as it will be able to do. | 3456 * as much cleanup as it will be able to do. |
3437 * | 3457 * |
3438 * The hint argument specifies the amount of work to be done in the function | 3458 * 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 | 3459 * on scale from 1 to 1000. There is no guarantee that the actual work will |
3440 * match the hint. | 3460 * match the hint. |
(...skipping 17 matching lines...) Expand all Loading... | |
3458 private: | 3478 private: |
3459 V8(); | 3479 V8(); |
3460 | 3480 |
3461 static internal::Object** GlobalizeReference(internal::Object** handle); | 3481 static internal::Object** GlobalizeReference(internal::Object** handle); |
3462 static void DisposeGlobal(internal::Object** global_handle); | 3482 static void DisposeGlobal(internal::Object** global_handle); |
3463 static void MakeWeak(internal::Object** global_handle, | 3483 static void MakeWeak(internal::Object** global_handle, |
3464 void* data, | 3484 void* data, |
3465 WeakReferenceCallback); | 3485 WeakReferenceCallback); |
3466 static void ClearWeak(internal::Object** global_handle); | 3486 static void ClearWeak(internal::Object** global_handle); |
3467 static void MarkIndependent(internal::Object** global_handle); | 3487 static void MarkIndependent(internal::Object** global_handle); |
3488 static bool IsGlobalIndependent(internal::Object** global_handle); | |
3468 static bool IsGlobalNearDeath(internal::Object** global_handle); | 3489 static bool IsGlobalNearDeath(internal::Object** global_handle); |
3469 static bool IsGlobalWeak(internal::Object** global_handle); | 3490 static bool IsGlobalWeak(internal::Object** global_handle); |
3470 static void SetWrapperClassId(internal::Object** global_handle, | 3491 static void SetWrapperClassId(internal::Object** global_handle, |
3471 uint16_t class_id); | 3492 uint16_t class_id); |
3493 static uint16_t GetWrapperClassId(internal::Object** global_handle); | |
3472 | 3494 |
3473 template <class T> friend class Handle; | 3495 template <class T> friend class Handle; |
3474 template <class T> friend class Local; | 3496 template <class T> friend class Local; |
3475 template <class T> friend class Persistent; | 3497 template <class T> friend class Persistent; |
3476 friend class Context; | 3498 friend class Context; |
3477 }; | 3499 }; |
3478 | 3500 |
3479 | 3501 |
3480 /** | 3502 /** |
3481 * An external exception handler. | 3503 * An external exception handler. |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4179 | 4201 |
4180 template <class T> | 4202 template <class T> |
4181 Persistent<T> Persistent<T>::New(Handle<T> that) { | 4203 Persistent<T> Persistent<T>::New(Handle<T> that) { |
4182 if (that.IsEmpty()) return Persistent<T>(); | 4204 if (that.IsEmpty()) return Persistent<T>(); |
4183 internal::Object** p = reinterpret_cast<internal::Object**>(*that); | 4205 internal::Object** p = reinterpret_cast<internal::Object**>(*that); |
4184 return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); | 4206 return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); |
4185 } | 4207 } |
4186 | 4208 |
4187 | 4209 |
4188 template <class T> | 4210 template <class T> |
4211 bool Persistent<T>::IsIndependent() const { | |
4212 if (this->IsEmpty()) return false; | |
4213 return V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**this)); | |
4214 } | |
4215 | |
4216 | |
4217 template <class T> | |
4189 bool Persistent<T>::IsNearDeath() const { | 4218 bool Persistent<T>::IsNearDeath() const { |
4190 if (this->IsEmpty()) return false; | 4219 if (this->IsEmpty()) return false; |
4191 return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this)); | 4220 return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this)); |
4192 } | 4221 } |
4193 | 4222 |
4194 | 4223 |
4195 template <class T> | 4224 template <class T> |
4196 bool Persistent<T>::IsWeak() const { | 4225 bool Persistent<T>::IsWeak() const { |
4197 if (this->IsEmpty()) return false; | 4226 if (this->IsEmpty()) return false; |
4198 return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this)); | 4227 return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this)); |
(...skipping 25 matching lines...) Expand all Loading... | |
4224 template <class T> | 4253 template <class T> |
4225 void Persistent<T>::MarkIndependent() { | 4254 void Persistent<T>::MarkIndependent() { |
4226 V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); | 4255 V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); |
4227 } | 4256 } |
4228 | 4257 |
4229 template <class T> | 4258 template <class T> |
4230 void Persistent<T>::SetWrapperClassId(uint16_t class_id) { | 4259 void Persistent<T>::SetWrapperClassId(uint16_t class_id) { |
4231 V8::SetWrapperClassId(reinterpret_cast<internal::Object**>(**this), class_id); | 4260 V8::SetWrapperClassId(reinterpret_cast<internal::Object**>(**this), class_id); |
4232 } | 4261 } |
4233 | 4262 |
4263 template <class T> | |
4264 uint16_t Persistent<T>::WrapperClassId() const { | |
4265 return V8::GetWrapperClassId(reinterpret_cast<internal::Object**>(**this)); | |
4266 } | |
4267 | |
4234 Arguments::Arguments(internal::Object** implicit_args, | 4268 Arguments::Arguments(internal::Object** implicit_args, |
4235 internal::Object** values, int length, | 4269 internal::Object** values, int length, |
4236 bool is_construct_call) | 4270 bool is_construct_call) |
4237 : implicit_args_(implicit_args), | 4271 : implicit_args_(implicit_args), |
4238 values_(values), | 4272 values_(values), |
4239 length_(length), | 4273 length_(length), |
4240 is_construct_call_(is_construct_call) { } | 4274 is_construct_call_(is_construct_call) { } |
4241 | 4275 |
4242 | 4276 |
4243 Local<Value> Arguments::operator[](int i) const { | 4277 Local<Value> Arguments::operator[](int i) const { |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4654 | 4688 |
4655 | 4689 |
4656 } // namespace v8 | 4690 } // namespace v8 |
4657 | 4691 |
4658 | 4692 |
4659 #undef V8EXPORT | 4693 #undef V8EXPORT |
4660 #undef TYPE_CHECK | 4694 #undef TYPE_CHECK |
4661 | 4695 |
4662 | 4696 |
4663 #endif // V8_H_ | 4697 #endif // V8_H_ |
OLD | NEW |