libv8 4.5.95.5-amd64-freebsd-10 → 5.0.71.48.1beta2-amd64-freebsd-10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c31f48ab20e5d70a85c455e309aca1d296d0c62
4
- data.tar.gz: 26dfac57635a22c1a03ad18e6c481c8bbb93d600
3
+ metadata.gz: d29345eeebbadc0956a0d6992c33573bbb1fe610
4
+ data.tar.gz: 49d6bb27768fbd824590ae589d4624842d5483a9
5
5
  SHA512:
6
- metadata.gz: 58c7df53644e702bd4f6e257deaba44b421b5f1ae62e89d8a5566141e193748d33c4f3fc46ec26ec64eb563131bd820b728aa993d11b68b2069e84fbd4e5a31c
7
- data.tar.gz: 931950748fdf1aab9e36c271bcaef8b8b69fba7bcb1d34a00640217130b6ee892cd92e3d4950d685437bbbddce2f9901756f509e4374569afdb015475a35de53
6
+ metadata.gz: 159e9c3259460ede9b5a6a72b35005c600716422762883de25a78296610fa40bae1bb62a719bd92107973172c646f5d39ee2a2c4b51267758823f4094166f135
7
+ data.tar.gz: 41acf675ea7153fe7f57c053086da7d57687f76a5db09d7a6f899f156f9589779af6ac92f3efb9b907754ec27d91095e88ab2cb2e104263c4c816a80160924e2
@@ -10,6 +10,7 @@ module Libv8
10
10
  when /^a(rm|arch)64$/ then 'arm64'
11
11
  when /^x86$/ then 'ia32'
12
12
  when /^(x86_64|amd64)$/ then 'x64'
13
+ when /^universal$/ then 'x64' # OS X
13
14
  else
14
15
  warn "Unsupported target: #{Gem::Platform.local.cpu}"
15
16
  Gem::Platform.local.cpu
@@ -59,16 +59,15 @@ module Libv8
59
59
  class NotFoundError < StandardError
60
60
  def initialize(*args)
61
61
  super(<<-EOS)
62
- You have chosen to use the version of V8 found on your system
63
- and *not* the one that is bundle with the libv8 rubygem. However,
64
- it could not be located. please make sure you have a version of
65
- v8 that is compatible with #{Libv8::VERSION} installed. You may
66
- need to special --with-v8-dir options if it is in a non-standard
67
- location
62
+ By using --with-system-v8, you have chosen to use the version
63
+ of V8 found on your system and *not* the one that is bundled with
64
+ the libv8 rubygem.
68
65
 
69
- thanks,
70
- The Mgmt
66
+ However, your system version of v8 could not be located.
71
67
 
68
+ Please make sure your system version of v8 that is compatible
69
+ with #{Libv8::VERSION} installed. You may need to use the
70
+ --with-v8-dir option if it is installed in a non-standard location
72
71
  EOS
73
72
  end
74
73
  end
@@ -1,3 +1,3 @@
1
1
  module Libv8
2
- VERSION = "4.5.95.5"
2
+ VERSION = "5.0.71.48.1beta2"
3
3
  end
@@ -5,7 +5,7 @@
5
5
  #ifndef V8_V8_DEBUG_H_
6
6
  #define V8_V8_DEBUG_H_
7
7
 
8
- #include "v8.h"
8
+ #include "v8.h" // NOLINT(build/include)
9
9
 
10
10
  /**
11
11
  * Debugger support for the V8 JavaScript engine.
@@ -60,20 +60,20 @@ class V8_EXPORT Debug {
60
60
  * callbacks as their content becomes invalid. These objects are from the
61
61
  * debugger event that started the debug message loop.
62
62
  */
63
- virtual Handle<Object> GetExecutionState() const = 0;
64
- virtual Handle<Object> GetEventData() const = 0;
63
+ virtual Local<Object> GetExecutionState() const = 0;
64
+ virtual Local<Object> GetEventData() const = 0;
65
65
 
