summaryrefslogtreecommitdiff
path: root/deps/v8/include
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2016-12-23 16:30:57 +0100
committerMichaël Zasso <targos@protonmail.com>2017-01-26 22:46:17 +0100
commit2739185b790e040c3b044c577327f5d44bffad4a (patch)
tree29a466999212f4c85958379d9d400eec8a185ba5 /deps/v8/include
parenta67a04d7654faaa04c8da00e42981ebc9fd0911c (diff)
downloadnode-new-2739185b790e040c3b044c577327f5d44bffad4a.tar.gz
deps: update V8 to 5.5.372.40
PR-URL: https://github.com/nodejs/node/pull/9618 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/v8/include')
-rw-r--r--deps/v8/include/DEPS4
-rw-r--r--deps/v8/include/OWNERS5
-rw-r--r--deps/v8/include/libplatform/v8-tracing.h62
-rw-r--r--deps/v8/include/v8-inspector-protocol.h13
-rw-r--r--deps/v8/include/v8-inspector.h267
-rw-r--r--deps/v8/include/v8-platform.h66
-rw-r--r--deps/v8/include/v8-profiler.h28
-rw-r--r--deps/v8/include/v8-util.h17
-rw-r--r--deps/v8/include/v8-version.h6
-rw-r--r--deps/v8/include/v8.h983
10 files changed, 1245 insertions, 206 deletions
diff --git a/deps/v8/include/DEPS b/deps/v8/include/DEPS
new file mode 100644
index 0000000000..ca60f841f5
--- /dev/null
+++ b/deps/v8/include/DEPS
@@ -0,0 +1,4 @@
+include_rules = [
+ # v8-inspector-protocol.h depends on generated files under include/inspector.
+ "+inspector",
+]
diff --git a/deps/v8/include/OWNERS b/deps/v8/include/OWNERS
index efa3b936d5..07f8a610c5 100644
--- a/deps/v8/include/OWNERS
+++ b/deps/v8/include/OWNERS
@@ -1,2 +1,7 @@
danno@chromium.org
jochen@chromium.org
+
+per-file v8-inspector.h=dgozman@chromium.org
+per-file v8-inspector.h=pfeldman@chromium.org
+per-file v8-inspector-protocol.h=dgozman@chromium.org
+per-file v8-inspector-protocol.h=pfeldman@chromium.org
diff --git a/deps/v8/include/libplatform/v8-tracing.h b/deps/v8/include/libplatform/v8-tracing.h
index 7646ea5489..e9f4941478 100644
--- a/deps/v8/include/libplatform/v8-tracing.h
+++ b/deps/v8/include/libplatform/v8-tracing.h
@@ -7,9 +7,17 @@
#include <fstream>
#include <memory>
+#include <unordered_set>
#include <vector>
+#include "v8-platform.h" // NOLINT(build/include)
+
namespace v8 {
+
+namespace base {
+class Mutex;
+} // namespace base
+
namespace platform {
namespace tracing {
@@ -28,19 +36,22 @@ class TraceObject {
TraceObject() {}
~TraceObject();
- void Initialize(char phase, const uint8_t* category_enabled_flag,
- const char* name, const char* scope, uint64_t id,
- uint64_t bind_id, int num_args, const char** arg_names,
- const uint8_t* arg_types, const uint64_t* arg_values,
- unsigned int flags);
+ void Initialize(
+ char phase, const uint8_t* category_enabled_flag, const char* name,
+ const char* scope, uint64_t id, uint64_t bind_id, int num_args,
+ const char** arg_names, const uint8_t* arg_types,
+ const uint64_t* arg_values,
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
+ unsigned int flags);
void UpdateDuration();
- void InitializeForTesting(char phase, const uint8_t* category_enabled_flag,
- const char* name, const char* scope, uint64_t id,
- uint64_t bind_id, int num_args,
- const char** arg_names, const uint8_t* arg_types,
- const uint64_t* arg_values, unsigned int flags,
- int pid, int tid, int64_t ts, int64_t tts,
- uint64_t duration, uint64_t cpu_duration);
+ void InitializeForTesting(
+ char phase, const uint8_t* category_enabled_flag, const char* name,
+ const char* scope, uint64_t id, uint64_t bind_id, int num_args,
+ const char** arg_names, const uint8_t* arg_types,
+ const uint64_t* arg_values,
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
+ unsigned int flags, int pid, int tid, int64_t ts, int64_t tts,
+ uint64_t duration, uint64_t cpu_duration);
int pid() const { return pid_; }
int tid() const { return tid_; }
@@ -56,6 +67,9 @@ class TraceObject {
const char** arg_names() { return arg_names_; }
uint8_t* arg_types() { return arg_types_; }
ArgValue* arg_values() { return arg_values_; }
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables() {
+ return arg_convertables_;
+ }
unsigned int flags() const { return flags_; }
int64_t ts() { return ts_; }
int64_t tts() { return tts_; }
@@ -71,10 +85,12 @@ class TraceObject {
const uint8_t* category_enabled_flag_;
uint64_t id_;
uint64_t bind_id_;
- int num_args_;
+ int num_args_ = 0;
const char* arg_names_[kTraceMaxNumArgs];
uint8_t arg_types_[kTraceMaxNumArgs];
ArgValue arg_values_[kTraceMaxNumArgs];
+ std::unique_ptr<v8::ConvertableToTraceFormat>
+ arg_convertables_[kTraceMaxNumArgs];
char* parameter_copy_storage_ = nullptr;
unsigned int flags_;
int64_t ts_;
@@ -217,21 +233,27 @@ class TracingController {
ENABLED_FOR_ETW_EXPORT = 1 << 3
};
- TracingController() {}
+ TracingController();
+ ~TracingController();
void Initialize(TraceBuffer* trace_buffer);
const uint8_t* GetCategoryGroupEnabled(const char* category_group);
static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag);
- uint64_t AddTraceEvent(char phase, const uint8_t* category_enabled_flag,
- const char* name, const char* scope, uint64_t id,
- uint64_t bind_id, int32_t num_args,
- const char** arg_names, const uint8_t* arg_types,
- const uint64_t* arg_values, unsigned int flags);
+ uint64_t AddTraceEvent(
+ char phase, const uint8_t* category_enabled_flag, const char* name,
+ const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
+ const char** arg_names, const uint8_t* arg_types,
+ const uint64_t* arg_values,
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
+ unsigned int flags);
void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
const char* name, uint64_t handle);
void StartTracing(TraceConfig* trace_config);
void StopTracing();
+ void AddTraceStateObserver(Platform::TraceStateObserver* observer);
+ void RemoveTraceStateObserver(Platform::TraceStateObserver* observer);
+
private:
const uint8_t* GetCategoryGroupEnabledInternal(const char* category_group);
void UpdateCategoryGroupEnabledFlag(size_t category_index);
@@ -239,6 +261,8 @@ class TracingController {
std::unique_ptr<TraceBuffer> trace_buffer_;
std::unique_ptr<TraceConfig> trace_config_;
+ std::unique_ptr<base::Mutex> mutex_;
+ std::unordered_set<Platform::TraceStateObserver*> observers_;
Mode mode_ = DISABLED;
// Disallow copy and assign
diff --git a/deps/v8/include/v8-inspector-protocol.h b/deps/v8/include/v8-inspector-protocol.h
new file mode 100644
index 0000000000..612a2ebc39
--- /dev/null
+++ b/deps/v8/include/v8-inspector-protocol.h
@@ -0,0 +1,13 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_V8_INSPECTOR_PROTOCOL_H_
+#define V8_V8_INSPECTOR_PROTOCOL_H_
+
+#include "inspector/Debugger.h" // NOLINT(build/include)
+#include "inspector/Runtime.h" // NOLINT(build/include)
+#include "inspector/Schema.h" // NOLINT(build/include)
+#include "v8-inspector.h" // NOLINT(build/include)
+
+#endif // V8_V8_INSPECTOR_PROTOCOL_H_
diff --git a/deps/v8/include/v8-inspector.h b/deps/v8/include/v8-inspector.h
new file mode 100644
index 0000000000..0855ac101b
--- /dev/null
+++ b/deps/v8/include/v8-inspector.h
@@ -0,0 +1,267 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_V8_INSPECTOR_H_
+#define V8_V8_INSPECTOR_H_
+
+#include <stdint.h>
+#include <cctype>
+
+#include <memory>
+
+#include "v8.h" // NOLINT(build/include)
+
+namespace v8_inspector {
+
+namespace protocol {
+namespace Debugger {
+namespace API {
+class SearchMatch;
+}
+}
+namespace Runtime {
+namespace API {
+class RemoteObject;
+class StackTrace;
+}
+}
+namespace Schema {
+namespace API {
+class Domain;
+}
+}
+} // namespace protocol
+
+class V8_EXPORT StringView {
+ public:
+ StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {}
+
+ StringView(const uint8_t* characters, size_t length)
+ : m_is8Bit(true), m_length(length), m_characters8(characters) {}
+
+ StringView(const uint16_t* characters, size_t length)
+ : m_is8Bit(false), m_length(length), m_characters16(characters) {}
+
+ bool is8Bit() const { return m_is8Bit; }
+ size_t length() const { return m_length; }
+
+ // TODO(dgozman): add DCHECK(m_is8Bit) to accessors once platform can be used
+ // here.
+ const uint8_t* characters8() const { return m_characters8; }
+ const uint16_t* characters16() const { return m_characters16; }
+
+ private:
+ bool m_is8Bit;
+ size_t m_length;
+ union {
+ const uint8_t* m_characters8;
+ const uint16_t* m_characters16;
+ };
+};
+
+class V8_EXPORT StringBuffer {
+ public:
+ virtual ~StringBuffer() {}
+ virtual const StringView& string() = 0;
+ // This method copies contents.
+ static std::unique_ptr<StringBuffer> create(const StringView&);
+};
+
+class V8_EXPORT V8ContextInfo {
+ public:
+ V8ContextInfo(v8::Local<v8::Context> context, int contextGroupId,
+ const StringView& humanReadableName)
+ : context(context),
+ contextGroupId(contextGroupId),
+ humanReadableName(humanReadableName),
+ hasMemoryOnConsole(false) {}
+
+ v8::Local<v8::Context> context;
+ // Each v8::Context is a part of a group. The group id must be non-zero.
+ int contextGroupId;
+ StringView humanReadableName;
+ StringView origin;
+ StringView auxData;
+ bool hasMemoryOnConsole;
+
+ private:
+ // Disallow copying and allocating this one.
+ enum NotNullTagEnum { NotNullLiteral };
+ void* operator new(size_t) = delete;
+ void* operator new(size_t, NotNullTagEnum, void*) = delete;
+ void* operator new(size_t, void*) = delete;
+ V8ContextInfo(const V8ContextInfo&) = delete;
+ V8ContextInfo& operator=(const V8ContextInfo&) = delete;
+};
+
+class V8_EXPORT V8StackTrace {
+ public:
+ virtual bool isEmpty() const = 0;
+ virtual StringView topSourceURL() const = 0;
+ virtual int topLineNumber() const = 0;
+ virtual int topColumnNumber() const = 0;
+ virtual StringView topScriptId() const = 0;
+ virtual StringView topFunctionName() const = 0;
+
+ virtual ~V8StackTrace() {}
+ virtual std::unique_ptr<protocol::Runtime::API::StackTrace>
+ buildInspectorObject() const = 0;
+ virtual std::unique_ptr<StringBuffer> toString() const = 0;
+
+ // Safe to pass between threads, drops async chain.
+ virtual std::unique_ptr<V8StackTrace> clone() = 0;
+};
+
+class V8_EXPORT V8InspectorSession {
+ public:
+ virtual ~V8InspectorSession() {}
+
+ // Cross-context inspectable values (DOM nodes in different worlds, etc.).
+ class V8_EXPORT Inspectable {
+ public:
+ virtual v8::Local<v8::Value> get(v8::Local<v8::Context>) = 0;
+ virtual ~Inspectable() {}
+ };
+ virtual void addInspectedObject(std::unique_ptr<Inspectable>) = 0;
+
+ // Dispatching protocol messages.
+ static bool canDispatchMethod(const StringView& method);
+ virtual void dispatchProtocolMessage(const StringView& message) = 0;
+ virtual std::unique_ptr<StringBuffer> stateJSON() = 0;
+ virtual std::vector<std::unique_ptr<protocol::Schema::API::Domain>>
+ supportedDomains() = 0;
+
+ // Debugger actions.
+ virtual void schedulePauseOnNextStatement(const StringView& breakReason,
+ const StringView& breakDetails) = 0;
+ virtual void cancelPauseOnNextStatement() = 0;
+ virtual void breakProgram(const StringView& breakReason,
+ const StringView& breakDetails) = 0;
+ virtual void setSkipAllPauses(bool) = 0;
+ virtual void resume() = 0;
+ virtual void stepOver() = 0;
+ virtual std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>>
+ searchInTextByLines(const StringView& text, const StringView& query,
+ bool caseSensitive, bool isRegex) = 0;
+
+ // Remote objects.
+ virtual std::unique_ptr<protocol::Runtime::API::RemoteObject> wrapObject(
+ v8::Local<v8::Context>, v8::Local<v8::Value>,
+ const StringView& groupName) = 0;
+ virtual bool unwrapObject(std::unique_ptr<StringBuffer>* error,
+ const StringView& objectId, v8::Local<v8::Value>*,
+ v8::Local<v8::Context>*,
+ std::unique_ptr<StringBuffer>* objectGroup) = 0;
+ virtual void releaseObjectGroup(const StringView&) = 0;
+};
+
+enum class V8ConsoleAPIType { kClear, kDebug, kLog, kInfo, kWarning, kError };
+
+class V8_EXPORT V8InspectorClient {
+ public:
+ virtual ~V8InspectorClient() {}
+
+ virtual void runMessageLoopOnPause(int contextGroupId) {}
+ virtual void quitMessageLoopOnPause() {}
+ virtual void runIfWaitingForDebugger(int contextGroupId) {}
+
+ virtual void muteMetrics(int contextGroupId) {}
+ virtual void unmuteMetrics(int contextGroupId) {}
+
+ virtual void beginUserGesture() {}
+ virtual void endUserGesture() {}
+
+ virtual std::unique_ptr<StringBuffer> valueSubtype(v8::Local<v8::Value>) {
+ return nullptr;
+ }
+ virtual bool formatAccessorsAsProperties(v8::Local<v8::Value>) {
+ return false;
+ }
+ virtual bool isInspectableHeapObject(v8::Local<v8::Object>) { return true; }
+
+ virtual v8::Local<v8::Context> ensureDefaultContextInGroup(
+ int contextGroupId) {
+ return v8::Local<v8::Context>();
+ }
+ virtual void beginEnsureAllContextsInGroup(int contextGroupId) {}
+ virtual void endEnsureAllContextsInGroup(int contextGroupId) {}
+
+ virtual void installAdditionalCommandLineAPI(v8::Local<v8::Context>,
+ v8::Local<v8::Object>) {}
+ virtual void consoleAPIMessage(int contextGroupId, V8ConsoleAPIType,
+ const StringView& message,
+ const StringView& url, unsigned lineNumber,
+ unsigned columnNumber, V8StackTrace*) {}
+ virtual v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*,
+ v8::Local<v8::Context>) {
+ return v8::MaybeLocal<v8::Value>();
+ }
+
+ virtual void consoleTime(const StringView& title) {}
+ virtual void consoleTimeEnd(const StringView& title) {}
+ virtual void consoleTimeStamp(const StringView& title) {}
+ virtual double currentTimeMS() { return 0; }
+ typedef void (*TimerCallback)(void*);
+ virtual void startRepeatingTimer(double, TimerCallback, void* data) {}
+ virtual void cancelTimer(void* data) {}
+
+ // TODO(dgozman): this was added to support service worker shadow page. We
+ // should not connect at all.
+ virtual bool canExecuteScripts(int contextGroupId) { return true; }
+};
+
+class V8_EXPORT V8Inspector {
+ public:
+ static std::unique_ptr<V8Inspector> create(v8::Isolate*, V8InspectorClient*);
+ virtual ~V8Inspector() {}
+
+ // Contexts instrumentation.
+ virtual void contextCreated(const V8ContextInfo&) = 0;
+ virtual void contextDestroyed(v8::Local<v8::Context>) = 0;
+ virtual void resetContextGroup(int contextGroupId) = 0;
+
+ // Various instrumentation.
+ virtual void willExecuteScript(v8::Local<v8::Context>, int scriptId) = 0;
+ virtual void didExecuteScript(v8::Local<v8::Context>) = 0;
+ virtual void idleStarted() = 0;
+ virtual void idleFinished() = 0;
+
+ // Async stack traces instrumentation.
+ virtual void asyncTaskScheduled(const StringView& taskName, void* task,
+ bool recurring) = 0;
+ virtual void asyncTaskCanceled(void* task) = 0;
+ virtual void asyncTaskStarted(void* task) = 0;
+ virtual void asyncTaskFinished(void* task) = 0;
+ virtual void allAsyncTasksCanceled() = 0;
+
+ // Exceptions instrumentation.
+ virtual unsigned exceptionThrown(
+ v8::Local<v8::Context>, const StringView& message,
+ v8::Local<v8::Value> exception, const StringView& detailedMessage,
+ const StringView& url, unsigned lineNumber, unsigned columnNumber,
+ std::unique_ptr<V8StackTrace>, int scriptId) = 0;
+ virtual void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId,
+ const StringView& message) = 0;
+
+ // Connection.
+ class V8_EXPORT Channel {
+ public:
+ virtual ~Channel() {}
+ virtual void sendProtocolResponse(int callId,
+ const StringView& message) = 0;
+ virtual void sendProtocolNotification(const StringView& message) = 0;
+ virtual void flushProtocolNotifications() = 0;
+ };
+ virtual std::unique_ptr<V8InspectorSession> connect(
+ int contextGroupId, Channel*, const StringView& state) = 0;
+
+ // API methods.
+ virtual std::unique_ptr<V8StackTrace> createStackTrace(
+ v8::Local<v8::StackTrace>) = 0;
+ virtual std::unique_ptr<V8StackTrace> captureStackTrace(bool fullStack) = 0;
+};
+
+} // namespace v8_inspector
+
+#endif // V8_V8_INSPECTOR_H_
diff --git a/deps/v8/include/v8-platform.h b/deps/v8/include/v8-platform.h
index 4023a5b234..e11567488b 100644
--- a/deps/v8/include/v8-platform.h
+++ b/deps/v8/include/v8-platform.h
@@ -7,6 +7,8 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
+#include <string>
namespace v8 {
@@ -17,24 +19,38 @@ class Isolate;
*/
class Task {
public:
- virtual ~Task() {}
+ virtual ~Task() = default;
virtual void Run() = 0;
};
-
/**
-* An IdleTask represents a unit of work to be performed in idle time.
-* The Run method is invoked with an argument that specifies the deadline in
-* seconds returned by MonotonicallyIncreasingTime().
-* The idle task is expected to complete by this deadline.
-*/
+ * An IdleTask represents a unit of work to be performed in idle time.
+ * The Run method is invoked with an argument that specifies the deadline in
+ * seconds returned by MonotonicallyIncreasingTime().
+ * The idle task is expected to complete by this deadline.
+ */
class IdleTask {
public:
- virtual ~IdleTask() {}
+ virtual ~IdleTask() = default;
virtual void Run(double deadline_in_seconds) = 0;
};
+/**
+ * The interface represents complex arguments to trace events.
+ */
+class ConvertableToTraceFormat {
+ public:
+ virtual ~ConvertableToTraceFormat() = default;
+
+ /**
+ * Append the class info to the provided |out| string. The appended
+ * data must be a valid JSON object. Strings must be properly quoted, and
+ * escaped. There is no processing applied to the content after it is
+ * appended.
+ */
+ virtual void AppendAsTraceFormat(std::string* out) const = 0;
+};
/**
* V8 Platform abstraction layer.
@@ -54,7 +70,7 @@ class Platform {
kLongRunningTask
};
- virtual ~Platform() {}
+ virtual ~Platform() = default;
/**
* Gets the number of threads that are used to execute background tasks. Is
@@ -159,11 +175,43 @@ class Platform {
}
/**
+ * Adds a trace event to the platform tracing system. This function call is
+ * usually the result of a TRACE_* macro from trace_event_common.h when
+ * tracing and the category of the particular trace are enabled. It is not
+ * advisable to call this function on its own; it is really only meant to be
+ * used by the trace macros. The returned handle can be used by
+ * UpdateTraceEventDuration to update the duration of COMPLETE events.
+ */
+ virtual uint64_t AddTraceEvent(
+ char phase, const uint8_t* category_enabled_flag, const char* name,
+ const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
+ const char** arg_names, const uint8_t* arg_types,
+ const uint64_t* arg_values,
+ std::unique_ptr<ConvertableToTraceFormat>* arg_convertables,
+ unsigned int flags) {
+ return AddTraceEvent(phase, category_enabled_flag, name, scope, id, bind_id,
+ num_args, arg_names, arg_types, arg_values, flags);
+ }
+
+ /**
* Sets the duration field of a COMPLETE trace event. It must be called with
* the handle returned from AddTraceEvent().
**/
virtual void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
const char* name, uint64_t handle) {}
+
+ class TraceStateObserver {
+ public:
+ virtual ~TraceStateObserver() = default;
+ virtual void OnTraceEnabled() = 0;
+ virtual void OnTraceDisabled() = 0;
+ };
+
+ /** Adds tracing state change observer. */
+ virtual void AddTraceStateObserver(TraceStateObserver*) {}
+
+ /** Removes tracing state change observer. */
+ virtual void RemoveTraceStateObserver(TraceStateObserver*) {}
};
} // namespace v8
diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h
index bcb69f3763..6ee0340f3c 100644
--- a/deps/v8/include/v8-profiler.h
+++ b/deps/v8/include/v8-profiler.h
@@ -46,6 +46,20 @@ template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>;
namespace v8 {
+/**
+ * TracingCpuProfiler monitors tracing being enabled/disabled
+ * and emits CpuProfile trace events once v8.cpu_profile2 tracing category
+ * is enabled. It has no overhead unless the category is enabled.
+ */
+class V8_EXPORT TracingCpuProfiler {
+ public:
+ static std::unique_ptr<TracingCpuProfiler> Create(Isolate*);
+ virtual ~TracingCpuProfiler() = default;
+
+ protected:
+ TracingCpuProfiler() = default;
+};
+
// TickSample captures the information collected for each sample.
struct TickSample {
// Internal profiling (with --prof + tools/$OS-tick-processor) wants to
@@ -131,6 +145,13 @@ class V8_EXPORT CpuProfileNode {
/** Returns function name (empty string for anonymous functions.) */
Local<String> GetFunctionName() const;
+ /**
+ * Returns function name (empty string for anonymous functions.)
+ * The string ownership is *not* passed to the caller. It stays valid until
+ * profile is deleted. The function is thread safe.
+ */
+ const char* GetFunctionNameStr() const;
+
/** Returns id of the script where function is located. */
int GetScriptId() const;
@@ -138,6 +159,13 @@ class V8_EXPORT CpuProfileNode {
Local<String> GetScriptResourceName() const;
/**
+ * Returns resource name for script from where the function originates.
+ * The string ownership is *not* passed to the caller. It stays valid until
+ * profile is deleted. The function is thread safe.
+ */
+ const char* GetScriptResourceNameStr() const;
+
+ /**
* Returns the number, 1-based, of the line where the function originates.
* kNoLineNumberInfo if no line number information is available.
*/
diff --git a/deps/v8/include/v8-util.h b/deps/v8/include/v8-util.h
index 8133fdd49d..99c59fe302 100644
--- a/deps/v8/include/v8-util.h
+++ b/deps/v8/include/v8-util.h
@@ -206,14 +206,19 @@ class PersistentValueMapBase {
}
/**
- * Call V8::RegisterExternallyReferencedObject with the map value for given
- * key.
+ * Deprecated. Call V8::RegisterExternallyReferencedObject with the map value
+ * for given key.
+ * TODO(hlopko) Remove once migration to reporter is finished.
*/
- void RegisterExternallyReferencedObject(K& key) {
+ void RegisterExternallyReferencedObject(K& key) {}
+
+ /**
+ * Use EmbedderReachableReferenceReporter with the map value for given key.
+ */
+ void RegisterExternallyReferencedObject(
+ EmbedderReachableReferenceReporter* reporter, K& key) {
DCHECK(Contains(key));
- V8::RegisterExternallyReferencedObject(
- reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key))),
- reinterpret_cast<internal::Isolate*>(GetIsolate()));
+ reporter->ReportExternalReference(FromVal(Traits::Get(&impl_, key)));
}
/**
diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h
index a39676e377..b216cf04c3 100644
--- a/deps/v8/include/v8-version.h
+++ b/deps/v8/include/v8-version.h
@@ -9,9 +9,9 @@
// NOTE these macros are used by some of the tool scripts and the build
// system so their names cannot be changed without changing the scripts.
#define V8_MAJOR_VERSION 5
-#define V8_MINOR_VERSION 4
-#define V8_BUILD_NUMBER 500
-#define V8_PATCH_LEVEL 46
+#define V8_MINOR_VERSION 5
+#define V8_BUILD_NUMBER 372
+#define V8_PATCH_LEVEL 40
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h
index d7e39adbae..36edf5334a 100644
--- a/deps/v8/include/v8.h
+++ b/deps/v8/include/v8.h
@@ -51,7 +51,7 @@
#else // V8_OS_WIN
// Setup for Linux shared library export.
-#if V8_HAS_ATTRIBUTE_VISIBILITY && defined(V8_SHARED)
+#if V8_HAS_ATTRIBUTE_VISIBILITY
# ifdef BUILDING_V8_SHARED
# define V8_EXPORT __attribute__ ((visibility("default")))
# else
@@ -70,6 +70,7 @@ namespace v8 {
class AccessorSignature;
class Array;
+class ArrayBuffer;
class Boolean;
class BooleanObject;
class Context;
@@ -95,6 +96,7 @@ class ObjectTemplate;
class Platform;
class Primitive;
class Promise;
+class PropertyDescriptor;
class Proxy;
class RawOperationDescriptor;
class Script;
@@ -341,7 +343,7 @@ class Local {
#if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
-// Local is an alias for Local for historical reasons.
+// Handle is an alias for Local for historical reasons.
template <class T>
using Handle = Local<T>;
#endif
@@ -466,6 +468,16 @@ class WeakCallbackInfo {
enum class WeakCallbackType { kParameter, kInternalFields, kFinalizer };
/**
+ * A reporter class that embedder will use to report reachable references found
+ * by EmbedderHeapTracer.
+ */
+class V8_EXPORT EmbedderReachableReferenceReporter {
+ public:
+ virtual void ReportExternalReference(Value* object) = 0;
+ virtual ~EmbedderReachableReferenceReporter() = default;
+};
+
+/**
* An object reference that is independent of any handle scope. Where
* a Local handle only lives as long as the HandleScope in which it was
* allocated, a PersistentBase handle remains valid until it is explicitly
@@ -562,11 +574,18 @@ template <class T> class PersistentBase {
V8_INLINE void ClearWeak() { ClearWeak<void>(); }
/**
+ * Deprecated.
+ * TODO(hlopko): remove once migration to reporter is finished.
+ */
+ V8_INLINE void RegisterExternalReference(Isolate* isolate) const {}
+
+ /**
* Allows the embedder to tell the v8 garbage collector that a certain object
* is alive. Only allowed when the embedder is asked to trace its heap by
* EmbedderHeapTracer.
*/
- V8_INLINE void RegisterExternalReference(Isolate* isolate) const;
+ V8_INLINE void RegisterExternalReference(
+ EmbedderReachableReferenceReporter* reporter) const;
/**
* Marks the reference to this object independent. Garbage collector is free
@@ -615,6 +634,9 @@ template <class T> class PersistentBase {
*/
V8_INLINE uint16_t WrapperClassId() const;
+ PersistentBase(const PersistentBase& other) = delete; // NOLINT
+ void operator=(const PersistentBase&) = delete;
+
private:
friend class Isolate;
friend class Utils;
@@ -630,8 +652,6 @@ template <class T> class PersistentBase {
friend class Object;
explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
- PersistentBase(const PersistentBase& other) = delete; // NOLINT
- void operator=(const PersistentBase&) = delete;
V8_INLINE static T* New(Isolate* isolate, T* that);
T* val_;
@@ -835,11 +855,12 @@ class Global : public PersistentBase<T> {
*/
typedef void MoveOnlyTypeForCPP03;
+ Global(const Global&) = delete;
+ void operator=(const Global&) = delete;
+
private:
template <class F>
friend class ReturnValue;
- Global(const Global&) = delete;
- void operator=(const Global&) = delete;
V8_INLINE T* operator*() const { return this->val_; }
};
@@ -878,6 +899,11 @@ class V8_EXPORT HandleScope {
return reinterpret_cast<Isolate*>(isolate_);
}
+ HandleScope(const HandleScope&) = delete;
+ void operator=(const HandleScope&) = delete;
+ void* operator new(size_t size) = delete;
+ void operator delete(void*, size_t) = delete;
+
protected:
V8_INLINE HandleScope() {}
@@ -891,13 +917,6 @@ class V8_EXPORT HandleScope {
static internal::Object** CreateHandle(internal::HeapObject* heap_object,
internal::Object* value);
- // Make it hard to create heap-allocated or illegal handle scopes by
- // disallowing certain operations.
- HandleScope(const HandleScope&);
- void operator=(const HandleScope&);
- void* operator new(size_t size);
- void operator delete(void*, size_t);
-
internal::Isolate* isolate_;
internal::Object** prev_next_;
internal::Object** prev_limit_;
@@ -932,16 +951,13 @@ class V8_EXPORT EscapableHandleScope : public HandleScope {
return Local<T>(reinterpret_cast<T*>(slot));
}
+ EscapableHandleScope(const EscapableHandleScope&) = delete;
+ void operator=(const EscapableHandleScope&) = delete;
+ void* operator new(size_t size) = delete;
+ void operator delete(void*, size_t) = delete;
+
private:
internal::Object** Escape(internal::Object** escape_value);
-
- // Make it hard to create heap-allocated or illegal handle scopes by
- // disallowing certain operations.
- EscapableHandleScope(const EscapableHandleScope&);
- void operator=(const EscapableHandleScope&);
- void* operator new(size_t size);
- void operator delete(void*, size_t);
-
internal::Object** escape_slot_;
};
@@ -950,14 +966,12 @@ class V8_EXPORT SealHandleScope {
SealHandleScope(Isolate* isolate);
~SealHandleScope();
- private:
- // Make it hard to create heap-allocated or illegal handle scopes by
- // disallowing certain operations.
- SealHandleScope(const SealHandleScope&);
- void operator=(const SealHandleScope&);
- void* operator new(size_t size);
- void operator delete(void*, size_t);
+ SealHandleScope(const SealHandleScope&) = delete;
+ void operator=(const SealHandleScope&) = delete;
+ void* operator new(size_t size) = delete;
+ void operator delete(void*, size_t) = delete;
+ private:
internal::Isolate* const isolate_;
internal::Object** prev_limit_;
int prev_sealed_level_;
@@ -1073,6 +1087,47 @@ class V8_EXPORT UnboundScript {
static const int kNoScriptId = 0;
};
+/**
+ * This is an unfinished experimental feature, and is only exposed
+ * here for internal testing purposes. DO NOT USE.
+ *
+ * A compiled JavaScript module.
+ */
+class V8_EXPORT Module {
+ public:
+ /**
+ * Returns the number of modules requested by this module.
+ */
+ int GetModuleRequestsLength() const;
+
+ /**
+ * Returns the ith module specifier in this module.
+ * i must be < GetModuleRequestsLength() and >= 0.
+ */
+ Local<String> GetModuleRequest(int i) const;
+
+ void SetEmbedderData(Local<Value> data);
+ Local<Value> GetEmbedderData() const;
+
+ typedef MaybeLocal<Module> (*ResolveCallback)(Local<Context> context,
+ Local<String> specifier,
+ Local<Module> referrer,
+ Local<Value> data);
+
+ /**
+ * ModuleDeclarationInstantiation
+ *
+ * Returns false if an exception occurred during instantiation.
+ */
+ V8_WARN_UNUSED_RESULT bool Instantiate(
+ Local<Context> context, ResolveCallback callback,
+ Local<Value> callback_data = Local<Value>());
+
+ /**
+ * ModuleEvaluation
+ */
+ V8_WARN_UNUSED_RESULT MaybeLocal<Value> Evaluate(Local<Context> context);
+};
/**
* A compiled JavaScript script, tied to a Context which was active when the
@@ -1148,10 +1203,9 @@ class V8_EXPORT ScriptCompiler {
bool rejected;
BufferPolicy buffer_policy;
- private:
- // Prevent copying. Not implemented.
- CachedData(const CachedData&);
- CachedData& operator=(const CachedData&);
+ // Prevent copying.
+ CachedData(const CachedData&) = delete;
+ CachedData& operator=(const CachedData&) = delete;
};
/**
@@ -1171,11 +1225,12 @@ class V8_EXPORT ScriptCompiler {
// alive.
V8_INLINE const CachedData* GetCachedData() const;
+ // Prevent copying.
+ Source(const Source&) = delete;
+ Source& operator=(const Source&) = delete;
+
private:
friend class ScriptCompiler;
- // Prevent copying. Not implemented.
- Source(const Source&);
- Source& operator=(const Source&);
Local<String> source_string;
@@ -1258,11 +1313,11 @@ class V8_EXPORT ScriptCompiler {
internal::StreamedSource* impl() const { return impl_; }
- private:
- // Prevent copying. Not implemented.
- StreamedSource(const StreamedSource&);
- StreamedSource& operator=(const StreamedSource&);
+ // Prevent copying.
+ StreamedSource(const StreamedSource&) = delete;
+ StreamedSource& operator=(const StreamedSource&) = delete;
+ private:
internal::StreamedSource* impl_;
};
@@ -1376,18 +1431,17 @@ class V8_EXPORT ScriptCompiler {
static uint32_t CachedDataVersionTag();
/**
- * Compile an ES6 module.
- *
* This is an unfinished experimental feature, and is only exposed
- * here for internal testing purposes.
- * Only parsing works at the moment. Do not use.
+ * here for internal testing purposes. DO NOT USE.
*
- * TODO(adamk): Script is likely the wrong return value for this;
- * should return some new Module type.
+ * Compile an ES module, returning a Module that encapsulates
+ * the compiled code.
+ *
+ * Corresponds to the ParseModule abstract operation in the
+ * ECMAScript specification.
*/
- static V8_WARN_UNUSED_RESULT MaybeLocal<Script> CompileModule(
- Local<Context> context, Source* source,
- CompileOptions options = kNoCompileOptions);
+ static V8_WARN_UNUSED_RESULT MaybeLocal<Module> CompileModule(
+ Isolate* isolate, Source* source);
/**
* Compile a function for a given context. This is equivalent to running
@@ -1664,6 +1718,174 @@ class V8_EXPORT JSON {
Local<String> gap = Local<String>());
};
+/**
+ * Value serialization compatible with the HTML structured clone algorithm.
+ * The format is backward-compatible (i.e. safe to store to disk).
+ *
+ * WARNING: This API is under development, and changes (including incompatible
+ * changes to the API or wire format) may occur without notice until this
+ * warning is removed.
+ */
+class V8_EXPORT ValueSerializer {
+ public:
+ class V8_EXPORT Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ /*
+ * Handles the case where a DataCloneError would be thrown in the structured
+ * clone spec. Other V8 embedders may throw some other appropriate exception
+ * type.
+ */
+ virtual void ThrowDataCloneError(Local<String> message) = 0;
+
+ /*
+ * The embedder overrides this method to write some kind of host object, if
+ * possible. If not, a suitable exception should be thrown and
+ * Nothing<bool>() returned.
+ */
+ virtual Maybe<bool> WriteHostObject(Isolate* isolate, Local<Object> object);
+ };
+
+ explicit ValueSerializer(Isolate* isolate);
+ ValueSerializer(Isolate* isolate, Delegate* delegate);
+ ~ValueSerializer();
+
+ /*
+ * Writes out a header, which includes the format version.
+ */
+ void WriteHeader();
+
+ /*
+ * Serializes a JavaScript value into the buffer.
+ */
+ V8_WARN_UNUSED_RESULT Maybe<bool> WriteValue(Local<Context> context,
+ Local<Value> value);
+
+ /*
+ * Returns the stored data. This serializer should not be used once the buffer
+ * is released. The contents are undefined if a previous write has failed.
+ */
+ std::vector<uint8_t> ReleaseBuffer();
+
+ /*
+ * Marks an ArrayBuffer as havings its contents transferred out of band.
+ * Pass the corresponding JSArrayBuffer in the deserializing context to
+ * ValueDeserializer::TransferArrayBuffer.
+ */
+ void TransferArrayBuffer(uint32_t transfer_id,
+ Local<ArrayBuffer> array_buffer);
+
+ /*
+ * Similar to TransferArrayBuffer, but for SharedArrayBuffer.
+ */
+ void TransferSharedArrayBuffer(uint32_t transfer_id,
+ Local<SharedArrayBuffer> shared_array_buffer);
+
+ /*
+ * Write raw data in various common formats to the buffer.
+ * Note that integer types are written in base-128 varint format, not with a
+ * binary copy. For use during an override of Delegate::WriteHostObject.
+ */
+ void WriteUint32(uint32_t value);
+ void WriteUint64(uint64_t value);
+ void WriteDouble(double value);
+ void WriteRawBytes(const void* source, size_t length);
+
+ private:
+ ValueSerializer(const ValueSerializer&) = delete;
+ void operator=(const ValueSerializer&) = delete;
+
+ struct PrivateData;
+ PrivateData* private_;
+};
+
+/**
+ * Deserializes values from data written with ValueSerializer, or a compatible
+ * implementation.
+ *
+ * WARNING: This API is under development, and changes (including incompatible
+ * changes to the API or wire format) may occur without notice until this
+ * warning is removed.
+ */
+class V8_EXPORT ValueDeserializer {
+ public:
+ class V8_EXPORT Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ /*
+ * The embedder overrides this method to read some kind of host object, if
+ * possible. If not, a suitable exception should be thrown and
+ * MaybeLocal<Object>() returned.
+ */
+ virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate);
+ };
+
+ ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size);
+ ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size,
+ Delegate* delegate);
+ ~ValueDeserializer();
+
+ /*
+ * Reads and validates a header (including the format version).
+ * May, for example, reject an invalid or unsupported wire format.
+ */
+ V8_WARN_UNUSED_RESULT Maybe<bool> ReadHeader(Local<Context> context);
+ V8_DEPRECATE_SOON("Use Local<Context> version", Maybe<bool> ReadHeader());
+
+ /*
+ * Deserializes a JavaScript value from the buffer.
+ */
+ V8_WARN_UNUSED_RESULT MaybeLocal<Value> ReadValue(Local<Context> context);
+
+ /*
+ * Accepts the array buffer corresponding to the one passed previously to
+ * ValueSerializer::TransferArrayBuffer.
+ */
+ void TransferArrayBuffer(uint32_t transfer_id,
+ Local<ArrayBuffer> array_buffer);
+
+ /*
+ * Similar to TransferArrayBuffer, but for SharedArrayBuffer.
+ * transfer_id exists in the same namespace as unshared ArrayBuffer objects.
+ */
+ void TransferSharedArrayBuffer(uint32_t transfer_id,
+ Local<SharedArrayBuffer> shared_array_buffer);
+
+ /*
+ * Must be called before ReadHeader to enable support for reading the legacy
+ * wire format (i.e., which predates this being shipped).
+ *
+ * Don't use this unless you need to read data written by previous versions of
+ * blink::ScriptValueSerializer.
+ */
+ void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format);
+
+ /*
+ * Reads the underlying wire format version. Likely mostly to be useful to
+ * legacy code reading old wire format versions. Must be called after
+ * ReadHeader.
+ */
+ uint32_t GetWireFormatVersion() const;
+
+ /*
+ * Reads raw data in various common formats to the buffer.
+ * Note that integer types are read in base-128 varint format, not with a
+ * binary copy. For use during an override of Delegate::ReadHostObject.
+ */
+ V8_WARN_UNUSED_RESULT bool ReadUint32(uint32_t* value);
+ V8_WARN_UNUSED_RESULT bool ReadUint64(uint64_t* value);
+ V8_WARN_UNUSED_RESULT bool ReadDouble(double* value);
+ V8_WARN_UNUSED_RESULT bool ReadRawBytes(size_t length, const void** data);
+
+ private:
+ ValueDeserializer(const ValueDeserializer&) = delete;
+ void operator=(const ValueDeserializer&) = delete;
+
+ struct PrivateData;
+ PrivateData* private_;
+};
/**
* A map whose keys are referenced weakly. It is similar to JavaScript WeakMap
@@ -1811,6 +2033,11 @@ class V8_EXPORT Value : public Data {
bool IsRegExp() const;
/**
+ * Returns true if this value is an async function.
+ */
+ bool IsAsyncFunction() const;
+
+ /**
* Returns true if this value is a Generator function.
* This is an experimental feature.
*/
@@ -2207,11 +2434,11 @@ class V8_EXPORT String : public Name {
*/
virtual void Dispose() { delete this; }
- private:
// Disallow copying and assigning.
- ExternalStringResourceBase(const ExternalStringResourceBase&);
- void operator=(const ExternalStringResourceBase&);
+ ExternalStringResourceBase(const ExternalStringResourceBase&) = delete;
+ void operator=(const ExternalStringResourceBase&) = delete;
+ private:
friend class v8::internal::Heap;
};
@@ -2413,13 +2640,14 @@ class V8_EXPORT String : public Name {
char* operator*() { return str_; }
const char* operator*() const { return str_; }
int length() const { return length_; }
+
+ // Disallow copying and assigning.
+ Utf8Value(const Utf8Value&) = delete;
+ void operator=(const Utf8Value&) = delete;
+
private:
char* str_;
int length_;
-
- // Disallow copying and assigning.
- Utf8Value(const Utf8Value&);
- void operator=(const Utf8Value&);
};
/**
@@ -2435,13 +2663,14 @@ class V8_EXPORT String : public Name {
uint16_t* operator*() { return str_; }
const uint16_t* operator*() const { return str_; }
int length() const { return length_; }
+
+ // Disallow copying and assigning.
+ Value(const Value&) = delete;
+ void operator=(const Value&) = delete;
+
private:
uint16_t* str_;
int length_;
-
- // Disallow copying and assigning.
- Value(const Value&);
- void operator=(const Value&);
};
private:
@@ -2575,11 +2804,17 @@ class V8_EXPORT Uint32 : public Integer {
static void CheckCast(v8::Value* obj);
};
-
+/**
+ * PropertyAttribute.
+ */
enum PropertyAttribute {
- None = 0,
- ReadOnly = 1 << 0,
- DontEnum = 1 << 1,
+ /** None. **/
+ None = 0,
+ /** ReadOnly, i.e., not writable. **/
+ ReadOnly = 1 << 0,
+ /** DontEnum, i.e., not enumerable. **/
+ DontEnum = 1 << 1,
+ /** DontDelete, i.e., not configurable. **/
DontDelete = 1 << 2
};
@@ -2693,6 +2928,22 @@ class V8_EXPORT Object : public Value {
Local<Context> context, Local<Name> key, Local<Value> value,
PropertyAttribute attributes = None);
+ // Implements Object.DefineProperty(O, P, Attributes), see Ecma-262 19.1.2.4.
+ //
+ // The defineProperty function is used to add an own property or
+ // update the attributes of an existing own property of an object.
+ //
+ // Both data and accessor descriptors can be used.
+ //
+ // In general, CreateDataProperty is faster, however, does not allow
+ // for specifying attributes or an accessor descriptor.
+ //
+ // The PropertyDescriptor can change when redefining a property.
+ //
+ // Returns true on success.
+ V8_WARN_UNUSED_RESULT Maybe<bool> DefineProperty(
+ Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor);
+
// Sets an own property on this object bypassing interceptors and
// overriding accessors or read-only properties.
//
@@ -2736,6 +2987,21 @@ class V8_EXPORT Object : public Value {
Local<Context> context, Local<String> key);
V8_DEPRECATE_SOON("Use maybe version", bool Has(Local<Value> key));
+ /**
+ * Object::Has() calls the abstract operation HasProperty(O, P) described
+ * in ECMA-262, 7.3.10. Has() returns
+ * true, if the object has the property, either own or on the prototype chain.
+ * Interceptors, i.e., PropertyQueryCallbacks, are called if present.
+ *
+ * Has() has the same side effects as JavaScript's `variable in object`.
+ * For example, calling Has() on a revoked proxy will throw an exception.
+ *
+ * \note Has() converts the key to a name, which possibly calls back into
+ * JavaScript.
+ *
+ * See also v8::Object::HasOwnProperty() and
+ * v8::Object::HasRealNamedProperty().
+ */
V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context,
Local<Value> key);
@@ -2900,12 +3166,31 @@ class V8_EXPORT Object : public Value {
// Testers for local properties.
V8_DEPRECATED("Use maybe version", bool HasOwnProperty(Local<String> key));
+
+ /**
+ * HasOwnProperty() is like JavaScript's Object.prototype.hasOwnProperty().
+ *
+ * See also v8::Object::Has() and v8::Object::HasRealNamedProperty().
+ */
V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
Local<Name> key);
V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context,
uint32_t index);
V8_DEPRECATE_SOON("Use maybe version",
bool HasRealNamedProperty(Local<String> key));
+ /**
+ * Use HasRealNamedProperty() if you want to check if an object has an own
+ * property without causing side effects, i.e., without calling interceptors.
+ *
+ * This function is similar to v8::Object::HasOwnProperty(), but it does not
+ * call interceptors.
+ *
+ * \note Consider using non-masking interceptors, i.e., the interceptors are
+ * not called if the receiver has the real named property. See
+ * `v8::PropertyHandlerFlags::kNonMasking`.
+ *
+ * See also v8::Object::Has().
+ */
V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedProperty(Local<Context> context,
Local<Name> key);
V8_DEPRECATE_SOON("Use maybe version",
@@ -2988,6 +3273,12 @@ class V8_EXPORT Object : public Value {
*/
Local<Context> CreationContext();
+ /** Same as above, but works for Persistents */
+ V8_INLINE static Local<Context> CreationContext(
+ const PersistentBase<Object>& object) {
+ return object.val_->CreationContext();
+ }
+
/**
* Checks whether a callback is set by the
* ObjectTemplate::SetCallAsFunctionHandler method.
@@ -3236,12 +3527,91 @@ class FunctionCallbackInfo {
template<typename T>
class PropertyCallbackInfo {
public:
+ /**
+ * \return The isolate of the property access.
+ */
V8_INLINE Isolate* GetIsolate() const;
+
+ /**
+ * \return The data set in the configuration, i.e., in
+ * `NamedPropertyHandlerConfiguration` or
+ * `IndexedPropertyHandlerConfiguration.`
+ */
V8_INLINE Local<Value> Data() const;
+
+ /**
+ * \return The receiver. In many cases, this is the object on which the
+ * property access was intercepted. When using
+ * `Reflect.Get`, `Function.prototype.call`, or similar functions, it is the
+ * object passed in as receiver or thisArg.
+ *
+ * \code
+ * void GetterCallback(Local<Name> name,
+ * const v8::PropertyCallbackInfo<v8::Value>& info) {
+ * auto context = info.GetIsolate()->GetCurrentContext();
+ *
+ * v8::Local<v8::Value> a_this =
+ * info.This()
+ * ->GetRealNamedProperty(context, v8_str("a"))
+ * .ToLocalChecked();
+ * v8::Local<v8::Value> a_holder =
+ * info.Holder()
+ * ->GetRealNamedProperty(context, v8_str("a"))
+ * .ToLocalChecked();
+ *
+ * CHECK(v8_str("r")->Equals(context, a_this).FromJust());
+ * CHECK(v8_str("obj")->Equals(context, a_holder).FromJust());
+ *
+ * info.GetReturnValue().Set(name);
+ * }
+ *
+ * v8::Local<v8::FunctionTemplate> templ =
+ * v8::FunctionTemplate::New(isolate);
+ * templ->InstanceTemplate()->SetHandler(
+ * v8::NamedPropertyHandlerConfiguration(GetterCallback));
+ * LocalContext env;
+ * env->Global()
+ * ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local())
+ * .ToLocalChecked()
+ * ->NewInstance(env.local())
+ * .ToLocalChecked())
+ * .FromJust();
+ *
+ * CompileRun("obj.a = 'obj'; var r = {a: 'r'}; Reflect.get(obj, 'x', r)");
+ * \endcode
+ */
V8_INLINE Local<Object> This() const;
+
+ /**
+ * \return The object in the prototype chain of the receiver that has the
+ * interceptor. Suppose you have `x` and its prototype is `y`, and `y`
+ * has an interceptor. Then `info.This()` is `x` and `info.Holder()` is `y`.
+ * The Holder() could be a hidden object (the global object, rather
+ * than the global proxy).
+ *
+ * \note For security reasons, do not pass the object back into the runtime.
+ */
V8_INLINE Local<Object> Holder() const;
+
+ /**
+ * \return The return value of the callback.
+ * Can be changed by calling Set().
+ * \code
+ * info.GetReturnValue().Set(...)
+ * \endcode
+ *
+ */
V8_INLINE ReturnValue<T> GetReturnValue() const;
+
+ /**
+ * \return True if the intercepted function should throw if an error occurs.
+ * Usually, `true` corresponds to `'use strict'`.
+ *
+ * \note Always `false` when intercepting `Reflect.Set()`
+ * independent of the language mode.
+ */
V8_INLINE bool ShouldThrowOnError() const;
+
// This shouldn't be public, but the arm compiler needs it.
static const int kArgsLength = 7;
@@ -3431,6 +3801,78 @@ class V8_EXPORT Promise : public Object {
static void CheckCast(Value* obj);
};
+/**
+ * An instance of a Property Descriptor, see Ecma-262 6.2.4.
+ *
+ * Properties in a descriptor are present or absent. If you do not set
+ * `enumerable`, `configurable`, and `writable`, they are absent. If `value`,
+ * `get`, or `set` are absent, but you must specify them in the constructor, use
+ * empty handles.
+ *
+ * Accessors `get` and `set` must be callable or undefined if they are present.
+ *
+ * \note Only query properties if they are present, i.e., call `x()` only if
+ * `has_x()` returns true.
+ *
+ * \code
+ * // var desc = {writable: false}
+ * v8::PropertyDescriptor d(Local<Value>()), false);
+ * d.value(); // error, value not set
+ * if (d.has_writable()) {
+ * d.writable(); // false
+ * }
+ *
+ * // var desc = {value: undefined}
+ * v8::PropertyDescriptor d(v8::Undefined(isolate));
+ *
+ * // var desc = {get: undefined}
+ * v8::PropertyDescriptor d(v8::Undefined(isolate), Local<Value>()));
+ * \endcode
+ */
+class V8_EXPORT PropertyDescriptor {
+ public:
+ // GenericDescriptor
+ PropertyDescriptor();
+
+ // DataDescriptor
+ PropertyDescriptor(Local<Value> value);
+
+ // DataDescriptor with writable property
+ PropertyDescriptor(Local<Value> value, bool writable);
+
+ // AccessorDescriptor
+ PropertyDescriptor(Local<Value> get, Local<Value> set);
+
+ ~PropertyDescriptor();
+
+ Local<Value> value() const;
+ bool has_value() const;
+
+ Local<Value> get() const;
+ bool has_get() const;
+ Local<Value> set() const;
+ bool has_set() const;
+
+ void set_enumerable(bool enumerable);
+ bool enumerable() const;
+ bool has_enumerable() const;
+
+ void set_configurable(bool configurable);
+ bool configurable() const;
+ bool has_configurable() const;
+
+ bool writable() const;
+ bool has_writable() const;
+
+ struct PrivateData;
+ PrivateData* get_private() const { return private_; }
+
+ PropertyDescriptor(const PropertyDescriptor&) = delete;
+ void operator=(const PropertyDescriptor&) = delete;
+
+ private:
+ PrivateData* private_;
+};
/**
* An instance of the built-in Proxy constructor (ECMA-262, 6th Edition,
@@ -3444,7 +3886,7 @@ class V8_EXPORT Proxy : public Object {
void Revoke();
/**
- * Creates a new empty Map.
+ * Creates a new Proxy for the target object.
*/
static MaybeLocal<Proxy> New(Local<Context> context,
Local<Object> local_target,
@@ -4296,36 +4738,115 @@ typedef void (*NamedPropertyEnumeratorCallback)(
// TODO(dcarney): Deprecate and remove previous typedefs, and replace
// GenericNamedPropertyFooCallback with just NamedPropertyFooCallback.
+
/**
- * GenericNamedProperty[Getter|Setter] are used as interceptors on object.
- * See ObjectTemplate::SetNamedPropertyHandler.
+ * Interceptor for get requests on an object.
+ *
+ * Use `info.GetReturnValue().Set()` to set the return value of the
+ * intercepted get request.
+ *
+ * \param property The name of the property for which the request was
+ * intercepted.
+ * \param info Information about the intercepted request, such as
+ * isolate, receiver, return value, or whether running in `'use strict`' mode.
+ * See `PropertyCallbackInfo`.
+ *
+ * \code
+ * void GetterCallback(
+ * Local<Name> name,
+ * const v8::PropertyCallbackInfo<v8::Value>& info) {
+ * info.GetReturnValue().Set(v8_num(42));
+ * }
+ *
+ * v8::Local<v8::FunctionTemplate> templ =
+ * v8::FunctionTemplate::New(isolate);
+ * templ->InstanceTemplate()->SetHandler(
+ * v8::NamedPropertyHandlerConfiguration(GetterCallback));
+ * LocalContext env;
+ * env->Global()
+ * ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local())
+ * .ToLocalChecked()
+ * ->NewInstance(env.local())
+ * .ToLocalChecked())
+ * .FromJust();
+ * v8::Local<v8::Value> result = CompileRun("obj.a = 17; obj.a");
+ * CHECK(v8_num(42)->Equals(env.local(), result).FromJust());
+ * \endcode
+ *
+ * See also `ObjectTemplate::SetHandler`.
*/
typedef void (*GenericNamedPropertyGetterCallback)(
Local<Name> property, const PropertyCallbackInfo<Value>& info);
-
/**
- * Returns the value if the setter intercepts the request.
- * Otherwise, returns an empty handle.
+ * Interceptor for set requests on an object.
+ *
+ * Use `info.GetReturnValue()` to indicate whether the request was intercepted
+ * or not. If the setter successfully intercepts the request, i.e., if the
+ * request should not be further executed, call
+ * `info.GetReturnValue().Set(value)`. If the setter
+ * did not intercept the request, i.e., if the request should be handled as
+ * if no interceptor is present, do not not call `Set()`.
+ *
+ * \param property The name of the property for which the request was
+ * intercepted.
+ * \param value The value which the property will have if the request
+ * is not intercepted.
+ * \param info Information about the intercepted request, such as
+ * isolate, receiver, return value, or whether running in `'use strict'` mode.
+ * See `PropertyCallbackInfo`.
+ *
+ * See also
+ * `ObjectTemplate::SetHandler.`
*/
typedef void (*GenericNamedPropertySetterCallback)(
Local<Name> property, Local<Value> value,
const PropertyCallbackInfo<Value>& info);
-
/**
- * Returns a non-empty handle if the interceptor intercepts the request.
- * The result is an integer encoding property attributes (like v8::None,
- * v8::DontEnum, etc.)
+ * Intercepts all requests that query the attributes of the
+ * property, e.g., getOwnPropertyDescriptor(), propertyIsEnumerable(), and
+ * defineProperty().
+ *
+ * Use `info.GetReturnValue().Set(value)` to set the property attributes. The
+ * value is an interger encoding a `v8::PropertyAttribute`.
+ *
+ * \param property The name of the property for which the request was
+ * intercepted.
+ * \param info Information about the intercepted request, such as
+ * isolate, receiver, return value, or whether running in `'use strict'` mode.
+ * See `PropertyCallbackInfo`.
+ *
+ * \note Some functions query the property attributes internally, even though
+ * they do not return the attributes. For example, `hasOwnProperty()` can
+ * trigger this interceptor depending on the state of the object.
+ *
+ * See also
+ * `ObjectTemplate::SetHandler.`
*/
typedef void (*GenericNamedPropertyQueryCallback)(
Local<Name> property, const PropertyCallbackInfo<Integer>& info);
-
/**
- * Returns a non-empty handle if the deleter intercepts the request.
- * The return value is true if the property could be deleted and false
- * otherwise.
+ * Interceptor for delete requests on an object.
+ *
+ * Use `info.GetReturnValue()` to indicate whether the request was intercepted
+ * or not. If the deleter successfully intercepts the request, i.e., if the
+ * request should not be further executed, call
+ * `info.GetReturnValue().Set(value)` with a boolean `value`. The `value` is
+ * used as the return value of `delete`.
+ *
+ * \param property The name of the property for which the request was
+ * intercepted.
+ * \param info Information about the intercepted request, such as
+ * isolate, receiver, return value, or whether running in `'use strict'` mode.
+ * See `PropertyCallbackInfo`.
+ *
+ * \note If you need to mimic the behavior of `delete`, i.e., throw in strict
+ * mode instead of returning false, use `info.ShouldThrowOnError()` to determine
+ * if you are in strict mode.
+ *
+ * See also `ObjectTemplate::SetHandler.`
*/
typedef void (*GenericNamedPropertyDeleterCallback)(
Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
@@ -4338,52 +4859,99 @@ typedef void (*GenericNamedPropertyDeleterCallback)(
typedef void (*GenericNamedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
+/**
+ * Interceptor for defineProperty requests on an object.
+ *
+ * Use `info.GetReturnValue()` to indicate whether the request was intercepted
+ * or not. If the definer successfully intercepts the request, i.e., if the
+ * request should not be further executed, call
+ * `info.GetReturnValue().Set(value)`. If the definer
+ * did not intercept the request, i.e., if the request should be handled as
+ * if no interceptor is present, do not not call `Set()`.
+ *
+ * \param property The name of the property for which the request was
+ * intercepted.
+ * \param desc The property descriptor which is used to define the
+ * property if the request is not intercepted.
+ * \param info Information about the intercepted request, such as
+ * isolate, receiver, return value, or whether running in `'use strict'` mode.
+ * See `PropertyCallbackInfo`.
+ *
+ * See also `ObjectTemplate::SetHandler`.
+ */
+typedef void (*GenericNamedPropertyDefinerCallback)(
+ Local<Name> property, const PropertyDescriptor& desc,
+ const PropertyCallbackInfo<Value>& info);
+
+/**
+ * Interceptor for getOwnPropertyDescriptor requests on an object.
+ *
+ * Use `info.GetReturnValue().Set()` to set the return value of the
+ * intercepted request. The return value must be an object that
+ * can be converted to a PropertyDescriptor, e.g., a `v8::value` returned from
+ * `v8::Object::getOwnPropertyDescriptor`.
+ *
+ * \param property The name of the property for which the request was
+ * intercepted.
+ * \info Information about the intercepted request, such as
+ * isolate, receiver, return value, or whether running in `'use strict'` mode.
+ * See `PropertyCallbackInfo`.
+ *
+ * \note If GetOwnPropertyDescriptor is intercepted, it will
+ * always return true, i.e., indicate that the property was found.
+ *
+ * See also `ObjectTemplate::SetHandler`.
+ */
+typedef void (*GenericNamedPropertyDescriptorCallback)(
+ Local<Name> property, const PropertyCallbackInfo<Value>& info);
/**
- * Returns the value of the property if the getter intercepts the
- * request. Otherwise, returns an empty handle.
+ * See `v8::GenericNamedPropertyGetterCallback`.
*/
typedef void (*IndexedPropertyGetterCallback)(
uint32_t index,
const PropertyCallbackInfo<Value>& info);
-
/**
- * Returns the value if the setter intercepts the request.
- * Otherwise, returns an empty handle.
+ * See `v8::GenericNamedPropertySetterCallback`.
*/
typedef void (*IndexedPropertySetterCallback)(
uint32_t index,
Local<Value> value,
const PropertyCallbackInfo<Value>& info);
-
/**
- * Returns a non-empty handle if the interceptor intercepts the request.
- * The result is an integer encoding property attributes.
+ * See `v8::GenericNamedPropertyQueryCallback`.
*/
typedef void (*IndexedPropertyQueryCallback)(
uint32_t index,
const PropertyCallbackInfo<Integer>& info);
-
/**
- * Returns a non-empty handle if the deleter intercepts the request.
- * The return value is true if the property could be deleted and false
- * otherwise.
+ * See `v8::GenericNamedPropertyDeleterCallback`.
*/
typedef void (*IndexedPropertyDeleterCallback)(
uint32_t index,
const PropertyCallbackInfo<Boolean>& info);
-
/**
- * Returns an array containing the indices of the properties the
- * indexed property getter intercepts.
+ * See `v8::GenericNamedPropertyEnumeratorCallback`.
*/
typedef void (*IndexedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
+/**
+ * See `v8::GenericNamedPropertyDefinerCallback`.
+ */
+typedef void (*IndexedPropertyDefinerCallback)(
+ uint32_t index, const PropertyDescriptor& desc,
+ const PropertyCallbackInfo<Value>& info);
+
+/**
+ * See `v8::GenericNamedPropertyDescriptorCallback`.
+ */
+typedef void (*IndexedPropertyDescriptorCallback)(
+ uint32_t index, const PropertyCallbackInfo<Value>& info);
/**
* Access type specification.
@@ -4617,23 +5185,37 @@ class V8_EXPORT FunctionTemplate : public Template {
friend class ObjectTemplate;
};
-
+/**
+ * Configuration flags for v8::NamedPropertyHandlerConfiguration or
+ * v8::IndexedPropertyHandlerConfiguration.
+ */
enum class PropertyHandlerFlags {
+ /**
+ * None.
+ */
kNone = 0,
- // See ALL_CAN_READ above.
+
+ /**
+ * See ALL_CAN_READ above.
+ */
kAllCanRead = 1,
- // Will not call into interceptor for properties on the receiver or prototype
- // chain. Currently only valid for named interceptors.
+
+ /** Will not call into interceptor for properties on the receiver or prototype
+ * chain, i.e., only call into interceptor for properties that do not exist.
+ * Currently only valid for named interceptors.
+ */
kNonMasking = 1 << 1,
- // Will not call into interceptor for symbol lookup. Only meaningful for
- // named interceptors.
+
+ /**
+ * Will not call into interceptor for symbol lookup. Only meaningful for
+ * named interceptors.
+ */
kOnlyInterceptStrings = 1 << 2,
};
-
struct NamedPropertyHandlerConfiguration {
NamedPropertyHandlerConfiguration(
- /** Note: getter is required **/
+ /** Note: getter is required */
GenericNamedPropertyGetterCallback getter = 0,
GenericNamedPropertySetterCallback setter = 0,
GenericNamedPropertyQueryCallback query = 0,
@@ -4646,6 +5228,27 @@ struct NamedPropertyHandlerConfiguration {
query(query),
deleter(deleter),
enumerator(enumerator),
+ definer(0),
+ descriptor(0),
+ data(data),
+ flags(flags) {}
+
+ NamedPropertyHandlerConfiguration(
+ GenericNamedPropertyGetterCallback getter,
+ GenericNamedPropertySetterCallback setter,
+ GenericNamedPropertyDescriptorCallback descriptor,
+ GenericNamedPropertyDeleterCallback deleter,
+ GenericNamedPropertyEnumeratorCallback enumerator,
+ GenericNamedPropertyDefinerCallback definer,
+ Local<Value> data = Local<Value>(),
+ PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
+ : getter(getter),
+ setter(setter),
+ query(0),
+ deleter(deleter),
+ enumerator(enumerator),
+ definer(definer),
+ descriptor(descriptor),
data(data),
flags(flags) {}
@@ -4654,6 +5257,8 @@ struct NamedPropertyHandlerConfiguration {
GenericNamedPropertyQueryCallback query;
GenericNamedPropertyDeleterCallback deleter;
GenericNamedPropertyEnumeratorCallback enumerator;
+ GenericNamedPropertyDefinerCallback definer;
+ GenericNamedPropertyDescriptorCallback descriptor;
Local<Value> data;
PropertyHandlerFlags flags;
};
@@ -4661,7 +5266,7 @@ struct NamedPropertyHandlerConfiguration {
struct IndexedPropertyHandlerConfiguration {
IndexedPropertyHandlerConfiguration(
- /** Note: getter is required **/
+ /** Note: getter is required */
IndexedPropertyGetterCallback getter = 0,
IndexedPropertySetterCallback setter = 0,
IndexedPropertyQueryCallback query = 0,
@@ -4674,6 +5279,27 @@ struct IndexedPropertyHandlerConfiguration {
query(query),
deleter(deleter),
enumerator(enumerator),
+ definer(0),
+ descriptor(0),
+ data(data),
+ flags(flags) {}
+
+ IndexedPropertyHandlerConfiguration(
+ IndexedPropertyGetterCallback getter,
+ IndexedPropertySetterCallback setter,
+ IndexedPropertyDescriptorCallback descriptor,
+ IndexedPropertyDeleterCallback deleter,
+ IndexedPropertyEnumeratorCallback enumerator,
+ IndexedPropertyDefinerCallback definer,
+ Local<Value> data = Local<Value>(),
+ PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
+ : getter(getter),
+ setter(setter),
+ query(0),
+ deleter(deleter),
+ enumerator(enumerator),
+ definer(definer),
+ descriptor(descriptor),
data(data),
flags(flags) {}
@@ -4682,6 +5308,8 @@ struct IndexedPropertyHandlerConfiguration {
IndexedPropertyQueryCallback query;
IndexedPropertyDeleterCallback deleter;
IndexedPropertyEnumeratorCallback enumerator;
+ IndexedPropertyDefinerCallback definer;
+ IndexedPropertyDescriptorCallback descriptor;
Local<Value> data;
PropertyHandlerFlags flags;
};
@@ -4977,6 +5605,10 @@ class V8_EXPORT Extension { // NOLINT
void set_auto_enable(bool value) { auto_enable_ = value; }
bool auto_enable() { return auto_enable_; }
+ // Disallow copying and assigning.
+ Extension(const Extension&) = delete;
+ void operator=(const Extension&) = delete;
+
private:
const char* name_;
size_t source_length_; // expected to initialize before source_
@@ -4984,10 +5616,6 @@ class V8_EXPORT Extension { // NOLINT
int dep_count_;
const char** deps_;
bool auto_enable_;
-
- // Disallow copying and assigning.
- Extension(const Extension&);
- void operator=(const Extension&);
};
@@ -5213,13 +5841,13 @@ class V8_EXPORT MicrotasksScope {
*/
static bool IsRunningMicrotasks(Isolate* isolate);
+ // Prevent copying.
+ MicrotasksScope(const MicrotasksScope&) = delete;
+ MicrotasksScope& operator=(const MicrotasksScope&) = delete;
+
private:
internal::Isolate* const isolate_;
bool run_;
-
- // Prevent copying.
- MicrotasksScope(const MicrotasksScope&);
- MicrotasksScope& operator=(const MicrotasksScope&);
};
@@ -5520,8 +6148,8 @@ enum class MemoryPressureLevel { kNone, kModerate, kCritical };
* Interface for tracing through the embedder heap. During the v8 garbage
* collection, v8 collects hidden fields of all potential wrappers, and at the
* end of its marking phase iterates the collection and asks the embedder to
- * trace through its heap and call PersistentBase::RegisterExternalReference on
- * each js object reachable from any of the given wrappers.
+ * trace through its heap and use reporter to report each js object reachable
+ * from any of the given wrappers.
*
* Before the first call to the TraceWrappersFrom function TracePrologue will be
* called. When the garbage collection cycle is finished, TraceEpilogue will be
@@ -5530,36 +6158,49 @@ enum class MemoryPressureLevel { kNone, kModerate, kCritical };
class V8_EXPORT EmbedderHeapTracer {
public:
enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION };
+
struct AdvanceTracingActions {
explicit AdvanceTracingActions(ForceCompletionAction force_completion_)
: force_completion(force_completion_) {}
ForceCompletionAction force_completion;
};
+
/**
- * V8 will call this method with internal fields of found wrappers.
- * Embedder is expected to store them in it's marking deque and trace
- * reachable wrappers from them when asked by AdvanceTracing method.
+ * V8 will call this method with internal fields of found wrappers. The
+ * embedder is expected to store them in its marking deque and trace
+ * reachable wrappers from them when called through |AdvanceTracing|.
*/
virtual void RegisterV8References(
const std::vector<std::pair<void*, void*> >& internal_fields) = 0;
+
+ /**
+ * Deprecated.
+ * TODO(hlopko) Remove once the migration to reporter is finished.
+ */
+ virtual void TracePrologue() {}
+
/**
- * V8 will call this method at the beginning of the gc cycle.
+ * V8 will call this method at the beginning of a GC cycle. Embedder is
+ * expected to use EmbedderReachableReferenceReporter for reporting all
+ * reachable v8 objects.
*/
- virtual void TracePrologue() = 0;
+ virtual void TracePrologue(EmbedderReachableReferenceReporter* reporter) {}
+
/**
* Embedder is expected to trace its heap starting from wrappers reported by
- * RegisterV8References method, and call
- * PersistentBase::RegisterExternalReference() on all reachable wrappers.
+ * RegisterV8References method, and use reporter for all reachable wrappers.
* Embedder is expected to stop tracing by the given deadline.
*
* Returns true if there is still work to do.
*/
virtual bool AdvanceTracing(double deadline_in_ms,
AdvanceTracingActions actions) = 0;
+
/**
- * V8 will call this method at the end of the gc cycle. Allocation is *not*
- * allowed in the TraceEpilogue.
+ * V8 will call this method at the end of a GC cycle.
+ *
+ * Note that allocation is *not* allowed within |TraceEpilogue|.
*/
virtual void TraceEpilogue() = 0;
@@ -5574,6 +6215,11 @@ class V8_EXPORT EmbedderHeapTracer {
*/
virtual void AbortTracing() {}
+ /**
+ * Returns the number of wrappers that are still to be traced by the embedder.
+ */
+ virtual size_t NumberOfWrappersToTrace() { return 0; }
+
protected:
virtual ~EmbedderHeapTracer() = default;
};
@@ -5671,12 +6317,12 @@ class V8_EXPORT Isolate {
~Scope() { isolate_->Exit(); }
+ // Prevent copying of Scope objects.
+ Scope(const Scope&) = delete;
+ Scope& operator=(const Scope&) = delete;
+
private:
Isolate* const isolate_;
-
- // Prevent copying of Scope objects.
- Scope(const Scope&);
- Scope& operator=(const Scope&);
};
@@ -5690,14 +6336,15 @@ class V8_EXPORT Isolate {
DisallowJavascriptExecutionScope(Isolate* isolate, OnFailure on_failure);
~DisallowJavascriptExecutionScope();
+ // Prevent copying of Scope objects.
+ DisallowJavascriptExecutionScope(const DisallowJavascriptExecutionScope&) =
+ delete;
+ DisallowJavascriptExecutionScope& operator=(
+ const DisallowJavascriptExecutionScope&) = delete;
+
private:
bool on_failure_;
void* internal_;
-
- // Prevent copying of Scope objects.
- DisallowJavascriptExecutionScope(const DisallowJavascriptExecutionScope&);
- DisallowJavascriptExecutionScope& operator=(
- const DisallowJavascriptExecutionScope&);
};
@@ -5709,14 +6356,15 @@ class V8_EXPORT Isolate {
explicit AllowJavascriptExecutionScope(Isolate* isolate);
~AllowJavascriptExecutionScope();
+ // Prevent copying of Scope objects.
+ AllowJavascriptExecutionScope(const AllowJavascriptExecutionScope&) =
+ delete;
+ AllowJavascriptExecutionScope& operator=(
+ const AllowJavascriptExecutionScope&) = delete;
+
private:
void* internal_throws_;
void* internal_assert_;
-
- // Prevent copying of Scope objects.
- AllowJavascriptExecutionScope(const AllowJavascriptExecutionScope&);
- AllowJavascriptExecutionScope& operator=(
- const AllowJavascriptExecutionScope&);
};
/**
@@ -5728,13 +6376,14 @@ class V8_EXPORT Isolate {
explicit SuppressMicrotaskExecutionScope(Isolate* isolate);
~SuppressMicrotaskExecutionScope();
- private:
- internal::Isolate* const isolate_;
-
// Prevent copying of Scope objects.
- SuppressMicrotaskExecutionScope(const SuppressMicrotaskExecutionScope&);
+ SuppressMicrotaskExecutionScope(const SuppressMicrotaskExecutionScope&) =
+ delete;
SuppressMicrotaskExecutionScope& operator=(
- const SuppressMicrotaskExecutionScope&);
+ const SuppressMicrotaskExecutionScope&) = delete;
+
+ private:
+ internal::Isolate* const isolate_;
};
/**
@@ -6460,17 +7109,17 @@ class V8_EXPORT Isolate {
*/
bool IsInUse();
+ Isolate() = delete;
+ ~Isolate() = delete;
+ Isolate(const Isolate&) = delete;
+ Isolate& operator=(const Isolate&) = delete;
+ void* operator new(size_t size) = delete;
+ void operator delete(void*, size_t) = delete;
+
private:
template <class K, class V, class Traits>
friend class PersistentValueMapBase;
- Isolate();
- Isolate(const Isolate&);
- ~Isolate();
- Isolate& operator=(const Isolate&);
- void* operator new(size_t size);
- void operator delete(void*, size_t);
-
void SetObjectGroupId(internal::Object** object, UniqueId id);
void SetReferenceFromGroup(UniqueId id, internal::Object** object);
void SetReference(internal::Object** parent, internal::Object** child);
@@ -6857,8 +7506,6 @@ class V8_EXPORT V8 {
int* index);
static Local<Value> GetEternal(Isolate* isolate, int index);
- static void RegisterExternallyReferencedObject(internal::Object** object,
- internal::Isolate* isolate);
template <class K, class V, class T>
friend class PersistentValueMapBase;
@@ -6925,12 +7572,12 @@ class SnapshotCreator {
*/
StartupData CreateBlob(FunctionCodeHandling function_code_handling);
+ // Disallow copying and assigning.
+ SnapshotCreator(const SnapshotCreator&) = delete;
+ void operator=(const SnapshotCreator&) = delete;
+
private:
void* data_;
-
- // Disallow copying and assigning.
- SnapshotCreator(const SnapshotCreator&);
- void operator=(const SnapshotCreator&);
};
/**
@@ -7134,15 +7781,14 @@ class V8_EXPORT TryCatch {
return handler->js_stack_comparable_address_;
}
+ TryCatch(const TryCatch&) = delete;
+ void operator=(const TryCatch&) = delete;
+ void* operator new(size_t size) = delete;
+ void operator delete(void*, size_t) = delete;
+
private:
void ResetInternal();
- // Make it hard to create heap-allocated TryCatch blocks.
- TryCatch(const TryCatch&);
- void operator=(const TryCatch&);
- void* operator new(size_t size);
- void operator delete(void*, size_t);
-
v8::internal::Isolate* isolate_;
v8::TryCatch* next_;
void* exception_;
@@ -7498,16 +8144,16 @@ class V8_EXPORT Locker {
*/
static bool IsActive();
+ // Disallow copying and assigning.
+ Locker(const Locker&) = delete;
+ void operator=(const Locker&) = delete;
+
private:
void Initialize(Isolate* isolate);
bool has_lock_;
bool top_level_;
internal::Isolate* isolate_;
-
- // Disallow copying and assigning.
- Locker(const Locker&);
- void operator=(const Locker&);
};
@@ -7643,8 +8289,8 @@ class Internals {
static const int kNodeIsPartiallyDependentShift = 4;
static const int kNodeIsActiveShift = 4;
- static const int kJSObjectType = 0xb7;
- static const int kJSApiObjectType = 0xb6;
+ static const int kJSObjectType = 0xb9;
+ static const int kJSApiObjectType = 0xb8;
static const int kFirstNonstringType = 0x80;
static const int kOddballType = 0x83;
static const int kForeignType = 0x87;
@@ -7920,11 +8566,10 @@ P* PersistentBase<T>::ClearWeak() {
}
template <class T>
-void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const {
+void PersistentBase<T>::RegisterExternalReference(
+ EmbedderReachableReferenceReporter* reporter) const {
if (IsEmpty()) return;
- V8::RegisterExternallyReferencedObject(
- reinterpret_cast<internal::Object**>(this->val_),
- reinterpret_cast<internal::Isolate*>(isolate));
+ reporter->ReportExternalReference(this->val_);
}
template <class T>