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

Side by Side Diff: include/v8.h

Issue 12033011: Add Isolate parameter to Persistent class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added explicit Created 7 years, 11 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 | samples/lineprocessor.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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 * 150 *
151 * This callback should either explicitly invoke Dispose on |object| if 151 * This callback should either explicitly invoke Dispose on |object| if
152 * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak. 152 * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWeak.
153 * 153 *
154 * \param object the weak global object to be reclaimed by the garbage collector 154 * \param object the weak global object to be reclaimed by the garbage collector
155 * \param parameter the value passed in when making the weak global object 155 * \param parameter the value passed in when making the weak global object
156 */ 156 */
157 typedef void (*WeakReferenceCallback)(Persistent<Value> object, 157 typedef void (*WeakReferenceCallback)(Persistent<Value> object,
158 void* parameter); 158 void* parameter);
159 159
160 // TODO(svenpanne) Temporary definition until Chrome is in sync.
161 typedef void (*NearDeathCallback)(Isolate* isolate,
162 Persistent<Value> object,
163 void* parameter);
160 164
161 // --- Handles --- 165 // --- Handles ---
162 166
163 #define TYPE_CHECK(T, S) \ 167 #define TYPE_CHECK(T, S) \
164 while (false) { \ 168 while (false) { \
165 *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \ 169 *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \
166 } 170 }
167 171
168 /** 172 /**
169 * An object reference managed by the v8 garbage collector. 173 * An object reference managed by the v8 garbage collector.
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // that the handle isn't empty before doing the checked cast. 386 // that the handle isn't empty before doing the checked cast.
383 if (that.IsEmpty()) return Persistent<T>(); 387 if (that.IsEmpty()) return Persistent<T>();
384 #endif 388 #endif
385 return Persistent<T>(T::Cast(*that)); 389 return Persistent<T>(T::Cast(*that));
386 } 390 }
387 391
388 template <class S> V8_INLINE(Persistent<S> As()) { 392 template <class S> V8_INLINE(Persistent<S> As()) {
389 return Persistent<S>::Cast(*this); 393 return Persistent<S>::Cast(*this);
390 } 394 }
391 395
396 /** Deprecated. Use Isolate version instead. */
397 V8_DEPRECATED(static Persistent<T> New(Handle<T> that));
398
392 /** 399 /**
393 * Creates a new persistent handle for an existing local or 400 * Creates a new persistent handle for an existing local or persistent handle.
394 * persistent handle.
395 */ 401 */
396 V8_INLINE(static Persistent<T> New(Handle<T> that)); 402 V8_INLINE(static Persistent<T> New(Isolate* isolate, Handle<T> that));
403
404 /** Deprecated. Use Isolate version instead. */
405 V8_DEPRECATED(void Dispose());
397 406
398 /** 407 /**
399 * Releases the storage cell referenced by this persistent handle. 408 * Releases the storage cell referenced by this persistent handle.
400 * Does not remove the reference to the cell from any handles. 409 * Does not remove the reference to the cell from any handles.
401 * This handle's reference, and any other references to the storage 410 * This handle's reference, and any other references to the storage
402 * cell remain and IsEmpty will still return false. 411 * cell remain and IsEmpty will still return false.
403 */ 412 */
404 V8_INLINE(void Dispose());
405 V8_INLINE(void Dispose(Isolate* isolate)); 413 V8_INLINE(void Dispose(Isolate* isolate));
406 414
415 /** Deprecated. Use Isolate version instead. */
416 V8_DEPRECATED(void MakeWeak(void* parameters,
417 WeakReferenceCallback callback));
418
407 /** 419 /**
408 * Make the reference to this object weak. When only weak handles 420 * Make the reference to this object weak. When only weak handles
409 * refer to the object, the garbage collector will perform a 421 * refer to the object, the garbage collector will perform a
410 * callback to the given V8::WeakReferenceCallback function, passing 422 * callback to the given V8::NearDeathCallback function, passing
411 * it the object reference and the given parameters. 423 * it the object reference and the given parameters.
412 */ 424 */
413 V8_INLINE(void MakeWeak(void* parameters, WeakReferenceCallback callback));
414 V8_INLINE(void MakeWeak(Isolate* isolate, 425 V8_INLINE(void MakeWeak(Isolate* isolate,
415 void* parameters, 426 void* parameters,
416 WeakReferenceCallback callback)); 427 NearDeathCallback callback));
428
429 /** Deprecated. Use Isolate version instead. */
430 V8_DEPRECATED(void ClearWeak());
417 431
418 /** Clears the weak reference to this object. */ 432 /** Clears the weak reference to this object. */
419 V8_INLINE(void ClearWeak()); 433 V8_INLINE(void ClearWeak(Isolate* isolate));
434
435 /** Deprecated. Use Isolate version instead. */
436 V8_DEPRECATED(void MarkIndependent());
420 437
421 /** 438 /**
422 * Marks the reference to this object independent. Garbage collector 439 * Marks the reference to this object independent. Garbage collector is free
423 * is free to ignore any object groups containing this object. 440 * to ignore any object groups containing this object. Weak callback for an
424 * Weak callback for an independent handle should not 441 * independent handle should not assume that it will be preceded by a global
425 * assume that it will be preceded by a global GC prologue callback 442 * GC prologue callback or followed by a global GC epilogue callback.
426 * or followed by a global GC epilogue callback.
427 */ 443 */
428 V8_INLINE(void MarkIndependent());
429 V8_INLINE(void MarkIndependent(Isolate* isolate)); 444 V8_INLINE(void MarkIndependent(Isolate* isolate));
430 445
446 /** Deprecated. Use Isolate version instead. */
447 V8_DEPRECATED(void MarkPartiallyDependent());
448
431 /** 449 /**
432 * Marks the reference to this object partially dependent. Partially 450 * Marks the reference to this object partially dependent. Partially dependent
433 * dependent handles only depend on other partially dependent handles and 451 * handles only depend on other partially dependent handles and these
434 * these dependencies are provided through object groups. It provides a way 452 * dependencies are provided through object groups. It provides a way to build
435 * to build smaller object groups for young objects that represent only a 453 * smaller object groups for young objects that represent only a subset of all
436 * subset of all external dependencies. This mark is automatically cleared 454 * external dependencies. This mark is automatically cleared after each
437 * after each garbage collection. 455 * garbage collection.
438 */ 456 */
439 V8_INLINE(void MarkPartiallyDependent());
440 V8_INLINE(void MarkPartiallyDependent(Isolate* isolate)); 457 V8_INLINE(void MarkPartiallyDependent(Isolate* isolate));
441 458
459 /** Deprecated. Use Isolate version instead. */
460 V8_DEPRECATED(bool IsIndependent() const);
461
442 /** Returns true if this handle was previously marked as independent. */ 462 /** Returns true if this handle was previously marked as independent. */
443 V8_INLINE(bool IsIndependent() const);
444 V8_INLINE(bool IsIndependent(Isolate* isolate) const); 463 V8_INLINE(bool IsIndependent(Isolate* isolate) const);
445 464
465 /** Deprecated. Use Isolate version instead. */
466 V8_DEPRECATED(bool IsNearDeath() const);
467
446 /** Checks if the handle holds the only reference to an object. */ 468 /** Checks if the handle holds the only reference to an object. */
447 V8_INLINE(bool IsNearDeath() const); 469 V8_INLINE(bool IsNearDeath(Isolate* isolate) const);
470
471 /** Deprecated. Use Isolate version instead. */
472 V8_DEPRECATED(bool IsWeak() const);
448 473
449 /** Returns true if the handle's reference is weak. */ 474 /** Returns true if the handle's reference is weak. */
450 V8_INLINE(bool IsWeak() const);
451 V8_INLINE(bool IsWeak(Isolate* isolate) const); 475 V8_INLINE(bool IsWeak(Isolate* isolate) const);
452 476
453 /** 477 /** Deprecated. Use Isolate version instead. */
454 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo 478 V8_DEPRECATED(void SetWrapperClassId(uint16_t class_id));
455 * interface description in v8-profiler.h for details.
456 */
457 V8_INLINE(void SetWrapperClassId(uint16_t class_id));
458 479
459 /** 480 /**
460 * Returns the class ID previously assigned to this handle or 0 if no class 481 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface
461 * ID was previously assigned. 482 * description in v8-profiler.h for details.
462 */ 483 */
463 V8_INLINE(uint16_t WrapperClassId() const); 484 V8_INLINE(void SetWrapperClassId(Isolate* isolate, uint16_t class_id));
485
486 /** Deprecated. Use Isolate version instead. */
487 V8_DEPRECATED(uint16_t WrapperClassId() const);
488
489 /**
490 * Returns the class ID previously assigned to this handle or 0 if no class ID
491 * was previously assigned.
492 */
493 V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const);
464 494
465 private: 495 private:
466 friend class ImplementationUtilities; 496 friend class ImplementationUtilities;
467 friend class ObjectTemplate; 497 friend class ObjectTemplate;
468 }; 498 };
469 499
470 500
471 /** 501 /**
472 * A stack-allocated class that governs a number of local handles. 502 * A stack-allocated class that governs a number of local handles.
473 * After a handle scope has been created, all local handles will be 503 * After a handle scope has been created, all local handles will be
(...skipping 3048 matching lines...) Expand 10 before | Expand all | Expand 10 after
3522 * Optional notification that a context has been disposed. V8 uses 3552 * Optional notification that a context has been disposed. V8 uses
3523 * these notifications to guide the GC heuristic. Returns the number 3553 * these notifications to guide the GC heuristic. Returns the number
3524 * of context disposals - including this one - since the last time 3554 * of context disposals - including this one - since the last time
3525 * V8 had a chance to clean up. 3555 * V8 had a chance to clean up.
3526 */ 3556 */
3527 static int ContextDisposedNotification(); 3557 static int ContextDisposedNotification();
3528 3558
3529 private: 3559 private:
3530 V8(); 3560 V8();
3531 3561
3532 static internal::Object** GlobalizeReference(internal::Object** handle); 3562 static internal::Object** GlobalizeReference(internal::Isolate* isolate,
3533 static void DisposeGlobal(internal::Object** global_handle); 3563 internal::Object** handle);
3534 static void DisposeGlobal(internal::Isolate* isolate, 3564 static void DisposeGlobal(internal::Isolate* isolate,
3535 internal::Object** global_handle); 3565 internal::Object** global_handle);
3536 static void MakeWeak(internal::Object** global_handle,
3537 void* data,
3538 WeakReferenceCallback);
3539 static void MakeWeak(internal::Isolate* isolate, 3566 static void MakeWeak(internal::Isolate* isolate,
3540 internal::Object** global_handle, 3567 internal::Object** global_handle,
3541 void* data, 3568 void* data,
3542 WeakReferenceCallback); 3569 WeakReferenceCallback weak_reference_callback,
3543 static void ClearWeak(internal::Object** global_handle); 3570 NearDeathCallback near_death_callback);
3544 static void MarkIndependent(internal::Object** global_handle); 3571 static void ClearWeak(internal::Isolate* isolate,
3545 static void MarkIndependent(internal::Isolate* isolate, 3572 internal::Object** global_handle);
3546 internal::Object** global_handle);
3547 static void MarkPartiallyDependent(internal::Object** global_handle);
3548 static void MarkPartiallyDependent(internal::Isolate* isolate,
3549 internal::Object** global_handle);
3550 static bool IsGlobalIndependent(internal::Object** global_handle);
3551 static bool IsGlobalIndependent(internal::Isolate* isolate,
3552 internal::Object** global_handle);
3553 static bool IsGlobalNearDeath(internal::Object** global_handle);
3554 static bool IsGlobalWeak(internal::Object** global_handle);
3555 static bool IsGlobalWeak(internal::Isolate* isolate,
3556 internal::Object** global_handle);
3557 3573
3558 template <class T> friend class Handle; 3574 template <class T> friend class Handle;
3559 template <class T> friend class Local; 3575 template <class T> friend class Local;
3560 template <class T> friend class Persistent; 3576 template <class T> friend class Persistent;
3561 friend class Context; 3577 friend class Context;
3562 }; 3578 };
3563 3579
3564 3580
3565 /** 3581 /**
3566 * An external exception handler. 3582 * An external exception handler.
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
3967 * // V8 Now no longer locked. 3983 * // V8 Now no longer locked.
3968 * \endcode 3984 * \endcode
3969 */ 3985 */
3970 class V8EXPORT Unlocker { 3986 class V8EXPORT Unlocker {
3971 public: 3987 public:
3972 /** 3988 /**
3973 * Initialize Unlocker for a given Isolate. 3989 * Initialize Unlocker for a given Isolate.
3974 */ 3990 */
3975 V8_INLINE(explicit Unlocker(Isolate* isolate)) { Initialize(isolate); } 3991 V8_INLINE(explicit Unlocker(Isolate* isolate)) { Initialize(isolate); }
3976 3992
3977 /** 3993 /** Deprecated. Use Isolate version instead. */
3978 * Deprecated. Use Isolate version instead.
3979 */
3980 V8_DEPRECATED(Unlocker()); 3994 V8_DEPRECATED(Unlocker());
3981 3995
3982 ~Unlocker(); 3996 ~Unlocker();
3983 private: 3997 private:
3984 void Initialize(Isolate* isolate); 3998 void Initialize(Isolate* isolate);
3985 3999
3986 internal::Isolate* isolate_; 4000 internal::Isolate* isolate_;
3987 }; 4001 };
3988 4002
3989 4003
3990 class V8EXPORT Locker { 4004 class V8EXPORT Locker {
3991 public: 4005 public:
3992 /** 4006 /**
3993 * Initialize Locker for a given Isolate. 4007 * Initialize Locker for a given Isolate.
3994 */ 4008 */
3995 V8_INLINE(explicit Locker(Isolate* isolate)) { Initialize(isolate); } 4009 V8_INLINE(explicit Locker(Isolate* isolate)) { Initialize(isolate); }
3996 4010
3997 /** 4011 /** Deprecated. Use Isolate version instead. */
3998 * Deprecated. Use Isolate version instead.
3999 */
4000 V8_DEPRECATED(Locker()); 4012 V8_DEPRECATED(Locker());
4001 4013
4002 ~Locker(); 4014 ~Locker();
4003 4015
4004 /** 4016 /**
4005 * Start preemption. 4017 * Start preemption.
4006 * 4018 *
4007 * When preemption is started, a timer is fired every n milliseconds 4019 * When preemption is started, a timer is fired every n milliseconds
4008 * that will switch between multiple threads that are in contention 4020 * that will switch between multiple threads that are in contention
4009 * for the V8 lock. 4021 * for the V8 lock.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
4168 static const int kContextHeaderSize = 2 * kApiPointerSize; 4180 static const int kContextHeaderSize = 2 * kApiPointerSize;
4169 static const int kContextEmbedderDataIndex = 54; 4181 static const int kContextEmbedderDataIndex = 54;
4170 static const int kFullStringRepresentationMask = 0x07; 4182 static const int kFullStringRepresentationMask = 0x07;
4171 static const int kStringEncodingMask = 0x4; 4183 static const int kStringEncodingMask = 0x4;
4172 static const int kExternalTwoByteRepresentationTag = 0x02; 4184 static const int kExternalTwoByteRepresentationTag = 0x02;
4173 static const int kExternalAsciiRepresentationTag = 0x06; 4185 static const int kExternalAsciiRepresentationTag = 0x06;
4174 4186
4175 static const int kIsolateStateOffset = 0; 4187 static const int kIsolateStateOffset = 0;
4176 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; 4188 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize;
4177 static const int kIsolateRootsOffset = 3 * kApiPointerSize; 4189 static const int kIsolateRootsOffset = 3 * kApiPointerSize;
4178 static const int kNodeClassIdOffset = 1 * kApiPointerSize;
4179 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
4180 static const int kUndefinedValueRootIndex = 5; 4190 static const int kUndefinedValueRootIndex = 5;
4181 static const int kNullValueRootIndex = 7; 4191 static const int kNullValueRootIndex = 7;
4182 static const int kTrueValueRootIndex = 8; 4192 static const int kTrueValueRootIndex = 8;
4183 static const int kFalseValueRootIndex = 9; 4193 static const int kFalseValueRootIndex = 9;
4184 static const int kEmptySymbolRootIndex = 119; 4194 static const int kEmptySymbolRootIndex = 119;
4185 4195
4196 static const int kNodeClassIdOffset = 1 * kApiPointerSize;
4197 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
4198 static const int kNodeStateMask = 0xf;
4199 static const int kNodeStateIsWeakValue = 2;
4200 static const int kNodeStateIsNearDeathValue = 4;
4186 static const int kNodeIsIndependentShift = 4; 4201 static const int kNodeIsIndependentShift = 4;
4187 static const int kNodeIsPartiallyDependentShift = 5; 4202 static const int kNodeIsPartiallyDependentShift = 5;
4188 4203
4189 static const int kJSObjectType = 0xab; 4204 static const int kJSObjectType = 0xab;
4190 static const int kFirstNonstringType = 0x80; 4205 static const int kFirstNonstringType = 0x80;
4191 static const int kOddballType = 0x82; 4206 static const int kOddballType = 0x82;
4192 static const int kForeignType = 0x85; 4207 static const int kForeignType = 0x85;
4193 4208
4194 static const int kUndefinedOddballKind = 5; 4209 static const int kUndefinedOddballKind = 5;
4195 static const int kNullOddballKind = 3; 4210 static const int kNullOddballKind = 3;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4229 return *addr & (1 << shift); 4244 return *addr & (1 << shift);
4230 } 4245 }
4231 4246
4232 V8_INLINE(static void UpdateNodeFlag(internal::Object** obj, 4247 V8_INLINE(static void UpdateNodeFlag(internal::Object** obj,
4233 bool value, int shift)) { 4248 bool value, int shift)) {
4234 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; 4249 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
4235 uint8_t mask = 1 << shift; 4250 uint8_t mask = 1 << shift;
4236 *addr = (*addr & ~mask) | (value << shift); 4251 *addr = (*addr & ~mask) | (value << shift);
4237 } 4252 }
4238 4253
4254 V8_INLINE(static uint8_t GetNodeState(internal::Object** obj)) {
4255 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
4256 return *addr & kNodeStateMask;
4257 }
4258
4259 V8_INLINE(static void UpdateNodeState(internal::Object** obj,
4260 uint8_t value)) {
4261 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
4262 *addr = (*addr & ~kNodeStateMask) | value;
4263 }
4264
4239 V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) { 4265 V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) {
4240 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + 4266 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
4241 kIsolateEmbedderDataOffset; 4267 kIsolateEmbedderDataOffset;
4242 *reinterpret_cast<void**>(addr) = data; 4268 *reinterpret_cast<void**>(addr) = data;
4243 } 4269 }
4244 4270
4245 V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) { 4271 V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) {
4246 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + 4272 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
4247 kIsolateEmbedderDataOffset; 4273 kIsolateEmbedderDataOffset;
4248 return *reinterpret_cast<void**>(addr); 4274 return *reinterpret_cast<void**>(addr);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4296 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); 4322 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
4297 if (internal::Internals::CanCastToHeapObject(that_ptr)) { 4323 if (internal::Internals::CanCastToHeapObject(that_ptr)) {
4298 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( 4324 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
4299 reinterpret_cast<internal::HeapObject*>(*p)))); 4325 reinterpret_cast<internal::HeapObject*>(*p))));
4300 } 4326 }
4301 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p))); 4327 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p)));
4302 } 4328 }
4303 4329
4304 4330
4305 template <class T> 4331 template <class T>
4306 Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) { 4332 Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) {
4307 if (that.IsEmpty()) return Local<T>(); 4333 if (that.IsEmpty()) return Local<T>();
4308 T* that_ptr = *that; 4334 T* that_ptr = *that;
4309 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); 4335 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
4310 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( 4336 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
4311 reinterpret_cast<internal::Isolate*>(isolate), *p))); 4337 reinterpret_cast<internal::Isolate*>(isolate), *p)));
4312 } 4338 }
4313 4339
4314 4340
4315 template <class T> 4341 template <class T>
4316 Persistent<T> Persistent<T>::New(Handle<T> that) { 4342 Persistent<T> Persistent<T>::New(Handle<T> that) {
4343 return New(Isolate::GetCurrent(), that);
4344 }
4345
4346
4347 template <class T>
4348 Persistent<T> Persistent<T>::New(Isolate* isolate, Handle<T> that) {
4317 if (that.IsEmpty()) return Persistent<T>(); 4349 if (that.IsEmpty()) return Persistent<T>();
4318 internal::Object** p = reinterpret_cast<internal::Object**>(*that); 4350 internal::Object** p = reinterpret_cast<internal::Object**>(*that);
4319 return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); 4351 return Persistent<T>(reinterpret_cast<T*>(
4352 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
4353 p)));
4320 } 4354 }
4321 4355
4322 4356
4323 template <class T> 4357 template <class T>
4324 bool Persistent<T>::IsIndependent() const { 4358 bool Persistent<T>::IsIndependent() const {
4325 if (this->IsEmpty()) return false; 4359 return IsIndependent(Isolate::GetCurrent());
4326 return V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**this));
4327 } 4360 }
4328 4361
4329 4362
4330 template <class T> 4363 template <class T>
4331 bool Persistent<T>::IsIndependent(Isolate* isolate) const { 4364 bool Persistent<T>::IsIndependent(Isolate* isolate) const {
4332 typedef internal::Internals I; 4365 typedef internal::Internals I;
4333 if (this->IsEmpty()) return false; 4366 if (this->IsEmpty()) return false;
4334 if (!I::IsInitialized(isolate)) return false; 4367 if (!I::IsInitialized(isolate)) return false;
4335 return I::GetNodeFlag(reinterpret_cast<internal::Object**>(**this), 4368 return I::GetNodeFlag(reinterpret_cast<internal::Object**>(**this),
4336 I::kNodeIsIndependentShift); 4369 I::kNodeIsIndependentShift);
4337 } 4370 }
4338 4371
4339 4372
4340 template <class T> 4373 template <class T>
4341 bool Persistent<T>::IsNearDeath() const { 4374 bool Persistent<T>::IsNearDeath() const {
4375 return IsNearDeath(Isolate::GetCurrent());
4376 }
4377
4378
4379 template <class T>
4380 bool Persistent<T>::IsNearDeath(Isolate* isolate) const {
4381 typedef internal::Internals I;
4342 if (this->IsEmpty()) return false; 4382 if (this->IsEmpty()) return false;
4343 return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this)); 4383 if (!I::IsInitialized(isolate)) return false;
4384 return I::GetNodeState(reinterpret_cast<internal::Object**>(**this)) ==
4385 I::kNodeStateIsNearDeathValue;
4344 } 4386 }
4345 4387
4346 4388
4347 template <class T> 4389 template <class T>
4348 bool Persistent<T>::IsWeak() const { 4390 bool Persistent<T>::IsWeak() const {
4349 if (this->IsEmpty()) return false; 4391 return IsWeak(Isolate::GetCurrent());
4350 return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this));
4351 } 4392 }
4352 4393
4353 4394
4354 template <class T> 4395 template <class T>
4355 bool Persistent<T>::IsWeak(Isolate* isolate) const { 4396 bool Persistent<T>::IsWeak(Isolate* isolate) const {
4397 typedef internal::Internals I;
4356 if (this->IsEmpty()) return false; 4398 if (this->IsEmpty()) return false;
4357 return V8::IsGlobalWeak(reinterpret_cast<internal::Isolate*>(isolate), 4399 if (!I::IsInitialized(isolate)) return false;
4358 reinterpret_cast<internal::Object**>(**this)); 4400 return I::GetNodeState(reinterpret_cast<internal::Object**>(**this)) ==
4401 I::kNodeStateIsWeakValue;
4359 } 4402 }
4360 4403
4361 4404
4362 template <class T> 4405 template <class T>
4363 void Persistent<T>::Dispose() { 4406 void Persistent<T>::Dispose() {
4364 if (this->IsEmpty()) return; 4407 Dispose(Isolate::GetCurrent());
4365 V8::DisposeGlobal(reinterpret_cast<internal::Object**>(**this));
4366 } 4408 }
4367 4409
4368 4410
4369 template <class T> 4411 template <class T>
4370 void Persistent<T>::Dispose(Isolate* isolate) { 4412 void Persistent<T>::Dispose(Isolate* isolate) {
4371 if (this->IsEmpty()) return; 4413 if (this->IsEmpty()) return;
4372 V8::DisposeGlobal(reinterpret_cast<internal::Isolate*>(isolate), 4414 V8::DisposeGlobal(reinterpret_cast<internal::Isolate*>(isolate),
4373 reinterpret_cast<internal::Object**>(**this)); 4415 reinterpret_cast<internal::Object**>(**this));
4374 } 4416 }
4375 4417
4376 4418
4377 template <class T> 4419 template <class T>
4378 Persistent<T>::Persistent() : Handle<T>() { } 4420 Persistent<T>::Persistent() : Handle<T>() { }
4379 4421
4380 template <class T> 4422 template <class T>
4381 void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) { 4423 void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) {
4382 V8::MakeWeak(reinterpret_cast<internal::Object**>(**this), 4424 Isolate* isolate = Isolate::GetCurrent();
4425 V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate),
4426 reinterpret_cast<internal::Object**>(**this),
4383 parameters, 4427 parameters,
4384 callback); 4428 callback,
4429 NULL);
4385 } 4430 }
4386 4431
4387 template <class T> 4432 template <class T>
4388 void Persistent<T>::MakeWeak(Isolate* isolate, void* parameters, 4433 void Persistent<T>::MakeWeak(Isolate* isolate,
4389 WeakReferenceCallback callback) { 4434 void* parameters,
4435 NearDeathCallback callback) {
4390 V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate), 4436 V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate),
4391 reinterpret_cast<internal::Object**>(**this), 4437 reinterpret_cast<internal::Object**>(**this),
4392 parameters, 4438 parameters,
4439 NULL,
4393 callback); 4440 callback);
4394 } 4441 }
4395 4442
4396 template <class T> 4443 template <class T>
4397 void Persistent<T>::ClearWeak() { 4444 void Persistent<T>::ClearWeak() {
4398 V8::ClearWeak(reinterpret_cast<internal::Object**>(**this)); 4445 ClearWeak(Isolate::GetCurrent());
4446 }
4447
4448 template <class T>
4449 void Persistent<T>::ClearWeak(Isolate* isolate) {
4450 V8::ClearWeak(reinterpret_cast<internal::Isolate*>(isolate),
4451 reinterpret_cast<internal::Object**>(**this));
4399 } 4452 }
4400 4453
4401 template <class T> 4454 template <class T>
4402 void Persistent<T>::MarkIndependent() { 4455 void Persistent<T>::MarkIndependent() {
4403 V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); 4456 MarkIndependent(Isolate::GetCurrent());
4404 } 4457 }
4405 4458
4406 template <class T> 4459 template <class T>
4407 void Persistent<T>::MarkIndependent(Isolate* isolate) { 4460 void Persistent<T>::MarkIndependent(Isolate* isolate) {
4408 typedef internal::Internals I; 4461 typedef internal::Internals I;
4409 if (this->IsEmpty()) return; 4462 if (this->IsEmpty()) return;
4410 if (!I::IsInitialized(isolate)) return; 4463 if (!I::IsInitialized(isolate)) return;
4411 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this), 4464 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this),
4412 true, I::kNodeIsIndependentShift); 4465 true,
4466 I::kNodeIsIndependentShift);
4413 } 4467 }
4414 4468
4415 template <class T> 4469 template <class T>
4416 void Persistent<T>::MarkPartiallyDependent() { 4470 void Persistent<T>::MarkPartiallyDependent() {
4417 V8::MarkPartiallyDependent(reinterpret_cast<internal::Object**>(**this)); 4471 MarkPartiallyDependent(Isolate::GetCurrent());
4418 } 4472 }
4419 4473
4420 template <class T> 4474 template <class T>
4421 void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) { 4475 void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) {
4422 typedef internal::Internals I; 4476 typedef internal::Internals I;
4423 if (this->IsEmpty()) return; 4477 if (this->IsEmpty()) return;
4424 if (!I::IsInitialized(isolate)) return; 4478 if (!I::IsInitialized(isolate)) return;
4425 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this), 4479 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this),
4426 true, I::kNodeIsPartiallyDependentShift); 4480 true,
4481 I::kNodeIsPartiallyDependentShift);
4427 } 4482 }
4428 4483
4429 template <class T> 4484 template <class T>
4430 void Persistent<T>::SetWrapperClassId(uint16_t class_id) { 4485 void Persistent<T>::SetWrapperClassId(uint16_t class_id) {
4486 SetWrapperClassId(Isolate::GetCurrent(), class_id);
4487 }
4488
4489 template <class T>
4490 void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) {
4431 typedef internal::Internals I; 4491 typedef internal::Internals I;
4492 if (this->IsEmpty()) return;
4493 if (!I::IsInitialized(isolate)) return;
4432 internal::Object** obj = reinterpret_cast<internal::Object**>(**this); 4494 internal::Object** obj = reinterpret_cast<internal::Object**>(**this);
4433 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; 4495 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
4434 *reinterpret_cast<uint16_t*>(addr) = class_id; 4496 *reinterpret_cast<uint16_t*>(addr) = class_id;
4435 } 4497 }
4436 4498
4437 template <class T> 4499 template <class T>
4438 uint16_t Persistent<T>::WrapperClassId() const { 4500 uint16_t Persistent<T>::WrapperClassId() const {
4501 return WrapperClassId(Isolate::GetCurrent());
4502 }
4503
4504 template <class T>
4505 uint16_t Persistent<T>::WrapperClassId(Isolate* isolate) const {
4439 typedef internal::Internals I; 4506 typedef internal::Internals I;
4507 if (this->IsEmpty()) return 0;
4508 if (!I::IsInitialized(isolate)) return 0;
4440 internal::Object** obj = reinterpret_cast<internal::Object**>(**this); 4509 internal::Object** obj = reinterpret_cast<internal::Object**>(**this);
4441 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; 4510 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
4442 return *reinterpret_cast<uint16_t*>(addr); 4511 return *reinterpret_cast<uint16_t*>(addr);
4443 } 4512 }
4444 4513
4445 Arguments::Arguments(internal::Object** implicit_args, 4514 Arguments::Arguments(internal::Object** implicit_args,
4446 internal::Object** values, int length, 4515 internal::Object** values, int length,
4447 bool is_construct_call) 4516 bool is_construct_call)
4448 : implicit_args_(implicit_args), 4517 : implicit_args_(implicit_args),
4449 values_(values), 4518 values_(values),
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
4859 4928
4860 4929
4861 } // namespace v8 4930 } // namespace v8
4862 4931
4863 4932
4864 #undef V8EXPORT 4933 #undef V8EXPORT
4865 #undef TYPE_CHECK 4934 #undef TYPE_CHECK
4866 4935
4867 4936
4868 #endif // V8_H_ 4937 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | samples/lineprocessor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698