66
66
  /**
67
67
  * Get the debugger protocol JSON.
68
68
  */
69
- virtual Handle<String> GetJSON() const = 0;
69
+ virtual Local<String> GetJSON() const = 0;
70
70
 
71
71
  /**
72
72
  * Get the context active when the debug event happened. Note this is not
73
73
  * the current active context as the JavaScript part of the debugger is
74
74
  * running in its own context which is entered at this point.
75
75
  */
76
- virtual Handle<Context> GetEventContext() const = 0;
76
+ virtual Local<Context> GetEventContext() const = 0;
77
77
 
78
78
  /**
79
79
  * Client data passed with the corresponding request if any. This is the
@@ -104,21 +104,21 @@ class V8_EXPORT Debug {
104
104
  * Access to execution state and event data of the debug event. Don't store
105
105
  * these cross callbacks as their content becomes invalid.
106
106
  */
107
- virtual Handle<Object> GetExecutionState() const = 0;
108
- virtual Handle<Object> GetEventData() const = 0;
107
+ virtual Local<Object> GetExecutionState() const = 0;
108
+ virtual Local<Object> GetEventData() const = 0;
109
109
 
110
110
  /**
111
111
  * Get the context active when the debug event happened. Note this is not
112
112
  * the current active context as the JavaScript part of the debugger is
113
113
  * running in its own context which is entered at this point.
114
114
  */
115
- virtual Handle<Context> GetEventContext() const = 0;
115
+ virtual Local<Context> GetEventContext() const = 0;
116
116
 
117
117
  /**
118
118
  * Client data passed with the corresponding callback when it was
119
119
  * registered.
120
120
  */
121
- virtual Handle<Value> GetCallbackData() const = 0;
121
+ virtual Local<Value> GetCallbackData() const = 0;
122
122
 
123
123
  /**
124
124
  * Client data passed to DebugBreakForCommand function. The
@@ -155,8 +155,11 @@ class V8_EXPORT Debug {
155
155
  */
156
156
  typedef void (*DebugMessageDispatchHandler)();
157
157
 
158
- static bool SetDebugEventListener(EventCallback that,
159
- Handle<Value> data = Handle<Value>());
158
+ static bool SetDebugEventListener(Isolate* isolate, EventCallback that,
159
+ Local<Value> data = Local<Value>());
160
+ V8_DEPRECATED("Use version with an Isolate",
161
+ static bool SetDebugEventListener(
162
+ EventCallback that, Local<Value> data = Local<Value>()));
160
163
 
161
164
  // Schedule a debugger break to happen when JavaScript code is run
162
165
  // in the given isolate.
@@ -170,7 +173,9 @@ class V8_EXPORT Debug {
170
173
  static bool CheckDebugBreak(Isolate* isolate);
171
174
 
172
175
  // Message based interface. The message protocol is JSON.
173
- static void SetMessageHandler(MessageHandler handler);
176
+ static void SetMessageHandler(Isolate* isolate, MessageHandler handler);
177
+ V8_DEPRECATED("Use version with an Isolate",
178
+ static void SetMessageHandler(MessageHandler handler));
174
179
 
175
180
  static void SendCommand(Isolate* isolate,
176
181
  const uint16_t* command, int length,
@@ -194,22 +199,21 @@ class V8_EXPORT Debug {
194
199
  * }
195
200
  * \endcode
196
201
  */
197
- static V8_DEPRECATE_SOON(
198
- "Use maybe version",
199
- Local<Value> Call(v8::Handle<v8::Function> fun,
200
- Handle<Value> data = Handle<Value>()));
202
+ static V8_DEPRECATED("Use maybe version",
203
+ Local<Value> Call(v8::Local<v8::Function> fun,
204
+ Local<Value> data = Local<Value>()));
201
205
  // TODO(dcarney): data arg should be a MaybeLocal
202
206
  static MaybeLocal<Value> Call(Local<Context> context,
203
- v8::Handle<v8::Function> fun,
204
- Handle<Value> data = Handle<Value>());
207
+ v8::Local<v8::Function> fun,
208
+ Local<Value> data = Local<Value>());
205
209
 
206
210
  /**
207
211
  * Returns a mirror object for the given object.
208
212
  */
209
- static V8_DEPRECATE_SOON("Use maybe version",
210
- Local<Value> GetMirror(v8::Handle<v8::Value> obj));
213
+ static V8_DEPRECATED("Use maybe version",
214
+ Local<Value> GetMirror(v8::Local<v8::Value> obj));
211
215
  static MaybeLocal<Value> GetMirror(Local<Context> context,
212
- v8::Handle<v8::Value> obj);
216
+ v8::Local<v8::Value> obj);
213
217
 
