libv8 3.11.8.17-x86-linux → 3.16.14.11-x86-linux

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 43d946d0bab755d0a7d8898b20eb557b43474bd5
4
+ data.tar.gz: a81399e1632cb2117eb27706ef6007b3876d86a6
5
+ SHA512:
6
+ metadata.gz: f35a90abe64347c23cf8986305aeca937cb78dd4d42ec20364cea9a2b316eee9009ae839a9d90620c2023fc687a660484071bd07b38f323aa39649b67ef211c7
7
+ data.tar.gz: 8814944f77ff7aee747c178e9c7b786476bacdd5ade5108ef82574f4f9229bc4c4fe369a30d5b3318c0c946931a1d8df0a7e506128207f472180ef1113f68851
@@ -30,7 +30,7 @@ module Libv8
30
30
  end
31
31
 
32
32
  def arm?
33
- RbConfig::MAKEFILE_CONFIG['build_cpu'] == 'arm'
33
+ RbConfig::MAKEFILE_CONFIG['build_cpu'] =~ /^arm/
34
34
  end
35
35
 
36
36
  def libv8_arch
@@ -33,7 +33,7 @@ module Libv8
33
33
 
34
34
  def verify_installation!
35
35
  Libv8::Paths.object_paths.each do |p|
36
- fail ArchiveNotFound, p unless File.exists? p
36
+ fail ArchiveNotFound, p unless File.exist? p
37
37
  end
38
38
  end
39
39
 
@@ -48,6 +48,7 @@ module Libv8
48
48
  def configure(context = MkmfContext.new)
49
49
  context.send(:dir_config, 'v8')
50
50
  context.send(:find_header, 'v8.h') or fail NotFoundError
51
+ context.send(:have_library, 'v8') or fail NotFoundError
51
52
  end
52
53
 
53
54
  class NotFoundError < StandardError
@@ -1,4 +1,5 @@
1
1
  require 'rbconfig'
2
+ require 'shellwords'
2
3
  require File.expand_path '../arch', __FILE__
3
4
 
4
5
  module Libv8
@@ -6,11 +7,13 @@ module Libv8
6
7
  module_function
7
8
 
8
9
  def include_paths
9
- ["#{vendored_source_path}/include"]
10
+ [Shellwords.escape("#{vendored_source_path}/include")]
10
11
  end
11
12
 
12
13
  def object_paths
13
- [libv8_object(:base), libv8_object(:snapshot)]
14
+ [libv8_object(:base), libv8_object(:snapshot)].map do |path|
15
+ Shellwords.escape path
16
+ end
14
17
  end
15
18
 
16
19
  def config
@@ -19,7 +22,7 @@ module Libv8
19
22
 
20
23
  def libv8_object(name)
21
24
  filename = "#{libv8_profile}/libv8_#{name}.#{config['LIBEXT']}"
22
- unless File.exists? filename
25
+ unless File.exist? filename
23
26
  filename = "#{libv8_profile}/obj.target/tools/gyp/libv8_#{name}.#{config['LIBEXT']}"
24
27
  end
25
28
  return filename
@@ -28,7 +31,7 @@ module Libv8
28
31
  def libv8_profile
29
32
  base = "#{vendored_source_path}/out/#{Libv8::Arch.libv8_arch}"
30
33
  debug = "#{base}.debug"
31
- File.exists?(debug) ? debug : "#{base}.release"
34
+ File.exist?(debug) ? debug : "#{base}.release"
32
35
  end
33
36
 
34
37
  def vendored_source_path
@@ -1,3 +1,3 @@
1
1
  module Libv8
2
- VERSION = "3.11.8.17"
2
+ VERSION = "3.16.14.11"
3
3
  end
@@ -321,7 +321,7 @@ class EXPORT Debug {
321
321
  * \endcode
322
322
  */
323
323
  static Local<Value> Call(v8::Handle<v8::Function> fun,
324
- Handle<Value> data = Handle<Value>());
324
+ Handle<Value> data = Handle<Value>());
325
325
 
326
326
  /**
327
327
  * Returns a mirror object for the given object.
@@ -388,6 +388,14 @@ class EXPORT Debug {
388
388
  * to change.
389
389
  */
390
390
  static Local<Context> GetDebugContext();
391
+
392
+
393
+ /**
394
+ * Enable/disable LiveEdit functionality for the given Isolate
395
+ * (default Isolate if not provided). V8 will abort if LiveEdit is
396
+ * unexpectedly used. LiveEdit is enabled by default.
397
+ */
398
+ static void SetLiveEditEnabled(bool enable, Isolate* isolate = NULL);
391
399
  };
392
400
 
393
401
 
@@ -55,11 +55,12 @@
55
55
  // Setup for Linux shared library export. There is no need to distinguish
56
56
  // between building or using the V8 shared library, but we should not
57
57
  // export symbols when we are building a static library.
