Revert "Revert "Upgrade to 5.0.71.48"" DO NOT MERGE
This reverts commit f2e3994fa5148cc3d9946666f0b0596290192b0e,
and updates the x64 makefile properly so it doesn't break that
build.
FPIIM-449
Change-Id: Ib83e35bfbae6af627451c926a9650ec57c045605
(cherry picked from commit 109988c7ccb6f3fd1a58574fa3dfb88beaef6632)
diff --git a/include/v8-experimental.h b/include/v8-experimental.h
index f988e14..3874e91 100644
--- a/include/v8-experimental.h
+++ b/include/v8-experimental.h
@@ -39,6 +39,7 @@
LabelId MakeLabel();
void SetLabel(LabelId label_id);
void CheckNotZeroOrJump(ValueId value_id, LabelId label_id);
+ ValueId Call(v8::FunctionCallback callback, ValueId value_id);
private:
FastAccessorBuilder() = delete;
diff --git a/include/v8-platform.h b/include/v8-platform.h
index 4fbef0f..11f8d51 100644
--- a/include/v8-platform.h
+++ b/include/v8-platform.h
@@ -5,6 +5,7 @@
#ifndef V8_V8_PLATFORM_H_
#define V8_V8_PLATFORM_H_
+#include <stddef.h>
#include <stdint.h>
namespace v8 {
@@ -56,6 +57,15 @@
virtual ~Platform() {}
/**
+ * Gets the number of threads that are used to execute background tasks. Is
+ * used to estimate the number of tasks a work package should be split into.
+ * A return value of 0 means that there are no background threads available.
+ * Note that a value of 0 won't prohibit V8 from posting tasks using
+ * |CallOnBackgroundThread|.
+ */
+ virtual size_t NumberOfAvailableBackgroundThreads() { return 0; }
+
+ /**
* Schedules a task to be invoked on a background thread. |expected_runtime|
* indicates that the task will run a long time. The Platform implementation
* takes ownership of |task|. There is no guarantee about order of execution
diff --git a/include/v8-profiler.h b/include/v8-profiler.h
index e432600..007ae2e 100644
--- a/include/v8-profiler.h
+++ b/include/v8-profiler.h
@@ -207,6 +207,13 @@
CpuProfile* StopProfiling(Local<String> title);
/**
+ * Force collection of a sample. Must be called on the VM thread.
+ * Recording the forced sample does not contribute to the aggregated
+ * profile statistics.
+ */
+ void CollectSample();
+
+ /**
* Tells the profiler whether the embedder is idle.
*/
void SetIdle(bool is_idle);
@@ -419,6 +426,90 @@
/**
+ * AllocationProfile is a sampled profile of allocations done by the program.
+ * This is structured as a call-graph.
+ */
+class V8_EXPORT AllocationProfile {
+ public:
+ struct Allocation {
+ /**
+ * Size of the sampled allocation object.
+ */
+ size_t size;
+
+ /**
+ * The number of objects of such size that were sampled.
+ */
+ unsigned int count;
+ };
+
+ /**
+ * Represents a node in the call-graph.
+ */
+ struct Node {
+ /**
+ * Name of the function. May be empty for anonymous functions or if the
+ * script corresponding to this function has been unloaded.
+ */
+ Local<String> name;
+
+ /**
+ * Name of the script containing the function. May be empty if the script
+ * name is not available, or if the script has been unloaded.
+ */
+ Local<String> script_name;
+
+ /**
+ * id of the script where the function is located. May be equal to
+ * v8::UnboundScript::kNoScriptId in cases where the script doesn't exist.
+ */
+ int script_id;
+
+ /**
+ * Start position of the function in the script.
+ */
+ int start_position;
+
+ /**
+ * 1-indexed line number where the function starts. May be
+ * kNoLineNumberInfo if no line number information is available.
+ */
+ int line_number;
+
+ /**
+ * 1-indexed column number where the function starts. May be
+ * kNoColumnNumberInfo if no line number information is available.
+ */
+ int column_number;
+
+ /**
+ * List of callees called from this node for which we have sampled
+ * allocations. The lifetime of the children is scoped to the containing
+ * AllocationProfile.
+ */
+ std::vector<Node*> children;
+
+ /**
+ * List of self allocations done by this node in the call-graph.
+ */
+ std::vector<Allocation> allocations;
+ };
+
+ /**
+ * Returns the root node of the call-graph. The root node corresponds to an
+ * empty JS call-stack. The lifetime of the returned Node* is scoped to the
+ * containing AllocationProfile.
+ */
+ virtual Node* GetRootNode() = 0;
+
+ virtual ~AllocationProfile() {}
+
+ static const int kNoLineNumberInfo = Message::kNoLineNumberInfo;
+ static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
+};
+
+
+/**
* Interface for controlling heap profiling. Instance of the
* profiler can be retrieved using v8::Isolate::GetHeapProfiler.
*/
@@ -522,6 +613,49 @@
void StopTrackingHeapObjects();
/**
+ * Starts gathering a sampling heap profile. A sampling heap profile is
+ * similar to tcmalloc's heap profiler and Go's mprof. It samples object
+ * allocations and builds an online 'sampling' heap profile. At any point in
+ * time, this profile is expected to be a representative sample of objects
+ * currently live in the system. Each sampled allocation includes the stack
+ * trace at the time of allocation, which makes this really useful for memory
+ * leak detection.
+ *
+ * This mechanism is intended to be cheap enough that it can be used in
+ * production with minimal performance overhead.
+ *
+ * Allocations are sampled using a randomized Poisson process. On average, one
+ * allocation will be sampled every |sample_interval| bytes allocated. The
+ * |stack_depth| parameter controls the maximum number of stack frames to be
+ * captured on each allocation.
+ *
+ * NOTE: This is a proof-of-concept at this point. Right now we only sample
+ * newspace allocations. Support for paged space allocation (e.g. pre-tenured
+ * objects, large objects, code objects, etc.) and native allocations
+ * doesn't exist yet, but is anticipated in the future.
+ *
+ * Objects allocated before the sampling is started will not be included in
+ * the profile.
+ *
+ * Returns false if a sampling heap profiler is already running.
+ */
+ bool StartSamplingHeapProfiler(uint64_t sample_interval = 512 * 1024,
+ int stack_depth = 16);
+
+ /**
+ * Stops the sampling heap profile and discards the current profile.
+ */
+ void StopSamplingHeapProfiler();
+
+ /**
+ * Returns the sampled profile of allocations allocated (and still live) since
+ * StartSamplingHeapProfiler was called. The ownership of the pointer is
+ * transfered to the caller. Returns nullptr if sampling heap profiler is not
+ * active.
+ */
+ AllocationProfile* GetAllocationProfile();
+
+ /**
* Deletes all snapshots taken. All previously returned pointers to
* snapshots and their contents become invalid after this call.
*/
diff --git a/include/v8-version.h b/include/v8-version.h
index c1231d4..f155b8a 100644
--- a/include/v8-version.h
+++ b/include/v8-version.h
@@ -8,10 +8,10 @@
// These macros define the version number for the current version.
// 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 4
-#define V8_MINOR_VERSION 9
-#define V8_BUILD_NUMBER 385
-#define V8_PATCH_LEVEL 28
+#define V8_MAJOR_VERSION 5
+#define V8_MINOR_VERSION 0
+#define V8_BUILD_NUMBER 71
+#define V8_PATCH_LEVEL 48
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
diff --git a/include/v8.h b/include/v8.h
index d9ad17c..9ccbc6e 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -329,9 +329,7 @@
friend class PersistentValueMapBase;
template<class F1, class F2> friend class PersistentValueVector;
- template <class S>
- V8_INLINE Local(S* that)
- : val_(that) {}
+ explicit V8_INLINE Local(T* that) : val_(that) {}
V8_INLINE static Local<T> New(Isolate* isolate, T* that);
T* val_;
};
@@ -434,7 +432,10 @@
return internal_fields_[1];
}
- bool IsFirstPass() const { return callback_ != nullptr; }
+ V8_DEPRECATED("Not realiable once SetSecondPassCallback() was used.",
+ bool IsFirstPass() const) {
+ return callback_ != nullptr;
+ }
// When first called, the embedder MUST Reset() the Global which triggered the
// callback. The Global itself is unusable for anything else. No v8 other api
@@ -787,7 +788,7 @@
template<class F1, class F2> friend class Persistent;
template<class F> friend class ReturnValue;
- template <class S> V8_INLINE Persistent(S* that) : PersistentBase<T>(that) { }
+ explicit V8_INLINE Persistent(T* that) : PersistentBase<T>(that) {}
V8_INLINE T* operator*() const { return this->val_; }
template<class S, class M2>
V8_INLINE void Copy(const Persistent<S, M2>& that);
@@ -886,7 +887,7 @@
*/
class V8_EXPORT HandleScope {
public:
- HandleScope(Isolate* isolate);
+ explicit HandleScope(Isolate* isolate);
~HandleScope();
@@ -939,7 +940,7 @@
*/
class V8_EXPORT EscapableHandleScope : public HandleScope {
public:
- EscapableHandleScope(Isolate* isolate);
+ explicit EscapableHandleScope(Isolate* isolate);
V8_INLINE ~EscapableHandleScope() {}
/**
@@ -2678,10 +2679,10 @@
V8_DEPRECATED("Use CreateDataProperty / DefineOwnProperty",
bool ForceSet(Local<Value> key, Local<Value> value,
PropertyAttribute attribs = None));
- V8_DEPRECATED("Use CreateDataProperty / DefineOwnProperty",
- Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
- Local<Value> value,
- PropertyAttribute attribs = None));
+ V8_DEPRECATE_SOON("Use CreateDataProperty / DefineOwnProperty",
+ Maybe<bool> ForceSet(Local<Context> context,
+ Local<Value> key, Local<Value> value,
+ PropertyAttribute attribs = None));
V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key));
V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
@@ -3147,7 +3148,8 @@
public:
V8_INLINE int Length() const;
V8_INLINE Local<Value> operator[](int i) const;
- V8_INLINE Local<Function> Callee() const;
+ V8_INLINE V8_DEPRECATED("Use Data() to explicitly pass Callee instead",
+ Local<Function> Callee() const);
V8_INLINE Local<Object> This() const;
V8_INLINE Local<Object> Holder() const;
V8_INLINE bool IsConstructCall() const;
@@ -3191,19 +3193,21 @@
V8_INLINE Local<Object> This() const;
V8_INLINE Local<Object> Holder() const;
V8_INLINE ReturnValue<T> GetReturnValue() const;
+ V8_INLINE bool ShouldThrowOnError() const;
// This shouldn't be public, but the arm compiler needs it.
- static const int kArgsLength = 6;
+ static const int kArgsLength = 7;
protected:
friend class MacroAssembler;
friend class internal::PropertyCallbackArguments;
friend class internal::CustomArguments<PropertyCallbackInfo>;
- static const int kHolderIndex = 0;
- static const int kIsolateIndex = 1;
- static const int kReturnValueDefaultValueIndex = 2;
- static const int kReturnValueIndex = 3;
- static const int kDataIndex = 4;
- static const int kThisIndex = 5;
+ static const int kShouldThrowOnErrorIndex = 0;
+ static const int kHolderIndex = 1;
+ static const int kIsolateIndex = 2;
+ static const int kReturnValueDefaultValueIndex = 3;
+ static const int kReturnValueIndex = 4;
+ static const int kDataIndex = 5;
+ static const int kThisIndex = 6;
V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {}
internal::Object** args_;
@@ -4322,8 +4326,10 @@
* object.
*/
typedef bool (*AccessCheckCallback)(Local<Context> accessing_context,
- Local<Object> accessed_object);
-
+ Local<Object> accessed_object,
+ Local<Value> data);
+typedef bool (*DeprecatedAccessCheckCallback)(Local<Context> accessing_context,
+ Local<Object> accessed_object);
/**
* Returns true if cross-context access should be allowed to the named
@@ -4753,6 +4759,10 @@
*/
void SetAccessCheckCallback(AccessCheckCallback callback,
Local<Value> data = Local<Value>());
+ V8_DEPRECATED(
+ "Use SetAccessCheckCallback with new AccessCheckCallback signature.",
+ void SetAccessCheckCallback(DeprecatedAccessCheckCallback callback,
+ Local<Value> data = Local<Value>()));
V8_DEPRECATED(
"Use SetAccessCheckCallback instead",
@@ -4999,8 +5009,10 @@
AllocationAction action,
int size);
-// --- Leave Script Callback ---
-typedef void (*CallCompletedCallback)();
+// --- Enter/Leave Script Callback ---
+typedef void (*BeforeCallEnteredCallback)(Isolate*);
+typedef void (*CallCompletedCallback)(Isolate*);
+typedef void (*DeprecatedCallCompletedCallback)();
// --- Promise Reject Callback ---
enum PromiseRejectEvent {
@@ -5069,11 +5081,24 @@
kGCTypeIncrementalMarking | kGCTypeProcessWeakCallbacks
};
+/**
+ * GCCallbackFlags is used to notify additional information about the GC
+ * callback.
+ * - kGCCallbackFlagConstructRetainedObjectInfos: The GC callback is for
+ * constructing retained object infos.
+ * - kGCCallbackFlagForced: The GC callback is for a forced GC for testing.
+ * - kGCCallbackFlagSynchronousPhantomCallbackProcessing: The GC callback
+ * is called synchronously without getting posted to an idle task.
+ * - kGCCallbackFlagCollectAllAvailableGarbage: The GC callback is called
+ * in a phase where V8 is trying to collect all available garbage
+ * (e.g., handling a low memory notification).
+ */
enum GCCallbackFlags {
kNoGCCallbackFlags = 0,
kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1,
kGCCallbackFlagForced = 1 << 2,
- kGCCallbackFlagSynchronousPhantomCallbackProcessing = 1 << 3
+ kGCCallbackFlagSynchronousPhantomCallbackProcessing = 1 << 3,
+ kGCCallbackFlagCollectAllAvailableGarbage = 1 << 4,
};
typedef void (*GCCallback)(GCType type, GCCallbackFlags flags);
@@ -5455,6 +5480,18 @@
kPromiseChain = 17,
kPromiseAccept = 18,
kPromiseDefer = 19,
+ kHtmlCommentInExternalScript = 20,
+ kHtmlComment = 21,
+ kSloppyModeBlockScopedFunctionRedefinition = 22,
+ kForInInitializer = 23,
+ kArrayProtectorDirtied = 24,
+ kArraySpeciesModified = 25,
+ kArrayPrototypeConstructorModified = 26,
+ kArrayInstanceProtoModified = 27,
+ kArrayInstanceConstructorModified = 28,
+
+ // If you add new values here, you'll also need to update V8Initializer.cpp
+ // in Chromium.
kUseCounterFeatureCount // This enum value must be last.
};
@@ -5796,6 +5833,19 @@
void SetEventLogger(LogEventCallback that);
/**
+ * Adds a callback to notify the host application right before a script
+ * is about to run. If a script re-enters the runtime during executing, the
+ * BeforeCallEnteredCallback is invoked for each re-entrance.
+ * Executing scripts inside the callback will re-trigger the callback.
+ */
+ void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
+
+ /**
+ * Removes callback that was installed by AddBeforeCallEnteredCallback.
+ */
+ void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
+
+ /**
* Adds a callback to notify the host application when a script finished
* running. If a script re-enters the runtime during executing, the
* CallCompletedCallback is only invoked when the outer-most script
@@ -5803,12 +5853,18 @@
* further callbacks.
*/
void AddCallCompletedCallback(CallCompletedCallback callback);
+ V8_DEPRECATE_SOON(
+ "Use callback with parameter",
+ void AddCallCompletedCallback(DeprecatedCallCompletedCallback callback));
/**
* Removes callback that was installed by AddCallCompletedCallback.
*/
void RemoveCallCompletedCallback(CallCompletedCallback callback);
-
+ V8_DEPRECATE_SOON(
+ "Use callback with parameter",
+ void RemoveCallCompletedCallback(
+ DeprecatedCallCompletedCallback callback));
/**
* Set callback to notify about promise reject with no handler, or
@@ -7132,7 +7188,7 @@
static const int kNodeIsPartiallyDependentShift = 4;
static const int kNodeIsActiveShift = 4;
- static const int kJSObjectType = 0xb7;
+ static const int kJSObjectType = 0xb5;
static const int kFirstNonstringType = 0x80;
static const int kOddballType = 0x83;
static const int kForeignType = 0x87;
@@ -8262,6 +8318,12 @@
return ReturnValue<T>(&args_[kReturnValueIndex]);
}
+template <typename T>
+bool PropertyCallbackInfo<T>::ShouldThrowOnError() const {
+ typedef internal::Internals I;
+ return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(0);
+}
+
Local<Primitive> Undefined(Isolate* isolate) {
typedef internal::Object* S;