214
218
  /**
215
219
  * Makes V8 process all pending debug messages.
@@ -242,7 +246,9 @@ class V8_EXPORT Debug {
242
246
  * "Evaluate" debug command behavior currently is not specified in scope
243
247
  * of this method.
244
248
  */
245
- static void ProcessDebugMessages();
249
+ static void ProcessDebugMessages(Isolate* isolate);
250
+ V8_DEPRECATED("Use version with an Isolate",
251
+ static void ProcessDebugMessages());
246
252
 
247
253
  /**
248
254
  * Debugger is running in its own context which is entered while debugger
@@ -251,7 +257,9 @@ class V8_EXPORT Debug {
251
257
  * to change. The Context exists only when the debugger is active, i.e. at
252
258
  * least one DebugEventListener or MessageHandler is set.
253
259
  */
254
- static Local<Context> GetDebugContext();
260
+ static Local<Context> GetDebugContext(Isolate* isolate);
261
+ V8_DEPRECATED("Use version with an Isolate",
262
+ static Local<Context> GetDebugContext());
255
263
 
256
264
 
257
265
  /**
@@ -0,0 +1,54 @@
1
+ // Copyright 2015 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ /**
6
+ * This header contains a set of experimental V8 APIs. We hope these will
7
+ * become a part of standard V8, but they may also be removed if we deem the
8
+ * experiment to not be successul.
9
+ */
10
+ #ifndef V8_INCLUDE_V8_EXPERIMENTAL_H_
11
+ #define V8_INCLUDE_V8_EXPERIMENTAL_H_
12
+
13
+ #include "include/v8.h"
14
+
15
+ namespace v8 {
16
+ namespace experimental {
17
+
18
+ // Allow the embedder to construct accessors that V8 can compile and use
19
+ // directly, without jumping into the runtime.
20
+ class V8_EXPORT FastAccessorBuilder {
21
+ public:
22
+ struct ValueId {
23
+ size_t value_id;
24
+ };
25
+ struct LabelId {
26
+ size_t label_id;
27
+ };
28
+
29
+ static FastAccessorBuilder* New(Isolate* isolate);
30
+
31
+ ValueId IntegerConstant(int int_constant);
32
+ ValueId GetReceiver();
33
+ ValueId LoadInternalField(ValueId value_id, int field_no);
34
+ ValueId LoadValue(ValueId value_id, int offset);
35
+ ValueId LoadObject(ValueId value_id, int offset);
36
+ void ReturnValue(ValueId value_id);
37
+ void CheckFlagSetOrReturnNull(ValueId value_id, int mask);
38
+ void CheckNotZeroOrReturnNull(ValueId value_id);
39
+ LabelId MakeLabel();
40
+ void SetLabel(LabelId label_id);
41
+ void CheckNotZeroOrJump(ValueId value_id, LabelId label_id);
42
+ ValueId Call(v8::FunctionCallback callback, ValueId value_id);
43
+
44
+ private:
45
+ FastAccessorBuilder() = delete;
46
+ FastAccessorBuilder(const FastAccessorBuilder&) = delete;
47
+ ~FastAccessorBuilder() = delete;
48
+ void operator=(const FastAccessorBuilder&) = delete;
49
+ };
50
+
51
+ } // namespace experimental
52
+ } // namespace v8
53
+
54
+ #endif // V8_INCLUDE_V8_EXPERIMENTAL_H_
@@ -5,6 +5,9 @@
5
5
  #ifndef V8_V8_PLATFORM_H_