58
- #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(V8_SHARED)
58
+ #if defined(__GNUC__) && ((__GNUC__ >= 4) || \
59
+ (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(V8_SHARED)
59
60
  #define V8EXPORT __attribute__ ((visibility("default")))
60
- #else // defined(__GNUC__) && (__GNUC__ >= 4)
61
+ #else
61
62
  #define V8EXPORT
62
- #endif // defined(__GNUC__) && (__GNUC__ >= 4)
63
+ #endif
63
64
 
64
65
  #endif // _WIN32
65
66
 
@@ -50,11 +50,12 @@
50
50
 
51
51
  // Setup for Linux shared library export. See v8.h in this directory for
52
52
  // information on how to build/use V8 as shared library.
53
- #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(V8_SHARED)
53
+ #if defined(__GNUC__) && ((__GNUC__ >= 4) || \
54
+ (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(V8_SHARED)
54
55
  #define V8EXPORT __attribute__ ((visibility("default")))
55
- #else // defined(__GNUC__) && (__GNUC__ >= 4)
56
+ #else
56
57
  #define V8EXPORT
57
- #endif // defined(__GNUC__) && (__GNUC__ >= 4)
58
+ #endif
58
59
 
59
60
  #endif // _WIN32
60
61
 
@@ -280,32 +281,12 @@ class V8EXPORT HeapGraphNode {
280
281
  /** Returns node's own size, in bytes. */
281
282
  int GetSelfSize() const;
282
283
 
283
- /**
284
- * Returns node's retained size, in bytes. That is, self + sizes of
285
- * the objects that are reachable only from this object. In other
286
- * words, the size of memory that will be reclaimed having this node
287
- * collected.
288
- */
289
- int GetRetainedSize() const;
290
-
291
284
  /** Returns child nodes count of the node. */
292
285
  int GetChildrenCount() const;
293
286
 
294
287
  /** Retrieves a child by index. */
295
288
  const HeapGraphEdge* GetChild(int index) const;
296
289
 
297
- /** Returns retainer nodes count of the node. */
298
- int GetRetainersCount() const;
299
-
300
- /** Returns a retainer by index. */
301
- const HeapGraphEdge* GetRetainer(int index) const;
302
-
303
- /**
304
- * Returns a dominator node. This is the node that participates in every
305
- * path from the snapshot root to the current node.
306
- */
307
- const HeapGraphNode* GetDominatorNode() const;
308
-
309
290
  /**
310
291
  * Finds and returns a value from the heap corresponding to this node,
311
292
  * if the value is still reachable.
@@ -425,6 +406,20 @@ class V8EXPORT HeapProfiler {
425
406
  */
426
407
  static const SnapshotObjectId kUnknownObjectId = 0;
427
408
 
409
+ /**
410
+ * Callback interface for retrieving user friendly names of global objects.
411
+ */
412
+ class ObjectNameResolver {
413
+ public:
414
+ /**
415
+ * Returns name to be used in the heap snapshot for given node. Returned
416
+ * string must stay alive until snapshot collection is completed.
417
+ */
418
+ virtual const char* GetName(Handle<Object> object) = 0;
419
+ protected:
420
+ virtual ~ObjectNameResolver() {}
421
+ };
422
+
428
423
  /**
429
424
  * Takes a heap snapshot and returns it. Title may be an empty string.
430
425
  * See HeapSnapshot::Type for types description.
@@ -432,7 +427,8 @@ class V8EXPORT HeapProfiler {
432
427
  static const HeapSnapshot* TakeSnapshot(
433
428
  Handle<String> title,
434
429
  HeapSnapshot::Type type = HeapSnapshot::kFull,
435
- ActivityControl* control = NULL);
430
+ ActivityControl* control = NULL,
431
+ ObjectNameResolver* global_object_name_resolver = NULL);
436
432
 
437
433
  /**
438
434
  * Starts tracking of heap objects population statistics. After calling
@@ -448,11 +444,12 @@ class V8EXPORT HeapProfiler {
448
444
  * reports updates for all previous time intervals via the OutputStream
449
445
  * object. Updates on each time interval are provided as a stream of the
450
446
  * HeapStatsUpdate structure instances.
447
+ * The return value of the function is the last seen heap object Id.
451
448
  *
452
449
  * StartHeapObjectsTracking must be called before the first call to this
453
450
  * method.
454
451
  */
455
- static void PushHeapObjectsStats(OutputStream* stream);
452
+ static SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
456
453
 
457
454
  /**
458
455
  * Stops tracking of heap objects population statistics, cleans up all
@@ -481,6 +478,9 @@ class V8EXPORT HeapProfiler {
481
478
 
482
479
  /** Returns the number of currently existing persistent handles. */
483
480
  static int GetPersistentHandleCount();
481
+
482
+ /** Returns memory used for profiler internal data and snapshots. */
483
+ static size_t GetMemorySizeUsedByProfiler();
484
484
  };
485
485
 
486
486
 
@@ -50,11 +50,12 @@
50
50
 
51
51
  // Setup for Linux shared library export. See v8.h in this directory for
52
52
  // information on how to build/use V8 as shared library.
53
- #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(V8_SHARED)
53
+ #if defined(__GNUC__) && ((__GNUC__ >= 4) || \
54
+ (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(V8_SHARED)
54
55
  #define V8EXPORT __attribute__ ((visibility("default")))
55
- #else // defined(__GNUC__) && (__GNUC__ >= 4)
56
+ #else
56
57
  #define V8EXPORT
57
- #endif // defined(__GNUC__) && (__GNUC__ >= 4)
58
+ #endif
58
59
 
59
60
  #endif // _WIN32
60
61
 
@@ -38,6 +38,9 @@
38
38
  #ifndef V8_H_
39
39
  #define V8_H_
40
40
 
41
+ // TODO(svenpanne) Remove me when the Chrome bindings are adapted.
42
+ #define V8_DISABLE_DEPRECATIONS 1
43
+
41
44
  #include "v8stdint.h"
42
45
 
43
46
  #ifdef _WIN32
@@ -63,18 +66,35 @@
63
66
  #else // _WIN32
64
67
 
65
68
  // Setup for Linux shared library export.
66
- #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(V8_SHARED)
69
+ #if defined(__GNUC__) && ((__GNUC__ >= 4) || \
70
+ (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(V8_SHARED)
67
71
  #ifdef BUILDING_V8_SHARED
68
72
  #define V8EXPORT __attribute__ ((visibility("default")))
69
73
  #else
70
74
  #define V8EXPORT
71
75
  #endif
72
- #else // defined(__GNUC__) && (__GNUC__ >= 4)
76
+ #else
73
77
  #define V8EXPORT
74
- #endif // defined(__GNUC__) && (__GNUC__ >= 4)
78
+ #endif
75
79
 
76
80
  #endif // _WIN32
77
81
 
82
+ #if defined(__GNUC__) && !defined(DEBUG)
83
+ #define V8_INLINE(declarator) inline __attribute__((always_inline)) declarator
84
+ #elif defined(_MSC_VER) && !defined(DEBUG)
85
+ #define V8_INLINE(declarator) __forceinline declarator
86
+ #else
87
+ #define V8_INLINE(declarator) inline declarator
88
+ #endif
89
+
90
+ #if defined(__GNUC__) && !V8_DISABLE_DEPRECATIONS
91
+ #define V8_DEPRECATED(declarator) declarator __attribute__ ((deprecated))
92
+ #elif defined(_MSC_VER) && !V8_DISABLE_DEPRECATIONS
93
+ #define V8_DEPRECATED(declarator) __declspec(deprecated) declarator
94
+ #else
95
+ #define V8_DEPRECATED(declarator) declarator
96
+ #endif
97
+
78
98
  /**
79
99
  * The v8 JavaScript engine.
80
100
  */
@@ -100,6 +120,7 @@ class Function;
100
120
  class Date;
101
121
  class ImplementationUtilities;
102
122
  class Signature;
123
+ class AccessorSignature;
103
124
  template <class T> class Handle;
104
125
  template <class T> class Local;
105
126
  template <class T> class Persistent;
@@ -136,6 +157,10 @@ class Isolate;
136
157
  typedef void (*WeakReferenceCallback)(Persistent<Value> object,
137
158
  void* parameter);
138
159
 
160
+ // TODO(svenpanne) Temporary definition until Chrome is in sync.
161
+ typedef void (*NearDeathCallback)(Isolate* isolate,
162
+ Persistent<Value> object,
163
+ void* parameter);
139
164
 
140
165
  // --- Handles ---
141
166
 
@@ -174,12 +199,12 @@ template <class T> class Handle {
174
199
  /**
175
200
  * Creates an empty handle.
176
201
  */
177
- inline Handle() : val_(0) {}
202
+ V8_INLINE(Handle()) : val_(0) {}
178
203
 
179
204
  /**
180
205
  * Creates a new handle for the specified value.
181
206
  */
182
- inline explicit Handle(T* val) : val_(val) {}
207
+ V8_INLINE(explicit Handle(T* val)) : val_(val) {}
183
208
 
184
209
  /**
185
210
  * Creates a handle for the contents of the specified handle. This
@@ -191,7 +216,7 @@ template <class T> class Handle {
191
216
  * Handle<String> to a variable declared as Handle<Value>, is legal
192
217
  * because String is a subclass of Value.
193
218
  */
194
- template <class S> inline Handle(Handle<S> that)
219
+ template <class S> V8_INLINE(Handle(Handle<S> that))
195
220
  : val_(reinterpret_cast<T*>(*that)) {
196
221
  /**
197
222
  * This check fails when trying to convert between incompatible
@@ -204,16 +229,16 @@ template <class T> class Handle {
204
229
  /**
205
230
  * Returns true if the handle is empty.
206
231
  */
207
- inline bool IsEmpty() const { return val_ == 0; }
232
+ V8_INLINE(bool IsEmpty() const) { return val_ == 0; }
208
233
 
209
234
  /**
210
235
  * Sets the handle to be empty. IsEmpty() will then return true.
211
236
  */
212
- inline void Clear() { val_ = 0; }
237
+ V8_INLINE(void Clear()) { val_ = 0; }
213
238
 
214
- inline T* operator->() const { return val_; }
239
+ V8_INLINE(T* operator->() const) { return val_; }
215
240
 
216
- inline T* operator*() const { return val_; }
241
+ V8_INLINE(T* operator*() const) { return val_; }
217
242
 
218
243
  /**
219
244
  * Checks whether two handles are the same.
@@ -221,7 +246,7 @@ template <class T> class Handle {
221
246
  * to which they refer are identical.
222
247
  * The handles' references are not checked.
223
248
  */
224
- template <class S> inline bool operator==(Handle<S> that) const {
249
+ template <class S> V8_INLINE(bool operator==(Handle<S> that) const) {
225
250
  internal::Object** a = reinterpret_cast<internal::Object**>(**this);
226
251
  internal::Object** b = reinterpret_cast<internal::Object**>(*that);
227
252
  if (a == 0) return b == 0;
@@ -235,11 +260,11 @@ template <class T> class Handle {
235
260
  * the objects to which they refer are different.
236
261
  * The handles' references are not checked.
237
262
  */
238
- template <class S> inline bool operator!=(Handle<S> that) const {
263
+ template <class S> V8_INLINE(bool operator!=(Handle<S> that) const) {
239
264
  return !operator==(that);
240
265
  }
241
266
 
242
- template <class S> static inline Handle<T> Cast(Handle<S> that) {
267
+ template <class S> V8_INLINE(static Handle<T> Cast(Handle<S> that)) {
243
268
  #ifdef V8_ENABLE_CHECKS
244
269
  // If we're going to perform the type check then we have to check
245
270
  // that the handle isn't empty before doing the checked cast.
@@ -248,7 +273,7 @@ template <class T> class Handle {
248
273
  return Handle<T>(T::Cast(*that));
249
274
  }
250
275
 
251
- template <class S> inline Handle<S> As() {
276
+ template <class S> V8_INLINE(Handle<S> As()) {
252
277
  return Handle<S>::Cast(*this);
253
278
  }
254
279
 
@@ -266,8 +291,8 @@ template <class T> class Handle {
266
291
  */
267
292
  template <class T> class Local : public Handle<T> {
268
293
  public:
269
- inline Local();
270
- template <class S> inline Local(Local<S> that)
294
+ V8_INLINE(Local());
295
+ template <class S> V8_INLINE(Local(Local<S> that))
271
296
  : Handle<T>(reinterpret_cast<T*>(*that)) {
272
297
  /**
273
298
  * This check fails when trying to convert between incompatible
@@ -276,8 +301,8 @@ template <class T> class Local : public Handle<T> {
276
301
  */
277
302
  TYPE_CHECK(T, S);
278
303
  }
279
- template <class S> inline Local(S* that) : Handle<T>(that) { }
280
- template <class S> static inline Local<T> Cast(Local<S> that) {
304
+ template <class S> V8_INLINE(Local(S* that) : Handle<T>(that)) { }
305
+ template <class S> V8_INLINE(static Local<T> Cast(Local<S> that)) {
281
306
  #ifdef V8_ENABLE_CHECKS
282
307
  // If we're going to perform the type check then we have to check
283
308
  // that the handle isn't empty before doing the checked cast.
@@ -286,15 +311,17 @@ template <class T> class Local : public Handle<T> {
286
311
  return Local<T>(T::Cast(*that));
287
312
  }
288
313
 
289
- template <class S> inline Local<S> As() {
314
+ template <class S> V8_INLINE(Local<S> As()) {
290
315
  return Local<S>::Cast(*this);
291
316
  }
292
317
 
293
- /** Create a local handle for the content of another handle.
294
- * The referee is kept alive by the local handle even when
295
- * the original handle is destroyed/disposed.
318
+ /**
319
+ * Create a local handle for the content of another handle.
320
+ * The referee is kept alive by the local handle even when
321
+ * the original handle is destroyed/disposed.
296
322
  */
297
- inline static Local<T> New(Handle<T> that);
323
+ V8_INLINE(static Local<T> New(Handle<T> that));
324
+ V8_INLINE(static Local<T> New(Isolate* isolate, Handle<T> that));
298
325
  };
299
326
 
300
327
 
@@ -321,7 +348,7 @@ template <class T> class Persistent : public Handle<T> {
321
348
  * Creates an empty persistent handle that doesn't point to any
322
349
  * storage cell.
323
350
  */
324
- inline Persistent();
351
+ V8_INLINE(Persistent());
325
352
 
326
353
  /**
327
354
  * Creates a persistent handle for the same storage cell as the
@@ -334,7 +361,7 @@ template <class T> class Persistent : public Handle<T> {
334
361
  * Persistent<String> to a variable declared as Persistent<Value>,
335
362
  * is allowed as String is a subclass of Value.
336
363
  */
337
- template <class S> inline Persistent(Persistent<S> that)
364
+ template <class S> V8_INLINE(Persistent(Persistent<S> that))
338
365
  : Handle<T>(reinterpret_cast<T*>(*that)) {
339
366
  /**
340
367
  * This check fails when trying to convert between incompatible
@@ -344,16 +371,16 @@ template <class T> class Persistent : public Handle<T> {
344
371
  TYPE_CHECK(T, S);
345
372
  }
346
373
 
347
- template <class S> inline Persistent(S* that) : Handle<T>(that) { }
374
+ template <class S> V8_INLINE(Persistent(S* that)) : Handle<T>(that) { }
348
375
 
349
376
  /**
350
377
  * "Casts" a plain handle which is known to be a persistent handle
351
378
  * to a persistent handle.
352
379
  */
353
- template <class S> explicit inline Persistent(Handle<S> that)
380
+ template <class S> explicit V8_INLINE(Persistent(Handle<S> that))
354
381
  : Handle<T>(*that) { }
355
382
 
356
- template <class S> static inline Persistent<T> Cast(Persistent<S> that) {
383
+ template <class S> V8_INLINE(static Persistent<T> Cast(Persistent<S> that)) {
357
384
  #ifdef V8_ENABLE_CHECKS
358
385
  // If we're going to perform the type check then we have to check
359
386
  // that the handle isn't empty before doing the checked cast.
@@ -362,15 +389,20 @@ template <class T> class Persistent : public Handle<T> {
362
389
  return Persistent<T>(T::Cast(*that));
363
390
  }
364
391
 
365
- template <class S> inline Persistent<S> As() {
392
+ template <class S> V8_INLINE(Persistent<S> As()) {
366
393
  return Persistent<S>::Cast(*this);
367
394
  }
368
395
 
396
+ /** Deprecated. Use Isolate version instead. */
397
+ V8_DEPRECATED(static Persistent<T> New(Handle<T> that));
398
+
369
399
  /**
370
- * Creates a new persistent handle for an existing local or
371
- * persistent handle.
400
+ * Creates a new persistent handle for an existing local or persistent handle.
372
401
  */
373
- 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());
374
406
 
375
407
  /**
376
408
  * Releases the storage cell referenced by this persistent handle.
@@ -378,43 +410,87 @@ template <class T> class Persistent : public Handle<T> {
378
410
  * This handle's reference, and any other references to the storage
379
411
  * cell remain and IsEmpty will still return false.
380
412
  */
381
- inline void Dispose();
413
+ V8_INLINE(void Dispose(Isolate* isolate));
414
+
415
+ /** Deprecated. Use Isolate version instead. */
416
+ V8_DEPRECATED(void MakeWeak(void* parameters,
417
+ WeakReferenceCallback callback));
382
418
 
383
419
  /**
384
420
  * Make the reference to this object weak. When only weak handles
385
421
  * refer to the object, the garbage collector will perform a
386
- * callback to the given V8::WeakReferenceCallback function, passing
422
+ * callback to the given V8::NearDeathCallback function, passing
387
423
  * it the object reference and the given parameters.
388
424
  */
389
- inline void MakeWeak(void* parameters, WeakReferenceCallback callback);
425
+ V8_INLINE(void MakeWeak(Isolate* isolate,
426
+ void* parameters,
427
+ NearDeathCallback callback));
428
+
429
+ /** Deprecated. Use Isolate version instead. */
430
+ V8_DEPRECATED(void ClearWeak());
390
431
 
391
- /** Clears the weak reference to this object.*/
392
- inline void ClearWeak();
432
+ /** Clears the weak reference to this object. */
433
+ V8_INLINE(void ClearWeak(Isolate* isolate));
434
+
435
+ /** Deprecated. Use Isolate version instead. */
436
+ V8_DEPRECATED(void MarkIndependent());
393
437
 
394
438
  /**
395
- * Marks the reference to this object independent. Garbage collector
396
- * is free to ignore any object groups containing this object.
397
- * Weak callback for an independent handle should not
398
- * assume that it will be preceded by a global GC prologue callback
399
- * or followed by a global GC epilogue callback.
439
+ * Marks the reference to this object independent. Garbage collector is free
440
+ * to ignore any object groups containing this object. Weak callback for an
441
+ * independent handle should not assume that it will be preceded by a global
442
+ * GC prologue callback or followed by a global GC epilogue callback.
400
443
  */
401
- inline void MarkIndependent();
444
+ V8_INLINE(void MarkIndependent(Isolate* isolate));
445
+
446
+ /** Deprecated. Use Isolate version instead. */
447
+ V8_DEPRECATED(void MarkPartiallyDependent());
402
448
 
403
449
  /**
404
- *Checks if the handle holds the only reference to an object.
450
+ * Marks the reference to this object partially dependent. Partially dependent
451
+ * handles only depend on other partially dependent handles and these
452
+ * dependencies are provided through object groups. It provides a way to build
453
+ * smaller object groups for young objects that represent only a subset of all
454
+ * external dependencies. This mark is automatically cleared after each
455
+ * garbage collection.
405
456
  */
406
- inline bool IsNearDeath() const;
457
+ V8_INLINE(void MarkPartiallyDependent(Isolate* isolate));
458
+
459
+ /** Deprecated. Use Isolate version instead. */
460
+ V8_DEPRECATED(bool IsIndependent() const);
461
+
462
+ /** Returns true if this handle was previously marked as independent. */
463
+ V8_INLINE(bool IsIndependent(Isolate* isolate) const);
464
+
465
+ /** Deprecated. Use Isolate version instead. */
466
+ V8_DEPRECATED(bool IsNearDeath() const);
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
+
474
+ /** Returns true if the handle's reference is weak. */
475
+ V8_INLINE(bool IsWeak(Isolate* isolate) const);
476
+
477
+ /** Deprecated. Use Isolate version instead. */
478
+ V8_DEPRECATED(void SetWrapperClassId(uint16_t class_id));
407
479
 
408
480
  /**
409
- * Returns true if the handle's reference is weak.
481
+ * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface
482
+ * description in v8-profiler.h for details.
410
483
  */
411
- inline bool IsWeak() 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);
412
488
 
413
489
  /**
414
- * Assigns a wrapper class ID to the handle. See RetainedObjectInfo
415
- * interface description in v8-profiler.h for details.
490
+ * Returns the class ID previously assigned to this handle or 0 if no class ID
491
+ * was previously assigned.
416
492
  */
417
- inline void SetWrapperClassId(uint16_t class_id);
493
+ V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const);
418
494
 
419
495
  private:
420
496
  friend class ImplementationUtilities;
@@ -457,12 +533,14 @@ class V8EXPORT HandleScope {
457
533
  * Creates a new handle with the given value.
458
534
  */
459
535
  static internal::Object** CreateHandle(internal::Object* value);
536
+ static internal::Object** CreateHandle(internal::Isolate* isolate,
537
+ internal::Object* value);
460
538
  // Faster version, uses HeapObject to obtain the current Isolate.
461
539
  static internal::Object** CreateHandle(internal::HeapObject* value);
462
540
 
463
541
  private:
464
- // Make it impossible to create heap-allocated or illegal handle
465
- // scopes by disallowing certain operations.
542
+ // Make it hard to create heap-allocated or illegal handle scopes by
543
+ // disallowing certain operations.
466
544
  HandleScope(const HandleScope&);
467
545
  void operator=(const HandleScope&);
468
546
  void* operator new(size_t size);
@@ -475,7 +553,7 @@ class V8EXPORT HandleScope {
475
553
  internal::Object** next;
476
554
  internal::Object** limit;
477
555
  int level;
478
- inline void Initialize() {
556
+ V8_INLINE(void Initialize()) {
479
557
  next = limit = NULL;
480
558
  level = 0;
481
559
  }
@@ -568,16 +646,16 @@ class V8EXPORT ScriptData { // NOLINT
568
646
  */
569
647
  class ScriptOrigin {
570
648
  public:
571
- inline ScriptOrigin(
649
+ V8_INLINE(ScriptOrigin(
572
650
  Handle<Value> resource_name,
573
651
  Handle<Integer> resource_line_offset = Handle<Integer>(),
574
- Handle<Integer> resource_column_offset = Handle<Integer>())
652
+ Handle<Integer> resource_column_offset = Handle<Integer>()))
575
653
  : resource_name_(resource_name),
576
654
  resource_line_offset_(resource_line_offset),
577
655
  resource_column_offset_(resource_column_offset) { }
578
- inline Handle<Value> ResourceName() const;
579
- inline Handle<Integer> ResourceLineOffset() const;
580
- inline Handle<Integer> ResourceColumnOffset() const;
656
+ V8_INLINE(Handle<Value> ResourceName() const);
657
+ V8_INLINE(Handle<Integer> ResourceLineOffset() const);
658
+ V8_INLINE(Handle<Integer> ResourceColumnOffset() const);
581
659
  private:
582
660
  Handle<Value> resource_name_;
583
661
  Handle<Integer> resource_line_offset_;
@@ -859,173 +937,179 @@ class V8EXPORT StackFrame {
859
937
  /**
860
938
  * The superclass of all JavaScript values and objects.
861
939
  */
862
- class Value : public Data {
940
+ class V8EXPORT Value : public Data {
863
941
  public:
864
942
  /**
865
943
  * Returns true if this value is the undefined value. See ECMA-262
866
944
  * 4.3.10.
867
945
  */
868
- inline bool IsUndefined() const;
946
+ V8_INLINE(bool IsUndefined() const);
869
947
 
870
948
  /**
871
949
  * Returns true if this value is the null value. See ECMA-262
872
950
  * 4.3.11.
873
951
  */
874
- inline bool IsNull() const;
952
+ V8_INLINE(bool IsNull() const);
875
953
 
876
954
  /**
877
955
  * Returns true if this value is true.
878
956
  */
879
- V8EXPORT bool IsTrue() const;
957
+ bool IsTrue() const;
880
958
 
881
959
  /**
882
960
  * Returns true if this value is false.
883
961
  */
884
- V8EXPORT bool IsFalse() const;
962
+ bool IsFalse() const;
885
963
 
886
964
  /**
887
965
  * Returns true if this value is an instance of the String type.
888
966
  * See ECMA-262 8.4.
889
967
  */
890
- inline bool IsString() const;
968
+ V8_INLINE(bool IsString() const);
891
969
 
892
970
  /**
893
971
  * Returns true if this value is a function.
894
972
  */
895
- V8EXPORT bool IsFunction() const;
973
+ bool IsFunction() const;
896
974
 
897
975
  /**
898
976
  * Returns true if this value is an array.
899
977
  */
900
- V8EXPORT bool IsArray() const;
978
+ bool IsArray() const;
901
979
 
902
980
  /**
903
981
  * Returns true if this value is an object.
904
982
  */
905
- V8EXPORT bool IsObject() const;
983
+ bool IsObject() const;
906
984
 
907
985
  /**
908
986
  * Returns true if this value is boolean.
909
987
  */
910
- V8EXPORT bool IsBoolean() const;
988
+ bool IsBoolean() const;
911
989
 
912
990
  /**
913
991
  * Returns true if this value is a number.
914
992
  */
915
- V8EXPORT bool IsNumber() const;
993
+ bool IsNumber() const;
916
994
 
917
995
  /**
918
996
  * Returns true if this value is external.
919
997
  */
920
- V8EXPORT bool IsExternal() const;
998
+ bool IsExternal() const;
921
999
 
922
1000
  /**
923
1001
  * Returns true if this value is a 32-bit signed integer.
924
1002
  */
925
- V8EXPORT bool IsInt32() const;
1003
+ bool IsInt32() const;
926
1004
 
927
1005
  /**
928
1006
  * Returns true if this value is a 32-bit unsigned integer.
929
1007
  */
930
- V8EXPORT bool IsUint32() const;
1008
+ bool IsUint32() const;
931
1009
 
932
1010
  /**
933
1011
  * Returns true if this value is a Date.
934
1012
  */
935
- V8EXPORT bool IsDate() const;
1013
+ bool IsDate() const;
936
1014
 
937
1015
  /**
938
1016
  * Returns true if this value is a Boolean object.
939
1017
  */
940
- V8EXPORT bool IsBooleanObject() const;
1018
+ bool IsBooleanObject() const;
941
1019
 
942
1020
  /**
943
1021
  * Returns true if this value is a Number object.
944
1022
  */
945
- V8EXPORT bool IsNumberObject() const;
1023
+ bool IsNumberObject() const;
946
1024
 
947
1025
  /**
948
1026
  * Returns true if this value is a String object.
949
1027
  */
950
- V8EXPORT bool IsStringObject() const;
1028
+ bool IsStringObject() const;
951
1029
 
952
1030
  /**
953
1031
  * Returns true if this value is a NativeError.
954
1032
  */
955
- V8EXPORT bool IsNativeError() const;
1033
+ bool IsNativeError() const;
956
1034
 
957
1035
  /**
958
1036
  * Returns true if this value is a RegExp.
959
1037
  */
960
- V8EXPORT bool IsRegExp() const;
1038
+ bool IsRegExp() const;
961
1039
 
962
- V8EXPORT Local<Boolean> ToBoolean() const;
963
- V8EXPORT Local<Number> ToNumber() const;
964
- V8EXPORT Local<String> ToString() const;
965
- V8EXPORT Local<String> ToDetailString() const;
966
- V8EXPORT Local<Object> ToObject() const;
967
- V8EXPORT Local<Integer> ToInteger() const;
968
- V8EXPORT Local<Uint32> ToUint32() const;
969
- V8EXPORT Local<Int32> ToInt32() const;
1040
+ Local<Boolean> ToBoolean() const;
1041
+ Local<Number> ToNumber() const;
1042
+ Local<String> ToString() const;
1043
+ Local<String> ToDetailString() const;
1044
+ Local<Object> ToObject() const;
1045
+ Local<Integer> ToInteger() const;
1046
+ Local<Uint32> ToUint32() const;
1047
+ Local<Int32> ToInt32() const;
970
1048
 
971
1049
  /**
972
1050
  * Attempts to convert a string to an array index.
973
1051
  * Returns an empty handle if the conversion fails.
974
1052
  */
975
- V8EXPORT Local<Uint32> ToArrayIndex() const;
1053
+ Local<Uint32> ToArrayIndex() const;
976
1054
 
977
- V8EXPORT bool BooleanValue() const;
978
- V8EXPORT double NumberValue() const;
979
- V8EXPORT int64_t IntegerValue() const;
980
- V8EXPORT uint32_t Uint32Value() const;
981
- V8EXPORT int32_t Int32Value() const;
1055
+ bool BooleanValue() const;
1056
+ double NumberValue() const;
1057
+ int64_t IntegerValue() const;
1058
+ uint32_t Uint32Value() const;
1059
+ int32_t Int32Value() const;
982
1060
 
983
1061
  /** JS == */
984
- V8EXPORT bool Equals(Handle<Value> that) const;
985
- V8EXPORT bool StrictEquals(Handle<Value> that) const;
1062
+ bool Equals(Handle<Value> that) const;
1063
+ bool StrictEquals(Handle<Value> that) const;
986
1064
 
987
1065
  private:
988
- inline bool QuickIsUndefined() const;
989
- inline bool QuickIsNull() const;
990
- inline bool QuickIsString() const;
991
- V8EXPORT bool FullIsUndefined() const;
992
- V8EXPORT bool FullIsNull() const;
993
- V8EXPORT bool FullIsString() const;
1066
+ V8_INLINE(bool QuickIsUndefined() const);
1067
+ V8_INLINE(bool QuickIsNull() const);
1068
+ V8_INLINE(bool QuickIsString() const);
1069
+ bool FullIsUndefined() const;
1070
+ bool FullIsNull() const;
1071
+ bool FullIsString() const;
994
1072
  };
995
1073
 
996
1074
 
997
1075
  /**
998
1076
  * The superclass of primitive values. See ECMA-262 4.3.2.
999
1077
  */
1000
- class Primitive : public Value { };
1078
+ class V8EXPORT Primitive : public Value { };
1001
1079
 
1002
1080
 
1003
1081
  /**
1004
1082
  * A primitive boolean value (ECMA-262, 4.3.14). Either the true
1005
1083
  * or false value.
1006
1084
  */
1007
- class Boolean : public Primitive {
1085
+ class V8EXPORT Boolean : public Primitive {
1008
1086
  public:
1009
- V8EXPORT bool Value() const;
1010
- static inline Handle<Boolean> New(bool value);
1087
+ bool Value() const;
1088
+ V8_INLINE(static Handle<Boolean> New(bool value));
1011
1089
  };
1012
1090
 
1013
1091
 
1014
1092
  /**
1015
1093
  * A JavaScript string value (ECMA-262, 4.3.17).
1016
1094
  */
1017
- class String : public Primitive {
1095
+ class V8EXPORT String : public Primitive {
1018
1096
  public:
1097
+ enum Encoding {
1098
+ UNKNOWN_ENCODING = 0x1,
1099
+ TWO_BYTE_ENCODING = 0x0,
1100
+ ASCII_ENCODING = 0x4,
1101
+ ONE_BYTE_ENCODING = 0x4
1102
+ };
1019
1103
  /**
1020
1104
  * Returns the number of characters in this string.
1021
1105
  */
1022
- V8EXPORT int Length() const;
1106
+ int Length() const;
1023
1107
 
1024
1108
  /**
1025
1109
  * Returns the number of bytes in the UTF-8 encoded
1026
1110
  * representation of this string.
1027
1111
  */
1028
- V8EXPORT int Utf8Length() const;
1112
+ int Utf8Length() const;
1029
1113
 
1030
1114
  /**
1031
1115
  * A fast conservative check for non-ASCII characters. May
@@ -1033,7 +1117,12 @@ class String : public Primitive {
1033
1117
  * false you can be sure that all characters are in the range
1034
1118
  * 0-127.
1035
1119
  */
1036
- V8EXPORT bool MayContainNonAscii() const;
1120
+ bool MayContainNonAscii() const;
1121
+
1122
+ /**
1123
+ * Returns whether this string contains only one byte data.
1124
+ */
1125
+ bool IsOneByte() const;
1037
1126
 
1038
1127
  /**
1039
1128
  * Write the contents of the string to an external buffer.
@@ -1063,40 +1152,46 @@ class String : public Primitive {
1063
1152
  enum WriteOptions {
1064
1153
  NO_OPTIONS = 0,
1065
1154
  HINT_MANY_WRITES_EXPECTED = 1,
1066
- NO_NULL_TERMINATION = 2
1155
+ NO_NULL_TERMINATION = 2,
1156
+ PRESERVE_ASCII_NULL = 4
1067
1157
  };
1068
1158
 
1069
1159
  // 16-bit character codes.
1070
- V8EXPORT int Write(uint16_t* buffer,
1071
- int start = 0,
1072
- int length = -1,
1073
- int options = NO_OPTIONS) const;
1160
+ int Write(uint16_t* buffer,
1161
+ int start = 0,
1162
+ int length = -1,
1163
+ int options = NO_OPTIONS) const;
1074
1164
  // ASCII characters.
1075
- V8EXPORT int WriteAscii(char* buffer,
1076
- int start = 0,
1077
- int length = -1,
1078
- int options = NO_OPTIONS) const;
1165
+ int WriteAscii(char* buffer,
1166
+ int start = 0,
1167
+ int length = -1,
1168
+ int options = NO_OPTIONS) const;
1169
+ // One byte characters.
1170
+ int WriteOneByte(uint8_t* buffer,
1171
+ int start = 0,
1172
+ int length = -1,
1173
+ int options = NO_OPTIONS) const;
1079
1174
  // UTF-8 encoded characters.
1080
- V8EXPORT int WriteUtf8(char* buffer,
1081
- int length = -1,
1082
- int* nchars_ref = NULL,
1083
- int options = NO_OPTIONS) const;
1175
+ int WriteUtf8(char* buffer,
1176
+ int length = -1,
1177
+ int* nchars_ref = NULL,
1178
+ int options = NO_OPTIONS) const;
1084
1179
 
1085
1180
  /**
1086
1181
  * A zero length string.
1087
1182
  */
1088
- V8EXPORT static v8::Local<v8::String> Empty();
1089
- inline static v8::Local<v8::String> Empty(Isolate* isolate);
1183
+ static v8::Local<v8::String> Empty();
1184
+ V8_INLINE(static v8::Local<v8::String> Empty(Isolate* isolate));
1090
1185
 
1091
1186
  /**
1092
1187
  * Returns true if the string is external
1093
1188
  */
1094
- V8EXPORT bool IsExternal() const;
1189
+ bool IsExternal() const;
1095
1190
 
1096
1191
  /**
1097
1192
  * Returns true if the string is both external and ASCII
1098
1193
  */
1099
- V8EXPORT bool IsExternalAscii() const;
1194
+ bool IsExternalAscii() const;
1100
1195
 
1101
1196
  class V8EXPORT ExternalStringResourceBase { // NOLINT
1102
1197
  public:
@@ -1177,44 +1272,48 @@ class String : public Primitive {
1177
1272
  ExternalAsciiStringResource() {}
1178
1273
  };
1179
1274
 
1275
+ typedef ExternalAsciiStringResource ExternalOneByteStringResource;
1276
+
1277
+ /**
1278
+ * If the string is an external string, return the ExternalStringResourceBase
1279
+ * regardless of the encoding, otherwise return NULL. The encoding of the
1280
+ * string is returned in encoding_out.
1281
+ */
1282
+ V8_INLINE(ExternalStringResourceBase* GetExternalStringResourceBase(
1283
+ Encoding* encoding_out) const);
1284
+
1180
1285
  /**
1181
1286
  * Get the ExternalStringResource for an external string. Returns
1182
1287
  * NULL if IsExternal() doesn't return true.
1183
1288
  */
1184
- inline ExternalStringResource* GetExternalStringResource() const;
1289
+ V8_INLINE(ExternalStringResource* GetExternalStringResource() const);
1185
1290
 
1186
1291
  /**
1187
1292
  * Get the ExternalAsciiStringResource for an external ASCII string.
1188
1293
  * Returns NULL if IsExternalAscii() doesn't return true.
1189
1294
  */
1190
- V8EXPORT const ExternalAsciiStringResource* GetExternalAsciiStringResource()
1191
- const;
1295
+ const ExternalAsciiStringResource* GetExternalAsciiStringResource() const;
1192
1296
 
1193
- static inline String* Cast(v8::Value* obj);
1297
+ V8_INLINE(static String* Cast(v8::Value* obj));
1194
1298
 
1195
1299
  /**
1196
1300
  * Allocates a new string from either UTF-8 encoded or ASCII data.
1197
- * The second parameter 'length' gives the buffer length.
1198
- * If the data is UTF-8 encoded, the caller must
1199
- * be careful to supply the length parameter.
1200
- * If it is not given, the function calls
1201
- * 'strlen' to determine the buffer length, it might be
1202
- * wrong if 'data' contains a null character.
1301
+ * The second parameter 'length' gives the buffer length. If omitted,
1302
+ * the function calls 'strlen' to determine the buffer length.
1203
1303
  */
1204
- V8EXPORT static Local<String> New(const char* data, int length = -1);
1304
+ static Local<String> New(const char* data, int length = -1);
1205
1305
 
1206
1306
  /** Allocates a new string from 16-bit character codes.*/
1207
- V8EXPORT static Local<String> New(const uint16_t* data, int length = -1);
1307
+ static Local<String> New(const uint16_t* data, int length = -1);
1208
1308
 
1209
1309
  /** Creates a symbol. Returns one if it exists already.*/
1210
- V8EXPORT static Local<String> NewSymbol(const char* data, int length = -1);
1310
+ static Local<String> NewSymbol(const char* data, int length = -1);
1211
1311
 
1212
1312
  /**
1213
1313
  * Creates a new string by concatenating the left and the right strings
1214
1314
  * passed in as parameters.
1215
1315
  */
1216
- V8EXPORT static Local<String> Concat(Handle<String> left,
1217
- Handle<String> right);
1316
+ static Local<String> Concat(Handle<String> left, Handle<String> right);
1218
1317
 
1219
1318
  /**
1220
1319
  * Creates a new external string using the data defined in the given
@@ -1224,7 +1323,7 @@ class String : public Primitive {
1224
1323
  * should the underlying buffer be deallocated or modified except through the
1225
1324
  * destructor of the external string resource.
1226
1325
  */
1227
- V8EXPORT static Local<String> NewExternal(ExternalStringResource* resource);
1326
+ static Local<String> NewExternal(ExternalStringResource* resource);
1228
1327
 
1229
1328
  /**
1230
1329
  * Associate an external string resource with this string by transforming it
@@ -1235,7 +1334,7 @@ class String : public Primitive {
1235
1334
  * The string is not modified if the operation fails. See NewExternal for
1236
1335
  * information on the lifetime of the resource.
1237
1336
  */
1238
- V8EXPORT bool MakeExternal(ExternalStringResource* resource);
1337
+ bool MakeExternal(ExternalStringResource* resource);
1239
1338
 
1240
1339
  /**
1241
1340
  * Creates a new external string using the ASCII data defined in the given
@@ -1244,8 +1343,8 @@ class String : public Primitive {
1244
1343
  * this function should not otherwise delete or modify the resource. Neither
1245
1344
  * should the underlying buffer be deallocated or modified except through the
1246
1345
  * destructor of the external string resource.
1247
- */ V8EXPORT static Local<String> NewExternal(
1248
- ExternalAsciiStringResource* resource);
1346
+ */
1347
+ static Local<String> NewExternal(ExternalAsciiStringResource* resource);
1249
1348
 
1250
1349
  /**
1251
1350
  * Associate an external string resource with this string by transforming it
@@ -1256,20 +1355,18 @@ class String : public Primitive {
1256
1355
  * The string is not modified if the operation fails. See NewExternal for
1257
1356
  * information on the lifetime of the resource.
1258
1357
  */
1259
- V8EXPORT bool MakeExternal(ExternalAsciiStringResource* resource);
1358
+ bool MakeExternal(ExternalAsciiStringResource* resource);
1260
1359
 
1261
1360
  /**
1262
1361
  * Returns true if this string can be made external.
1263
1362
  */
1264
- V8EXPORT bool CanMakeExternal();
1363
+ bool CanMakeExternal();
1265
1364
 
1266
1365
  /** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/
1267
- V8EXPORT static Local<String> NewUndetectable(const char* data,
1268
- int length = -1);
1366
+ static Local<String> NewUndetectable(const char* data, int length = -1);
1269
1367
 
1270
1368
  /** Creates an undetectable string from the supplied 16-bit character codes.*/
1271
- V8EXPORT static Local<String> NewUndetectable(const uint16_t* data,
1272
- int length = -1);
1369
+ static Local<String> NewUndetectable(const uint16_t* data, int length = -1);
1273
1370
 
1274
1371
  /**
1275
1372
  * Converts an object to a UTF-8-encoded character array. Useful if
@@ -1340,59 +1437,63 @@ class String : public Primitive {
1340
1437
  };
1341
1438
 
1342
1439
  private:
1343
- V8EXPORT void VerifyExternalStringResource(ExternalStringResource* val) const;
1344
- V8EXPORT static void CheckCast(v8::Value* obj);
1440
+ void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
1441
+ Encoding encoding) const;
1442
+ void VerifyExternalStringResource(ExternalStringResource* val) const;
1443
+ static void CheckCast(v8::Value* obj);
1345
1444
  };
1346
1445
 
1347
1446
 
1348
1447
  /**
1349
1448
  * A JavaScript number value (ECMA-262, 4.3.20)
1350
1449
  */
1351
- class Number : public Primitive {
1450
+ class V8EXPORT Number : public Primitive {
1352
1451
  public:
1353
- V8EXPORT double Value() const;
1354
- V8EXPORT static Local<Number> New(double value);
1355
- static inline Number* Cast(v8::Value* obj);
1452
+ double Value() const;
1453
+ static Local<Number> New(double value);
1454
+ V8_INLINE(static Number* Cast(v8::Value* obj));
1356
1455
  private:
1357
- V8EXPORT Number();
1358
- V8EXPORT static void CheckCast(v8::Value* obj);
1456
+ Number();
1457
+ static void CheckCast(v8::Value* obj);
1359
1458
  };
1360
1459
 
1361
1460
 
1362
1461
  /**
1363
1462
  * A JavaScript value representing a signed integer.
1364
1463
  */
1365
- class Integer : public Number {
1464
+ class V8EXPORT Integer : public Number {
1366
1465
  public:
1367
- V8EXPORT static Local<Integer> New(int32_t value);
1368
- V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value);
1369
- V8EXPORT int64_t Value() const;
1370
- static inline Integer* Cast(v8::Value* obj);
1466
+ static Local<Integer> New(int32_t value);
1467
+ static Local<Integer> NewFromUnsigned(uint32_t value);
1468
+ static Local<Integer> New(int32_t value, Isolate*);
1469
+ static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*);
1470
+ int64_t Value() const;
1471
+ V8_INLINE(static Integer* Cast(v8::Value* obj));
1371
1472
  private:
1372
- V8EXPORT Integer();
1373
- V8EXPORT static void CheckCast(v8::Value* obj);
1473
+ Integer();
1474
+ static void CheckCast(v8::Value* obj);
1374
1475
  };
1375
1476
 
1376
1477
 
1377
1478
  /**
1378
1479
  * A JavaScript value representing a 32-bit signed integer.
1379
1480
  */
1380
- class Int32 : public Integer {
1481
+ class V8EXPORT Int32 : public Integer {
1381
1482
  public:
1382
- V8EXPORT int32_t Value() const;
1483
+ int32_t Value() const;
1383
1484
  private:
1384
- V8EXPORT Int32();
1485
+ Int32();
1385
1486
  };
1386
1487
 
1387
1488
 
1388
1489
  /**
1389
1490
  * A JavaScript value representing a 32-bit unsigned integer.
1390
1491
  */
1391
- class Uint32 : public Integer {
1492
+ class V8EXPORT Uint32 : public Integer {
1392
1493
  public:
1393
- V8EXPORT uint32_t Value() const;
1494
+ uint32_t Value() const;
1394
1495
  private:
1395
- V8EXPORT Uint32();
1496
+ Uint32();
1396
1497
  };
1397
1498
 
1398
1499
 
@@ -1453,14 +1554,13 @@ enum AccessControl {
1453
1554
  /**
1454
1555
  * A JavaScript object (ECMA-262, 4.3.3)
1455
1556
  */
1456
- class Object : public Value {
1557
+ class V8EXPORT Object : public Value {
1457
1558
  public:
1458
- V8EXPORT bool Set(Handle<Value> key,
1459
- Handle<Value> value,
1460
- PropertyAttribute attribs = None);
1559
+ bool Set(Handle<Value> key,
1560
+ Handle<Value> value,
1561
+ PropertyAttribute attribs = None);
1461
1562
 
1462
- V8EXPORT bool Set(uint32_t index,
1463
- Handle<Value> value);
1563
+ bool Set(uint32_t index, Handle<Value> value);
1464
1564
 
1465
1565
  // Sets a local property on this object bypassing interceptors and
1466
1566
  // overriding accessors or read-only properties.
@@ -1470,41 +1570,41 @@ class Object : public Value {
1470
1570
  // will only be returned if the interceptor doesn't return a value.
1471
1571
  //
1472
1572
  // Note also that this only works for named properties.
1473
- V8EXPORT bool ForceSet(Handle<Value> key,
1474
- Handle<Value> value,
1475
- PropertyAttribute attribs = None);
1573
+ bool ForceSet(Handle<Value> key,
1574
+ Handle<Value> value,
1575
+ PropertyAttribute attribs = None);
1476
1576
 
1477
- V8EXPORT Local<Value> Get(Handle<Value> key);
1577
+ Local<Value> Get(Handle<Value> key);
1478
1578
 
1479
- V8EXPORT Local<Value> Get(uint32_t index);
1579
+ Local<Value> Get(uint32_t index);
1480
1580
 
1481
1581
  /**
1482
1582
  * Gets the property attributes of a property which can be None or
1483
1583
  * any combination of ReadOnly, DontEnum and DontDelete. Returns
1484
1584
  * None when the property doesn't exist.
1485
1585
  */
1486
- V8EXPORT PropertyAttribute GetPropertyAttributes(Handle<Value> key);
1586
+ PropertyAttribute GetPropertyAttributes(Handle<Value> key);
1487
1587
 
1488
1588
  // TODO(1245389): Replace the type-specific versions of these
1489
1589
  // functions with generic ones that accept a Handle<Value> key.
1490
- V8EXPORT bool Has(Handle<String> key);
1590
+ bool Has(Handle<String> key);
1491
1591
 
1492
- V8EXPORT bool Delete(Handle<String> key);
1592
+ bool Delete(Handle<String> key);
1493
1593
 
1494
1594
  // Delete a property on this object bypassing interceptors and
1495
1595
  // ignoring dont-delete attributes.
1496
- V8EXPORT bool ForceDelete(Handle<Value> key);
1596
+ bool ForceDelete(Handle<Value> key);
1497
1597
 
1498
- V8EXPORT bool Has(uint32_t index);
1598
+ bool Has(uint32_t index);
1499
1599
 
1500
- V8EXPORT bool Delete(uint32_t index);
1600
+ bool Delete(uint32_t index);
1501
1601
 
1502
- V8EXPORT bool SetAccessor(Handle<String> name,
1503
- AccessorGetter getter,
1504
- AccessorSetter setter = 0,
1505
- Handle<Value> data = Handle<Value>(),
1506
- AccessControl settings = DEFAULT,
1507
- PropertyAttribute attribute = None);
1602
+ bool SetAccessor(Handle<String> name,
1603
+ AccessorGetter getter,
1604
+ AccessorSetter setter = 0,
1605
+ Handle<Value> data = Handle<Value>(),
1606
+ AccessControl settings = DEFAULT,
1607
+ PropertyAttribute attribute = None);
1508
1608
 
1509
1609
  /**
1510
1610
  * Returns an array containing the names of the enumerable properties
@@ -1512,93 +1612,107 @@ class Object : public Value {
1512
1612
  * array returned by this method contains the same values as would
1513
1613
  * be enumerated by a for-in statement over this object.
1514
1614
  */
1515
- V8EXPORT Local<Array> GetPropertyNames();
1615
+ Local<Array> GetPropertyNames();
1516
1616
 
1517
1617
  /**
1518
1618
  * This function has the same functionality as GetPropertyNames but
1519
1619
  * the returned array doesn't contain the names of properties from
1520
1620
  * prototype objects.
1521
1621
  */
1522
- V8EXPORT Local<Array> GetOwnPropertyNames();
1622
+ Local<Array> GetOwnPropertyNames();
1523
1623
 
1524
1624
  /**
1525
1625
  * Get the prototype object. This does not skip objects marked to
1526
1626
  * be skipped by __proto__ and it does not consult the security
1527
1627
  * handler.
1528
1628
  */
1529
- V8EXPORT Local<Value> GetPrototype();
1629
+ Local<Value> GetPrototype();
1530
1630
 
1531
1631
  /**
1532
1632
  * Set the prototype object. This does not skip objects marked to
1533
1633
  * be skipped by __proto__ and it does not consult the security
1534
1634
  * handler.
1535
1635
  */
1536
- V8EXPORT bool SetPrototype(Handle<Value> prototype);
1636
+ bool SetPrototype(Handle<Value> prototype);
1537
1637
 
1538
1638
  /**
1539
1639
  * Finds an instance of the given function template in the prototype
1540
1640
  * chain.
1541
1641
  */
1542
- V8EXPORT Local<Object> FindInstanceInPrototypeChain(
1543
- Handle<FunctionTemplate> tmpl);
1642
+ Local<Object> FindInstanceInPrototypeChain(Handle<FunctionTemplate> tmpl);
1544
1643
 
1545
1644
  /**
1546
1645
  * Call builtin Object.prototype.toString on this object.
1547
1646
  * This is different from Value::ToString() that may call
1548
1647
  * user-defined toString function. This one does not.
1549
1648
  */
1550
- V8EXPORT Local<String> ObjectProtoToString();
1649
+ Local<String> ObjectProtoToString();
1650
+
1651
+ /**
1652
+ * Returns the function invoked as a constructor for this object.
1653
+ * May be the null value.
1654
+ */
1655
+ Local<Value> GetConstructor();
1551
1656
 
1552
1657
  /**
1553
1658
  * Returns the name of the function invoked as a constructor for this object.
1554
1659
  */
1555
- V8EXPORT Local<String> GetConstructorName();
1660
+ Local<String> GetConstructorName();
1556
1661
 
1557
1662
  /** Gets the number of internal fields for this Object. */
1558
- V8EXPORT int InternalFieldCount();
1559
- /** Gets the value in an internal field. */
1560
- inline Local<Value> GetInternalField(int index);
1663
+ int InternalFieldCount();
1664
+
1665
+ /** Gets the value from an internal field. */
1666
+ V8_INLINE(Local<Value> GetInternalField(int index));
1667
+
1561
1668
  /** Sets the value in an internal field. */
1562
- V8EXPORT void SetInternalField(int index, Handle<Value> value);
1669
+ void SetInternalField(int index, Handle<Value> value);
1563
1670
 
1564
- /** Gets a native pointer from an internal field. */
1565
- inline void* GetPointerFromInternalField(int index);
1671
+ /**
1672
+ * Gets a 2-byte-aligned native pointer from an internal field. This field
1673
+ * must have been set by SetAlignedPointerInInternalField, everything else
1674
+ * leads to undefined behavior.
1675
+ */
1676
+ V8_INLINE(void* GetAlignedPointerFromInternalField(int index));
1566
1677
 
1567
- /** Sets a native pointer in an internal field. */
1568
- V8EXPORT void SetPointerInInternalField(int index, void* value);
1678
+ /**
1679
+ * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such
1680
+ * a field, GetAlignedPointerFromInternalField must be used, everything else
1681
+ * leads to undefined behavior.
1682
+ */
1683
+ void SetAlignedPointerInInternalField(int index, void* value);
1569
1684
 
1570
1685
  // Testers for local properties.
1571
- V8EXPORT bool HasOwnProperty(Handle<String> key);
1572
- V8EXPORT bool HasRealNamedProperty(Handle<String> key);
1573
- V8EXPORT bool HasRealIndexedProperty(uint32_t index);
1574
- V8EXPORT bool HasRealNamedCallbackProperty(Handle<String> key);
1686
+ bool HasOwnProperty(Handle<String> key);
1687
+ bool HasRealNamedProperty(Handle<String> key);
1688
+ bool HasRealIndexedProperty(uint32_t index);
1689
+ bool HasRealNamedCallbackProperty(Handle<String> key);
1575
1690
 
1576
1691
  /**
1577
1692
  * If result.IsEmpty() no real property was located in the prototype chain.
1578
1693
  * This means interceptors in the prototype chain are not called.
1579
1694
  */
1580
- V8EXPORT Local<Value> GetRealNamedPropertyInPrototypeChain(
1581
- Handle<String> key);
1695
+ Local<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key);
1582
1696
 
1583
1697
  /**
1584
1698
  * If result.IsEmpty() no real property was located on the object or
1585
1699
  * in the prototype chain.
1586
1700
  * This means interceptors in the prototype chain are not called.
1587
1701
  */
1588
- V8EXPORT Local<Value> GetRealNamedProperty(Handle<String> key);
1702
+ Local<Value> GetRealNamedProperty(Handle<String> key);
1589
1703
 
1590
1704
  /** Tests for a named lookup interceptor.*/
1591
- V8EXPORT bool HasNamedLookupInterceptor();
1705
+ bool HasNamedLookupInterceptor();
1592
1706
 
1593
1707
  /** Tests for an index lookup interceptor.*/
1594
- V8EXPORT bool HasIndexedLookupInterceptor();
1708
+ bool HasIndexedLookupInterceptor();
1595
1709
 
1596
1710
  /**
1597
1711
  * Turns on access check on the object if the object is an instance of
1598
1712
  * a template that has access check callbacks. If an object has no
1599
1713
  * access check info, the object cannot be accessed by anyone.
1600
1714
  */
1601
- V8EXPORT void TurnOnAccessCheck();
1715
+ void TurnOnAccessCheck();
1602
1716
 
1603
1717
  /**
1604
1718
  * Returns the identity hash for this object. The current implementation
@@ -1607,7 +1721,7 @@ class Object : public Value {
1607
1721
  * The return value will never be 0. Also, it is not guaranteed to be
1608
1722
  * unique.
1609
1723
  */
1610
- V8EXPORT int GetIdentityHash();
1724
+ int GetIdentityHash();
1611
1725
 
1612
1726
  /**
1613
1727
  * Access hidden properties on JavaScript objects. These properties are
@@ -1615,9 +1729,9 @@ class Object : public Value {
1615
1729
  * C++ API. Hidden properties introduced by V8 internally (for example the
1616
1730
  * identity hash) are prefixed with "v8::".
1617
1731
  */
1618
- V8EXPORT bool SetHiddenValue(Handle<String> key, Handle<Value> value);
1619
- V8EXPORT Local<Value> GetHiddenValue(Handle<String> key);
1620
- V8EXPORT bool DeleteHiddenValue(Handle<String> key);
1732
+ bool SetHiddenValue(Handle<String> key, Handle<Value> value);
1733
+ Local<Value> GetHiddenValue(Handle<String> key);
1734
+ bool DeleteHiddenValue(Handle<String> key);
1621
1735
 
1622
1736
  /**
1623
1737
  * Returns true if this is an instance of an api function (one
@@ -1626,18 +1740,18 @@ class Object : public Value {
1626
1740
  * conservative and may return true for objects that haven't actually
1627
1741
  * been modified.
1628
1742
  */
1629
- V8EXPORT bool IsDirty();
1743
+ bool IsDirty();
1630
1744
 
1631
1745
  /**
1632
1746
  * Clone this object with a fast but shallow copy. Values will point
1633
1747
  * to the same values as the original object.
1634
1748
  */
1635
- V8EXPORT Local<Object> Clone();
1749
+ Local<Object> Clone();
1636
1750
 
1637
1751
  /**
1638
1752
  * Returns the context in which the object was created.
1639
1753
  */
1640
- V8EXPORT Local<Context> CreationContext();
1754
+ Local<Context> CreationContext();
1641
1755
 
1642
1756
  /**
1643
1757
  * Set the backing store of the indexed properties to be managed by the
@@ -1646,10 +1760,10 @@ class Object : public Value {
1646
1760
  * Note: The embedding program still owns the data and needs to ensure that
1647
1761
  * the backing store is preserved while V8 has a reference.
1648
1762
  */
1649
- V8EXPORT void SetIndexedPropertiesToPixelData(uint8_t* data, int length);
1650
- V8EXPORT bool HasIndexedPropertiesInPixelData();
1651
- V8EXPORT uint8_t* GetIndexedPropertiesPixelData();
1652
- V8EXPORT int GetIndexedPropertiesPixelDataLength();
1763
+ void SetIndexedPropertiesToPixelData(uint8_t* data, int length);
1764
+ bool HasIndexedPropertiesInPixelData();
1765
+ uint8_t* GetIndexedPropertiesPixelData();
1766
+ int GetIndexedPropertiesPixelDataLength();
1653
1767
 
1654
1768
  /**
1655
1769
  * Set the backing store of the indexed properties to be managed by the
@@ -1658,93 +1772,83 @@ class Object : public Value {
1658
1772
  * Note: The embedding program still owns the data and needs to ensure that
1659
1773
  * the backing store is preserved while V8 has a reference.
1660
1774
  */
1661
- V8EXPORT void SetIndexedPropertiesToExternalArrayData(
1662
- void* data,
1663
- ExternalArrayType array_type,
1664
- int number_of_elements);
1665
- V8EXPORT bool HasIndexedPropertiesInExternalArrayData();
1666
- V8EXPORT void* GetIndexedPropertiesExternalArrayData();
1667
- V8EXPORT ExternalArrayType GetIndexedPropertiesExternalArrayDataType();
1668
- V8EXPORT int GetIndexedPropertiesExternalArrayDataLength();
1775
+ void SetIndexedPropertiesToExternalArrayData(void* data,
1776
+ ExternalArrayType array_type,
1777
+ int number_of_elements);
1778
+ bool HasIndexedPropertiesInExternalArrayData();
1779
+ void* GetIndexedPropertiesExternalArrayData();
1780
+ ExternalArrayType GetIndexedPropertiesExternalArrayDataType();
1781
+ int GetIndexedPropertiesExternalArrayDataLength();
1669
1782
 
1670
1783
  /**
1671
1784
  * Checks whether a callback is set by the
1672
1785
  * ObjectTemplate::SetCallAsFunctionHandler method.
1673
1786
  * When an Object is callable this method returns true.
1674
1787
  */
1675
- V8EXPORT bool IsCallable();
1788
+ bool IsCallable();
1676
1789
 
1677
1790
  /**
1678
1791
  * Call an Object as a function if a callback is set by the
1679
1792
  * ObjectTemplate::SetCallAsFunctionHandler method.
1680
1793
  */
1681
- V8EXPORT Local<Value> CallAsFunction(Handle<Object> recv,
1682
- int argc,
1683
- Handle<Value> argv[]);
1794
+ Local<Value> CallAsFunction(Handle<Object> recv,
1795
+ int argc,
1796
+ Handle<Value> argv[]);
1684
1797
 
1685
1798
  /**
1686
1799
  * Call an Object as a constructor if a callback is set by the
1687
1800
  * ObjectTemplate::SetCallAsFunctionHandler method.
1688
1801
  * Note: This method behaves like the Function::NewInstance method.
1689
1802
  */
1690
- V8EXPORT Local<Value> CallAsConstructor(int argc,
1691
- Handle<Value> argv[]);
1803
+ Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]);
1692
1804
 
1693
- V8EXPORT static Local<Object> New();
1694
- static inline Object* Cast(Value* obj);
1805
+ static Local<Object> New();
1806
+ V8_INLINE(static Object* Cast(Value* obj));
1695
1807
 
1696
1808
  private:
1697
- V8EXPORT Object();
1698
- V8EXPORT static void CheckCast(Value* obj);
1699
- V8EXPORT Local<Value> CheckedGetInternalField(int index);
1700
- V8EXPORT void* SlowGetPointerFromInternalField(int index);
1701
-
1702
- /**
1703
- * If quick access to the internal field is possible this method
1704
- * returns the value. Otherwise an empty handle is returned.
1705
- */
1706
- inline Local<Value> UncheckedGetInternalField(int index);
1809
+ Object();
1810
+ static void CheckCast(Value* obj);
1811
+ Local<Value> SlowGetInternalField(int index);
1812
+ void* SlowGetAlignedPointerFromInternalField(int index);
1707
1813
  };
1708
1814
 
1709
1815
 
1710
1816
  /**
1711
1817
  * An instance of the built-in array constructor (ECMA-262, 15.4.2).
1712
1818
  */
1713
- class Array : public Object {
1819
+ class V8EXPORT Array : public Object {
1714
1820
  public:
1715
- V8EXPORT uint32_t Length() const;
1821
+ uint32_t Length() const;
1716
1822
 
1717
1823
  /**
1718
1824
  * Clones an element at index |index|. Returns an empty
1719
1825
  * handle if cloning fails (for any reason).
1720
1826
  */
1721
- V8EXPORT Local<Object> CloneElementAt(uint32_t index);
1827
+ Local<Object> CloneElementAt(uint32_t index);
1722
1828
 
1723
1829
  /**
1724
1830
  * Creates a JavaScript array with the given length. If the length
1725
1831
  * is negative the returned array will have length 0.
1726
1832
  */
1727
- V8EXPORT static Local<Array> New(int length = 0);
1833
+ static Local<Array> New(int length = 0);
1728
1834
 
1729
- static inline Array* Cast(Value* obj);
1835
+ V8_INLINE(static Array* Cast(Value* obj));
1730
1836
  private:
1731
- V8EXPORT Array();
1732
- V8EXPORT static void CheckCast(Value* obj);
1837
+ Array();
1838
+ static void CheckCast(Value* obj);
1733
1839
  };
1734
1840
 
1735
1841
 
1736
1842
  /**
1737
1843
  * A JavaScript function object (ECMA-262, 15.3).
1738
1844
  */
1739
- class Function : public Object {
1845
+ class V8EXPORT Function : public Object {
1740
1846
  public:
1741
- V8EXPORT Local<Object> NewInstance() const;
1742
- V8EXPORT Local<Object> NewInstance(int argc, Handle<Value> argv[]) const;
1743
- V8EXPORT Local<Value> Call(Handle<Object> recv,
1744
- int argc,
1745
- Handle<Value> argv[]);
1746
- V8EXPORT void SetName(Handle<String> name);
1747
- V8EXPORT Handle<Value> GetName() const;
1847
+ Local<Object> NewInstance() const;
1848
+ Local<Object> NewInstance(int argc, Handle<Value> argv[]) const;
1849
+ Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]);
1850
+ void SetName(Handle<String> name);
1851
+ Handle<Value> GetName() const;
1748
1852
 
1749
1853
  /**
1750
1854
  * Name inferred from variable or property assignment of this function.
@@ -1752,43 +1856,43 @@ class Function : public Object {
1752
1856
  * in an OO style, where many functions are anonymous but are assigned
1753
1857
  * to object properties.
1754
1858
  */
1755
- V8EXPORT Handle<Value> GetInferredName() const;
1859
+ Handle<Value> GetInferredName() const;
1756
1860
 
1757
1861
  /**
1758
1862
  * Returns zero based line number of function body and
1759
1863
  * kLineOffsetNotFound if no information available.
1760
1864
  */
1761
- V8EXPORT int GetScriptLineNumber() const;
1865
+ int GetScriptLineNumber() const;
1762
1866
  /**
1763
1867
  * Returns zero based column number of function body and
1764
1868
  * kLineOffsetNotFound if no information available.
1765
1869
  */
1766
- V8EXPORT int GetScriptColumnNumber() const;
1767
- V8EXPORT Handle<Value> GetScriptId() const;
1768
- V8EXPORT ScriptOrigin GetScriptOrigin() const;
1769
- static inline Function* Cast(Value* obj);
1770
- V8EXPORT static const int kLineOffsetNotFound;
1870
+ int GetScriptColumnNumber() const;
1871
+ Handle<Value> GetScriptId() const;
1872
+ ScriptOrigin GetScriptOrigin() const;
1873
+ V8_INLINE(static Function* Cast(Value* obj));
1874
+ static const int kLineOffsetNotFound;
1771
1875
 
1772
1876
  private:
1773
- V8EXPORT Function();
1774
- V8EXPORT static void CheckCast(Value* obj);
1877
+ Function();
1878
+ static void CheckCast(Value* obj);
1775
1879
  };
1776
1880
 
1777
1881
 
1778
1882
  /**
1779
1883
  * An instance of the built-in Date constructor (ECMA-262, 15.9).
1780
1884
  */
1781
- class Date : public Object {
1885
+ class V8EXPORT Date : public Object {
1782
1886
  public:
1783
- V8EXPORT static Local<Value> New(double time);
1887
+ static Local<Value> New(double time);
1784
1888
 
1785
1889
  /**
1786
1890
  * A specialization of Value::NumberValue that is more efficient
1787
1891
  * because we know the structure of this object.
1788
1892
  */
1789
- V8EXPORT double NumberValue() const;
1893
+ double NumberValue() const;
1790
1894
 
1791
- static inline Date* Cast(v8::Value* obj);
1895
+ V8_INLINE(static Date* Cast(v8::Value* obj));
1792
1896
 
1793
1897
  /**
1794
1898
  * Notification that the embedder has changed the time zone,
@@ -1802,74 +1906,74 @@ class Date : public Object {
1802
1906
  * This API should not be called more than needed as it will
1803
1907
  * negatively impact the performance of date operations.
1804
1908
  */
1805
- V8EXPORT static void DateTimeConfigurationChangeNotification();
1909
+ static void DateTimeConfigurationChangeNotification();
1806
1910
 
1807
1911
  private:
1808
- V8EXPORT static void CheckCast(v8::Value* obj);
1912
+ static void CheckCast(v8::Value* obj);
1809
1913
  };
1810
1914
 
1811
1915
 
1812
1916
  /**
1813
1917
  * A Number object (ECMA-262, 4.3.21).
1814
1918
  */
1815
- class NumberObject : public Object {
1919
+ class V8EXPORT NumberObject : public Object {
1816
1920
  public:
1817
- V8EXPORT static Local<Value> New(double value);
1921
+ static Local<Value> New(double value);
1818
1922
 
1819
1923
  /**
1820
1924
  * Returns the Number held by the object.
1821
1925
  */
1822
- V8EXPORT double NumberValue() const;
1926
+ double NumberValue() const;
1823
1927
 
1824
- static inline NumberObject* Cast(v8::Value* obj);
1928
+ V8_INLINE(static NumberObject* Cast(v8::Value* obj));
1825
1929
 
1826
1930
  private:
1827
- V8EXPORT static void CheckCast(v8::Value* obj);
1931
+ static void CheckCast(v8::Value* obj);
1828
1932
  };
1829
1933
 
1830
1934
 
1831
1935
  /**
1832
1936
  * A Boolean object (ECMA-262, 4.3.15).
1833
1937
  */
1834
- class BooleanObject : public Object {
1938
+ class V8EXPORT BooleanObject : public Object {
1835
1939
  public:
1836
- V8EXPORT static Local<Value> New(bool value);
1940
+ static Local<Value> New(bool value);
1837
1941
 
1838
1942
  /**
1839
1943
  * Returns the Boolean held by the object.
1840
1944
  */
1841
- V8EXPORT bool BooleanValue() const;
1945
+ bool BooleanValue() const;
1842
1946
 
1843
- static inline BooleanObject* Cast(v8::Value* obj);
1947
+ V8_INLINE(static BooleanObject* Cast(v8::Value* obj));
1844
1948
 
1845
1949
  private:
1846
- V8EXPORT static void CheckCast(v8::Value* obj);
1950
+ static void CheckCast(v8::Value* obj);
1847
1951
  };
1848
1952
 
1849
1953
 
1850
1954
  /**
1851
1955
  * A String object (ECMA-262, 4.3.18).
1852
1956
  */
1853
- class StringObject : public Object {
1957
+ class V8EXPORT StringObject : public Object {
1854
1958
  public:
1855
- V8EXPORT static Local<Value> New(Handle<String> value);
1959
+ static Local<Value> New(Handle<String> value);
1856
1960
 
1857
1961
  /**
1858
1962
  * Returns the String held by the object.
1859
1963
  */
1860
- V8EXPORT Local<String> StringValue() const;
1964
+ Local<String> StringValue() const;
1861
1965
 
1862
- static inline StringObject* Cast(v8::Value* obj);
1966
+ V8_INLINE(static StringObject* Cast(v8::Value* obj));
1863
1967
 
1864
1968
  private:
1865
- V8EXPORT static void CheckCast(v8::Value* obj);
1969
+ static void CheckCast(v8::Value* obj);
1866
1970
  };
1867
1971
 
1868
1972
 
1869
1973
  /**
1870
1974
  * An instance of the built-in RegExp constructor (ECMA-262, 15.10).
1871
1975
  */
1872
- class RegExp : public Object {
1976
+ class V8EXPORT RegExp : public Object {
1873
1977
  public:
1874
1978
  /**
1875
1979
  * Regular expression flag bits. They can be or'ed to enable a set
@@ -1892,51 +1996,37 @@ class RegExp : public Object {
1892
1996
  * static_cast<RegExp::Flags>(kGlobal | kMultiline))
1893
1997
  * is equivalent to evaluating "/foo/gm".
1894
1998
  */
1895
- V8EXPORT static Local<RegExp> New(Handle<String> pattern,
1896
- Flags flags);
1999
+ static Local<RegExp> New(Handle<String> pattern, Flags flags);
1897
2000
 
1898
2001
  /**
1899
2002
  * Returns the value of the source property: a string representing
1900
2003
  * the regular expression.
1901
2004
  */
1902
- V8EXPORT Local<String> GetSource() const;
2005
+ Local<String> GetSource() const;
1903
2006
 
1904
2007
  /**
1905
2008
  * Returns the flags bit field.
1906
2009
  */
1907
- V8EXPORT Flags GetFlags() const;
2010
+ Flags GetFlags() const;
1908
2011
 
1909
- static inline RegExp* Cast(v8::Value* obj);
2012
+ V8_INLINE(static RegExp* Cast(v8::Value* obj));
1910
2013
 
1911
2014
  private:
1912
- V8EXPORT static void CheckCast(v8::Value* obj);
2015
+ static void CheckCast(v8::Value* obj);
1913
2016
  };
1914
2017
 
1915
2018
 
1916
2019
  /**
1917
- * A JavaScript value that wraps a C++ void*. This type of value is
1918
- * mainly used to associate C++ data structures with JavaScript
1919
- * objects.
1920
- *
1921
- * The Wrap function V8 will return the most optimal Value object wrapping the
1922
- * C++ void*. The type of the value is not guaranteed to be an External object
1923
- * and no assumptions about its type should be made. To access the wrapped
1924
- * value Unwrap should be used, all other operations on that object will lead
1925
- * to unpredictable results.
2020
+ * A JavaScript value that wraps a C++ void*. This type of value is mainly used
2021
+ * to associate C++ data structures with JavaScript objects.
1926
2022
  */
1927
- class External : public Value {
2023
+ class V8EXPORT External : public Value {
1928
2024
  public:
1929
- V8EXPORT static Local<Value> Wrap(void* data);
1930
- static inline void* Unwrap(Handle<Value> obj);
1931
-
1932
- V8EXPORT static Local<External> New(void* value);
1933
- static inline External* Cast(Value* obj);
1934
- V8EXPORT void* Value() const;
2025
+ static Local<External> New(void* value);
2026
+ V8_INLINE(static External* Cast(Value* obj));
2027
+ void* Value() const;
1935
2028
  private:
1936
- V8EXPORT External();
1937
- V8EXPORT static void CheckCast(v8::Value* obj);
1938
- static inline void* QuickUnwrap(Handle<v8::Value> obj);
1939
- V8EXPORT static void* FullUnwrap(Handle<v8::Value> obj);
2029
+ static void CheckCast(v8::Value* obj);
1940
2030
  };
1941
2031
 
1942
2032
 
@@ -1951,7 +2041,7 @@ class V8EXPORT Template : public Data {
1951
2041
  /** Adds a property to each instance created by this template.*/
1952
2042
  void Set(Handle<String> name, Handle<Data> value,
1953
2043
  PropertyAttribute attributes = None);
1954
- inline void Set(const char* name, Handle<Data> value);
2044
+ V8_INLINE(void Set(const char* name, Handle<Data> value));
1955
2045
  private:
1956
2046
  Template();
1957
2047
 
@@ -1966,16 +2056,16 @@ class V8EXPORT Template : public Data {
1966
2056
  * including the receiver, the number and values of arguments, and
1967
2057
  * the holder of the function.
1968
2058
  */
1969
- class Arguments {
2059
+ class V8EXPORT Arguments {
1970
2060
  public:
1971
- inline int Length() const;
1972
- inline Local<Value> operator[](int i) const;
1973
- inline Local<Function> Callee() const;
1974
- inline Local<Object> This() const;
1975
- inline Local<Object> Holder() const;
1976
- inline bool IsConstructCall() const;
1977
- inline Local<Value> Data() const;
1978
- inline Isolate* GetIsolate() const;
2061
+ V8_INLINE(int Length() const);
2062
+ V8_INLINE(Local<Value> operator[](int i) const);
2063
+ V8_INLINE(Local<Function> Callee() const);
2064
+ V8_INLINE(Local<Object> This() const);
2065
+ V8_INLINE(Local<Object> Holder() const);
2066
+ V8_INLINE(bool IsConstructCall() const);
2067
+ V8_INLINE(Local<Value> Data() const);
2068
+ V8_INLINE(Isolate* GetIsolate() const);
1979
2069
 
1980
2070
  private:
1981
2071
  static const int kIsolateIndex = 0;
@@ -1984,10 +2074,10 @@ class Arguments {
1984
2074
  static const int kHolderIndex = -3;
1985
2075
 
1986
2076
  friend class ImplementationUtilities;
1987
- inline Arguments(internal::Object** implicit_args,
2077
+ V8_INLINE(Arguments(internal::Object** implicit_args,
1988
2078
  internal::Object** values,
1989
2079
  int length,
1990
- bool is_construct_call);
2080
+ bool is_construct_call));
1991
2081
  internal::Object** implicit_args_;
1992
2082
  internal::Object** values_;
1993
2083
  int length_;
@@ -2001,12 +2091,12 @@ class Arguments {
2001
2091
  */
2002
2092
  class V8EXPORT AccessorInfo {
2003
2093
  public:
2004
- inline AccessorInfo(internal::Object** args)
2094
+ V8_INLINE(AccessorInfo(internal::Object** args))
2005
2095
  : args_(args) { }
2006
- inline Isolate* GetIsolate() const;
2007
- inline Local<Value> Data() const;
2008
- inline Local<Object> This() const;
2009
- inline Local<Object> Holder() const;
2096
+ V8_INLINE(Isolate* GetIsolate() const);
2097
+ V8_INLINE(Local<Value> Data() const);
2098
+ V8_INLINE(Local<Object> This() const);
2099
+ V8_INLINE(Local<Object> Holder() const);
2010
2100
 
2011
2101
  private:
2012
2102
  internal::Object** args_;
@@ -2224,7 +2314,8 @@ class V8EXPORT FunctionTemplate : public Template {
2224
2314
  static Local<FunctionTemplate> New(
2225
2315
  InvocationCallback callback = 0,
2226
2316
  Handle<Value> data = Handle<Value>(),
2227
- Handle<Signature> signature = Handle<Signature>());
2317
+ Handle<Signature> signature = Handle<Signature>(),
2318
+ int length = 0);
2228
2319
  /** Returns the unique function instance in the current execution context.*/
2229
2320
  Local<Function> GetFunction();
2230
2321
 
@@ -2236,6 +2327,9 @@ class V8EXPORT FunctionTemplate : public Template {
2236
2327
  void SetCallHandler(InvocationCallback callback,
2237
2328
  Handle<Value> data = Handle<Value>());
2238
2329
 
2330
+ /** Set the predefined length property for the FunctionTemplate. */
2331
+ void SetLength(int length);
2332
+
2239
2333
  /** Get the InstanceTemplate. */
2240
2334
  Local<ObjectTemplate> InstanceTemplate();
2241
2335
 
@@ -2248,7 +2342,6 @@ class V8EXPORT FunctionTemplate : public Template {
2248
2342
  */
2249
2343
  Local<ObjectTemplate> PrototypeTemplate();
2250
2344
 
2251
-
2252
2345
  /**
2253
2346
  * Set the class name of the FunctionTemplate. This is used for
2254
2347
  * printing objects created with the function created from the
@@ -2289,7 +2382,8 @@ class V8EXPORT FunctionTemplate : public Template {
2289
2382
  AccessorSetter setter,
2290
2383
  Handle<Value> data,
2291
2384
  AccessControl settings,
2292
- PropertyAttribute attributes);
2385
+ PropertyAttribute attributes,
2386
+ Handle<AccessorSignature> signature);
2293
2387
  void SetNamedInstancePropertyHandler(NamedPropertyGetter getter,
2294
2388
  NamedPropertySetter setter,
2295
2389
  NamedPropertyQuery query,
@@ -2347,13 +2441,20 @@ class V8EXPORT ObjectTemplate : public Template {
2347
2441
  * cross-context access.
2348
2442
  * \param attribute The attributes of the property for which an accessor
2349
2443
  * is added.
2444
+ * \param signature The signature describes valid receivers for the accessor
2445
+ * and is used to perform implicit instance checks against them. If the
2446
+ * receiver is incompatible (i.e. is not an instance of the constructor as
2447
+ * defined by FunctionTemplate::HasInstance()), an implicit TypeError is
2448
+ * thrown and no callback is invoked.
2350
2449
  */
2351
2450
  void SetAccessor(Handle<String> name,
2352
2451
  AccessorGetter getter,
2353
2452
  AccessorSetter setter = 0,
2354
2453
  Handle<Value> data = Handle<Value>(),
2355
2454
  AccessControl settings = DEFAULT,
2356
- PropertyAttribute attribute = None);
2455
+ PropertyAttribute attribute = None,
2456
+ Handle<AccessorSignature> signature =
2457
+ Handle<AccessorSignature>());
2357
2458
 
2358
2459
  /**
2359
2460
  * Sets a named property handler on the object template.
@@ -2457,8 +2558,8 @@ class V8EXPORT ObjectTemplate : public Template {
2457
2558
 
2458
2559
 
2459
2560
  /**
2460
- * A Signature specifies which receivers and arguments a function can
2461
- * legally be called with.
2561
+ * A Signature specifies which receivers and arguments are valid
2562
+ * parameters to a function.
2462
2563
  */
2463
2564
  class V8EXPORT Signature : public Data {
2464
2565
  public:
@@ -2471,6 +2572,19 @@ class V8EXPORT Signature : public Data {
2471
2572
  };
2472
2573
 
2473
2574
 
2575
+ /**
2576
+ * An AccessorSignature specifies which receivers are valid parameters
2577
+ * to an accessor callback.
2578
+ */
2579
+ class V8EXPORT AccessorSignature : public Data {
2580
+ public:
2581
+ static Local<AccessorSignature> New(Handle<FunctionTemplate> receiver =
2582
+ Handle<FunctionTemplate>());
2583
+ private:
2584
+ AccessorSignature();
2585
+ };
2586
+
2587
+
2474
2588
  /**
2475
2589
  * A utility for determining the type of objects based on the template
2476
2590
  * they were constructed from.
@@ -2550,7 +2664,7 @@ void V8EXPORT RegisterExtension(Extension* extension);
2550
2664
  */
2551
2665
  class V8EXPORT DeclareExtension {
2552
2666
  public:
2553
- inline DeclareExtension(Extension* extension) {
2667
+ V8_INLINE(DeclareExtension(Extension* extension)) {
2554
2668
  RegisterExtension(extension);
2555
2669
  }
2556
2670
  };
@@ -2564,10 +2678,10 @@ Handle<Primitive> V8EXPORT Null();
2564
2678
  Handle<Boolean> V8EXPORT True();
2565
2679
  Handle<Boolean> V8EXPORT False();
2566
2680
 
2567
- inline Handle<Primitive> Undefined(Isolate* isolate);
2568
- inline Handle<Primitive> Null(Isolate* isolate);
2569
- inline Handle<Boolean> True(Isolate* isolate);
2570
- inline Handle<Boolean> False(Isolate* isolate);
2681
+ V8_INLINE(Handle<Primitive> Undefined(Isolate* isolate));
2682
+ V8_INLINE(Handle<Primitive> Null(Isolate* isolate));
2683
+ V8_INLINE(Handle<Boolean> True(Isolate* isolate));
2684
+ V8_INLINE(Handle<Boolean> False(Isolate* isolate));
2571
2685
 
2572
2686
 
2573
2687
  /**
@@ -2608,7 +2722,7 @@ bool V8EXPORT SetResourceConstraints(ResourceConstraints* constraints);
2608
2722
  typedef void (*FatalErrorCallback)(const char* location, const char* message);
2609
2723
 
2610
2724
 
2611
- typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> data);
2725
+ typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> error);
2612
2726
 
2613
2727
 
2614
2728
  /**
@@ -2721,6 +2835,7 @@ class V8EXPORT HeapStatistics {
2721
2835
  HeapStatistics();
2722
2836
  size_t total_heap_size() { return total_heap_size_; }
2723
2837
  size_t total_heap_size_executable() { return total_heap_size_executable_; }
2838
+ size_t total_physical_size() { return total_physical_size_; }
2724
2839
  size_t used_heap_size() { return used_heap_size_; }
2725
2840
  size_t heap_size_limit() { return heap_size_limit_; }
2726
2841
 
@@ -2729,11 +2844,15 @@ class V8EXPORT HeapStatistics {
2729
2844
  void set_total_heap_size_executable(size_t size) {
2730
2845
  total_heap_size_executable_ = size;
2731
2846
  }
2847
+ void set_total_physical_size(size_t size) {
2848
+ total_physical_size_ = size;
2849
+ }
2732
2850
  void set_used_heap_size(size_t size) { used_heap_size_ = size; }
2733
2851
  void set_heap_size_limit(size_t size) { heap_size_limit_ = size; }
2734
2852
 
2735
2853
  size_t total_heap_size_;
2736
2854
  size_t total_heap_size_executable_;
2855
+ size_t total_physical_size_;
2737
2856
  size_t used_heap_size_;
2738
2857
  size_t heap_size_limit_;
2739
2858
 
@@ -2819,13 +2938,13 @@ class V8EXPORT Isolate {
2819
2938
  /**
2820
2939
  * Associate embedder-specific data with the isolate
2821
2940
  */
2822
- inline void SetData(void* data);
2941
+ V8_INLINE(void SetData(void* data));
2823
2942
 
2824
2943
  /**
2825
2944
  * Retrieve embedder-specific data from the isolate.
2826
2945
  * Returns NULL if SetData has never been called.
2827
2946
  */
2828
- inline void* GetData();
2947
+ V8_INLINE(void* GetData());
2829
2948
 
2830
2949
  private:
2831
2950
  Isolate();
@@ -2837,7 +2956,7 @@ class V8EXPORT Isolate {
2837
2956
  };
2838
2957
 
2839
2958
 
2840
- class StartupData {
2959
+ class V8EXPORT StartupData {
2841
2960
  public:
2842
2961
  enum CompressionAlgorithm {
2843
2962
  kUncompressed,
@@ -2887,17 +3006,86 @@ typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
2887
3006
  * resolving the location of a return address on the stack. Profilers that
2888
3007
  * change the return address on the stack can use this to resolve the stack
2889
3008
  * location to whereever the profiler stashed the original return address.
2890
- * When invoked, return_addr_location will point to a location on stack where
2891
- * a machine return address resides, this function should return either the
2892
- * same pointer, or a pointer to the profiler's copy of the original return
2893
- * address.
3009
+ *
3010
+ * \param return_addr_location points to a location on stack where a machine
3011
+ * return address resides.
3012
+ * \returns either return_addr_location, or else a pointer to the profiler's
3013
+ * copy of the original return address.
3014
+ *
3015
+ * \note the resolver function must not cause garbage collection.
2894
3016
  */
2895
3017
  typedef uintptr_t (*ReturnAddressLocationResolver)(
2896
3018
  uintptr_t return_addr_location);
2897
3019
 
2898
3020
 
2899
3021
  /**
2900
- * Interface for iterating though all external resources in the heap.
3022
+ * FunctionEntryHook is the type of the profile entry hook called at entry to
3023
+ * any generated function when function-level profiling is enabled.
3024
+ *
3025
+ * \param function the address of the function that's being entered.
3026
+ * \param return_addr_location points to a location on stack where the machine
3027
+ * return address resides. This can be used to identify the caller of
3028
+ * \p function, and/or modified to divert execution when \p function exits.
3029
+ *
3030
+ * \note the entry hook must not cause garbage collection.
3031
+ */
3032
+ typedef void (*FunctionEntryHook)(uintptr_t function,
3033
+ uintptr_t return_addr_location);
3034
+
3035
+
3036
+ /**
3037
+ * A JIT code event is issued each time code is added, moved or removed.
3038
+ *
3039
+ * \note removal events are not currently issued.
3040
+ */
3041
+ struct JitCodeEvent {
3042
+ enum EventType {
3043
+ CODE_ADDED,
3044
+ CODE_MOVED,
3045
+ CODE_REMOVED
3046
+ };
3047
+
3048
+ // Type of event.
3049
+ EventType type;
3050
+ // Start of the instructions.
3051
+ void* code_start;
3052
+ // Size of the instructions.
3053
+ size_t code_len;
3054
+
3055
+ union {
3056
+ // Only valid for CODE_ADDED.
3057
+ struct {
3058
+ // Name of the object associated with the code, note that the string is
3059
+ // not zero-terminated.
3060
+ const char* str;
3061
+ // Number of chars in str.
3062
+ size_t len;
3063
+ } name;
3064
+ // New location of instructions. Only valid for CODE_MOVED.
3065
+ void* new_code_start;
3066
+ };
3067
+ };
3068
+
3069
+ /**
3070
+ * Option flags passed to the SetJitCodeEventHandler function.
3071
+ */
3072
+ enum JitCodeEventOptions {
3073
+ kJitCodeEventDefault = 0,
3074
+ // Generate callbacks for already existent code.
3075
+ kJitCodeEventEnumExisting = 1
3076
+ };
3077
+
3078
+
3079
+ /**
3080
+ * Callback function passed to SetJitCodeEventHandler.
3081
+ *
3082
+ * \param event code add, move or removal event.
3083
+ */
3084
+ typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
3085
+
3086
+
3087
+ /**
3088
+ * Interface for iterating through all external resources in the heap.
2901
3089
  */
2902
3090
  class V8EXPORT ExternalResourceVisitor { // NOLINT
2903
3091
  public:
@@ -2906,6 +3094,17 @@ class V8EXPORT ExternalResourceVisitor { // NOLINT
2906
3094
  };
2907
3095
 
2908
3096
 
3097
+ /**
3098
+ * Interface for iterating through all the persistent handles in the heap.
3099
+ */
3100
+ class V8EXPORT PersistentHandleVisitor { // NOLINT
3101
+ public:
3102
+ virtual ~PersistentHandleVisitor() {}
3103
+ virtual void VisitPersistentHandle(Persistent<Value> value,
3104
+ uint16_t class_id) {}
3105
+ };
3106
+
3107
+
2909
3108
  /**
2910
3109
  * Container class for static utility functions.
2911
3110
  */
@@ -2971,8 +3170,7 @@ class V8EXPORT V8 {
2971
3170
  * The same message listener can be added more than once and in that
2972
3171
  * case it will be called more than once for each message.
2973
3172
  */
2974
- static bool AddMessageListener(MessageCallback that,
2975
- Handle<Value> data = Handle<Value>());
3173
+ static bool AddMessageListener(MessageCallback that);
2976
3174
 
2977
3175
  /**
2978
3176
  * Remove all message listeners from the specified callback function.
@@ -3018,12 +3216,6 @@ class V8EXPORT V8 {
3018
3216
  static void SetCreateHistogramFunction(CreateHistogramCallback);
3019
3217
  static void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
3020
3218
 
3021
- /**
3022
- * Enables the computation of a sliding window of states. The sliding
3023
- * window information is recorded in statistics counters.
3024
- */
3025
- static void EnableSlidingStateWindow();
3026
-
3027
3219
  /** Callback function for reporting failed access checks.*/
3028
3220
  static void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
3029
3221
 
@@ -3054,7 +3246,7 @@ class V8EXPORT V8 {
3054
3246
  * or delete properties for example) since it is possible such
3055
3247
  * operations will result in the allocation of objects.
3056
3248
  */
3057
- static void SetGlobalGCPrologueCallback(GCCallback);
3249
+ V8_DEPRECATED(static void SetGlobalGCPrologueCallback(GCCallback));
3058
3250
 
3059
3251
  /**
3060
3252
  * Enables the host application to receive a notification after a
@@ -3083,7 +3275,7 @@ class V8EXPORT V8 {
3083
3275
  * or delete properties for example) since it is possible such
3084
3276
  * operations will result in the allocation of objects.
3085
3277
  */
3086
- static void SetGlobalGCEpilogueCallback(GCCallback);
3278
+ V8_DEPRECATED(static void SetGlobalGCEpilogueCallback(GCCallback));
3087
3279
 
3088
3280
  /**
3089
3281
  * Enables the host application to provide a mechanism to be notified
@@ -3118,12 +3310,19 @@ class V8EXPORT V8 {
3118
3310
  * After each garbage collection, object groups are removed. It is
3119
3311
  * intended to be used in the before-garbage-collection callback
3120
3312
  * function, for instance to simulate DOM tree connections among JS
3121
- * wrapper objects.
3313
+ * wrapper objects. Object groups for all dependent handles need to
3314
+ * be provided for kGCTypeMarkSweepCompact collections, for all other
3315
+ * garbage collection types it is sufficient to provide object groups
3316
+ * for partially dependent handles only.
3122
3317
  * See v8-profiler.h for RetainedObjectInfo interface description.
3123
3318
  */
3124
3319
  static void AddObjectGroup(Persistent<Value>* objects,
3125
3320
  size_t length,
3126
3321
  RetainedObjectInfo* info = NULL);
3322
+ static void AddObjectGroup(Isolate* isolate,
3323
+ Persistent<Value>* objects,
3324
+ size_t length,
3325
+ RetainedObjectInfo* info = NULL);
3127
3326
 
3128
3327
  /**
3129
3328
  * Allows the host application to declare implicit references between
@@ -3156,6 +3355,43 @@ class V8EXPORT V8 {
3156
3355
  static void SetReturnAddressLocationResolver(
3157
3356
  ReturnAddressLocationResolver return_address_resolver);
3158
3357
 
3358
+ /**
3359
+ * Allows the host application to provide the address of a function that's
3360
+ * invoked on entry to every V8-generated function.
3361
+ * Note that \p entry_hook is invoked at the very start of each
3362
+ * generated function.
3363
+ *
3364
+ * \param entry_hook a function that will be invoked on entry to every
3365
+ * V8-generated function.
3366
+ * \returns true on success on supported platforms, false on failure.
3367
+ * \note Setting a new entry hook function when one is already active will
3368
+ * fail.
3369
+ */
3370
+ static bool SetFunctionEntryHook(FunctionEntryHook entry_hook);
3371
+
3372
+ /**
3373
+ * Allows the host application to provide the address of a function that is
3374
+ * notified each time code is added, moved or removed.
3375
+ *
3376
+ * \param options options for the JIT code event handler.
3377
+ * \param event_handler the JIT code event handler, which will be invoked
3378
+ * each time code is added, moved or removed.
3379
+ * \note \p event_handler won't get notified of existent code.
3380
+ * \note since code removal notifications are not currently issued, the
3381
+ * \p event_handler may get notifications of code that overlaps earlier
3382
+ * code notifications. This happens when code areas are reused, and the
3383
+ * earlier overlapping code areas should therefore be discarded.
3384
+ * \note the events passed to \p event_handler and the strings they point to
3385
+ * are not guaranteed to live past each call. The \p event_handler must
3386
+ * copy strings and other parameters it needs to keep around.
3387
+ * \note the set of events declared in JitCodeEvent::EventType is expected to
3388
+ * grow over time, and the JitCodeEvent structure is expected to accrue
3389
+ * new members. The \p event_handler function must ignore event codes
3390
+ * it does not recognize to maintain future compatibility.
3391
+ */
3392
+ static void SetJitCodeEventHandler(JitCodeEventOptions options,
3393
+ JitCodeEventHandler event_handler);
3394
+
3159
3395
  /**
3160
3396
  * Adjusts the amount of registered external memory. Used to give
3161
3397
  * V8 an indication of the amount of externally allocated memory
@@ -3271,11 +3507,27 @@ class V8EXPORT V8 {
3271
3507
 
3272
3508
  /**
3273
3509
  * Iterates through all external resources referenced from current isolate
3274
- * heap. This method is not expected to be used except for debugging purposes
3275
- * and may be quite slow.
3510
+ * heap. GC is not invoked prior to iterating, therefore there is no
3511
+ * guarantee that visited objects are still alive.
3276
3512
  */
3277
3513
  static void VisitExternalResources(ExternalResourceVisitor* visitor);
3278
3514
 
3515
+ /**
3516
+ * Iterates through all the persistent handles in the current isolate's heap
3517
+ * that have class_ids.
3518
+ */
3519
+ static void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
3520
+
3521
+ /**
3522
+ * Iterates through all the persistent handles in the current isolate's heap
3523
+ * that have class_ids and are candidates to be marked as partially dependent
3524
+ * handles. This will visit handles to young objects created since the last
3525
+ * garbage collection but is free to visit an arbitrary superset of these
3526
+ * objects.
3527
+ */
3528
+ static void VisitHandlesForPartialDependence(
3529
+ Isolate* isolate, PersistentHandleVisitor* visitor);
3530
+
3279
3531
  /**
3280
3532
  * Optional notification that the embedder is idle.
3281
3533
  * V8 uses the notification to reduce memory footprint.
@@ -3307,17 +3559,17 @@ class V8EXPORT V8 {
3307
3559
  private:
3308
3560
  V8();
3309
3561
 
3310
- static internal::Object** GlobalizeReference(internal::Object** handle);
3311
- static void DisposeGlobal(internal::Object** global_handle);
3312
- static void MakeWeak(internal::Object** global_handle,
3562
+ static internal::Object** GlobalizeReference(internal::Isolate* isolate,
3563
+ internal::Object** handle);
3564
+ static void DisposeGlobal(internal::Isolate* isolate,
3565
+ internal::Object** global_handle);
3566
+ static void MakeWeak(internal::Isolate* isolate,
3567
+ internal::Object** global_handle,
3313
3568
  void* data,
3314
- WeakReferenceCallback);
3315
- static void ClearWeak(internal::Object** global_handle);
3316
- static void MarkIndependent(internal::Object** global_handle);
3317
- static bool IsGlobalNearDeath(internal::Object** global_handle);
3318
- static bool IsGlobalWeak(internal::Object** global_handle);
3319
- static void SetWrapperClassId(internal::Object** global_handle,
3320
- uint16_t class_id);
3569
+ WeakReferenceCallback weak_reference_callback,
3570
+ NearDeathCallback near_death_callback);
3571
+ static void ClearWeak(internal::Isolate* isolate,
3572
+ internal::Object** global_handle);
3321
3573
 
3322
3574
  template <class T> friend class Handle;
3323
3575
  template <class T> friend class Local;
@@ -3332,7 +3584,9 @@ class V8EXPORT V8 {
3332
3584
  class V8EXPORT TryCatch {
3333
3585
  public:
3334
3586
  /**
3335
- * Creates a new try/catch block and registers it with v8.
3587
+ * Creates a new try/catch block and registers it with v8. Note that
3588
+ * all TryCatch blocks should be stack allocated because the memory
3589
+ * location itself is compared against JavaScript try/catch blocks.
3336
3590
  */
3337
3591
  TryCatch();
3338
3592
 
@@ -3422,6 +3676,12 @@ class V8EXPORT TryCatch {
3422
3676
  void SetCaptureMessage(bool value);
3423
3677
 
3424
3678
  private:
3679
+ // Make it hard to create heap-allocated TryCatch blocks.
3680
+ TryCatch(const TryCatch&);
3681
+ void operator=(const TryCatch&);
3682
+ void* operator new(size_t size);
3683
+ void operator delete(void*, size_t);
3684
+
3425
3685
  v8::internal::Isolate* isolate_;
3426
3686
  void* next_;
3427
3687
  void* exception_;
@@ -3562,13 +3822,37 @@ class V8EXPORT Context {
3562
3822
  /** Returns true if V8 has a current context. */
3563
3823
  static bool InContext();
3564
3824
 
3825
+ /** Returns an isolate associated with a current context. */
3826
+ v8::Isolate* GetIsolate();
3827
+
3565
3828
  /**
3566
- * Associate an additional data object with the context. This is mainly used
3567
- * with the debugger to provide additional information on the context through
3568
- * the debugger API.
3829
+ * Gets the embedder data with the given index, which must have been set by a
3830
+ * previous call to SetEmbedderData with the same index. Note that index 0
3831
+ * currently has a special meaning for Chrome's debugger.
3569
3832
  */
3570
- void SetData(Handle<String> data);
3571
- Local<Value> GetData();
3833
+ V8_INLINE(Local<Value> GetEmbedderData(int index));
3834
+
3835
+ /**
3836
+ * Sets the embedder data with the given index, growing the data as
3837
+ * needed. Note that index 0 currently has a special meaning for Chrome's
3838
+ * debugger.
3839
+ */
3840
+ void SetEmbedderData(int index, Handle<Value> value);
3841
+
3842
+ /**
3843
+ * Gets a 2-byte-aligned native pointer from the embedder data with the given
3844
+ * index, which must have bees set by a previous call to
3845
+ * SetAlignedPointerInEmbedderData with the same index. Note that index 0
3846
+ * currently has a special meaning for Chrome's debugger.
3847
+ */
3848
+ V8_INLINE(void* GetAlignedPointerFromEmbedderData(int index));
3849
+
3850
+ /**
3851
+ * Sets a 2-byte-aligned native pointer in the embedder data with the given
3852
+ * index, growing the data as needed. Note that index 0 currently has a
3853
+ * special meaning for Chrome's debugger.
3854
+ */
3855
+ void SetAlignedPointerInEmbedderData(int index, void* value);
3572
3856
 
3573
3857
  /**
3574
3858
  * Control whether code generation from strings is allowed. Calling
@@ -3591,16 +3875,23 @@ class V8EXPORT Context {
3591
3875
  */
3592
3876
  bool IsCodeGenerationFromStringsAllowed();
3593
3877
 
3878
+ /**
3879
+ * Sets the error description for the exception that is thrown when
3880
+ * code generation from strings is not allowed and 'eval' or the 'Function'
3881
+ * constructor are called.
3882
+ */
3883
+ void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message);
3884
+
3594
3885
  /**
3595
3886
  * Stack-allocated class which sets the execution context for all
3596
3887
  * operations executed within a local scope.
3597
3888
  */
3598
3889
  class Scope {
3599
3890
  public:
3600
- explicit inline Scope(Handle<Context> context) : context_(context) {
3891
+ explicit V8_INLINE(Scope(Handle<Context> context)) : context_(context) {
3601
3892
  context_->Enter();
3602
3893
  }
3603
- inline ~Scope() { context_->Exit(); }
3894
+ V8_INLINE(~Scope()) { context_->Exit(); }
3604
3895
  private:
3605
3896
  Handle<Context> context_;
3606
3897
  };
@@ -3610,25 +3901,26 @@ class V8EXPORT Context {
3610
3901
  friend class Script;
3611
3902
  friend class Object;
3612
3903
  friend class Function;
3904
+
3905
+ Local<Value> SlowGetEmbedderData(int index);
3906
+ void* SlowGetAlignedPointerFromEmbedderData(int index);
3613
3907
  };
3614
3908
 
3615
3909
 
3616
3910
  /**
3617
- * Multiple threads in V8 are allowed, but only one thread at a time
3618
- * is allowed to use any given V8 isolate. See Isolate class
3619
- * comments. The definition of 'using V8 isolate' includes
3620
- * accessing handles or holding onto object pointers obtained
3621
- * from V8 handles while in the particular V8 isolate. It is up
3622
- * to the user of V8 to ensure (perhaps with locking) that this
3623
- * constraint is not violated. In addition to any other synchronization
3624
- * mechanism that may be used, the v8::Locker and v8::Unlocker classes
3625
- * must be used to signal thead switches to V8.
3911
+ * Multiple threads in V8 are allowed, but only one thread at a time is allowed
3912
+ * to use any given V8 isolate, see the comments in the Isolate class. The
3913
+ * definition of 'using a V8 isolate' includes accessing handles or holding onto
3914
+ * object pointers obtained from V8 handles while in the particular V8 isolate.
3915
+ * It is up to the user of V8 to ensure, perhaps with locking, that this
3916
+ * constraint is not violated. In addition to any other synchronization
3917
+ * mechanism that may be used, the v8::Locker and v8::Unlocker classes must be
3918
+ * used to signal thead switches to V8.
3626
3919
  *
3627
- * v8::Locker is a scoped lock object. While it's
3628
- * active (i.e. between its construction and destruction) the current thread is
3629
- * allowed to use the locked isolate. V8 guarantees that an isolate can be
3630
- * locked by at most one thread at any time. In other words, the scope of a
3631
- * v8::Locker is a critical section.
3920
+ * v8::Locker is a scoped lock object. While it's active, i.e. between its
3921
+ * construction and destruction, the current thread is allowed to use the locked
3922
+ * isolate. V8 guarantees that an isolate can be locked by at most one thread at
3923
+ * any time. In other words, the scope of a v8::Locker is a critical section.
3632
3924
  *
3633
3925
  * Sample usage:
3634
3926
  * \code
@@ -3642,9 +3934,9 @@ class V8EXPORT Context {
3642
3934
  * } // Destructor called here
3643
3935
  * \endcode
3644
3936
  *
3645
- * If you wish to stop using V8 in a thread A you can do this either
3646
- * by destroying the v8::Locker object as above or by constructing a
3647
- * v8::Unlocker object:
3937
+ * If you wish to stop using V8 in a thread A you can do this either by
3938
+ * destroying the v8::Locker object as above or by constructing a v8::Unlocker
3939
+ * object:
3648
3940
  *
3649
3941
  * \code
3650
3942
  * {
@@ -3657,19 +3949,17 @@ class V8EXPORT Context {
3657
3949
  * isolate->Enter();
3658
3950
  * \endcode
3659
3951
  *
3660
- * The Unlocker object is intended for use in a long-running callback
3661
- * from V8, where you want to release the V8 lock for other threads to
3662
- * use.
3952
+ * The Unlocker object is intended for use in a long-running callback from V8,
3953
+ * where you want to release the V8 lock for other threads to use.
3663
3954
  *
3664
- * The v8::Locker is a recursive lock. That is, you can lock more than
3665
- * once in a given thread. This can be useful if you have code that can
3666
- * be called either from code that holds the lock or from code that does
3667
- * not. The Unlocker is not recursive so you can not have several
3668
- * Unlockers on the stack at once, and you can not use an Unlocker in a
3669
- * thread that is not inside a Locker's scope.
3955
+ * The v8::Locker is a recursive lock, i.e. you can lock more than once in a
3956
+ * given thread. This can be useful if you have code that can be called either
3957
+ * from code that holds the lock or from code that does not. The Unlocker is
3958
+ * not recursive so you can not have several Unlockers on the stack at once, and
3959
+ * you can not use an Unlocker in a thread that is not inside a Locker's scope.
3670
3960
  *
3671
- * An unlocker will unlock several lockers if it has to and reinstate
3672
- * the correct depth of locking on its destruction. eg.:
3961
+ * An unlocker will unlock several lockers if it has to and reinstate the
3962
+ * correct depth of locking on its destruction, e.g.:
3673
3963
  *
3674
3964
  * \code
3675
3965
  * // V8 not locked.
@@ -3692,17 +3982,21 @@ class V8EXPORT Context {
3692
3982
  * }
3693
3983
  * // V8 Now no longer locked.
3694
3984
  * \endcode
3695
- *
3696
- *
3697
3985
  */
3698
3986
  class V8EXPORT Unlocker {
3699
3987
  public:
3700
3988
  /**
3701
- * Initialize Unlocker for a given Isolate. NULL means default isolate.
3989
+ * Initialize Unlocker for a given Isolate.
3702
3990
  */
3703
- explicit Unlocker(Isolate* isolate = NULL);
3991
+ V8_INLINE(explicit Unlocker(Isolate* isolate)) { Initialize(isolate); }
3992
+
3993
+ /** Deprecated. Use Isolate version instead. */
3994
+ V8_DEPRECATED(Unlocker());
3995
+
3704
3996
  ~Unlocker();
3705
3997
  private:
3998
+ void Initialize(Isolate* isolate);
3999
+
3706
4000
  internal::Isolate* isolate_;
3707
4001
  };
3708
4002
 
@@ -3710,9 +4004,13 @@ class V8EXPORT Unlocker {
3710
4004
  class V8EXPORT Locker {
3711
4005
  public:
3712
4006
  /**
3713
- * Initialize Locker for a given Isolate. NULL means default isolate.
4007
+ * Initialize Locker for a given Isolate.
3714
4008
  */
3715
- explicit Locker(Isolate* isolate = NULL);
4009
+ V8_INLINE(explicit Locker(Isolate* isolate)) { Initialize(isolate); }
4010
+
4011
+ /** Deprecated. Use Isolate version instead. */
4012
+ V8_DEPRECATED(Locker());
4013
+
3716
4014
  ~Locker();
3717
4015
 
3718
4016
  /**
@@ -3730,10 +4028,10 @@ class V8EXPORT Locker {
3730
4028
  static void StopPreemption();
3731
4029
 
3732
4030
  /**
3733
- * Returns whether or not the locker for a given isolate, or default isolate
3734
- * if NULL is given, is locked by the current thread.
4031
+ * Returns whether or not the locker for a given isolate, is locked by the
4032
+ * current thread.
3735
4033
  */
3736
- static bool IsLocked(Isolate* isolate = NULL);
4034
+ static bool IsLocked(Isolate* isolate);
3737
4035
 
3738
4036
  /**
3739
4037
  * Returns whether v8::Locker is being used by this V8 instance.
@@ -3741,6 +4039,8 @@ class V8EXPORT Locker {
3741
4039
  static bool IsActive();
3742
4040
 
3743
4041
  private:
4042
+ void Initialize(Isolate* isolate);
4043
+
3744
4044
  bool has_lock_;
3745
4045
  bool top_level_;
3746
4046
  internal::Isolate* isolate_;
@@ -3838,47 +4138,27 @@ template <size_t ptr_size> struct SmiTagging;
3838
4138
  template <> struct SmiTagging<4> {
3839
4139
  static const int kSmiShiftSize = 0;
3840
4140
  static const int kSmiValueSize = 31;
3841
- static inline int SmiToInt(internal::Object* value) {
4141
+ V8_INLINE(static int SmiToInt(internal::Object* value)) {
3842
4142
  int shift_bits = kSmiTagSize + kSmiShiftSize;
3843
4143
  // Throw away top 32 bits and shift down (requires >> to be sign extending).
3844
4144
  return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
3845
4145
  }
3846
-
3847
- // For 32-bit systems any 2 bytes aligned pointer can be encoded as smi
3848
- // with a plain reinterpret_cast.
3849
- static const uintptr_t kEncodablePointerMask = 0x1;
3850
- static const int kPointerToSmiShift = 0;
3851
4146
  };
3852
4147
 
3853
4148
  // Smi constants for 64-bit systems.
3854
4149
  template <> struct SmiTagging<8> {
3855
4150
  static const int kSmiShiftSize = 31;
3856
4151
  static const int kSmiValueSize = 32;
3857
- static inline int SmiToInt(internal::Object* value) {
4152
+ V8_INLINE(static int SmiToInt(internal::Object* value)) {
3858
4153
  int shift_bits = kSmiTagSize + kSmiShiftSize;
3859
4154
  // Shift down and throw away top 32 bits.
3860
4155
  return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
3861
4156
  }
3862
-
3863
- // To maximize the range of pointers that can be encoded
3864
- // in the available 32 bits, we require them to be 8 bytes aligned.
3865
- // This gives 2 ^ (32 + 3) = 32G address space covered.
3866
- // It might be not enough to cover stack allocated objects on some platforms.
3867
- static const int kPointerAlignment = 3;
3868
-
3869
- static const uintptr_t kEncodablePointerMask =
3870
- ~(uintptr_t(0xffffffff) << kPointerAlignment);
3871
-
3872
- static const int kPointerToSmiShift =
3873
- kSmiTagSize + kSmiShiftSize - kPointerAlignment;
3874
4157
  };
3875
4158
 
3876
4159
  typedef SmiTagging<kApiPointerSize> PlatformSmiTagging;
3877
4160
  const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
3878
4161
  const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
3879
- const uintptr_t kEncodablePointerMask =
3880
- PlatformSmiTagging::kEncodablePointerMask;
3881
- const int kPointerToSmiShift = PlatformSmiTagging::kPointerToSmiShift;
3882
4162
 
3883
4163
  /**
3884
4164
  * This class exports constants and functionality from within v8 that
@@ -3896,8 +4176,13 @@ class Internals {
3896
4176
  static const int kOddballKindOffset = 3 * kApiPointerSize;
3897
4177
  static const int kForeignAddressOffset = kApiPointerSize;
3898
4178
  static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
4179
+ static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
4180
+ static const int kContextHeaderSize = 2 * kApiPointerSize;
4181
+ static const int kContextEmbedderDataIndex = 54;
3899
4182
  static const int kFullStringRepresentationMask = 0x07;
4183
+ static const int kStringEncodingMask = 0x4;
3900
4184
  static const int kExternalTwoByteRepresentationTag = 0x02;
4185
+ static const int kExternalAsciiRepresentationTag = 0x06;
3901
4186
 
3902
4187
  static const int kIsolateStateOffset = 0;
3903
4188
  static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize;
@@ -3906,9 +4191,17 @@ class Internals {
3906
4191
  static const int kNullValueRootIndex = 7;
3907
4192
  static const int kTrueValueRootIndex = 8;
3908
4193
  static const int kFalseValueRootIndex = 9;
3909
- static const int kEmptySymbolRootIndex = 128;
4194
+ static const int kEmptySymbolRootIndex = 119;
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;
4201
+ static const int kNodeIsIndependentShift = 4;
4202
+ static const int kNodeIsPartiallyDependentShift = 5;
3910
4203
 
3911
- static const int kJSObjectType = 0xaa;
4204
+ static const int kJSObjectType = 0xab;
3912
4205
  static const int kFirstNonstringType = 0x80;
3913
4206
  static const int kOddballType = 0x82;
3914
4207
  static const int kForeignType = 0x85;
@@ -3916,85 +4209,103 @@ class Internals {
3916
4209
  static const int kUndefinedOddballKind = 5;
3917
4210
  static const int kNullOddballKind = 3;
3918
4211
 
3919
- static inline bool HasHeapObjectTag(internal::Object* value) {
4212
+ V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) {
3920
4213
  return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
3921
4214
  kHeapObjectTag);
3922
4215
  }
3923
4216
 
3924
- static inline bool HasSmiTag(internal::Object* value) {
3925
- return ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag);
3926
- }
3927
-
3928
- static inline int SmiValue(internal::Object* value) {
4217
+ V8_INLINE(static int SmiValue(internal::Object* value)) {
3929
4218
  return PlatformSmiTagging::SmiToInt(value);
3930
4219
  }
3931
4220
 
3932
- static inline int GetInstanceType(internal::Object* obj) {
4221
+ V8_INLINE(static int GetInstanceType(internal::Object* obj)) {
3933
4222
  typedef internal::Object O;
3934
4223
  O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
3935
4224
  return ReadField<uint8_t>(map, kMapInstanceTypeOffset);
3936
4225
  }
3937
4226
 
3938
- static inline int GetOddballKind(internal::Object* obj) {
4227
+ V8_INLINE(static int GetOddballKind(internal::Object* obj)) {
3939
4228
  typedef internal::Object O;
3940
4229
  return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
3941
4230
  }
3942
4231
 
3943
- static inline void* GetExternalPointerFromSmi(internal::Object* value) {
3944
- const uintptr_t address = reinterpret_cast<uintptr_t>(value);
3945
- return reinterpret_cast<void*>(address >> kPointerToSmiShift);
3946
- }
3947
-
3948
- static inline void* GetExternalPointer(internal::Object* obj) {
3949
- if (HasSmiTag(obj)) {
3950
- return GetExternalPointerFromSmi(obj);
3951
- } else if (GetInstanceType(obj) == kForeignType) {
3952
- return ReadField<void*>(obj, kForeignAddressOffset);
3953
- } else {
3954
- return NULL;
3955
- }
3956
- }
3957
-
3958
- static inline bool IsExternalTwoByteString(int instance_type) {
4232
+ V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) {
3959
4233
  int representation = (instance_type & kFullStringRepresentationMask);
3960
4234
  return representation == kExternalTwoByteRepresentationTag;
3961
4235
  }
3962
4236
 
3963
- static inline bool IsInitialized(v8::Isolate* isolate) {
4237
+ V8_INLINE(static bool IsInitialized(v8::Isolate* isolate)) {
3964
4238
  uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset;
3965
4239
  return *reinterpret_cast<int*>(addr) == 1;
3966
4240
  }
3967
4241
 
3968
- static inline void SetEmbedderData(v8::Isolate* isolate, void* data) {
4242
+ V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) {
4243
+ uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
4244
+ return *addr & (1 << shift);
4245
+ }
4246
+
4247
+ V8_INLINE(static void UpdateNodeFlag(internal::Object** obj,
4248
+ bool value, int shift)) {
4249
+ uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
4250
+ uint8_t mask = 1 << shift;
4251
+ *addr = (*addr & ~mask) | (value << shift);
4252
+ }
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
+
4265
+ V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) {
3969
4266
  uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
3970
4267
  kIsolateEmbedderDataOffset;
3971
4268
  *reinterpret_cast<void**>(addr) = data;
3972
4269
  }
3973
4270
 
3974
- static inline void* GetEmbedderData(v8::Isolate* isolate) {
4271
+ V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) {
3975
4272
  uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
3976
4273
  kIsolateEmbedderDataOffset;
3977
4274
  return *reinterpret_cast<void**>(addr);
3978
4275
  }
3979
4276
 
3980
- static inline internal::Object** GetRoot(v8::Isolate* isolate, int index) {
4277
+ V8_INLINE(static internal::Object** GetRoot(v8::Isolate* isolate,
4278
+ int index)) {
3981
4279
  uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset;
3982
4280
  return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize);
3983
4281
  }
3984
4282
 
3985
4283
  template <typename T>
3986
- static inline T ReadField(Object* ptr, int offset) {
4284
+ V8_INLINE(static T ReadField(Object* ptr, int offset)) {
3987
4285
  uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag;
3988
4286
  return *reinterpret_cast<T*>(addr);
3989
4287
  }
3990
4288
 
3991
- static inline bool CanCastToHeapObject(void* o) { return false; }
3992
- static inline bool CanCastToHeapObject(Context* o) { return true; }
3993
- static inline bool CanCastToHeapObject(String* o) { return true; }
3994
- static inline bool CanCastToHeapObject(Object* o) { return true; }
3995
- static inline bool CanCastToHeapObject(Message* o) { return true; }
3996
- static inline bool CanCastToHeapObject(StackTrace* o) { return true; }
3997
- static inline bool CanCastToHeapObject(StackFrame* o) { return true; }
4289
+ template <typename T>
4290
+ V8_INLINE(static T ReadEmbedderData(Context* context, int index)) {
4291
+ typedef internal::Object O;
4292
+ typedef internal::Internals I;
4293
+ O* ctx = *reinterpret_cast<O**>(context);
4294
+ int embedder_data_offset = I::kContextHeaderSize +
4295
+ (internal::kApiPointerSize * I::kContextEmbedderDataIndex);
4296
+ O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset);
4297
+ int value_offset =
4298
+ I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index);
4299
+ return I::ReadField<T>(embedder_data, value_offset);
4300
+ }
4301
+
4302
+ V8_INLINE(static bool CanCastToHeapObject(void* o)) { return false; }
4303
+ V8_INLINE(static bool CanCastToHeapObject(Context* o)) { return true; }
4304
+ V8_INLINE(static bool CanCastToHeapObject(String* o)) { return true; }
4305
+ V8_INLINE(static bool CanCastToHeapObject(Object* o)) { return true; }
4306
+ V8_INLINE(static bool CanCastToHeapObject(Message* o)) { return true; }
4307
+ V8_INLINE(static bool CanCastToHeapObject(StackTrace* o)) { return true; }
4308
+ V8_INLINE(static bool CanCastToHeapObject(StackFrame* o)) { return true; }
3998
4309
  };
3999
4310
 
4000
4311
  } // namespace internal
@@ -4017,32 +4328,91 @@ Local<T> Local<T>::New(Handle<T> that) {
4017
4328
  }
4018
4329
 
4019
4330
 
4331
+ template <class T>
4332
+ Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) {
4333
+ if (that.IsEmpty()) return Local<T>();
4334
+ T* that_ptr = *that;
4335
+ internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
4336
+ return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
4337
+ reinterpret_cast<internal::Isolate*>(isolate), *p)));
4338
+ }
4339
+
4340
+
4020
4341
  template <class T>
4021
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) {
4022
4349
  if (that.IsEmpty()) return Persistent<T>();
4023
4350
  internal::Object** p = reinterpret_cast<internal::Object**>(*that);
4024
- 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)));
4354
+ }
4355
+
4356
+
4357
+ template <class T>
4358
+ bool Persistent<T>::IsIndependent() const {
4359
+ return IsIndependent(Isolate::GetCurrent());
4360
+ }
4361
+
4362
+
4363
+ template <class T>
4364
+ bool Persistent<T>::IsIndependent(Isolate* isolate) const {
4365
+ typedef internal::Internals I;
4366
+ if (this->IsEmpty()) return false;
4367
+ if (!I::IsInitialized(isolate)) return false;
4368
+ return I::GetNodeFlag(reinterpret_cast<internal::Object**>(**this),
4369
+ I::kNodeIsIndependentShift);
4025
4370
  }
4026
4371
 
4027
4372
 
4028
4373
  template <class T>
4029
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;
4030
4382
  if (this->IsEmpty()) return false;
4031
- 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;
4032
4386
  }
4033
4387
 
4034
4388
 
4035
4389
  template <class T>
4036
4390
  bool Persistent<T>::IsWeak() const {
4391
+ return IsWeak(Isolate::GetCurrent());
4392
+ }
4393
+
4394
+
4395
+ template <class T>
4396
+ bool Persistent<T>::IsWeak(Isolate* isolate) const {
4397
+ typedef internal::Internals I;
4037
4398
  if (this->IsEmpty()) return false;
4038
- return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this));
4399
+ if (!I::IsInitialized(isolate)) return false;
4400
+ return I::GetNodeState(reinterpret_cast<internal::Object**>(**this)) ==
4401
+ I::kNodeStateIsWeakValue;
4039
4402
  }
4040
4403
 
4041
4404
 
4042
4405
  template <class T>
4043
4406
  void Persistent<T>::Dispose() {
4407
+ Dispose(Isolate::GetCurrent());
4408
+ }
4409
+
4410
+
4411
+ template <class T>
4412
+ void Persistent<T>::Dispose(Isolate* isolate) {
4044
4413
  if (this->IsEmpty()) return;
4045
- V8::DisposeGlobal(reinterpret_cast<internal::Object**>(**this));
4414
+ V8::DisposeGlobal(reinterpret_cast<internal::Isolate*>(isolate),
4415
+ reinterpret_cast<internal::Object**>(**this));
4046
4416
  }
4047
4417
 
4048
4418
 
@@ -4051,24 +4421,94 @@ Persistent<T>::Persistent() : Handle<T>() { }
4051
4421
 
4052
4422
  template <class T>
4053
4423
  void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) {
4054
- 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),
4055
4427
  parameters,
4428
+ callback,
4429
+ NULL);
4430
+ }
4431
+
4432
+ template <class T>
4433
+ void Persistent<T>::MakeWeak(Isolate* isolate,
4434
+ void* parameters,
4435
+ NearDeathCallback callback) {
4436
+ V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate),
4437
+ reinterpret_cast<internal::Object**>(**this),
4438
+ parameters,
4439
+ NULL,
4056
4440
  callback);
4057
4441
  }
4058
4442
 
4059
4443
  template <class T>
4060
4444
  void Persistent<T>::ClearWeak() {
4061
- 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));
4062
4452
  }
4063
4453
 
4064
4454
  template <class T>
4065
4455
  void Persistent<T>::MarkIndependent() {
4066
- V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this));
4456
+ MarkIndependent(Isolate::GetCurrent());
4457
+ }
4458
+
4459
+ template <class T>
4460
+ void Persistent<T>::MarkIndependent(Isolate* isolate) {
4461
+ typedef internal::Internals I;
4462
+ if (this->IsEmpty()) return;
4463
+ if (!I::IsInitialized(isolate)) return;
4464
+ I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this),
4465
+ true,
4466
+ I::kNodeIsIndependentShift);
4467
+ }
4468
+
4469
+ template <class T>
4470
+ void Persistent<T>::MarkPartiallyDependent() {
4471
+ MarkPartiallyDependent(Isolate::GetCurrent());
4472
+ }
4473
+
4474
+ template <class T>
4475
+ void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) {
4476
+ typedef internal::Internals I;
4477
+ if (this->IsEmpty()) return;
4478
+ if (!I::IsInitialized(isolate)) return;
4479
+ I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this),
4480
+ true,
4481
+ I::kNodeIsPartiallyDependentShift);
4067
4482
  }
4068
4483
 
4069
4484
  template <class T>
4070
4485
  void Persistent<T>::SetWrapperClassId(uint16_t class_id) {
4071
- V8::SetWrapperClassId(reinterpret_cast<internal::Object**>(**this), 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) {
4491
+ typedef internal::Internals I;
4492
+ if (this->IsEmpty()) return;
4493
+ if (!I::IsInitialized(isolate)) return;
4494
+ internal::Object** obj = reinterpret_cast<internal::Object**>(**this);
4495
+ uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
4496
+ *reinterpret_cast<uint16_t*>(addr) = class_id;
4497
+ }
4498
+
4499
+ template <class T>
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 {
4506
+ typedef internal::Internals I;
4507
+ if (this->IsEmpty()) return 0;
4508
+ if (!I::IsInitialized(isolate)) return 0;
4509
+ internal::Object** obj = reinterpret_cast<internal::Object**>(**this);
4510
+ uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
4511
+ return *reinterpret_cast<uint16_t*>(addr);
4072
4512
  }
4073
4513
 
4074
4514
  Arguments::Arguments(internal::Object** implicit_args,
@@ -4157,63 +4597,35 @@ void Template::Set(const char* name, v8::Handle<Data> value) {
4157
4597
 
4158
4598
  Local<Value> Object::GetInternalField(int index) {
4159
4599
  #ifndef V8_ENABLE_CHECKS
4160
- Local<Value> quick_result = UncheckedGetInternalField(index);
4161
- if (!quick_result.IsEmpty()) return quick_result;
4162
- #endif
4163
- return CheckedGetInternalField(index);
4164
- }
4165
-
4166
-
4167
- Local<Value> Object::UncheckedGetInternalField(int index) {
4168
4600
  typedef internal::Object O;
4169
4601
  typedef internal::Internals I;
4170
4602
  O* obj = *reinterpret_cast<O**>(this);
4603
+ // Fast path: If the object is a plain JSObject, which is the common case, we
4604
+ // know where to find the internal fields and can return the value directly.
4171
4605
  if (I::GetInstanceType(obj) == I::kJSObjectType) {
4172
- // If the object is a plain JSObject, which is the common case,
4173
- // we know where to find the internal fields and can return the
4174
- // value directly.
4175
4606
  int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
4176
4607
  O* value = I::ReadField<O*>(obj, offset);
4177
4608
  O** result = HandleScope::CreateHandle(value);
4178
4609
  return Local<Value>(reinterpret_cast<Value*>(result));
4179
- } else {
4180
- return Local<Value>();
4181
4610
  }
4182
- }
4183
-
4184
-
4185
- void* External::Unwrap(Handle<v8::Value> obj) {
4186
- #ifdef V8_ENABLE_CHECKS
4187
- return FullUnwrap(obj);
4188
- #else
4189
- return QuickUnwrap(obj);
4190
4611
  #endif
4612
+ return SlowGetInternalField(index);
4191
4613
  }
4192
4614
 
4193
4615
 
4194
- void* External::QuickUnwrap(Handle<v8::Value> wrapper) {
4195
- typedef internal::Object O;
4196
- O* obj = *reinterpret_cast<O**>(const_cast<v8::Value*>(*wrapper));
4197
- return internal::Internals::GetExternalPointer(obj);
4198
- }
4199
-
4200
-
4201
- void* Object::GetPointerFromInternalField(int index) {
4616
+ void* Object::GetAlignedPointerFromInternalField(int index) {
4617
+ #ifndef V8_ENABLE_CHECKS
4202
4618
  typedef internal::Object O;
4203
4619
  typedef internal::Internals I;
4204
-
4205
4620
  O* obj = *reinterpret_cast<O**>(this);
4206
-
4621
+ // Fast path: If the object is a plain JSObject, which is the common case, we
4622
+ // know where to find the internal fields and can return the value directly.
4207
4623
  if (I::GetInstanceType(obj) == I::kJSObjectType) {
4208
- // If the object is a plain JSObject, which is the common case,
4209
- // we know where to find the internal fields and can return the
4210
- // value directly.
4211
4624
  int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
4212
- O* value = I::ReadField<O*>(obj, offset);
4213
- return I::GetExternalPointer(value);
4625
+ return I::ReadField<void*>(obj, offset);
4214
4626
  }
4215
-
4216
- return SlowGetPointerFromInternalField(index);
4627
+ #endif
4628
+ return SlowGetAlignedPointerFromInternalField(index);
4217
4629
  }
4218
4630
 
4219
4631
 
@@ -4252,6 +4664,26 @@ String::ExternalStringResource* String::GetExternalStringResource() const {
4252
4664
  }
4253
4665
 
4254
4666
 
4667
+ String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
4668
+ String::Encoding* encoding_out) const {
4669
+ typedef internal::Object O;
4670
+ typedef internal::Internals I;
4671
+ O* obj = *reinterpret_cast<O**>(const_cast<String*>(this));
4672
+ int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
4673
+ *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
4674
+ ExternalStringResourceBase* resource = NULL;
4675
+ if (type == I::kExternalAsciiRepresentationTag ||
4676
+ type == I::kExternalTwoByteRepresentationTag) {
4677
+ void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
4678
+ resource = static_cast<ExternalStringResourceBase*>(value);
4679
+ }
4680
+ #ifdef V8_ENABLE_CHECKS
4681
+ VerifyExternalStringResourceBase(resource, *encoding_out);
4682
+ #endif
4683
+ return resource;
4684
+ }
4685
+
4686
+
4255
4687
  bool Value::IsUndefined() const {
4256
4688
  #ifdef V8_ENABLE_CHECKS
4257
4689
  return FullIsUndefined();
@@ -4461,6 +4893,28 @@ void* Isolate::GetData() {
4461
4893
  }
4462
4894
 
4463
4895
 
4896
+ Local<Value> Context::GetEmbedderData(int index) {
4897
+ #ifndef V8_ENABLE_CHECKS
4898
+ typedef internal::Object O;
4899
+ typedef internal::Internals I;
4900
+ O** result = HandleScope::CreateHandle(I::ReadEmbedderData<O*>(this, index));
4901
+ return Local<Value>(reinterpret_cast<Value*>(result));
4902
+ #else
4903
+ return SlowGetEmbedderData(index);
4904
+ #endif
4905
+ }
4906
+
4907
+
4908
+ void* Context::GetAlignedPointerFromEmbedderData(int index) {
4909
+ #ifndef V8_ENABLE_CHECKS
4910
+ typedef internal::Internals I;
4911
+ return I::ReadEmbedderData<void*>(this, index);
4912
+ #else
4913
+ return SlowGetAlignedPointerFromEmbedderData(index);
4914
+ #endif
4915
+ }
4916
+
4917
+
4464
4918
  /**
4465
4919
  * \example shell.cc
4466
4920
  * A simple shell that takes a list of expressions on the