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

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 new kind of callback 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/process.cc » ('j') | src/global-handles.cc » ('J')
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 21 matching lines...) Expand all
32 * This set of documents provides reference material generated from the 32 * This set of documents provides reference material generated from the
33 * V8 header file, include/v8.h. 33 * V8 header file, include/v8.h.
34 * 34 *
35 * For other documentation see http://code.google.com/apis/v8/ 35 * For other documentation see http://code.google.com/apis/v8/
36 */ 36 */
37 37
38 #ifndef V8_H_ 38 #ifndef V8_H_
39 #define V8_H_ 39 #define V8_H_
40 40
41 // TODO(svenpanne) Remove me when the Chrome bindings are adapted. 41 // TODO(svenpanne) Remove me when the Chrome bindings are adapted.
42 #define V8_DISABLE_DEPRECATIONS 1 42 // #define V8_DISABLE_DEPRECATIONS 1
43 43
44 #include "v8stdint.h" 44 #include "v8stdint.h"
45 45
46 #ifdef _WIN32 46 #ifdef _WIN32
47 47
48 // Setup for Windows DLL export/import. When building the V8 DLL the 48 // Setup for Windows DLL export/import. When building the V8 DLL the
49 // BUILDING_V8_SHARED needs to be defined. When building a program which uses 49 // BUILDING_V8_SHARED needs to be defined. When building a program which uses
50 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 50 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
51 // static library or building a program which uses the V8 static library neither 51 // static library or building a program which uses the V8 static library neither
52 // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. 52 // BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.
(...skipping 97 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
392 /** 396 /** Deprecated. Use Isolate version instead. */
393 * Creates a new persistent handle for an existing local or
394 * persistent handle.
395 */
396 V8_INLINE(static Persistent<T> New(Handle<T> that)); 397 V8_INLINE(static Persistent<T> New(Handle<T> that));
Michael Starzinger 2013/01/24 13:09:05 Should this be marked deprecated?
Sven Panne 2013/01/25 08:28:40 Done.
397 398
398 /** 399 /**
400 * Creates a new persistent handle for an existing local or persistent handle.
401 */
402 V8_INLINE(static Persistent<T> New(Isolate* isolate, Handle<T> that));
403
404 /** Deprecated. Use Isolate version instead. */
405 V8_DEPRECATED(void Dispose());
406
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
446 /** Checks if the handle holds the only reference to an object. */ 465 /** Deprecated. Use Isolate version instead. */
447 V8_INLINE(bool IsNearDeath() const); 466 V8_INLINE(bool IsNearDeath() const);
Michael Starzinger 2013/01/24 13:09:05 Should this be marked deprecated?
Sven Panne 2013/01/25 08:28:40 Done.
448 467
468 /** Checks if the handle holds the only reference to an object. */
469 V8_INLINE(bool IsNearDeath(Isolate* isolate) const);
470
471 /** Deprecated. Use Isolate version instead. */
472 V8_DEPRECATED(bool IsWeak() const);
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
455 * interface description in v8-profiler.h for details.
456 */
457 V8_INLINE(void SetWrapperClassId(uint16_t class_id)); 478 V8_INLINE(void SetWrapperClassId(uint16_t class_id));
Michael Starzinger 2013/01/24 13:09:05 Should this be marked deprecated?
Sven Panne 2013/01/25 08:28:40 Done.
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 3038 matching lines...) Expand 10 before | Expand all | Expand 10 after
3512 * Optional notification that a context has been disposed. V8 uses 3542 * Optional notification that a context has been disposed. V8 uses
3513 * these notifications to guide the GC heuristic. Returns the number 3543 * these notifications to guide the GC heuristic. Returns the number
3514 * of context disposals - including this one - since the last time 3544 * of context disposals - including this one - since the last time
3515 * V8 had a chance to clean up. 3545 * V8 had a chance to clean up.
3516 */ 3546 */
3517 static int ContextDisposedNotification(); 3547 static int ContextDisposedNotification();
3518 3548
3519 private: 3549 private:
3520 V8(); 3550 V8();
3521 3551
3522 static internal::Object** GlobalizeReference(internal::Object** handle); 3552 static internal::Object** GlobalizeReference(internal::Isolate* isolate,
3523 static void DisposeGlobal(internal::Object** global_handle); 3553 internal::Object** handle);
3524 static void DisposeGlobal(internal::Isolate* isolate, 3554 static void DisposeGlobal(internal::Isolate* isolate,
3525 internal::Object** global_handle); 3555 internal::Object** global_handle);
3526 static void MakeWeak(internal::Object** global_handle,
3527 void* data,
3528 WeakReferenceCallback);
3529 static void MakeWeak(internal::Isolate* isolate, 3556 static void MakeWeak(internal::Isolate* isolate,
3530 internal::Object** global_handle, 3557 internal::Object** global_handle,
3531 void* data, 3558 void* data,
3532 WeakReferenceCallback); 3559 WeakReferenceCallback weak_reference_callback,
3533 static void ClearWeak(internal::Object** global_handle); 3560 NearDeathCallback near_death_callback);
3534 static void MarkIndependent(internal::Object** global_handle); 3561 static void ClearWeak(internal::Isolate* isolate,
3535 static void MarkIndependent(internal::Isolate* isolate, 3562 internal::Object** global_handle);
3536 internal::Object** global_handle);
3537 static void MarkPartiallyDependent(internal::Object** global_handle);
3538 static void MarkPartiallyDependent(internal::Isolate* isolate,
3539 internal::Object** global_handle);
3540 static bool IsGlobalIndependent(internal::Object** global_handle);
3541 static bool IsGlobalIndependent(internal::Isolate* isolate,
3542 internal::Object** global_handle);
3543 static bool IsGlobalNearDeath(internal::Object** global_handle);
3544 static bool IsGlobalWeak(internal::Object** global_handle);
3545 static bool IsGlobalWeak(internal::Isolate* isolate,
3546 internal::Object** global_handle);
3547 3563
3548 template <class T> friend class Handle; 3564 template <class T> friend class Handle;
3549 template <class T> friend class Local; 3565 template <class T> friend class Local;
3550 template <class T> friend class Persistent; 3566 template <class T> friend class Persistent;
3551 friend class Context; 3567 friend class Context;
3552 }; 3568 };
3553 3569
3554 3570
3555 /** 3571 /**
3556 * An external exception handler. 3572 * An external exception handler.
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
3957 * // V8 Now no longer locked. 3973 * // V8 Now no longer locked.
3958 * \endcode 3974 * \endcode
3959 */ 3975 */
3960 class V8EXPORT Unlocker { 3976 class V8EXPORT Unlocker {
3961 public: 3977 public:
3962 /** 3978 /**
3963 * Initialize Unlocker for a given Isolate. 3979 * Initialize Unlocker for a given Isolate.
3964 */ 3980 */
3965 V8_INLINE(explicit Unlocker(Isolate* isolate)) { Initialize(isolate); } 3981 V8_INLINE(explicit Unlocker(Isolate* isolate)) { Initialize(isolate); }
3966 3982
3967 /** 3983 /** Deprecated. Use Isolate version instead. */
3968 * Deprecated. Use Isolate version instead.
3969 */
3970 V8_DEPRECATED(Unlocker()); 3984 V8_DEPRECATED(Unlocker());
3971 3985
3972 ~Unlocker(); 3986 ~Unlocker();
3973 private: 3987 private:
3974 void Initialize(Isolate* isolate); 3988 void Initialize(Isolate* isolate);
3975 3989
3976 internal::Isolate* isolate_; 3990 internal::Isolate* isolate_;
3977 }; 3991 };
3978 3992
3979 3993
3980 class V8EXPORT Locker { 3994 class V8EXPORT Locker {
3981 public: 3995 public:
3982 /** 3996 /**
3983 * Initialize Locker for a given Isolate. 3997 * Initialize Locker for a given Isolate.
3984 */ 3998 */
3985 V8_INLINE(explicit Locker(Isolate* isolate)) { Initialize(isolate); } 3999 V8_INLINE(explicit Locker(Isolate* isolate)) { Initialize(isolate); }
3986 4000
3987 /** 4001 /** Deprecated. Use Isolate version instead. */
3988 * Deprecated. Use Isolate version instead.
3989 */
3990 V8_DEPRECATED(Locker()); 4002 V8_DEPRECATED(Locker());
3991 4003
3992 ~Locker(); 4004 ~Locker();
3993 4005
3994 /** 4006 /**
3995 * Start preemption. 4007 * Start preemption.
3996 * 4008 *
3997 * When preemption is started, a timer is fired every n milliseconds 4009 * When preemption is started, a timer is fired every n milliseconds
3998 * that will switch between multiple threads that are in contention 4010 * that will switch between multiple threads that are in contention
3999 * for the V8 lock. 4011 * for the V8 lock.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
4158 static const int kContextHeaderSize = 2 * kApiPointerSize; 4170 static const int kContextHeaderSize = 2 * kApiPointerSize;
4159 static const int kContextEmbedderDataIndex = 54; 4171 static const int kContextEmbedderDataIndex = 54;
4160 static const int kFullStringRepresentationMask = 0x07; 4172 static const int kFullStringRepresentationMask = 0x07;
4161 static const int kStringEncodingMask = 0x4; 4173 static const int kStringEncodingMask = 0x4;
4162 static const int kExternalTwoByteRepresentationTag = 0x02; 4174 static const int kExternalTwoByteRepresentationTag = 0x02;
4163 static const int kExternalAsciiRepresentationTag = 0x06; 4175 static const int kExternalAsciiRepresentationTag = 0x06;
4164 4176
4165 static const int kIsolateStateOffset = 0; 4177 static const int kIsolateStateOffset = 0;
4166 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; 4178 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize;
4167 static const int kIsolateRootsOffset = 3 * kApiPointerSize; 4179 static const int kIsolateRootsOffset = 3 * kApiPointerSize;
4168 static const int kNodeClassIdOffset = 1 * kApiPointerSize;
4169 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
4170 static const int kUndefinedValueRootIndex = 5; 4180 static const int kUndefinedValueRootIndex = 5;
4171 static const int kNullValueRootIndex = 7; 4181 static const int kNullValueRootIndex = 7;
4172 static const int kTrueValueRootIndex = 8; 4182 static const int kTrueValueRootIndex = 8;
4173 static const int kFalseValueRootIndex = 9; 4183 static const int kFalseValueRootIndex = 9;
4174 static const int kEmptySymbolRootIndex = 119; 4184 static const int kEmptySymbolRootIndex = 119;
4175 4185
4186 static const int kNodeClassIdOffset = 1 * kApiPointerSize;
4187 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
4188 static const int kNodeStateMask = 0xf;
4189 static const int kNodeStateIsWeakValue = 2;
4190 static const int kNodeStateIsNearDeathValue = 4;
4176 static const int kNodeIsIndependentShift = 4; 4191 static const int kNodeIsIndependentShift = 4;
4177 static const int kNodeIsPartiallyDependentShift = 5; 4192 static const int kNodeIsPartiallyDependentShift = 5;
4178 4193
4179 static const int kJSObjectType = 0xab; 4194 static const int kJSObjectType = 0xab;
4180 static const int kFirstNonstringType = 0x80; 4195 static const int kFirstNonstringType = 0x80;
4181 static const int kOddballType = 0x82; 4196 static const int kOddballType = 0x82;
4182 static const int kForeignType = 0x85; 4197 static const int kForeignType = 0x85;
4183 4198
4184 static const int kUndefinedOddballKind = 5; 4199 static const int kUndefinedOddballKind = 5;
4185 static const int kNullOddballKind = 3; 4200 static const int kNullOddballKind = 3;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4219 return *addr & (1 << shift); 4234 return *addr & (1 << shift);
4220 } 4235 }
4221 4236
4222 V8_INLINE(static void UpdateNodeFlag(internal::Object** obj, 4237 V8_INLINE(static void UpdateNodeFlag(internal::Object** obj,
4223 bool value, int shift)) { 4238 bool value, int shift)) {
4224 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; 4239 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
4225 uint8_t mask = 1 << shift; 4240 uint8_t mask = 1 << shift;
4226 *addr = (*addr & ~mask) | (value << shift); 4241 *addr = (*addr & ~mask) | (value << shift);
4227 } 4242 }
4228 4243
4244 V8_INLINE(static uint8_t GetNodeState(internal::Object** obj)) {
4245 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
4246 return *addr & kNodeStateMask;
4247 }
4248
4249 V8_INLINE(static void UpdateNodeState(internal::Object** obj,
4250 uint8_t value)) {
4251 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
4252 *addr = (*addr & ~kNodeStateMask) | value;
4253 }
4254
4229 V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) { 4255 V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) {
4230 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + 4256 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
4231 kIsolateEmbedderDataOffset; 4257 kIsolateEmbedderDataOffset;
4232 *reinterpret_cast<void**>(addr) = data; 4258 *reinterpret_cast<void**>(addr) = data;
4233 } 4259 }
4234 4260
4235 V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) { 4261 V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) {
4236 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + 4262 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
4237 kIsolateEmbedderDataOffset; 4263 kIsolateEmbedderDataOffset;
4238 return *reinterpret_cast<void**>(addr); 4264 return *reinterpret_cast<void**>(addr);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4286 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); 4312 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
4287 if (internal::Internals::CanCastToHeapObject(that_ptr)) { 4313 if (internal::Internals::CanCastToHeapObject(that_ptr)) {
4288 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( 4314 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
4289 reinterpret_cast<internal::HeapObject*>(*p)))); 4315 reinterpret_cast<internal::HeapObject*>(*p))));
4290 } 4316 }
4291 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p))); 4317 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p)));
4292 } 4318 }
4293 4319
4294 4320
4295 template <class T> 4321 template <class T>
4296 Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) { 4322 Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) {
4297 if (that.IsEmpty()) return Local<T>(); 4323 if (that.IsEmpty()) return Local<T>();
4298 T* that_ptr = *that; 4324 T* that_ptr = *that;
4299 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); 4325 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
4300 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( 4326 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
4301 reinterpret_cast<internal::Isolate*>(isolate), *p))); 4327 reinterpret_cast<internal::Isolate*>(isolate), *p)));
4302 } 4328 }
4303 4329
4304 4330
4305 template <class T> 4331 template <class T>
4306 Persistent<T> Persistent<T>::New(Handle<T> that) { 4332 Persistent<T> Persistent<T>::New(Handle<T> that) {
4333 return New(Isolate::GetCurrent(), that);
4334 }
4335
4336
4337 template <class T>
4338 Persistent<T> Persistent<T>::New(Isolate* isolate, Handle<T> that) {
4307 if (that.IsEmpty()) return Persistent<T>(); 4339 if (that.IsEmpty()) return Persistent<T>();
4308 internal::Object** p = reinterpret_cast<internal::Object**>(*that); 4340 internal::Object** p = reinterpret_cast<internal::Object**>(*that);
4309 return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); 4341 return Persistent<T>(reinterpret_cast<T*>(
4342 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
4343 p)));
4310 } 4344 }
4311 4345
4312 4346
4313 template <class T> 4347 template <class T>
4314 bool Persistent<T>::IsIndependent() const { 4348 bool Persistent<T>::IsIndependent() const {
4315 if (this->IsEmpty()) return false; 4349 return IsIndependent(Isolate::GetCurrent());
4316 return V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**this));
4317 } 4350 }
4318 4351
4319 4352
4320 template <class T> 4353 template <class T>
4321 bool Persistent<T>::IsIndependent(Isolate* isolate) const { 4354 bool Persistent<T>::IsIndependent(Isolate* isolate) const {
4322 typedef internal::Internals I; 4355 typedef internal::Internals I;
4323 if (this->IsEmpty()) return false; 4356 if (this->IsEmpty()) return false;
4324 if (!I::IsInitialized(isolate)) return false; 4357 if (!I::IsInitialized(isolate)) return false;
4325 return I::GetNodeFlag(reinterpret_cast<internal::Object**>(**this), 4358 return I::GetNodeFlag(reinterpret_cast<internal::Object**>(**this),
4326 I::kNodeIsIndependentShift); 4359 I::kNodeIsIndependentShift);
4327 } 4360 }
4328 4361
4329 4362
4330 template <class T> 4363 template <class T>
4331 bool Persistent<T>::IsNearDeath() const { 4364 bool Persistent<T>::IsNearDeath() const {
4365 return IsNearDeath(Isolate::GetCurrent());
4366 }
4367
4368
4369 template <class T>
4370 bool Persistent<T>::IsNearDeath(Isolate* isolate) const {
4371 typedef internal::Internals I;
4332 if (this->IsEmpty()) return false; 4372 if (this->IsEmpty()) return false;
4333 return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this)); 4373 if (!I::IsInitialized(isolate)) return false;
4374 return I::GetNodeState(reinterpret_cast<internal::Object**>(**this)) ==
4375 I::kNodeStateIsNearDeathValue;
4334 } 4376 }
4335 4377
4336 4378
4337 template <class T> 4379 template <class T>
4338 bool Persistent<T>::IsWeak() const { 4380 bool Persistent<T>::IsWeak() const {
4339 if (this->IsEmpty()) return false; 4381 return IsWeak(Isolate::GetCurrent());
4340 return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this));
4341 } 4382 }
4342 4383
4343 4384
4344 template <class T> 4385 template <class T>
4345 bool Persistent<T>::IsWeak(Isolate* isolate) const { 4386 bool Persistent<T>::IsWeak(Isolate* isolate) const {
4387 typedef internal::Internals I;
4346 if (this->IsEmpty()) return false; 4388 if (this->IsEmpty()) return false;
4347 return V8::IsGlobalWeak(reinterpret_cast<internal::Isolate*>(isolate), 4389 if (!I::IsInitialized(isolate)) return false;
4348 reinterpret_cast<internal::Object**>(**this)); 4390 return I::GetNodeState(reinterpret_cast<internal::Object**>(**this)) ==
4391 I::kNodeStateIsWeakValue;
4349 } 4392 }
4350 4393
4351 4394
4352 template <class T> 4395 template <class T>
4353 void Persistent<T>::Dispose() { 4396 void Persistent<T>::Dispose() {
4354 if (this->IsEmpty()) return; 4397 Dispose(Isolate::GetCurrent());
4355 V8::DisposeGlobal(reinterpret_cast<internal::Object**>(**this));
4356 } 4398 }
4357 4399
4358 4400
4359 template <class T> 4401 template <class T>
4360 void Persistent<T>::Dispose(Isolate* isolate) { 4402 void Persistent<T>::Dispose(Isolate* isolate) {
4361 if (this->IsEmpty()) return; 4403 if (this->IsEmpty()) return;
4362 V8::DisposeGlobal(reinterpret_cast<internal::Isolate*>(isolate), 4404 V8::DisposeGlobal(reinterpret_cast<internal::Isolate*>(isolate),
4363 reinterpret_cast<internal::Object**>(**this)); 4405 reinterpret_cast<internal::Object**>(**this));
4364 } 4406 }
4365 4407
4366 4408
4367 template <class T> 4409 template <class T>
4368 Persistent<T>::Persistent() : Handle<T>() { } 4410 Persistent<T>::Persistent() : Handle<T>() { }
4369 4411
4370 template <class T> 4412 template <class T>
4371 void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) { 4413 void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) {
4372 V8::MakeWeak(reinterpret_cast<internal::Object**>(**this), 4414 Isolate* isolate = Isolate::GetCurrent();
4415 V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate),
4416 reinterpret_cast<internal::Object**>(**this),
4373 parameters, 4417 parameters,
4374 callback); 4418 callback,
4419 NULL);
4375 } 4420 }
4376 4421
4377 template <class T> 4422 template <class T>
4378 void Persistent<T>::MakeWeak(Isolate* isolate, void* parameters, 4423 void Persistent<T>::MakeWeak(Isolate* isolate,
4379 WeakReferenceCallback callback) { 4424 void* parameters,
4425 NearDeathCallback callback) {
4380 V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate), 4426 V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate),
4381 reinterpret_cast<internal::Object**>(**this), 4427 reinterpret_cast<internal::Object**>(**this),
4382 parameters, 4428 parameters,
4429 NULL,
4383 callback); 4430 callback);
4384 } 4431 }
4385 4432
4386 template <class T> 4433 template <class T>
4387 void Persistent<T>::ClearWeak() { 4434 void Persistent<T>::ClearWeak() {
4388 V8::ClearWeak(reinterpret_cast<internal::Object**>(**this)); 4435 ClearWeak(Isolate::GetCurrent());
4436 }
4437
4438 template <class T>
4439 void Persistent<T>::ClearWeak(Isolate* isolate) {
4440 V8::ClearWeak(reinterpret_cast<internal::Isolate*>(isolate),
4441 reinterpret_cast<internal::Object**>(**this));
4389 } 4442 }
4390 4443
4391 template <class T> 4444 template <class T>
4392 void Persistent<T>::MarkIndependent() { 4445 void Persistent<T>::MarkIndependent() {
4393 V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); 4446 MarkIndependent(Isolate::GetCurrent());
4394 } 4447 }
4395 4448
4396 template <class T> 4449 template <class T>
4397 void Persistent<T>::MarkIndependent(Isolate* isolate) { 4450 void Persistent<T>::MarkIndependent(Isolate* isolate) {
4398 typedef internal::Internals I; 4451 typedef internal::Internals I;
4399 if (this->IsEmpty()) return; 4452 if (this->IsEmpty()) return;
4400 if (!I::IsInitialized(isolate)) return; 4453 if (!I::IsInitialized(isolate)) return;
4401 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this), 4454 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this),
4402 true, I::kNodeIsIndependentShift); 4455 true,
4456 I::kNodeIsIndependentShift);
4403 } 4457 }
4404 4458
4405 template <class T> 4459 template <class T>
4406 void Persistent<T>::MarkPartiallyDependent() { 4460 void Persistent<T>::MarkPartiallyDependent() {
4407 V8::MarkPartiallyDependent(reinterpret_cast<internal::Object**>(**this)); 4461 MarkPartiallyDependent(Isolate::GetCurrent());
4408 } 4462 }
4409 4463
4410 template <class T> 4464 template <class T>
4411 void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) { 4465 void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) {
4412 typedef internal::Internals I; 4466 typedef internal::Internals I;
4413 if (this->IsEmpty()) return; 4467 if (this->IsEmpty()) return;
4414 if (!I::IsInitialized(isolate)) return; 4468 if (!I::IsInitialized(isolate)) return;
4415 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this), 4469 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this),
4416 true, I::kNodeIsPartiallyDependentShift); 4470 true,
4471 I::kNodeIsPartiallyDependentShift);
4417 } 4472 }
4418 4473
4419 template <class T> 4474 template <class T>
4420 void Persistent<T>::SetWrapperClassId(uint16_t class_id) { 4475 void Persistent<T>::SetWrapperClassId(uint16_t class_id) {
4476 SetWrapperClassId(Isolate::GetCurrent(), class_id);
4477 }
4478
4479 template <class T>
4480 void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) {
4421 typedef internal::Internals I; 4481 typedef internal::Internals I;
4482 if (this->IsEmpty()) return;
4483 if (!I::IsInitialized(isolate)) return;
4422 internal::Object** obj = reinterpret_cast<internal::Object**>(**this); 4484 internal::Object** obj = reinterpret_cast<internal::Object**>(**this);
4423 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; 4485 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
4424 *reinterpret_cast<uint16_t*>(addr) = class_id; 4486 *reinterpret_cast<uint16_t*>(addr) = class_id;
4425 } 4487 }
4426 4488
4427 template <class T> 4489 template <class T>
4428 uint16_t Persistent<T>::WrapperClassId() const { 4490 uint16_t Persistent<T>::WrapperClassId() const {
4491 return WrapperClassId(Isolate::GetCurrent());
4492 }
4493
4494 template <class T>
4495 uint16_t Persistent<T>::WrapperClassId(Isolate* isolate) const {
4429 typedef internal::Internals I; 4496 typedef internal::Internals I;
4497 if (this->IsEmpty()) return 0;
4498 if (!I::IsInitialized(isolate)) return 0;
4430 internal::Object** obj = reinterpret_cast<internal::Object**>(**this); 4499 internal::Object** obj = reinterpret_cast<internal::Object**>(**this);
4431 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; 4500 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
4432 return *reinterpret_cast<uint16_t*>(addr); 4501 return *reinterpret_cast<uint16_t*>(addr);
4433 } 4502 }
4434 4503
4435 Arguments::Arguments(internal::Object** implicit_args, 4504 Arguments::Arguments(internal::Object** implicit_args,
4436 internal::Object** values, int length, 4505 internal::Object** values, int length,
4437 bool is_construct_call) 4506 bool is_construct_call)
4438 : implicit_args_(implicit_args), 4507 : implicit_args_(implicit_args),
4439 values_(values), 4508 values_(values),
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
4849 4918
4850 4919
4851 } // namespace v8 4920 } // namespace v8
4852 4921
4853 4922
4854 #undef V8EXPORT 4923 #undef V8EXPORT
4855 #undef TYPE_CHECK 4924 #undef TYPE_CHECK
4856 4925
4857 4926
4858 #endif // V8_H_ 4927 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | samples/process.cc » ('j') | src/global-handles.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698