6
6
  #define V8_V8_PLATFORM_H_
7
7
 
8
+ #include <stddef.h>
9
+ #include <stdint.h>
10
+
8
11
  namespace v8 {
9
12
 
10
13
  class Isolate;
@@ -19,6 +22,20 @@ class Task {
19
22
  virtual void Run() = 0;
20
23
  };
21
24
 
25
+
26
+ /**
27
+ * An IdleTask represents a unit of work to be performed in idle time.
28
+ * The Run method is invoked with an argument that specifies the deadline in
29
+ * seconds returned by MonotonicallyIncreasingTime().
30
+ * The idle task is expected to complete by this deadline.
31
+ */
32
+ class IdleTask {
33
+ public:
34
+ virtual ~IdleTask() {}
35
+ virtual void Run(double deadline_in_seconds) = 0;
36
+ };
37
+
38
+
22
39
  /**
23
40
  * V8 Platform abstraction layer.
24
41
  *
@@ -39,6 +56,15 @@ class Platform {
39
56
 
40
57
  virtual ~Platform() {}
41
58
 
59
+ /**
60
+ * Gets the number of threads that are used to execute background tasks. Is
61
+ * used to estimate the number of tasks a work package should be split into.
62
+ * A return value of 0 means that there are no background threads available.
63
+ * Note that a value of 0 won't prohibit V8 from posting tasks using
64
+ * |CallOnBackgroundThread|.
65
+ */
66
+ virtual size_t NumberOfAvailableBackgroundThreads() { return 0; }
67
+
42
68
  /**
43
69
  * Schedules a task to be invoked on a background thread. |expected_runtime|
44
70
  * indicates that the task will run a long time. The Platform implementation
@@ -63,8 +89,26 @@ class Platform {
63
89
  * scheduling. The definition of "foreground" is opaque to V8.
64
90
  */
65
91
  virtual void CallDelayedOnForegroundThread(Isolate* isolate, Task* task,
66
- double delay_in_seconds) {
92
+ double delay_in_seconds) = 0;
93
+
94
+ /**
95
+ * Schedules a task to be invoked on a foreground thread wrt a specific
96
+ * |isolate| when the embedder is idle.
97
+ * Requires that SupportsIdleTasks(isolate) is true.
98
+ * Idle tasks may be reordered relative to other task types and may be
99
+ * starved for an arbitrarily long time if no idle time is available.
100
+ * The definition of "foreground" is opaque to V8.
101
+ */
102
+ virtual void CallIdleOnForegroundThread(Isolate* isolate, IdleTask* task) {
103
+ // TODO(ulan): Make this function abstract after V8 roll in Chromium.
104
+ }
105
+
106
+ /**
107
+ * Returns true if idle tasks are enabled for the given |isolate|.
108
+ */
109
+ virtual bool IdleTasksEnabled(Isolate* isolate) {
67
110
  // TODO(ulan): Make this function abstract after V8 roll in Chromium.
111
+ return false;
68
112
  }
69
113
 
70
114
  /**
@@ -75,6 +119,51 @@ class Platform {
75
119
  * the epoch.
76
120
  **/
77
121
  virtual double MonotonicallyIncreasingTime() = 0;
122
+
123
+ /**
124
+ * Called by TRACE_EVENT* macros, don't call this directly.
125
+ * The name parameter is a category group for example:
126
+ * TRACE_EVENT0("v8,parse", "V8.Parse")
127
+ * The pointer returned points to a value with zero or more of the bits
128
+ * defined in CategoryGroupEnabledFlags.
129
+ **/
130
+ virtual const uint8_t* GetCategoryGroupEnabled(const char* name) {
131
+ static uint8_t no = 0;
132
+ return &no;
133
+ }
134
+
135
+ /**
136
+ * Gets the category group name of the given category_enabled_flag pointer.
137
+ * Usually used while serliazing TRACE_EVENTs.
138
+ **/
139
+ virtual const char* GetCategoryGroupName(
140
+ const uint8_t* category_enabled_flag) {
141
+ static const char dummy[] = "dummy";
142
+ return dummy;
143
+ }
144
+
145
+ /**
146
+ * Adds a trace event to the platform tracing system. This function call is
147
+ * usually the result of a TRACE_* macro from trace_event_common.h when
148
+ * tracing and the category of the particular trace are enabled. It is not
149
+ * advisable to call this function on its own; it is really only meant to be
150
+ * used by the trace macros. The returned handle can be used by
151
+ * UpdateTraceEventDuration to update the duration of COMPLETE events.
152
+ */
153
+ virtual uint64_t AddTraceEvent(
154
+ char phase, const uint8_t* category_enabled_flag, const char* name,
155
+ uint64_t id, uint64_t bind_id, int32_t num_args, const char** arg_names,
156
+ const uint8_t* arg_types, const uint64_t* arg_values,
157
+ unsigned int flags) {
158
+ return 0;
159
+ }
160
+
161
+ /**
162
+ * Sets the duration field of a COMPLETE trace event. It must be called with
163
+ * the handle returned from AddTraceEvent().
164
+ **/
165
+ virtual void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
166
+ const char* name, uint64_t handle) {}
78
167
  };
79
168
 
80
169
  } // namespace v8
@@ -6,7 +6,7 @@
6
6
  #define V8_V8_PROFILER_H_
7
7
 
8
8
  #include <vector>
9
- #include "v8.h"
9
+ #include "v8.h" // NOLINT(build/include)
10
10
 
11
11
  /**
12
12
  * Profiler support for the V8 JavaScript engine.
@@ -60,13 +60,13 @@ class V8_EXPORT CpuProfileNode {
60
60
  };
61
61
 
62
62
  /** Returns function name (empty string for anonymous functions.) */
63
- Handle<String> GetFunctionName() const;
63
+ Local<String> GetFunctionName() const;
64
64
 
65
65
  /** Returns id of the script where function is located. */
66
66
  int GetScriptId() const;
67
67
 
68
68
  /** Returns resource name for script from where the function originates. */
69
- Handle<String> GetScriptResourceName() const;
69
+ Local<String> GetScriptResourceName() const;
70
70
 
71
71
  /**
72
72
  * Returns the number, 1-based, of the line where the function originates.
@@ -129,7 +129,7 @@ class V8_EXPORT CpuProfileNode {
129
129
  class V8_EXPORT CpuProfile {
130
130
  public:
131
131
  /** Returns CPU profile title. */
132
- Handle<String> GetTitle() const;
132
+ Local<String> GetTitle() const;
133
133
 
134
134
  /** Returns the root node of the top down call tree. */
135
135
  const CpuProfileNode* GetTopDownRoot() const;
@@ -198,13 +198,20 @@ class V8_EXPORT CpuProfiler {
198
198
  * |record_samples| parameter controls whether individual samples should
199
199
  * be recorded in addition to the aggregated tree.
200
200
  */
201
- void StartProfiling(Handle<String> title, bool record_samples = false);
201
+ void StartProfiling(Local<String> title, bool record_samples = false);
202
202
 
203
203
  /**
204
204
  * Stops collecting CPU profile with a given title and returns it.
205
205
  * If the title given is empty, finishes the last profile started.
206
206
  */
207
- CpuProfile* StopProfiling(Handle<String> title);
207
+ CpuProfile* StopProfiling(Local<String> title);
208
+
209
+ /**
210
+ * Force collection of a sample. Must be called on the VM thread.
211
+ * Recording the forced sample does not contribute to the aggregated
212
+ * profile statistics.
213
+ */
214
+ void CollectSample();
208
215
 
209
216
  /**
210
217
  * Tells the profiler whether the embedder is idle.
@@ -246,7 +253,7 @@ class V8_EXPORT HeapGraphEdge {
246
253
  * Returns edge name. This can be a variable name, an element index, or
247
254
  * a property name.
248
255
  */
249
- Handle<Value> GetName() const;
256
+ Local<Value> GetName() const;
250
257
 
251
258
  /** Returns origin node. */
252
259
  const HeapGraphNode* GetFromNode() const;
@@ -287,7 +294,7 @@ class V8_EXPORT HeapGraphNode {
287
294
  * of the constructor (for objects), the name of the function (for
288
295
  * closures), string value, or an empty string (for compiled code).
289
296
  */
290
- Handle<String> GetName() const;
297
+ Local<String> GetName() const;
291
298
 
292
299
  /**
293
300
  * Returns node id. For the same heap object, the id remains the same
@@ -418,6 +425,90 @@ class V8_EXPORT ActivityControl { // NOLINT
418
425
  };
419
426
 
420
427
 
428
+ /**
429
+ * AllocationProfile is a sampled profile of allocations done by the program.
430
+ * This is structured as a call-graph.
431
+ */
432
+ class V8_EXPORT AllocationProfile {
433
+ public:
434
+ struct Allocation {
435
+ /**
436
+ * Size of the sampled allocation object.
437
+ */
438
+ size_t size;
439
+
440
+ /**
441
+ * The number of objects of such size that were sampled.
442
+ */
443
+ unsigned int count;
444
+ };
445
+
446
+ /**
447
+ * Represents a node in the call-graph.
448
+ */
449
+ struct Node {
450
+ /**
451
+ * Name of the function. May be empty for anonymous functions or if the
452
+ * script corresponding to this function has been unloaded.
453
+ */
454
+ Local<String> name;
455
+
456
+ /**
457
+ * Name of the script containing the function. May be empty if the script
458
+ * name is not available, or if the script has been unloaded.
459
+ */
460
+ Local<String> script_name;
461
+
462
+ /**
463
+ * id of the script where the function is located. May be equal to
464
+ * v8::UnboundScript::kNoScriptId in cases where the script doesn't exist.
465
+ */
466
+ int script_id;
467
+
468
+ /**
469
+ * Start position of the function in the script.
470
+ */
471
+ int start_position;
472
+
473
+ /**
474
+ * 1-indexed line number where the function starts. May be
475
+ * kNoLineNumberInfo if no line number information is available.
476
+ */
477
+ int line_number;
478
+
479
+ /**
480
+ * 1-indexed column number where the function starts. May be
481
+ * kNoColumnNumberInfo if no line number information is available.
482
+ */
483
+ int column_number;
484
+
485
+ /**
486
+ * List of callees called from this node for which we have sampled
487
+ * allocations. The lifetime of the children is scoped to the containing
488
+ * AllocationProfile.
489
+ */
490
+ std::vector<Node*> children;
491
+
492
+ /**
493
+ * List of self allocations done by this node in the call-graph.
494
+ */
495
+ std::vector<Allocation> allocations;
496
+ };
497
+
498
+ /**
499
+ * Returns the root node of the call-graph. The root node corresponds to an
500
+ * empty JS call-stack. The lifetime of the returned Node* is scoped to the
501
+ * containing AllocationProfile.
502
+ */
503
+ virtual Node* GetRootNode() = 0;
504
+
505
+ virtual ~AllocationProfile() {}
506
+
507
+ static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
508
+ static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
509
+ };
510
+
511
+
421
512
  /**
422
513
  * Interface for controlling heap profiling. Instance of the
423
514
  * profiler can be retrieved using v8::Isolate::GetHeapProfiler.
@@ -430,8 +521,8 @@ class V8_EXPORT HeapProfiler {
430
521
  * while the callback is running: only getters on the handle and
431
522
  * GetPointerFromInternalField on the objects are allowed.
432
523
  */
433
- typedef RetainedObjectInfo* (*WrapperInfoCallback)
434
- (uint16_t class_id, Handle<Value> wrapper);
524
+ typedef RetainedObjectInfo* (*WrapperInfoCallback)(uint16_t class_id,
525
+ Local<Value> wrapper);
435
526
 
436
527
  /** Returns the number of snapshots taken. */
437
528
  int GetSnapshotCount();
@@ -443,13 +534,13 @@ class V8_EXPORT HeapProfiler {
443
534
  * Returns SnapshotObjectId for a heap object referenced by |value| if
444
535
  * it has been seen by the heap profiler, kUnknownObjectId otherwise.
445
536
  */
446
- SnapshotObjectId GetObjectId(Handle<Value> value);
537
+ SnapshotObjectId GetObjectId(Local<Value> value);
447
538
 
448
539
  /**
449
540
  * Returns heap object with given SnapshotObjectId if the object is alive,
450
541
  * otherwise empty handle is returned.
451
542
  */
452
- Handle<Value> FindObjectById(SnapshotObjectId id);
543
+ Local<Value> FindObjectById(SnapshotObjectId id);
453
544
 
454
545
  /**
455
546
  * Clears internal map from SnapshotObjectId to heap object. The new objects
@@ -474,7 +565,8 @@ class V8_EXPORT HeapProfiler {
474
565
  * Returns name to be used in the heap snapshot for given node. Returned
475
566
  * string must stay alive until snapshot collection is completed.
476
567
  */
477
- virtual const char* GetName(Handle<Object> object) = 0;
568
+ virtual const char* GetName(Local<Object> object) = 0;
569
+
478
570
  protected:
479
571
  virtual ~ObjectNameResolver() {}
480
572
  };
@@ -520,6 +612,49 @@ class V8_EXPORT HeapProfiler {
520
612
  */
521
613
  void StopTrackingHeapObjects();
522
614
 
615
+ /**
616
+ * Starts gathering a sampling heap profile. A sampling heap profile is
617
+ * similar to tcmalloc's heap profiler and Go's mprof. It samples object
618
+ * allocations and builds an online 'sampling' heap profile. At any point in
619
+ * time, this profile is expected to be a representative sample of objects
620
+ * currently live in the system. Each sampled allocation includes the stack
621
+ * trace at the time of allocation, which makes this really useful for memory
622
+ * leak detection.
623
+ *
624
+ * This mechanism is intended to be cheap enough that it can be used in
625
+ * production with minimal performance overhead.
626
+ *
627
+ * Allocations are sampled using a randomized Poisson process. On average, one
628
+ * allocation will be sampled every |sample_interval| bytes allocated. The
629
+ * |stack_depth| parameter controls the maximum number of stack frames to be
630
+ * captured on each allocation.
631
+ *
632
+ * NOTE: This is a proof-of-concept at this point. Right now we only sample
633
+ * newspace allocations. Support for paged space allocation (e.g. pre-tenured
634
+ * objects, large objects, code objects, etc.) and native allocations
635
+ * doesn't exist yet, but is anticipated in the future.
636
+ *
637
+ * Objects allocated before the sampling is started will not be included in
638
+ * the profile.
639
+ *
640
+ * Returns false if a sampling heap profiler is already running.
641
+ */
642
+ bool StartSamplingHeapProfiler(uint64_t sample_interval = 512 * 1024,
643
+ int stack_depth = 16);
644
+
645
+ /**
646
+ * Stops the sampling heap profile and discards the current profile.
647
+ */
648
+ void StopSamplingHeapProfiler();
649
+
650
+ /**
651
+ * Returns the sampled profile of allocations allocated (and still live) since
652
+ * StartSamplingHeapProfiler was called. The ownership of the pointer is
653
+ * transfered to the caller. Returns nullptr if sampling heap profiler is not
654
+ * active.
655
+ */
656
+ AllocationProfile* GetAllocationProfile();
657
+
523
658
  /**
524
659
  * Deletes all snapshots taken. All previously returned pointers to
525
660
  * snapshots and their contents become invalid after this call.