Update V8 patches to make in work with Node.js 9.2.0
This commit is contained in:
Родитель
9983e56204
Коммит
bf9e5c70d5
|
@ -1,73 +0,0 @@
|
||||||
6e157c8eb4633da4b66aa3488c1f00b87f560505
|
|
||||||
diff --git a/include/v8.h b/include/v8.h
|
|
||||||
index eec2256aea..cb16b21d2a 100644
|
|
||||||
--- a/include/v8.h
|
|
||||||
+++ b/include/v8.h
|
|
||||||
@@ -6348,6 +6348,8 @@ typedef void (*FailedAccessCheckCallback)(Local<Object> target,
|
|
||||||
* Callback to check if code generation from strings is allowed. See
|
|
||||||
* Context::AllowCodeGenerationFromStrings.
|
|
||||||
*/
|
|
||||||
+typedef bool (*DeprecatedAllowCodeGenerationFromStringsCallback)(
|
|
||||||
+ Local<Context> context);
|
|
||||||
typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context,
|
|
||||||
Local<String> source);
|
|
||||||
|
|
||||||
@@ -7627,6 +7629,9 @@ class V8_EXPORT Isolate {
|
|
||||||
*/
|
|
||||||
void SetAllowCodeGenerationFromStringsCallback(
|
|
||||||
AllowCodeGenerationFromStringsCallback callback);
|
|
||||||
+ V8_DEPRECATED("Use callback with source parameter.",
|
|
||||||
+ void SetAllowCodeGenerationFromStringsCallback(
|
|
||||||
+ DeprecatedAllowCodeGenerationFromStringsCallback callback));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Embedder over{ride|load} injection points for wasm APIs. The expectation
|
|
||||||
@@ -7787,6 +7792,15 @@ class V8_EXPORT V8 {
|
|
||||||
"Use isolate version",
|
|
||||||
void SetFatalErrorHandler(FatalErrorCallback that));
|
|
||||||
|
|
||||||
+ /**
|
|
||||||
+ * Set the callback to invoke to check if code generation from
|
|
||||||
+ * strings should be allowed.
|
|
||||||
+ */
|
|
||||||
+ V8_INLINE static V8_DEPRECATED(
|
|
||||||
+ "Use isolate version",
|
|
||||||
+ void SetAllowCodeGenerationFromStringsCallback(
|
|
||||||
+ DeprecatedAllowCodeGenerationFromStringsCallback that));
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Check if V8 is dead and therefore unusable. This is the case after
|
|
||||||
* fatal errors such as out-of-memory situations.
|
|
||||||
@@ -10266,6 +10280,14 @@ void* Context::GetAlignedPointerFromEmbedderData(int index) {
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
+void V8::SetAllowCodeGenerationFromStringsCallback(
|
|
||||||
+ DeprecatedAllowCodeGenerationFromStringsCallback callback) {
|
|
||||||
+ Isolate* isolate = Isolate::GetCurrent();
|
|
||||||
+ isolate->SetAllowCodeGenerationFromStringsCallback(
|
|
||||||
+ reinterpret_cast<AllowCodeGenerationFromStringsCallback>(callback));
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
bool V8::IsDead() {
|
|
||||||
Isolate* isolate = Isolate::GetCurrent();
|
|
||||||
return isolate->IsDead();
|
|
||||||
diff --git a/src/api.cc b/src/api.cc
|
|
||||||
index d676a7426c..644ac55a69 100644
|
|
||||||
--- a/src/api.cc
|
|
||||||
+++ b/src/api.cc
|
|
||||||
@@ -9023,6 +9023,13 @@ void Isolate::SetAllowCodeGenerationFromStringsCallback(
|
|
||||||
isolate->set_allow_code_gen_callback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
+void Isolate::SetAllowCodeGenerationFromStringsCallback(
|
|
||||||
+ DeprecatedAllowCodeGenerationFromStringsCallback callback) {
|
|
||||||
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
|
||||||
+ isolate->set_allow_code_gen_callback(
|
|
||||||
+ reinterpret_cast<AllowCodeGenerationFromStringsCallback>(callback));
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
#define CALLBACK_SETTER(ExternalName, Type, InternalName) \
|
|
||||||
void Isolate::Set##ExternalName(Type callback) { \
|
|
||||||
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); \
|
|
|
@ -1,718 +0,0 @@
|
||||||
6209ac6df08479ec0e44df4a6c873fdf4527760c
|
|
||||||
diff --git a/include/v8.h b/include/v8.h
|
|
||||||
index 578df8dc52..700bfa1930 100644
|
|
||||||
--- a/include/v8.h
|
|
||||||
+++ b/include/v8.h
|
|
||||||
@@ -3097,9 +3097,12 @@ class V8_EXPORT Object : public Value {
|
|
||||||
//
|
|
||||||
// Note also that this only works for named properties.
|
|
||||||
V8_DEPRECATED("Use CreateDataProperty / DefineOwnProperty",
|
|
||||||
- Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
|
|
||||||
- Local<Value> value,
|
|
||||||
- PropertyAttribute attribs = None));
|
|
||||||
+ bool ForceSet(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,
|
|
||||||
@@ -4288,18 +4291,7 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
||||||
*/
|
|
||||||
class V8_EXPORT Contents { // NOLINT
|
|
||||||
public:
|
|
||||||
- Contents()
|
|
||||||
- : data_(nullptr),
|
|
||||||
- byte_length_(0),
|
|
||||||
- allocation_base_(nullptr),
|
|
||||||
- allocation_length_(0),
|
|
||||||
- allocation_mode_(Allocator::AllocationMode::kNormal) {}
|
|
||||||
-
|
|
||||||
- void* AllocationBase() const { return allocation_base_; }
|
|
||||||
- size_t AllocationLength() const { return allocation_length_; }
|
|
||||||
- Allocator::AllocationMode AllocationMode() const {
|
|
||||||
- return allocation_mode_;
|
|
||||||
- }
|
|
||||||
+ Contents() : data_(NULL), byte_length_(0) {}
|
|
||||||
|
|
||||||
void* Data() const { return data_; }
|
|
||||||
size_t ByteLength() const { return byte_length_; }
|
|
||||||
@@ -4307,9 +4299,6 @@ class V8_EXPORT ArrayBuffer : public Object {
|
|
||||||
private:
|
|
||||||
void* data_;
|
|
||||||
size_t byte_length_;
|
|
||||||
- void* allocation_base_;
|
|
||||||
- size_t allocation_length_;
|
|
||||||
- Allocator::AllocationMode allocation_mode_;
|
|
||||||
|
|
||||||
friend class ArrayBuffer;
|
|
||||||
};
|
|
||||||
@@ -4658,18 +4647,7 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
||||||
*/
|
|
||||||
class V8_EXPORT Contents { // NOLINT
|
|
||||||
public:
|
|
||||||
- Contents()
|
|
||||||
- : data_(nullptr),
|
|
||||||
- byte_length_(0),
|
|
||||||
- allocation_base_(nullptr),
|
|
||||||
- allocation_length_(0),
|
|
||||||
- allocation_mode_(ArrayBuffer::Allocator::AllocationMode::kNormal) {}
|
|
||||||
-
|
|
||||||
- void* AllocationBase() const { return allocation_base_; }
|
|
||||||
- size_t AllocationLength() const { return allocation_length_; }
|
|
||||||
- ArrayBuffer::Allocator::AllocationMode AllocationMode() const {
|
|
||||||
- return allocation_mode_;
|
|
||||||
- }
|
|
||||||
+ Contents() : data_(NULL), byte_length_(0) {}
|
|
||||||
|
|
||||||
void* Data() const { return data_; }
|
|
||||||
size_t ByteLength() const { return byte_length_; }
|
|
||||||
@@ -4677,9 +4655,6 @@ class V8_EXPORT SharedArrayBuffer : public Object {
|
|
||||||
private:
|
|
||||||
void* data_;
|
|
||||||
size_t byte_length_;
|
|
||||||
- void* allocation_base_;
|
|
||||||
- size_t allocation_length_;
|
|
||||||
- ArrayBuffer::Allocator::AllocationMode allocation_mode_;
|
|
||||||
|
|
||||||
friend class SharedArrayBuffer;
|
|
||||||
};
|
|
||||||
@@ -4926,8 +4901,8 @@ class V8_EXPORT External : public Value {
|
|
||||||
F(ArrayProto_forEach, array_for_each_iterator) \
|
|
||||||
F(ArrayProto_keys, array_keys_iterator) \
|
|
||||||
F(ArrayProto_values, array_values_iterator) \
|
|
||||||
+ F(IteratorPrototype, initial_iterator_prototype) \
|
|
||||||
F(ErrorPrototype, initial_error_prototype) \
|
|
||||||
- F(IteratorPrototype, initial_iterator_prototype)
|
|
||||||
|
|
||||||
enum Intrinsic {
|
|
||||||
#define V8_DECL_INTRINSIC(name, iname) k##name,
|
|
||||||
@@ -5991,8 +5966,6 @@ V8_INLINE Local<Boolean> False(Isolate* isolate);
|
|
||||||
*
|
|
||||||
* The arguments for set_max_semi_space_size, set_max_old_space_size,
|
|
||||||
* set_max_executable_size, set_code_range_size specify limits in MB.
|
|
||||||
- *
|
|
||||||
- * The argument for set_max_semi_space_size_in_kb is in KB.
|
|
||||||
*/
|
|
||||||
class V8_EXPORT ResourceConstraints {
|
|
||||||
public:
|
|
||||||
@@ -6010,28 +5983,10 @@ class V8_EXPORT ResourceConstraints {
|
|
||||||
void ConfigureDefaults(uint64_t physical_memory,
|
|
||||||
uint64_t virtual_memory_limit);
|
|
||||||
|
|
||||||
- // Returns the max semi-space size in MB.
|
|
||||||
- V8_DEPRECATE_SOON("Use max_semi_space_size_in_kb()",
|
|
||||||
- int max_semi_space_size()) {
|
|
||||||
- return static_cast<int>(max_semi_space_size_in_kb_ / 1024);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- // Sets the max semi-space size in MB.
|
|
||||||
- V8_DEPRECATE_SOON("Use set_max_semi_space_size_in_kb(size_t limit_in_kb)",
|
|
||||||
- void set_max_semi_space_size(int limit_in_mb)) {
|
|
||||||
- max_semi_space_size_in_kb_ = limit_in_mb * 1024;
|
|
||||||
+ int max_semi_space_size() const { return max_semi_space_size_; }
|
|
||||||
+ void set_max_semi_space_size(int limit_in_mb) {
|
|
||||||
+ max_semi_space_size_ = limit_in_mb;
|
|
||||||
}
|
|
||||||
-
|
|
||||||
- // Returns the max semi-space size in KB.
|
|
||||||
- size_t max_semi_space_size_in_kb() const {
|
|
||||||
- return max_semi_space_size_in_kb_;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- // Sets the max semi-space size in KB.
|
|
||||||
- void set_max_semi_space_size_in_kb(size_t limit_in_kb) {
|
|
||||||
- max_semi_space_size_in_kb_ = limit_in_kb;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
int max_old_space_size() const { return max_old_space_size_; }
|
|
||||||
void set_max_old_space_size(int limit_in_mb) {
|
|
||||||
max_old_space_size_ = limit_in_mb;
|
|
||||||
@@ -6057,10 +6012,7 @@ class V8_EXPORT ResourceConstraints {
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
- // max_semi_space_size_ is in KB
|
|
||||||
- size_t max_semi_space_size_in_kb_;
|
|
||||||
-
|
|
||||||
- // The remaining limits are in MB
|
|
||||||
+ int max_semi_space_size_;
|
|
||||||
int max_old_space_size_;
|
|
||||||
int max_executable_size_;
|
|
||||||
uint32_t* stack_limit_;
|
|
||||||
@@ -6289,8 +6241,22 @@ typedef void (*FailedAccessCheckCallback)(Local<Object> target,
|
|
||||||
*/
|
|
||||||
typedef bool (*DeprecatedAllowCodeGenerationFromStringsCallback)(
|
|
||||||
Local<Context> context);
|
|
||||||
-typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context,
|
|
||||||
- Local<String> source);
|
|
||||||
+// The naming of this alias is for **Node v8.x releases only**
|
|
||||||
+// plain V8 >= 6.1 just calls it AllowCodeGenerationFromStringsCallback
|
|
||||||
+typedef bool (*FreshNewAllowCodeGenerationFromStringsCallback)(
|
|
||||||
+ Local<Context> context, Local<String> source);
|
|
||||||
+
|
|
||||||
+// a) no addon uses this anyway
|
|
||||||
+// b) this is sufficient because c++ type mangling takes care of resolving
|
|
||||||
+// the typedefs
|
|
||||||
+// c) doing it this way allows people to use the Fresh New variant
|
|
||||||
+#ifdef USING_V8_SHARED
|
|
||||||
+typedef DeprecatedAllowCodeGenerationFromStringsCallback
|
|
||||||
+ AllowCodeGenerationFromStringsCallback;
|
|
||||||
+#else
|
|
||||||
+typedef FreshNewAllowCodeGenerationFromStringsCallback
|
|
||||||
+ AllowCodeGenerationFromStringsCallback;
|
|
||||||
+#endif
|
|
||||||
|
|
||||||
// --- WebAssembly compilation callbacks ---
|
|
||||||
typedef bool (*ExtensionCallback)(const FunctionCallbackInfo<Value>&);
|
|
||||||
@@ -7569,7 +7535,7 @@ class V8_EXPORT Isolate {
|
|
||||||
* strings should be allowed.
|
|
||||||
*/
|
|
||||||
void SetAllowCodeGenerationFromStringsCallback(
|
|
||||||
- AllowCodeGenerationFromStringsCallback callback);
|
|
||||||
+ FreshNewAllowCodeGenerationFromStringsCallback callback);
|
|
||||||
V8_DEPRECATED("Use callback with source parameter.",
|
|
||||||
void SetAllowCodeGenerationFromStringsCallback(
|
|
||||||
DeprecatedAllowCodeGenerationFromStringsCallback callback));
|
|
||||||
@@ -7690,7 +7656,6 @@ class V8_EXPORT Isolate {
|
|
||||||
friend class PersistentValueMapBase;
|
|
||||||
|
|
||||||
void ReportExternalAllocationLimitReached();
|
|
||||||
- void CheckMemoryPressure();
|
|
||||||
};
|
|
||||||
|
|
||||||
class V8_EXPORT StartupData {
|
|
||||||
@@ -8051,7 +8016,7 @@ class V8_EXPORT V8 {
|
|
||||||
*/
|
|
||||||
static void ShutdownPlatform();
|
|
||||||
|
|
||||||
-#if V8_OS_POSIX
|
|
||||||
+#if V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID
|
|
||||||
/**
|
|
||||||
* Give the V8 signal handler a chance to handle a fault.
|
|
||||||
*
|
|
||||||
@@ -8072,7 +8037,7 @@ class V8_EXPORT V8 {
|
|
||||||
* points to a ucontext_t structure.
|
|
||||||
*/
|
|
||||||
static bool TryHandleSignal(int signal_number, void* info, void* context);
|
|
||||||
-#endif // V8_OS_POSIX
|
|
||||||
+#endif // V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable the default signal handler rather than using one provided by the
|
|
||||||
@@ -8940,8 +8905,6 @@ class Internals {
|
|
||||||
static const int kExternalMemoryOffset = 4 * kApiPointerSize;
|
|
||||||
static const int kExternalMemoryLimitOffset =
|
|
||||||
kExternalMemoryOffset + kApiInt64Size;
|
|
||||||
- static const int kExternalMemoryAtLastMarkCompactOffset =
|
|
||||||
- kExternalMemoryLimitOffset + kApiInt64Size;
|
|
||||||
static const int kIsolateRootsOffset = kExternalMemoryLimitOffset +
|
|
||||||
kApiInt64Size + kApiInt64Size +
|
|
||||||
kApiPointerSize + kApiPointerSize;
|
|
||||||
@@ -10160,32 +10123,13 @@ uint32_t Isolate::GetNumberOfDataSlots() {
|
|
||||||
int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
|
|
||||||
int64_t change_in_bytes) {
|
|
||||||
typedef internal::Internals I;
|
|
||||||
- const int64_t kMemoryReducerActivationLimit = 32 * 1024 * 1024;
|
|
||||||
int64_t* external_memory = reinterpret_cast<int64_t*>(
|
|
||||||
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset);
|
|
||||||
- int64_t* external_memory_limit = reinterpret_cast<int64_t*>(
|
|
||||||
+ const int64_t external_memory_limit = *reinterpret_cast<int64_t*>(
|
|
||||||
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryLimitOffset);
|
|
||||||
- int64_t* external_memory_at_last_mc =
|
|
||||||
- reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) +
|
|
||||||
- I::kExternalMemoryAtLastMarkCompactOffset);
|
|
||||||
const int64_t amount = *external_memory + change_in_bytes;
|
|
||||||
-
|
|
||||||
*external_memory = amount;
|
|
||||||
-
|
|
||||||
- int64_t allocation_diff_since_last_mc =
|
|
||||||
- *external_memory_at_last_mc - *external_memory;
|
|
||||||
- allocation_diff_since_last_mc = allocation_diff_since_last_mc < 0
|
|
||||||
- ? -allocation_diff_since_last_mc
|
|
||||||
- : allocation_diff_since_last_mc;
|
|
||||||
- if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) {
|
|
||||||
- CheckMemoryPressure();
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (change_in_bytes < 0) {
|
|
||||||
- *external_memory_limit += change_in_bytes;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (change_in_bytes > 0 && amount > *external_memory_limit) {
|
|
||||||
+ if (change_in_bytes > 0 && amount > external_memory_limit) {
|
|
||||||
ReportExternalAllocationLimitReached();
|
|
||||||
}
|
|
||||||
return *external_memory;
|
|
||||||
@@ -10219,7 +10163,8 @@ void V8::SetAllowCodeGenerationFromStringsCallback(
|
|
||||||
DeprecatedAllowCodeGenerationFromStringsCallback callback) {
|
|
||||||
Isolate* isolate = Isolate::GetCurrent();
|
|
||||||
isolate->SetAllowCodeGenerationFromStringsCallback(
|
|
||||||
- reinterpret_cast<AllowCodeGenerationFromStringsCallback>(callback));
|
|
||||||
+ reinterpret_cast<FreshNewAllowCodeGenerationFromStringsCallback>(
|
|
||||||
+ callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/api.cc b/src/api.cc
|
|
||||||
index ec1d583ea7..d33949252d 100644
|
|
||||||
--- a/src/api.cc
|
|
||||||
+++ b/src/api.cc
|
|
||||||
@@ -878,7 +878,7 @@ Extension::Extension(const char* name,
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceConstraints::ResourceConstraints()
|
|
||||||
- : max_semi_space_size_in_kb_(0),
|
|
||||||
+ : max_semi_space_size_(0),
|
|
||||||
max_old_space_size_(0),
|
|
||||||
stack_limit_(NULL),
|
|
||||||
code_range_size_(0),
|
|
||||||
@@ -886,8 +886,8 @@ ResourceConstraints::ResourceConstraints()
|
|
||||||
|
|
||||||
void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
|
|
||||||
uint64_t virtual_memory_limit) {
|
|
||||||
- set_max_semi_space_size_in_kb(
|
|
||||||
- i::Heap::ComputeMaxSemiSpaceSize(physical_memory));
|
|
||||||
+ set_max_semi_space_size(
|
|
||||||
+ static_cast<int>(i::Heap::ComputeMaxSemiSpaceSize(physical_memory)));
|
|
||||||
set_max_old_space_size(
|
|
||||||
static_cast<int>(i::Heap::ComputeMaxOldGenerationSize(physical_memory)));
|
|
||||||
set_max_zone_pool_size(i::AccountingAllocator::kMaxPoolSize);
|
|
||||||
@@ -903,7 +903,7 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
|
|
||||||
|
|
||||||
void SetResourceConstraints(i::Isolate* isolate,
|
|
||||||
const ResourceConstraints& constraints) {
|
|
||||||
- size_t semi_space_size = constraints.max_semi_space_size_in_kb();
|
|
||||||
+ int semi_space_size = constraints.max_semi_space_size();
|
|
||||||
int old_space_size = constraints.max_old_space_size();
|
|
||||||
size_t code_range_size = constraints.code_range_size();
|
|
||||||
size_t max_pool_size = constraints.max_zone_pool_size();
|
|
||||||
@@ -4505,6 +4505,24 @@ Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
+bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value,
|
|
||||||
+ v8::PropertyAttribute attribs) {
|
|
||||||
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
|
|
||||||
+ ENTER_V8_HELPER_DO_NOT_USE(isolate, Local<Context>(), Object, ForceSet,
|
|
||||||
+ false, i::HandleScope, false);
|
|
||||||
+ i::Handle<i::JSObject> self =
|
|
||||||
+ i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
|
|
||||||
+ i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
|
|
||||||
+ i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
|
|
||||||
+ has_pending_exception =
|
|
||||||
+ DefineObjectProperty(self, key_obj, value_obj,
|
|
||||||
+ static_cast<i::PropertyAttributes>(attribs))
|
|
||||||
+ .is_null();
|
|
||||||
+ EXCEPTION_BAILOUT_CHECK_SCOPED_DO_NOT_USE(isolate, false);
|
|
||||||
+ return true;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key,
|
|
||||||
Local<Value> value) {
|
|
||||||
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
|
|
||||||
@@ -6331,16 +6349,11 @@ bool v8::V8::Initialize() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
-#if V8_OS_POSIX
|
|
||||||
-bool V8::TryHandleSignal(int signum, void* info, void* context) {
|
|
||||||
#if V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID
|
|
||||||
- return v8::internal::trap_handler::TryHandleSignal(
|
|
||||||
- signum, static_cast<siginfo_t*>(info), static_cast<ucontext_t*>(context));
|
|
||||||
-#else // V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID
|
|
||||||
+bool V8::TryHandleSignal(int signum, void* info, void* context) {
|
|
||||||
return false;
|
|
||||||
-#endif
|
|
||||||
}
|
|
||||||
-#endif
|
|
||||||
+#endif // V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID
|
|
||||||
|
|
||||||
bool V8::RegisterDefaultSignalHandler() {
|
|
||||||
return v8::internal::trap_handler::RegisterDefaultSignalHandler();
|
|
||||||
@@ -7867,11 +7880,6 @@ v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents() {
|
|
||||||
i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this);
|
|
||||||
size_t byte_length = static_cast<size_t>(self->byte_length()->Number());
|
|
||||||
Contents contents;
|
|
||||||
- contents.allocation_base_ = self->allocation_base();
|
|
||||||
- contents.allocation_length_ = self->allocation_length();
|
|
||||||
- contents.allocation_mode_ = self->has_guard_region()
|
|
||||||
- ? Allocator::AllocationMode::kReservation
|
|
||||||
- : Allocator::AllocationMode::kNormal;
|
|
||||||
contents.data_ = self->backing_store();
|
|
||||||
contents.byte_length_ = byte_length;
|
|
||||||
return contents;
|
|
||||||
@@ -8080,12 +8088,6 @@ v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::GetContents() {
|
|
||||||
Contents contents;
|
|
||||||
contents.data_ = self->backing_store();
|
|
||||||
contents.byte_length_ = byte_length;
|
|
||||||
- // SharedArrayBuffers never have guard regions, so their allocation and data
|
|
||||||
- // are equivalent.
|
|
||||||
- contents.allocation_base_ = self->backing_store();
|
|
||||||
- contents.allocation_length_ = byte_length;
|
|
||||||
- contents.allocation_mode_ =
|
|
||||||
- ArrayBufferAllocator::Allocator::AllocationMode::kNormal;
|
|
||||||
return contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -8242,11 +8244,6 @@ void Isolate::ReportExternalAllocationLimitReached() {
|
|
||||||
heap->ReportExternalMemoryPressure();
|
|
||||||
}
|
|
||||||
|
|
||||||
-void Isolate::CheckMemoryPressure() {
|
|
||||||
- i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
|
|
||||||
- if (heap->gc_state() != i::Heap::NOT_IN_GC) return;
|
|
||||||
- heap->CheckMemoryPressure();
|
|
||||||
-}
|
|
||||||
|
|
||||||
HeapProfiler* Isolate::GetHeapProfiler() {
|
|
||||||
i::HeapProfiler* heap_profiler =
|
|
||||||
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
|
|
||||||
index 6cc718840a..399117ca32 100644
|
|
||||||
--- a/src/heap/heap.cc
|
|
||||||
+++ b/src/heap/heap.cc
|
|
||||||
@@ -85,7 +85,7 @@ Heap::Heap()
|
|
||||||
// semispace_size_ should be a power of 2 and old_generation_size_ should
|
|
||||||
// be a multiple of Page::kPageSize.
|
|
||||||
max_semi_space_size_(8 * (kPointerSize / 4) * MB),
|
|
||||||
- initial_semispace_size_(kMinSemiSpaceSizeInKB * KB),
|
|
||||||
+ initial_semispace_size_(MB),
|
|
||||||
max_old_generation_size_(700ul * (kPointerSize / 4) * MB),
|
|
||||||
initial_max_old_generation_size_(max_old_generation_size_),
|
|
||||||
initial_old_generation_size_(max_old_generation_size_ /
|
|
||||||
@@ -4573,12 +4573,10 @@ void Heap::CheckMemoryPressure() {
|
|
||||||
GarbageCollectionReason::kMemoryPressure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- if (memory_reducer_) {
|
|
||||||
- MemoryReducer::Event event;
|
|
||||||
- event.type = MemoryReducer::kPossibleGarbage;
|
|
||||||
- event.time_ms = MonotonicallyIncreasingTimeInMs();
|
|
||||||
- memory_reducer_->NotifyPossibleGarbage(event);
|
|
||||||
- }
|
|
||||||
+ MemoryReducer::Event event;
|
|
||||||
+ event.type = MemoryReducer::kPossibleGarbage;
|
|
||||||
+ event.time_ms = MonotonicallyIncreasingTimeInMs();
|
|
||||||
+ memory_reducer_->NotifyPossibleGarbage(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Heap::CollectGarbageOnMemoryPressure() {
|
|
||||||
@@ -5205,18 +5203,16 @@ void Heap::IterateStrongRoots(RootVisitor* v, VisitMode mode) {
|
|
||||||
// TODO(1236194): Since the heap size is configurable on the command line
|
|
||||||
// and through the API, we should gracefully handle the case that the heap
|
|
||||||
// size is not big enough to fit all the initial objects.
|
|
||||||
-bool Heap::ConfigureHeap(size_t max_semi_space_size_in_kb,
|
|
||||||
- size_t max_old_generation_size_in_mb,
|
|
||||||
- size_t code_range_size_in_mb) {
|
|
||||||
+bool Heap::ConfigureHeap(size_t max_semi_space_size, size_t max_old_space_size,
|
|
||||||
+ size_t code_range_size) {
|
|
||||||
if (HasBeenSetUp()) return false;
|
|
||||||
|
|
||||||
// Overwrite default configuration.
|
|
||||||
- if (max_semi_space_size_in_kb != 0) {
|
|
||||||
- max_semi_space_size_ =
|
|
||||||
- ROUND_UP(max_semi_space_size_in_kb * KB, Page::kPageSize);
|
|
||||||
+ if (max_semi_space_size != 0) {
|
|
||||||
+ max_semi_space_size_ = max_semi_space_size * MB;
|
|
||||||
}
|
|
||||||
- if (max_old_generation_size_in_mb != 0) {
|
|
||||||
- max_old_generation_size_ = max_old_generation_size_in_mb * MB;
|
|
||||||
+ if (max_old_space_size != 0) {
|
|
||||||
+ max_old_generation_size_ = max_old_space_size * MB;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If max space size flags are specified overwrite the configuration.
|
|
||||||
@@ -5244,12 +5240,6 @@ bool Heap::ConfigureHeap(size_t max_semi_space_size_in_kb,
|
|
||||||
max_semi_space_size_ = base::bits::RoundUpToPowerOfTwo32(
|
|
||||||
static_cast<uint32_t>(max_semi_space_size_));
|
|
||||||
|
|
||||||
- if (max_semi_space_size_ == kMaxSemiSpaceSizeInKB * KB) {
|
|
||||||
- // Start with at least 1*MB semi-space on machines with a lot of memory.
|
|
||||||
- initial_semispace_size_ =
|
|
||||||
- Max(initial_semispace_size_, static_cast<size_t>(1 * MB));
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
if (FLAG_min_semi_space_size > 0) {
|
|
||||||
size_t initial_semispace_size =
|
|
||||||
static_cast<size_t>(FLAG_min_semi_space_size) * MB;
|
|
||||||
@@ -5293,7 +5283,7 @@ bool Heap::ConfigureHeap(size_t max_semi_space_size_in_kb,
|
|
||||||
FixedArray::SizeFor(JSArray::kInitialMaxFastElementArray) +
|
|
||||||
AllocationMemento::kSize));
|
|
||||||
|
|
||||||
- code_range_size_ = code_range_size_in_mb * MB;
|
|
||||||
+ code_range_size_ = code_range_size * MB;
|
|
||||||
|
|
||||||
configured_ = true;
|
|
||||||
return true;
|
|
||||||
diff --git a/src/heap/heap.h b/src/heap/heap.h
|
|
||||||
index e90838e295..9beea144eb 100644
|
|
||||||
--- a/src/heap/heap.h
|
|
||||||
+++ b/src/heap/heap.h
|
|
||||||
@@ -573,11 +573,9 @@ class Heap {
|
|
||||||
static const int kPointerMultiplier = i::kPointerSize / 4;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
- // Semi-space size needs to be a multiple of page size.
|
|
||||||
- static const int kMinSemiSpaceSizeInKB =
|
|
||||||
- 1 * kPointerMultiplier * ((1 << kPageSizeBits) / KB);
|
|
||||||
- static const int kMaxSemiSpaceSizeInKB =
|
|
||||||
- 16 * kPointerMultiplier * ((1 << kPageSizeBits) / KB);
|
|
||||||
+ // The new space size has to be a power of 2. Sizes are in MB.
|
|
||||||
+ static const int kMinSemiSpaceSize = 1 * kPointerMultiplier;
|
|
||||||
+ static const int kMaxSemiSpaceSize = 8 * kPointerMultiplier;
|
|
||||||
|
|
||||||
// The old space size has to be a multiple of Page::kPageSize.
|
|
||||||
// Sizes are in MB.
|
|
||||||
@@ -927,14 +925,10 @@ class Heap {
|
|
||||||
// Initialization. ===========================================================
|
|
||||||
// ===========================================================================
|
|
||||||
|
|
||||||
- // Configure heap sizes
|
|
||||||
- // max_semi_space_size_in_kb: maximum semi-space size in KB
|
|
||||||
- // max_old_generation_size_in_mb: maximum old generation size in MB
|
|
||||||
- // code_range_size_in_mb: code range size in MB
|
|
||||||
- // Return false if the heap has been set up already.
|
|
||||||
- bool ConfigureHeap(size_t max_semi_space_size_in_kb,
|
|
||||||
- size_t max_old_generation_size_in_mb,
|
|
||||||
- size_t code_range_size_in_mb);
|
|
||||||
+ // Configure heap size in MB before setup. Return false if the heap has been
|
|
||||||
+ // set up already.
|
|
||||||
+ bool ConfigureHeap(size_t max_semi_space_size, size_t max_old_space_size,
|
|
||||||
+ size_t code_range_size);
|
|
||||||
bool ConfigureHeapDefault();
|
|
||||||
|
|
||||||
// Prepares the heap, setting up memory areas that are needed in the isolate
|
|
||||||
@@ -1310,12 +1304,10 @@ class Heap {
|
|
||||||
uint64_t capped_physical_memory =
|
|
||||||
Max(Min(physical_memory, max_physical_memory), min_physical_memory);
|
|
||||||
// linearly scale max semi-space size: (X-A)/(B-A)*(D-C)+C
|
|
||||||
- int semi_space_size_in_kb =
|
|
||||||
- static_cast<int>(((capped_physical_memory - min_physical_memory) *
|
|
||||||
- (kMaxSemiSpaceSizeInKB - kMinSemiSpaceSizeInKB)) /
|
|
||||||
- (max_physical_memory - min_physical_memory) +
|
|
||||||
- kMinSemiSpaceSizeInKB);
|
|
||||||
- return RoundUp(semi_space_size_in_kb, (1 << kPageSizeBits) / KB);
|
|
||||||
+ return static_cast<int>(((capped_physical_memory - min_physical_memory) *
|
|
||||||
+ (kMaxSemiSpaceSize - kMinSemiSpaceSize)) /
|
|
||||||
+ (max_physical_memory - min_physical_memory) +
|
|
||||||
+ kMinSemiSpaceSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the capacity of the heap in bytes w/o growing. Heap grows when
|
|
||||||
diff --git a/src/isolate.cc b/src/isolate.cc
|
|
||||||
index 48f5b30bd2..8e517982ac 100644
|
|
||||||
--- a/src/isolate.cc
|
|
||||||
+++ b/src/isolate.cc
|
|
||||||
@@ -2840,9 +2840,6 @@ bool Isolate::Init(Deserializer* des) {
|
|
||||||
Internals::kExternalMemoryOffset);
|
|
||||||
CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.external_memory_limit_)),
|
|
||||||
Internals::kExternalMemoryLimitOffset);
|
|
||||||
- CHECK_EQ(static_cast<int>(
|
|
||||||
- OFFSET_OF(Isolate, heap_.external_memory_at_last_mark_compact_)),
|
|
||||||
- Internals::kExternalMemoryAtLastMarkCompactOffset);
|
|
||||||
|
|
||||||
time_millis_at_init_ = heap_.MonotonicallyIncreasingTimeInMs();
|
|
||||||
|
|
||||||
diff --git a/src/trap-handler/handler-inside.cc b/src/trap-handler/handler-inside.cc
|
|
||||||
index a51bd9427f..4a748b8175 100644
|
|
||||||
--- a/src/trap-handler/handler-inside.cc
|
|
||||||
+++ b/src/trap-handler/handler-inside.cc
|
|
||||||
@@ -36,13 +36,13 @@ namespace trap_handler {
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
+#if V8_TRAP_HANDLER_SUPPORTED
|
|
||||||
bool IsKernelGeneratedSignal(siginfo_t* info) {
|
|
||||||
return info->si_code > 0 && info->si_code != SI_USER &&
|
|
||||||
info->si_code != SI_QUEUE && info->si_code != SI_TIMER &&
|
|
||||||
info->si_code != SI_ASYNCIO && info->si_code != SI_MESGQ;
|
|
||||||
}
|
|
||||||
|
|
||||||
-#if V8_TRAP_HANDLER_SUPPORTED
|
|
||||||
class SigUnmaskStack {
|
|
||||||
public:
|
|
||||||
explicit SigUnmaskStack(sigset_t sigs) {
|
|
||||||
diff --git a/src/trap-handler/trap-handler.h b/src/trap-handler/trap-handler.h
|
|
||||||
index ed9459918b..73a147f0cb 100644
|
|
||||||
--- a/src/trap-handler/trap-handler.h
|
|
||||||
+++ b/src/trap-handler/trap-handler.h
|
|
||||||
@@ -21,12 +21,7 @@ namespace v8 {
|
|
||||||
namespace internal {
|
|
||||||
namespace trap_handler {
|
|
||||||
|
|
||||||
-// TODO(eholk): Support trap handlers on other platforms.
|
|
||||||
-#if V8_TARGET_ARCH_X64 && V8_OS_LINUX && !V8_OS_ANDROID
|
|
||||||
-#define V8_TRAP_HANDLER_SUPPORTED 1
|
|
||||||
-#else
|
|
||||||
#define V8_TRAP_HANDLER_SUPPORTED 0
|
|
||||||
-#endif
|
|
||||||
|
|
||||||
struct ProtectedInstructionData {
|
|
||||||
// The offset of this instruction from the start of its code object.
|
|
||||||
diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc
|
|
||||||
index 6781d3de6a..d9608292e8 100644
|
|
||||||
--- a/test/cctest/heap/test-heap.cc
|
|
||||||
+++ b/test/cctest/heap/test-heap.cc
|
|
||||||
@@ -4806,7 +4806,7 @@ HEAP_TEST(Regress538257) {
|
|
||||||
FLAG_manual_evacuation_candidates_selection = true;
|
|
||||||
v8::Isolate::CreateParams create_params;
|
|
||||||
// Set heap limits.
|
|
||||||
- create_params.constraints.set_max_semi_space_size_in_kb(1024);
|
|
||||||
+ create_params.constraints.set_max_semi_space_size(1);
|
|
||||||
create_params.constraints.set_max_old_space_size(6);
|
|
||||||
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
||||||
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
|
||||||
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
|
||||||
index 2d64279bf8..aa4cba5a60 100644
|
|
||||||
--- a/test/cctest/test-api.cc
|
|
||||||
+++ b/test/cctest/test-api.cc
|
|
||||||
@@ -3453,16 +3453,10 @@ class ScopedArrayBufferContents {
|
|
||||||
public:
|
|
||||||
explicit ScopedArrayBufferContents(const v8::ArrayBuffer::Contents& contents)
|
|
||||||
: contents_(contents) {}
|
|
||||||
- ~ScopedArrayBufferContents() { free(contents_.AllocationBase()); }
|
|
||||||
+ ~ScopedArrayBufferContents() { free(contents_.Data()); }
|
|
||||||
void* Data() const { return contents_.Data(); }
|
|
||||||
size_t ByteLength() const { return contents_.ByteLength(); }
|
|
||||||
|
|
||||||
- void* AllocationBase() const { return contents_.AllocationBase(); }
|
|
||||||
- size_t AllocationLength() const { return contents_.AllocationLength(); }
|
|
||||||
- v8::ArrayBuffer::Allocator::AllocationMode AllocationMode() const {
|
|
||||||
- return contents_.AllocationMode();
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
private:
|
|
||||||
const v8::ArrayBuffer::Contents contents_;
|
|
||||||
};
|
|
||||||
@@ -3738,43 +3732,15 @@ THREADED_TEST(ArrayBuffer_NeuteringScript) {
|
|
||||||
CheckDataViewIsNeutered(dv);
|
|
||||||
}
|
|
||||||
|
|
||||||
-THREADED_TEST(ArrayBuffer_AllocationInformation) {
|
|
||||||
- LocalContext env;
|
|
||||||
- v8::Isolate* isolate = env->GetIsolate();
|
|
||||||
- v8::HandleScope handle_scope(isolate);
|
|
||||||
-
|
|
||||||
- const size_t ab_size = 1024;
|
|
||||||
- Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, ab_size);
|
|
||||||
- ScopedArrayBufferContents contents(ab->Externalize());
|
|
||||||
-
|
|
||||||
- // Array buffers should have normal allocation mode.
|
|
||||||
- CHECK(contents.AllocationMode() ==
|
|
||||||
- v8::ArrayBuffer::Allocator::AllocationMode::kNormal);
|
|
||||||
- // The allocation must contain the buffer (normally they will be equal, but
|
|
||||||
- // this is not required by the contract).
|
|
||||||
- CHECK_NOT_NULL(contents.AllocationBase());
|
|
||||||
- const uintptr_t alloc =
|
|
||||||
- reinterpret_cast<uintptr_t>(contents.AllocationBase());
|
|
||||||
- const uintptr_t data = reinterpret_cast<uintptr_t>(contents.Data());
|
|
||||||
- CHECK_LE(alloc, data);
|
|
||||||
- CHECK_LE(data + contents.ByteLength(), alloc + contents.AllocationLength());
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
class ScopedSharedArrayBufferContents {
|
|
||||||
public:
|
|
||||||
explicit ScopedSharedArrayBufferContents(
|
|
||||||
const v8::SharedArrayBuffer::Contents& contents)
|
|
||||||
: contents_(contents) {}
|
|
||||||
- ~ScopedSharedArrayBufferContents() { free(contents_.AllocationBase()); }
|
|
||||||
+ ~ScopedSharedArrayBufferContents() { free(contents_.Data()); }
|
|
||||||
void* Data() const { return contents_.Data(); }
|
|
||||||
size_t ByteLength() const { return contents_.ByteLength(); }
|
|
||||||
|
|
||||||
- void* AllocationBase() const { return contents_.AllocationBase(); }
|
|
||||||
- size_t AllocationLength() const { return contents_.AllocationLength(); }
|
|
||||||
- v8::ArrayBuffer::Allocator::AllocationMode AllocationMode() const {
|
|
||||||
- return contents_.AllocationMode();
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
private:
|
|
||||||
const v8::SharedArrayBuffer::Contents contents_;
|
|
||||||
};
|
|
||||||
@@ -20361,7 +20327,7 @@ class InitDefaultIsolateThread : public v8::base::Thread {
|
|
||||||
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
||||||
switch (testCase_) {
|
|
||||||
case SetResourceConstraints: {
|
|
||||||
- create_params.constraints.set_max_semi_space_size_in_kb(1024);
|
|
||||||
+ create_params.constraints.set_max_semi_space_size(1);
|
|
||||||
create_params.constraints.set_max_old_space_size(6);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
@@ -26057,29 +26023,6 @@ TEST(FutexInterruption) {
|
|
||||||
timeout_thread.Join();
|
|
||||||
}
|
|
||||||
|
|
||||||
-THREADED_TEST(SharedArrayBuffer_AllocationInformation) {
|
|
||||||
- i::FLAG_harmony_sharedarraybuffer = true;
|
|
||||||
- LocalContext env;
|
|
||||||
- v8::Isolate* isolate = env->GetIsolate();
|
|
||||||
- v8::HandleScope handle_scope(isolate);
|
|
||||||
-
|
|
||||||
- const size_t ab_size = 1024;
|
|
||||||
- Local<v8::SharedArrayBuffer> ab =
|
|
||||||
- v8::SharedArrayBuffer::New(isolate, ab_size);
|
|
||||||
- ScopedSharedArrayBufferContents contents(ab->Externalize());
|
|
||||||
-
|
|
||||||
- // Array buffers should have normal allocation mode.
|
|
||||||
- CHECK(contents.AllocationMode() ==
|
|
||||||
- v8::ArrayBuffer::Allocator::AllocationMode::kNormal);
|
|
||||||
- // The allocation must contain the buffer (normally they will be equal, but
|
|
||||||
- // this is not required by the contract).
|
|
||||||
- CHECK_NOT_NULL(contents.AllocationBase());
|
|
||||||
- const uintptr_t alloc =
|
|
||||||
- reinterpret_cast<uintptr_t>(contents.AllocationBase());
|
|
||||||
- const uintptr_t data = reinterpret_cast<uintptr_t>(contents.Data());
|
|
||||||
- CHECK_LE(alloc, data);
|
|
||||||
- CHECK_LE(data + contents.ByteLength(), alloc + contents.AllocationLength());
|
|
||||||
-}
|
|
||||||
|
|
||||||
static int nb_uncaught_exception_callback_calls = 0;
|
|
||||||
|
|
||||||
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc
|
|
||||||
index 73e9c58596..d98a4819b5 100644
|
|
||||||
--- a/test/cctest/test-strings.cc
|
|
||||||
+++ b/test/cctest/test-strings.cc
|
|
||||||
@@ -1301,7 +1301,7 @@ TEST(SliceFromSlice) {
|
|
||||||
UNINITIALIZED_TEST(OneByteArrayJoin) {
|
|
||||||
v8::Isolate::CreateParams create_params;
|
|
||||||
// Set heap limits.
|
|
||||||
- create_params.constraints.set_max_semi_space_size_in_kb(1024);
|
|
||||||
+ create_params.constraints.set_max_semi_space_size(1);
|
|
||||||
create_params.constraints.set_max_old_space_size(7);
|
|
||||||
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
||||||
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
|
||||||
diff --git a/test/unittests/heap/heap-unittest.cc b/test/unittests/heap/heap-unittest.cc
|
|
||||||
index 3b7b610c8c..8dab181ca7 100644
|
|
||||||
--- a/test/unittests/heap/heap-unittest.cc
|
|
||||||
+++ b/test/unittests/heap/heap-unittest.cc
|
|
||||||
@@ -63,14 +63,19 @@ TEST(Heap, MaxHeapGrowingFactor) {
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(Heap, SemiSpaceSize) {
|
|
||||||
- const size_t KB = static_cast<size_t>(i::KB);
|
|
||||||
- const size_t MB = static_cast<size_t>(i::MB);
|
|
||||||
- const size_t pm = i::Heap::kPointerMultiplier;
|
|
||||||
- ASSERT_EQ(1u * pm * MB / 2, i::Heap::ComputeMaxSemiSpaceSize(0u) * KB);
|
|
||||||
- ASSERT_EQ(1u * pm * MB / 2, i::Heap::ComputeMaxSemiSpaceSize(512u * MB) * KB);
|
|
||||||
- ASSERT_EQ(2u * pm * MB, i::Heap::ComputeMaxSemiSpaceSize(1024u * MB) * KB);
|
|
||||||
- ASSERT_EQ(5u * pm * MB, i::Heap::ComputeMaxSemiSpaceSize(2024u * MB) * KB);
|
|
||||||
- ASSERT_EQ(8u * pm * MB, i::Heap::ComputeMaxSemiSpaceSize(4095u * MB) * KB);
|
|
||||||
+ uint64_t configurations[][2] = {
|
|
||||||
+ {0, 1 * i::Heap::kPointerMultiplier},
|
|
||||||
+ {512 * i::MB, 1 * i::Heap::kPointerMultiplier},
|
|
||||||
+ {1 * i::GB, 3 * i::Heap::kPointerMultiplier},
|
|
||||||
+ {2 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize},
|
|
||||||
+ {4 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize},
|
|
||||||
+ {8 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize}};
|
|
||||||
+
|
|
||||||
+ for (auto configuration : configurations) {
|
|
||||||
+ ASSERT_EQ(configuration[1],
|
|
||||||
+ static_cast<uint64_t>(
|
|
||||||
+ i::Heap::ComputeMaxSemiSpaceSize(configuration[0])));
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(Heap, OldGenerationSize) {
|
|
|
@ -1,40 +0,0 @@
|
||||||
diff --git a/include/v8.h b/include/v8.h
|
|
||||||
index be51a94a53..04b9141873 100644
|
|
||||||
--- a/include/v8.h
|
|
||||||
+++ b/include/v8.h
|
|
||||||
@@ -8025,7 +8025,7 @@ class V8_EXPORT V8 {
|
|
||||||
*/
|
|
||||||
static void ShutdownPlatform();
|
|
||||||
|
|
||||||
-#if V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID
|
|
||||||
+#if V8_OS_POSIX
|
|
||||||
/**
|
|
||||||
* Give the V8 signal handler a chance to handle a fault.
|
|
||||||
*
|
|
||||||
@@ -8046,7 +8046,7 @@ class V8_EXPORT V8 {
|
|
||||||
* points to a ucontext_t structure.
|
|
||||||
*/
|
|
||||||
static bool TryHandleSignal(int signal_number, void* info, void* context);
|
|
||||||
-#endif // V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID
|
|
||||||
+#endif // V8_OS_POSIX
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable the default signal handler rather than using one provided by the
|
|
||||||
diff --git a/src/api.cc b/src/api.cc
|
|
||||||
index fa5610fa43..d9ee0e8c8a 100644
|
|
||||||
--- a/src/api.cc
|
|
||||||
+++ b/src/api.cc
|
|
||||||
@@ -6349,11 +6349,11 @@ bool v8::V8::Initialize() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
-#if V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID
|
|
||||||
+#if V8_OS_POSIX
|
|
||||||
bool V8::TryHandleSignal(int signum, void* info, void* context) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
-#endif // V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID
|
|
||||||
+#endif // V8_OS_POSIX
|
|
||||||
|
|
||||||
bool V8::RegisterDefaultSignalHandler() {
|
|
||||||
return v8::internal::trap_handler::RegisterDefaultSignalHandler();
|
|
|
@ -0,0 +1,262 @@
|
||||||
|
diff --git a/BUILD.gn b/BUILD.gn
|
||||||
|
index 434889d769..e1dabb10a3 100644
|
||||||
|
--- a/BUILD.gn
|
||||||
|
+++ b/BUILD.gn
|
||||||
|
@@ -40,6 +40,9 @@ declare_args() {
|
||||||
|
# Embeds the given script into the snapshot.
|
||||||
|
v8_embed_script = ""
|
||||||
|
|
||||||
|
+ # Allows the embedder to add a custom suffix to the version string.
|
||||||
|
+ v8_embedder_string = ""
|
||||||
|
+
|
||||||
|
# Sets -dENABLE_DISASSEMBLER.
|
||||||
|
v8_enable_disassembler = ""
|
||||||
|
|
||||||
|
@@ -252,6 +255,9 @@ config("features") {
|
||||||
|
|
||||||
|
defines = []
|
||||||
|
|
||||||
|
+ if (v8_embedder_string != "") {
|
||||||
|
+ defines += [ "V8_EMBEDDER_STRING=\"$v8_embedder_string\"" ]
|
||||||
|
+ }
|
||||||
|
if (v8_enable_disassembler) {
|
||||||
|
defines += [ "ENABLE_DISASSEMBLER" ]
|
||||||
|
}
|
||||||
|
diff --git a/gypfiles/features.gypi b/gypfiles/features.gypi
|
||||||
|
index 55b250ddc1..6b0b293db6 100644
|
||||||
|
--- a/gypfiles/features.gypi
|
||||||
|
+++ b/gypfiles/features.gypi
|
||||||
|
@@ -33,6 +33,9 @@
|
||||||
|
'v8_target_arch%': '<(target_arch)',
|
||||||
|
},
|
||||||
|
|
||||||
|
+ # Allows the embedder to add a custom suffix to the version string.
|
||||||
|
+ 'v8_embedder_string%': '',
|
||||||
|
+
|
||||||
|
'v8_enable_disassembler%': 0,
|
||||||
|
|
||||||
|
'v8_promise_internal_field_count%': 0,
|
||||||
|
@@ -86,6 +89,9 @@
|
||||||
|
},
|
||||||
|
'target_defaults': {
|
||||||
|
'conditions': [
|
||||||
|
+ ['v8_embedder_string!=""', {
|
||||||
|
+ 'defines': ['V8_EMBEDDER_STRING="<(v8_embedder_string)"',],
|
||||||
|
+ }],
|
||||||
|
['v8_enable_disassembler==1', {
|
||||||
|
'defines': ['ENABLE_DISASSEMBLER',],
|
||||||
|
}],
|
||||||
|
diff --git a/include/v8-version-string.h b/include/v8-version-string.h
|
||||||
|
index 075282de4c..eab0934804 100644
|
||||||
|
--- a/include/v8-version-string.h
|
||||||
|
+++ b/include/v8-version-string.h
|
||||||
|
@@ -16,6 +16,10 @@
|
||||||
|
#define V8_CANDIDATE_STRING ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+#ifndef V8_EMBEDDER_STRING
|
||||||
|
+#define V8_EMBEDDER_STRING ""
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
#define V8_SX(x) #x
|
||||||
|
#define V8_S(x) V8_SX(x)
|
||||||
|
|
||||||
|
@@ -23,7 +27,7 @@
|
||||||
|
#define V8_VERSION_STRING \
|
||||||
|
V8_S(V8_MAJOR_VERSION) \
|
||||||
|
"." V8_S(V8_MINOR_VERSION) "." V8_S(V8_BUILD_NUMBER) "." V8_S( \
|
||||||
|
- V8_PATCH_LEVEL) V8_CANDIDATE_STRING
|
||||||
|
+ V8_PATCH_LEVEL) V8_EMBEDDER_STRING V8_CANDIDATE_STRING
|
||||||
|
#else
|
||||||
|
#define V8_VERSION_STRING \
|
||||||
|
V8_S(V8_MAJOR_VERSION) \
|
||||||
|
diff --git a/src/log-utils.cc b/src/log-utils.cc
|
||||||
|
index bb2a82f17b..82d24a111e 100644
|
||||||
|
--- a/src/log-utils.cc
|
||||||
|
+++ b/src/log-utils.cc
|
||||||
|
@@ -52,9 +52,16 @@ void Log::Initialize(const char* log_file_name) {
|
||||||
|
|
||||||
|
if (output_handle_ != nullptr) {
|
||||||
|
Log::MessageBuilder msg(this);
|
||||||
|
- msg.Append("v8-version,%d,%d,%d,%d,%d", Version::GetMajor(),
|
||||||
|
- Version::GetMinor(), Version::GetBuild(), Version::GetPatch(),
|
||||||
|
- Version::IsCandidate());
|
||||||
|
+ if (strlen(Version::GetEmbedder()) == 0) {
|
||||||
|
+ msg.Append("v8-version,%d,%d,%d,%d,%d", Version::GetMajor(),
|
||||||
|
+ Version::GetMinor(), Version::GetBuild(),
|
||||||
|
+ Version::GetPatch(), Version::IsCandidate());
|
||||||
|
+ } else {
|
||||||
|
+ msg.Append("v8-version,%d,%d,%d,%d,%s,%d", Version::GetMajor(),
|
||||||
|
+ Version::GetMinor(), Version::GetBuild(),
|
||||||
|
+ Version::GetPatch(), Version::GetEmbedder(),
|
||||||
|
+ Version::IsCandidate());
|
||||||
|
+ }
|
||||||
|
msg.WriteToLogFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/version.cc b/src/version.cc
|
||||||
|
index 3252d55035..b050fc9ab5 100644
|
||||||
|
--- a/src/version.cc
|
||||||
|
+++ b/src/version.cc
|
||||||
|
@@ -20,6 +20,7 @@ int Version::major_ = V8_MAJOR_VERSION;
|
||||||
|
int Version::minor_ = V8_MINOR_VERSION;
|
||||||
|
int Version::build_ = V8_BUILD_NUMBER;
|
||||||
|
int Version::patch_ = V8_PATCH_LEVEL;
|
||||||
|
+const char* Version::embedder_ = V8_EMBEDDER_STRING;
|
||||||
|
bool Version::candidate_ = (V8_IS_CANDIDATE_VERSION != 0);
|
||||||
|
const char* Version::soname_ = SONAME;
|
||||||
|
const char* Version::version_string_ = V8_VERSION_STRING;
|
||||||
|
@@ -33,12 +34,12 @@ void Version::GetString(Vector<char> str) {
|
||||||
|
const char* is_simulator = "";
|
||||||
|
#endif // USE_SIMULATOR
|
||||||
|
if (GetPatch() > 0) {
|
||||||
|
- SNPrintF(str, "%d.%d.%d.%d%s%s",
|
||||||
|
- GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate,
|
||||||
|
- is_simulator);
|
||||||
|
+ SNPrintF(str, "%d.%d.%d.%d%s%s%s",
|
||||||
|
+ GetMajor(), GetMinor(), GetBuild(), GetPatch(), GetEmbedder(),
|
||||||
|
+ candidate, is_simulator);
|
||||||
|
} else {
|
||||||
|
- SNPrintF(str, "%d.%d.%d%s%s",
|
||||||
|
- GetMajor(), GetMinor(), GetBuild(), candidate,
|
||||||
|
+ SNPrintF(str, "%d.%d.%d%s%s%s",
|
||||||
|
+ GetMajor(), GetMinor(), GetBuild(), GetEmbedder(), candidate,
|
||||||
|
is_simulator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -50,11 +51,11 @@ void Version::GetSONAME(Vector<char> str) {
|
||||||
|
// Generate generic SONAME if no specific SONAME is defined.
|
||||||
|
const char* candidate = IsCandidate() ? "-candidate" : "";
|
||||||
|
if (GetPatch() > 0) {
|
||||||
|
- SNPrintF(str, "libv8-%d.%d.%d.%d%s.so",
|
||||||
|
- GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate);
|
||||||
|
+ SNPrintF(str, "libv8-%d.%d.%d.%d%s%s.so", GetMajor(), GetMinor(),
|
||||||
|
+ GetBuild(), GetPatch(), GetEmbedder(), candidate);
|
||||||
|
} else {
|
||||||
|
- SNPrintF(str, "libv8-%d.%d.%d%s.so",
|
||||||
|
- GetMajor(), GetMinor(), GetBuild(), candidate);
|
||||||
|
+ SNPrintF(str, "libv8-%d.%d.%d%s%s.so", GetMajor(), GetMinor(), GetBuild(),
|
||||||
|
+ GetEmbedder(), candidate);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Use specific SONAME.
|
||||||
|
diff --git a/src/version.h b/src/version.h
|
||||||
|
index 3395d7f4fe..20d9c71fe7 100644
|
||||||
|
--- a/src/version.h
|
||||||
|
+++ b/src/version.h
|
||||||
|
@@ -18,6 +18,7 @@ class Version {
|
||||||
|
static int GetMinor() { return minor_; }
|
||||||
|
static int GetBuild() { return build_; }
|
||||||
|
static int GetPatch() { return patch_; }
|
||||||
|
+ static const char* GetEmbedder() { return embedder_; }
|
||||||
|
static bool IsCandidate() { return candidate_; }
|
||||||
|
static uint32_t Hash() {
|
||||||
|
return static_cast<uint32_t>(
|
||||||
|
@@ -38,13 +39,15 @@ class Version {
|
||||||
|
static int minor_;
|
||||||
|
static int build_;
|
||||||
|
static int patch_;
|
||||||
|
+ static const char* embedder_;
|
||||||
|
static bool candidate_;
|
||||||
|
static const char* soname_;
|
||||||
|
static const char* version_string_;
|
||||||
|
|
||||||
|
// In test-version.cc.
|
||||||
|
friend void SetVersion(int major, int minor, int build, int patch,
|
||||||
|
- bool candidate, const char* soname);
|
||||||
|
+ const char* embedder, bool candidate,
|
||||||
|
+ const char* soname);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
diff --git a/test/cctest/test-version.cc b/test/cctest/test-version.cc
|
||||||
|
index 2c51af0ae6..78bc81a7e8 100644
|
||||||
|
--- a/test/cctest/test-version.cc
|
||||||
|
+++ b/test/cctest/test-version.cc
|
||||||
|
@@ -35,24 +35,25 @@ namespace v8 {
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
void SetVersion(int major, int minor, int build, int patch,
|
||||||
|
- bool candidate, const char* soname) {
|
||||||
|
+ const char* embedder, bool candidate, const char* soname) {
|
||||||
|
Version::major_ = major;
|
||||||
|
Version::minor_ = minor;
|
||||||
|
Version::build_ = build;
|
||||||
|
Version::patch_ = patch;
|
||||||
|
+ Version::embedder_ = embedder;
|
||||||
|
Version::candidate_ = candidate;
|
||||||
|
Version::soname_ = soname;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void CheckVersion(int major, int minor, int build,
|
||||||
|
- int patch, bool candidate,
|
||||||
|
+static void CheckVersion(int major, int minor, int build, int patch,
|
||||||
|
+ const char* embedder, bool candidate,
|
||||||
|
const char* expected_version_string,
|
||||||
|
const char* expected_generic_soname) {
|
||||||
|
static v8::internal::EmbeddedVector<char, 128> version_str;
|
||||||
|
static v8::internal::EmbeddedVector<char, 128> soname_str;
|
||||||
|
|
||||||
|
// Test version without specific SONAME.
|
||||||
|
- SetVersion(major, minor, build, patch, candidate, "");
|
||||||
|
+ SetVersion(major, minor, build, patch, embedder, candidate, "");
|
||||||
|
Version::GetString(version_str);
|
||||||
|
CHECK_EQ(0, strcmp(expected_version_string, version_str.start()));
|
||||||
|
Version::GetSONAME(soname_str);
|
||||||
|
@@ -60,7 +61,7 @@ static void CheckVersion(int major, int minor, int build,
|
||||||
|
|
||||||
|
// Test version with specific SONAME.
|
||||||
|
const char* soname = "libv8.so.1";
|
||||||
|
- SetVersion(major, minor, build, patch, candidate, soname);
|
||||||
|
+ SetVersion(major, minor, build, patch, embedder, candidate, soname);
|
||||||
|
Version::GetString(version_str);
|
||||||
|
CHECK_EQ(0, strcmp(expected_version_string, version_str.start()));
|
||||||
|
Version::GetSONAME(soname_str);
|
||||||
|
@@ -82,19 +83,35 @@ TEST(VersionString) {
|
||||||
|
CheckVersion(2, 5, 10, 7, false, "2.5.10.7 SIMULATOR", "libv8-2.5.10.7.so");
|
||||||
|
CheckVersion(2, 5, 10, 7, true,
|
||||||
|
"2.5.10.7 (candidate) SIMULATOR", "libv8-2.5.10.7-candidate.so");
|
||||||
|
+ CheckVersion(6, 0, 287, 0, "-emb.1", false, "6.0.287-emb.1 SIMULATOR",
|
||||||
|
+ "libv8-6.0.287-emb.1.so");
|
||||||
|
+ CheckVersion(6, 0, 287, 0, "-emb.1", true, "6.0.287-emb.1 (candidate) SIMULATOR",
|
||||||
|
+ "libv8-6.0.287-emb.1-candidate.so");
|
||||||
|
+ CheckVersion(6, 0, 287, 53, "-emb.1", false, "6.0.287.53-emb.1 SIMULATOR",
|
||||||
|
+ "libv8-6.0.287.53-emb.1.so");
|
||||||
|
+ CheckVersion(6, 0, 287, 53, "-emb.1", true, "6.0.287.53-emb.1 (candidate) SIMULATOR",
|
||||||
|
+ "libv8-6.0.287.53-emb.1-candidate.so");
|
||||||
|
#else
|
||||||
|
- CheckVersion(0, 0, 0, 0, false, "0.0.0", "libv8-0.0.0.so");
|
||||||
|
- CheckVersion(0, 0, 0, 0, true,
|
||||||
|
- "0.0.0 (candidate)", "libv8-0.0.0-candidate.so");
|
||||||
|
- CheckVersion(1, 0, 0, 0, false, "1.0.0", "libv8-1.0.0.so");
|
||||||
|
- CheckVersion(1, 0, 0, 0, true,
|
||||||
|
- "1.0.0 (candidate)", "libv8-1.0.0-candidate.so");
|
||||||
|
- CheckVersion(1, 0, 0, 1, false, "1.0.0.1", "libv8-1.0.0.1.so");
|
||||||
|
- CheckVersion(1, 0, 0, 1, true,
|
||||||
|
- "1.0.0.1 (candidate)", "libv8-1.0.0.1-candidate.so");
|
||||||
|
- CheckVersion(2, 5, 10, 7, false, "2.5.10.7", "libv8-2.5.10.7.so");
|
||||||
|
- CheckVersion(2, 5, 10, 7, true,
|
||||||
|
- "2.5.10.7 (candidate)", "libv8-2.5.10.7-candidate.so");
|
||||||
|
+ CheckVersion(0, 0, 0, 0, "", false, "0.0.0", "libv8-0.0.0.so");
|
||||||
|
+ CheckVersion(0, 0, 0, 0, "", true, "0.0.0 (candidate)",
|
||||||
|
+ "libv8-0.0.0-candidate.so");
|
||||||
|
+ CheckVersion(1, 0, 0, 0, "", false, "1.0.0", "libv8-1.0.0.so");
|
||||||
|
+ CheckVersion(1, 0, 0, 0, "", true, "1.0.0 (candidate)",
|
||||||
|
+ "libv8-1.0.0-candidate.so");
|
||||||
|
+ CheckVersion(1, 0, 0, 1, "", false, "1.0.0.1", "libv8-1.0.0.1.so");
|
||||||
|
+ CheckVersion(1, 0, 0, 1, "", true, "1.0.0.1 (candidate)",
|
||||||
|
+ "libv8-1.0.0.1-candidate.so");
|
||||||
|
+ CheckVersion(2, 5, 10, 7, "", false, "2.5.10.7", "libv8-2.5.10.7.so");
|
||||||
|
+ CheckVersion(2, 5, 10, 7, "", true, "2.5.10.7 (candidate)",
|
||||||
|
+ "libv8-2.5.10.7-candidate.so");
|
||||||
|
+ CheckVersion(6, 0, 287, 0, "-emb.1", false, "6.0.287-emb.1",
|
||||||
|
+ "libv8-6.0.287-emb.1.so");
|
||||||
|
+ CheckVersion(6, 0, 287, 0, "-emb.1", true, "6.0.287-emb.1 (candidate)",
|
||||||
|
+ "libv8-6.0.287-emb.1-candidate.so");
|
||||||
|
+ CheckVersion(6, 0, 287, 53, "-emb.1", false, "6.0.287.53-emb.1",
|
||||||
|
+ "libv8-6.0.287.53-emb.1.so");
|
||||||
|
+ CheckVersion(6, 0, 287, 53, "-emb.1", true, "6.0.287.53-emb.1 (candidate)",
|
||||||
|
+ "libv8-6.0.287.53-emb.1-candidate.so");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,410 @@
|
||||||
|
diff --git a/include/v8.h b/include/v8.h
|
||||||
|
index deedb13dee..2a2ca02700 100644
|
||||||
|
--- a/include/v8.h
|
||||||
|
+++ b/include/v8.h
|
||||||
|
@@ -7230,6 +7230,8 @@ class V8_EXPORT Isolate {
|
||||||
|
|
||||||
|
typedef void (*GCCallback)(Isolate* isolate, GCType type,
|
||||||
|
GCCallbackFlags flags);
|
||||||
|
+ typedef void (*GCCallbackWithData)(Isolate* isolate, GCType type,
|
||||||
|
+ GCCallbackFlags flags, void* data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the host application to receive a notification before a
|
||||||
|
@@ -7240,6 +7242,8 @@ class V8_EXPORT Isolate {
|
||||||
|
* not possible to register the same callback function two times with
|
||||||
|
* different GCType filters.
|
||||||
|
*/
|
||||||
|
+ void AddGCPrologueCallback(GCCallbackWithData callback, void* data = nullptr,
|
||||||
|
+ GCType gc_type_filter = kGCTypeAll);
|
||||||
|
void AddGCPrologueCallback(GCCallback callback,
|
||||||
|
GCType gc_type_filter = kGCTypeAll);
|
||||||
|
|
||||||
|
@@ -7247,6 +7251,7 @@ class V8_EXPORT Isolate {
|
||||||
|
* This function removes callback which was installed by
|
||||||
|
* AddGCPrologueCallback function.
|
||||||
|
*/
|
||||||
|
+ void RemoveGCPrologueCallback(GCCallbackWithData, void* data = nullptr);
|
||||||
|
void RemoveGCPrologueCallback(GCCallback callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@@ -7263,6 +7268,8 @@ class V8_EXPORT Isolate {
|
||||||
|
* not possible to register the same callback function two times with
|
||||||
|
* different GCType filters.
|
||||||
|
*/
|
||||||
|
+ void AddGCEpilogueCallback(GCCallbackWithData callback, void* data = nullptr,
|
||||||
|
+ GCType gc_type_filter = kGCTypeAll);
|
||||||
|
void AddGCEpilogueCallback(GCCallback callback,
|
||||||
|
GCType gc_type_filter = kGCTypeAll);
|
||||||
|
|
||||||
|
@@ -7270,6 +7277,8 @@ class V8_EXPORT Isolate {
|
||||||
|
* This function removes callback which was installed by
|
||||||
|
* AddGCEpilogueCallback function.
|
||||||
|
*/
|
||||||
|
+ void RemoveGCEpilogueCallback(GCCallbackWithData callback,
|
||||||
|
+ void* data = nullptr);
|
||||||
|
void RemoveGCEpilogueCallback(GCCallback callback);
|
||||||
|
|
||||||
|
typedef size_t (*GetExternallyAllocatedMemoryInBytesCallback)();
|
||||||
|
diff --git a/src/api.cc b/src/api.cc
|
||||||
|
index 4b6cb1e727..8c1fe898ed 100644
|
||||||
|
--- a/src/api.cc
|
||||||
|
+++ b/src/api.cc
|
||||||
|
@@ -8378,41 +8378,70 @@ v8::Local<Value> Isolate::ThrowException(v8::Local<v8::Value> value) {
|
||||||
|
return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
|
||||||
|
}
|
||||||
|
|
||||||
|
-void Isolate::AddGCPrologueCallback(GCCallback callback, GCType gc_type) {
|
||||||
|
+void Isolate::AddGCPrologueCallback(GCCallbackWithData callback, void* data,
|
||||||
|
+ GCType gc_type) {
|
||||||
|
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
||||||
|
- isolate->heap()->AddGCPrologueCallback(callback, gc_type);
|
||||||
|
+ isolate->heap()->AddGCPrologueCallback(callback, gc_type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
-
|
||||||
|
-void Isolate::RemoveGCPrologueCallback(GCCallback callback) {
|
||||||
|
+void Isolate::RemoveGCPrologueCallback(GCCallbackWithData callback,
|
||||||
|
+ void* data) {
|
||||||
|
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
||||||
|
- isolate->heap()->RemoveGCPrologueCallback(callback);
|
||||||
|
+ isolate->heap()->RemoveGCPrologueCallback(callback, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void Isolate::AddGCEpilogueCallback(GCCallbackWithData callback, void* data,
|
||||||
|
+ GCType gc_type) {
|
||||||
|
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
||||||
|
+ isolate->heap()->AddGCEpilogueCallback(callback, gc_type, data);
|
||||||
|
+}
|
||||||
|
|
||||||
|
-void Isolate::AddGCEpilogueCallback(GCCallback callback, GCType gc_type) {
|
||||||
|
+void Isolate::RemoveGCEpilogueCallback(GCCallbackWithData callback,
|
||||||
|
+ void* data) {
|
||||||
|
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
||||||
|
- isolate->heap()->AddGCEpilogueCallback(callback, gc_type);
|
||||||
|
+ isolate->heap()->RemoveGCEpilogueCallback(callback, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void CallGCCallbackWithoutData(Isolate* isolate, GCType type,
|
||||||
|
+ GCCallbackFlags flags, void* data) {
|
||||||
|
+ reinterpret_cast<Isolate::GCCallback>(data)(isolate, type, flags);
|
||||||
|
+}
|
||||||
|
|
||||||
|
-void Isolate::RemoveGCEpilogueCallback(GCCallback callback) {
|
||||||
|
- i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
||||||
|
- isolate->heap()->RemoveGCEpilogueCallback(callback);
|
||||||
|
+void Isolate::AddGCPrologueCallback(GCCallback callback, GCType gc_type) {
|
||||||
|
+ void* data = reinterpret_cast<void*>(callback);
|
||||||
|
+ AddGCPrologueCallback(CallGCCallbackWithoutData, data, gc_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void Isolate::RemoveGCPrologueCallback(GCCallback callback) {
|
||||||
|
+ void* data = reinterpret_cast<void*>(callback);
|
||||||
|
+ RemoveGCPrologueCallback(CallGCCallbackWithoutData, data);
|
||||||
|
+}
|
||||||
|
|
||||||
|
-void V8::AddGCPrologueCallback(GCCallback callback, GCType gc_type) {
|
||||||
|
- i::Isolate* isolate = i::Isolate::Current();
|
||||||
|
- isolate->heap()->AddGCPrologueCallback(
|
||||||
|
- reinterpret_cast<v8::Isolate::GCCallback>(callback), gc_type, false);
|
||||||
|
+void Isolate::AddGCEpilogueCallback(GCCallback callback, GCType gc_type) {
|
||||||
|
+ void* data = reinterpret_cast<void*>(callback);
|
||||||
|
+ AddGCEpilogueCallback(CallGCCallbackWithoutData, data, gc_type);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void Isolate::RemoveGCEpilogueCallback(GCCallback callback) {
|
||||||
|
+ void* data = reinterpret_cast<void*>(callback);
|
||||||
|
+ RemoveGCEpilogueCallback(CallGCCallbackWithoutData, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void CallGCCallbackWithoutIsolate(Isolate* isolate, GCType type,
|
||||||
|
+ GCCallbackFlags flags, void* data) {
|
||||||
|
+ reinterpret_cast<v8::GCCallback>(data)(type, flags);
|
||||||
|
+}
|
||||||
|
|
||||||
|
-void V8::AddGCEpilogueCallback(GCCallback callback, GCType gc_type) {
|
||||||
|
- i::Isolate* isolate = i::Isolate::Current();
|
||||||
|
- isolate->heap()->AddGCEpilogueCallback(
|
||||||
|
- reinterpret_cast<v8::Isolate::GCCallback>(callback), gc_type, false);
|
||||||
|
+void V8::AddGCPrologueCallback(v8::GCCallback callback, GCType gc_type) {
|
||||||
|
+ void* data = reinterpret_cast<void*>(callback);
|
||||||
|
+ Isolate::GetCurrent()->AddGCPrologueCallback(CallGCCallbackWithoutIsolate,
|
||||||
|
+ data, gc_type);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void V8::AddGCEpilogueCallback(v8::GCCallback callback, GCType gc_type) {
|
||||||
|
+ void* data = reinterpret_cast<void*>(callback);
|
||||||
|
+ Isolate::GetCurrent()->AddGCEpilogueCallback(CallGCCallbackWithoutIsolate,
|
||||||
|
+ data, gc_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Isolate::SetEmbedderHeapTracer(EmbedderHeapTracer* tracer) {
|
||||||
|
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
|
||||||
|
index 6a2128d1fb..2e6cfab292 100644
|
||||||
|
--- a/src/heap/heap.cc
|
||||||
|
+++ b/src/heap/heap.cc
|
||||||
|
@@ -58,15 +58,16 @@
|
||||||
|
namespace v8 {
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
-bool Heap::GCCallbackPair::operator==(const Heap::GCCallbackPair& other) const {
|
||||||
|
- return other.callback == callback;
|
||||||
|
+bool Heap::GCCallbackTuple::operator==(
|
||||||
|
+ const Heap::GCCallbackTuple& other) const {
|
||||||
|
+ return other.callback == callback && other.data == data;
|
||||||
|
}
|
||||||
|
|
||||||
|
-Heap::GCCallbackPair& Heap::GCCallbackPair::operator=(
|
||||||
|
- const Heap::GCCallbackPair& other) {
|
||||||
|
+Heap::GCCallbackTuple& Heap::GCCallbackTuple::operator=(
|
||||||
|
+ const Heap::GCCallbackTuple& other) {
|
||||||
|
callback = other.callback;
|
||||||
|
gc_type = other.gc_type;
|
||||||
|
- pass_isolate = other.pass_isolate;
|
||||||
|
+ data = other.data;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1592,35 +1593,21 @@ bool Heap::PerformGarbageCollection(
|
||||||
|
void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) {
|
||||||
|
RuntimeCallTimerScope runtime_timer(isolate(),
|
||||||
|
&RuntimeCallStats::GCPrologueCallback);
|
||||||
|
- for (const GCCallbackPair& info : gc_prologue_callbacks_) {
|
||||||
|
+ for (const GCCallbackTuple& info : gc_prologue_callbacks_) {
|
||||||
|
if (gc_type & info.gc_type) {
|
||||||
|
- if (!info.pass_isolate) {
|
||||||
|
- v8::GCCallback callback =
|
||||||
|
- reinterpret_cast<v8::GCCallback>(info.callback);
|
||||||
|
- callback(gc_type, flags);
|
||||||
|
- } else {
|
||||||
|
- v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
|
||||||
|
- info.callback(isolate, gc_type, flags);
|
||||||
|
- }
|
||||||
|
+ v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
|
||||||
|
+ info.callback(isolate, gc_type, flags, info.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-
|
||||||
|
-void Heap::CallGCEpilogueCallbacks(GCType gc_type,
|
||||||
|
- GCCallbackFlags gc_callback_flags) {
|
||||||
|
+void Heap::CallGCEpilogueCallbacks(GCType gc_type, GCCallbackFlags flags) {
|
||||||
|
RuntimeCallTimerScope runtime_timer(isolate(),
|
||||||
|
&RuntimeCallStats::GCEpilogueCallback);
|
||||||
|
- for (const GCCallbackPair& info : gc_epilogue_callbacks_) {
|
||||||
|
+ for (const GCCallbackTuple& info : gc_epilogue_callbacks_) {
|
||||||
|
if (gc_type & info.gc_type) {
|
||||||
|
- if (!info.pass_isolate) {
|
||||||
|
- v8::GCCallback callback =
|
||||||
|
- reinterpret_cast<v8::GCCallback>(info.callback);
|
||||||
|
- callback(gc_type, gc_callback_flags);
|
||||||
|
- } else {
|
||||||
|
- v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
|
||||||
|
- info.callback(isolate, gc_type, gc_callback_flags);
|
||||||
|
- }
|
||||||
|
+ v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
|
||||||
|
+ info.callback(isolate, gc_type, flags, info.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -6182,21 +6169,21 @@ void Heap::TearDown() {
|
||||||
|
memory_allocator_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
-
|
||||||
|
-void Heap::AddGCPrologueCallback(v8::Isolate::GCCallback callback,
|
||||||
|
- GCType gc_type, bool pass_isolate) {
|
||||||
|
+void Heap::AddGCPrologueCallback(v8::Isolate::GCCallbackWithData callback,
|
||||||
|
+ GCType gc_type, void* data) {
|
||||||
|
DCHECK_NOT_NULL(callback);
|
||||||
|
DCHECK(gc_prologue_callbacks_.end() ==
|
||||||
|
std::find(gc_prologue_callbacks_.begin(), gc_prologue_callbacks_.end(),
|
||||||
|
- GCCallbackPair(callback, gc_type, pass_isolate)));
|
||||||
|
- gc_prologue_callbacks_.emplace_back(callback, gc_type, pass_isolate);
|
||||||
|
+ GCCallbackTuple(callback, gc_type, data)));
|
||||||
|
+ gc_prologue_callbacks_.emplace_back(callback, gc_type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
-
|
||||||
|
-void Heap::RemoveGCPrologueCallback(v8::Isolate::GCCallback callback) {
|
||||||
|
+void Heap::RemoveGCPrologueCallback(v8::Isolate::GCCallbackWithData callback,
|
||||||
|
+ void* data) {
|
||||||
|
DCHECK_NOT_NULL(callback);
|
||||||
|
for (size_t i = 0; i < gc_prologue_callbacks_.size(); i++) {
|
||||||
|
- if (gc_prologue_callbacks_[i].callback == callback) {
|
||||||
|
+ if (gc_prologue_callbacks_[i].callback == callback &&
|
||||||
|
+ gc_prologue_callbacks_[i].data == data) {
|
||||||
|
gc_prologue_callbacks_[i] = gc_prologue_callbacks_.back();
|
||||||
|
gc_prologue_callbacks_.pop_back();
|
||||||
|
return;
|
||||||
|
@@ -6205,21 +6192,21 @@ void Heap::RemoveGCPrologueCallback(v8::Isolate::GCCallback callback) {
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
-
|
||||||
|
-void Heap::AddGCEpilogueCallback(v8::Isolate::GCCallback callback,
|
||||||
|
- GCType gc_type, bool pass_isolate) {
|
||||||
|
+void Heap::AddGCEpilogueCallback(v8::Isolate::GCCallbackWithData callback,
|
||||||
|
+ GCType gc_type, void* data) {
|
||||||
|
DCHECK_NOT_NULL(callback);
|
||||||
|
DCHECK(gc_epilogue_callbacks_.end() ==
|
||||||
|
std::find(gc_epilogue_callbacks_.begin(), gc_epilogue_callbacks_.end(),
|
||||||
|
- GCCallbackPair(callback, gc_type, pass_isolate)));
|
||||||
|
- gc_epilogue_callbacks_.emplace_back(callback, gc_type, pass_isolate);
|
||||||
|
+ GCCallbackTuple(callback, gc_type, data)));
|
||||||
|
+ gc_epilogue_callbacks_.emplace_back(callback, gc_type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
-
|
||||||
|
-void Heap::RemoveGCEpilogueCallback(v8::Isolate::GCCallback callback) {
|
||||||
|
+void Heap::RemoveGCEpilogueCallback(v8::Isolate::GCCallbackWithData callback,
|
||||||
|
+ void* data) {
|
||||||
|
DCHECK_NOT_NULL(callback);
|
||||||
|
for (size_t i = 0; i < gc_epilogue_callbacks_.size(); i++) {
|
||||||
|
- if (gc_epilogue_callbacks_[i].callback == callback) {
|
||||||
|
+ if (gc_epilogue_callbacks_[i].callback == callback &&
|
||||||
|
+ gc_epilogue_callbacks_[i].data == data) {
|
||||||
|
gc_epilogue_callbacks_[i] = gc_epilogue_callbacks_.back();
|
||||||
|
gc_epilogue_callbacks_.pop_back();
|
||||||
|
return;
|
||||||
|
diff --git a/src/heap/heap.h b/src/heap/heap.h
|
||||||
|
index e83e646de5..ab48e72651 100644
|
||||||
|
--- a/src/heap/heap.h
|
||||||
|
+++ b/src/heap/heap.h
|
||||||
|
@@ -1427,13 +1427,15 @@ class Heap {
|
||||||
|
// Prologue/epilogue callback methods.========================================
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
- void AddGCPrologueCallback(v8::Isolate::GCCallback callback,
|
||||||
|
- GCType gc_type_filter, bool pass_isolate = true);
|
||||||
|
- void RemoveGCPrologueCallback(v8::Isolate::GCCallback callback);
|
||||||
|
+ void AddGCPrologueCallback(v8::Isolate::GCCallbackWithData callback,
|
||||||
|
+ GCType gc_type_filter, void* data);
|
||||||
|
+ void RemoveGCPrologueCallback(v8::Isolate::GCCallbackWithData callback,
|
||||||
|
+ void* data);
|
||||||
|
|
||||||
|
- void AddGCEpilogueCallback(v8::Isolate::GCCallback callback,
|
||||||
|
- GCType gc_type_filter, bool pass_isolate = true);
|
||||||
|
- void RemoveGCEpilogueCallback(v8::Isolate::GCCallback callback);
|
||||||
|
+ void AddGCEpilogueCallback(v8::Isolate::GCCallbackWithData callback,
|
||||||
|
+ GCType gc_type_filter, void* data);
|
||||||
|
+ void RemoveGCEpilogueCallback(v8::Isolate::GCCallbackWithData callback,
|
||||||
|
+ void* data);
|
||||||
|
|
||||||
|
void CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags);
|
||||||
|
void CallGCEpilogueCallbacks(GCType gc_type, GCCallbackFlags flags);
|
||||||
|
@@ -1604,17 +1606,17 @@ class Heap {
|
||||||
|
RootListIndex index;
|
||||||
|
};
|
||||||
|
|
||||||
|
- struct GCCallbackPair {
|
||||||
|
- GCCallbackPair(v8::Isolate::GCCallback callback, GCType gc_type,
|
||||||
|
- bool pass_isolate)
|
||||||
|
- : callback(callback), gc_type(gc_type), pass_isolate(pass_isolate) {}
|
||||||
|
+ struct GCCallbackTuple {
|
||||||
|
+ GCCallbackTuple(v8::Isolate::GCCallbackWithData callback, GCType gc_type,
|
||||||
|
+ void* data)
|
||||||
|
+ : callback(callback), gc_type(gc_type), data(data) {}
|
||||||
|
|
||||||
|
- bool operator==(const GCCallbackPair& other) const;
|
||||||
|
- GCCallbackPair& operator=(const GCCallbackPair& other);
|
||||||
|
+ bool operator==(const GCCallbackTuple& other) const;
|
||||||
|
+ GCCallbackTuple& operator=(const GCCallbackTuple& other);
|
||||||
|
|
||||||
|
- v8::Isolate::GCCallback callback;
|
||||||
|
+ v8::Isolate::GCCallbackWithData callback;
|
||||||
|
GCType gc_type;
|
||||||
|
- bool pass_isolate;
|
||||||
|
+ void* data;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int kInitialStringTableSize = 2048;
|
||||||
|
@@ -2294,8 +2296,8 @@ class Heap {
|
||||||
|
// contains Smi(0) while marking is not active.
|
||||||
|
Object* encountered_weak_collections_;
|
||||||
|
|
||||||
|
- std::vector<GCCallbackPair> gc_epilogue_callbacks_;
|
||||||
|
- std::vector<GCCallbackPair> gc_prologue_callbacks_;
|
||||||
|
+ std::vector<GCCallbackTuple> gc_epilogue_callbacks_;
|
||||||
|
+ std::vector<GCCallbackTuple> gc_prologue_callbacks_;
|
||||||
|
|
||||||
|
GetExternallyAllocatedMemoryInBytesCallback external_memory_callback_;
|
||||||
|
|
||||||
|
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
||||||
|
index 575f64dd49..6cdb629160 100644
|
||||||
|
--- a/test/cctest/test-api.cc
|
||||||
|
+++ b/test/cctest/test-api.cc
|
||||||
|
@@ -19652,6 +19652,19 @@ void EpilogueCallbackSecond(v8::Isolate* isolate,
|
||||||
|
++epilogue_call_count_second;
|
||||||
|
}
|
||||||
|
|
||||||
|
+void PrologueCallbackNew(v8::Isolate* isolate, v8::GCType,
|
||||||
|
+ v8::GCCallbackFlags flags, void* data) {
|
||||||
|
+ CHECK_EQ(flags, v8::kNoGCCallbackFlags);
|
||||||
|
+ CHECK_EQ(gc_callbacks_isolate, isolate);
|
||||||
|
+ ++*static_cast<int*>(data);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void EpilogueCallbackNew(v8::Isolate* isolate, v8::GCType,
|
||||||
|
+ v8::GCCallbackFlags flags, void* data) {
|
||||||
|
+ CHECK_EQ(flags, v8::kNoGCCallbackFlags);
|
||||||
|
+ CHECK_EQ(gc_callbacks_isolate, isolate);
|
||||||
|
+ ++*static_cast<int*>(data);
|
||||||
|
+}
|
||||||
|
|
||||||
|
void PrologueCallbackAlloc(v8::Isolate* isolate,
|
||||||
|
v8::GCType,
|
||||||
|
@@ -19726,6 +19739,52 @@ TEST(GCCallbacksOld) {
|
||||||
|
CHECK_EQ(2, epilogue_call_count_second);
|
||||||
|
}
|
||||||
|
|
||||||
|
+TEST(GCCallbacksWithData) {
|
||||||
|
+ LocalContext context;
|
||||||
|
+
|
||||||
|
+ gc_callbacks_isolate = context->GetIsolate();
|
||||||
|
+ int prologue1 = 0;
|
||||||
|
+ int epilogue1 = 0;
|
||||||
|
+ int prologue2 = 0;
|
||||||
|
+ int epilogue2 = 0;
|
||||||
|
+
|
||||||
|
+ context->GetIsolate()->AddGCPrologueCallback(PrologueCallbackNew, &prologue1);
|
||||||
|
+ context->GetIsolate()->AddGCEpilogueCallback(EpilogueCallbackNew, &epilogue1);
|
||||||
|
+ CHECK_EQ(0, prologue1);
|
||||||
|
+ CHECK_EQ(0, epilogue1);
|
||||||
|
+ CHECK_EQ(0, prologue2);
|
||||||
|
+ CHECK_EQ(0, epilogue2);
|
||||||
|
+ CcTest::CollectAllGarbage();
|
||||||
|
+ CHECK_EQ(1, prologue1);
|
||||||
|
+ CHECK_EQ(1, epilogue1);
|
||||||
|
+ CHECK_EQ(0, prologue2);
|
||||||
|
+ CHECK_EQ(0, epilogue2);
|
||||||
|
+ context->GetIsolate()->AddGCPrologueCallback(PrologueCallbackNew, &prologue2);
|
||||||
|
+ context->GetIsolate()->AddGCEpilogueCallback(EpilogueCallbackNew, &epilogue2);
|
||||||
|
+ CcTest::CollectAllGarbage();
|
||||||
|
+ CHECK_EQ(2, prologue1);
|
||||||
|
+ CHECK_EQ(2, epilogue1);
|
||||||
|
+ CHECK_EQ(1, prologue2);
|
||||||
|
+ CHECK_EQ(1, epilogue2);
|
||||||
|
+ context->GetIsolate()->RemoveGCPrologueCallback(PrologueCallbackNew,
|
||||||
|
+ &prologue1);
|
||||||
|
+ context->GetIsolate()->RemoveGCEpilogueCallback(EpilogueCallbackNew,
|
||||||
|
+ &epilogue1);
|
||||||
|
+ CcTest::CollectAllGarbage();
|
||||||
|
+ CHECK_EQ(2, prologue1);
|
||||||
|
+ CHECK_EQ(2, epilogue1);
|
||||||
|
+ CHECK_EQ(2, prologue2);
|
||||||
|
+ CHECK_EQ(2, epilogue2);
|
||||||
|
+ context->GetIsolate()->RemoveGCPrologueCallback(PrologueCallbackNew,
|
||||||
|
+ &prologue2);
|
||||||
|
+ context->GetIsolate()->RemoveGCEpilogueCallback(EpilogueCallbackNew,
|
||||||
|
+ &epilogue2);
|
||||||
|
+ CcTest::CollectAllGarbage();
|
||||||
|
+ CHECK_EQ(2, prologue1);
|
||||||
|
+ CHECK_EQ(2, epilogue1);
|
||||||
|
+ CHECK_EQ(2, prologue2);
|
||||||
|
+ CHECK_EQ(2, epilogue2);
|
||||||
|
+}
|
||||||
|
|
||||||
|
TEST(GCCallbacks) {
|
||||||
|
LocalContext context;
|
|
@ -0,0 +1,18 @@
|
||||||
|
diff --git a/src/profiler/sampling-heap-profiler.h b/src/profiler/sampling-heap-profiler.h
|
||||||
|
index 07840244ce..3a347dd54e 100644
|
||||||
|
--- a/src/profiler/sampling-heap-profiler.h
|
||||||
|
+++ b/src/profiler/sampling-heap-profiler.h
|
||||||
|
@@ -172,8 +172,11 @@ class SamplingAllocationObserver : public AllocationObserver {
|
||||||
|
void Step(int bytes_allocated, Address soon_object, size_t size) override {
|
||||||
|
USE(heap_);
|
||||||
|
DCHECK(heap_->gc_state() == Heap::NOT_IN_GC);
|
||||||
|
- DCHECK(soon_object);
|
||||||
|
- profiler_->SampleObject(soon_object, size);
|
||||||
|
+ if (soon_object) {
|
||||||
|
+ // TODO(ofrobots): it would be better to sample the next object rather
|
||||||
|
+ // than skipping this sample epoch if soon_object happens to be null.
|
||||||
|
+ profiler_->SampleObject(soon_object, size);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
intptr_t GetNextStepSize() override { return GetNextSampleInterval(rate_); }
|
|
@ -0,0 +1,59 @@
|
||||||
|
diff --git a/src/compiler/common-operator.cc b/src/compiler/common-operator.cc
|
||||||
|
index c48773920d..d92722f701 100644
|
||||||
|
--- a/src/compiler/common-operator.cc
|
||||||
|
+++ b/src/compiler/common-operator.cc
|
||||||
|
@@ -1255,7 +1255,7 @@ bool IsRestOf(Operator const* op) {
|
||||||
|
return OpParameter<bool>(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
-const Operator* CommonOperatorBuilder::ObjectState(int object_id,
|
||||||
|
+const Operator* CommonOperatorBuilder::ObjectState(uint32_t object_id,
|
||||||
|
int pointer_slots) {
|
||||||
|
return new (zone()) Operator1<ObjectStateInfo>( // --
|
||||||
|
IrOpcode::kObjectState, Operator::kPure, // opcode
|
||||||
|
@@ -1265,7 +1265,7 @@ const Operator* CommonOperatorBuilder::ObjectState(int object_id,
|
||||||
|
}
|
||||||
|
|
||||||
|
const Operator* CommonOperatorBuilder::TypedObjectState(
|
||||||
|
- int object_id, const ZoneVector<MachineType>* types) {
|
||||||
|
+ uint32_t object_id, const ZoneVector<MachineType>* types) {
|
||||||
|
return new (zone()) Operator1<TypedObjectStateInfo>( // --
|
||||||
|
IrOpcode::kTypedObjectState, Operator::kPure, // opcode
|
||||||
|
"TypedObjectState", // name
|
||||||
|
diff --git a/src/compiler/common-operator.h b/src/compiler/common-operator.h
|
||||||
|
index f7638a3cca..9dfb059518 100644
|
||||||
|
--- a/src/compiler/common-operator.h
|
||||||
|
+++ b/src/compiler/common-operator.h
|
||||||
|
@@ -125,7 +125,8 @@ V8_EXPORT_PRIVATE int ParameterIndexOf(const Operator* const);
|
||||||
|
const ParameterInfo& ParameterInfoOf(const Operator* const);
|
||||||
|
|
||||||
|
struct ObjectStateInfo final : std::pair<uint32_t, int> {
|
||||||
|
- using std::pair<uint32_t, int>::pair;
|
||||||
|
+ ObjectStateInfo(uint32_t object_id, int size)
|
||||||
|
+ : std::pair<uint32_t, int>(object_id, size) {}
|
||||||
|
uint32_t object_id() const { return first; }
|
||||||
|
int size() const { return second; }
|
||||||
|
};
|
||||||
|
@@ -134,7 +135,10 @@ size_t hash_value(ObjectStateInfo const& p);
|
||||||
|
|
||||||
|
struct TypedObjectStateInfo final
|
||||||
|
: std::pair<uint32_t, const ZoneVector<MachineType>*> {
|
||||||
|
- using std::pair<uint32_t, const ZoneVector<MachineType>*>::pair;
|
||||||
|
+ TypedObjectStateInfo(uint32_t object_id,
|
||||||
|
+ const ZoneVector<MachineType>* machine_types)
|
||||||
|
+ : std::pair<uint32_t, const ZoneVector<MachineType>*>(object_id,
|
||||||
|
+ machine_types) {}
|
||||||
|
uint32_t object_id() const { return first; }
|
||||||
|
const ZoneVector<MachineType>* machine_types() const { return second; }
|
||||||
|
};
|
||||||
|
@@ -385,8 +389,8 @@ class V8_EXPORT_PRIVATE CommonOperatorBuilder final
|
||||||
|
SparseInputMask bitmask);
|
||||||
|
const Operator* ArgumentsElementsState(bool is_rest);
|
||||||
|
const Operator* ArgumentsLengthState(bool is_rest);
|
||||||
|
- const Operator* ObjectState(int object_id, int pointer_slots);
|
||||||
|
- const Operator* TypedObjectState(int object_id,
|
||||||
|
+ const Operator* ObjectState(uint32_t object_id, int pointer_slots);
|
||||||
|
+ const Operator* TypedObjectState(uint32_t object_id,
|
||||||
|
const ZoneVector<MachineType>* types);
|
||||||
|
const Operator* FrameState(BailoutId bailout_id,
|
||||||
|
OutputFrameStateCombine state_combine,
|
|
@ -0,0 +1,85 @@
|
||||||
|
diff --git a/src/lookup.h b/src/lookup.h
|
||||||
|
index 25c5a6cc3b..9ea2d77cf6 100644
|
||||||
|
--- a/src/lookup.h
|
||||||
|
+++ b/src/lookup.h
|
||||||
|
@@ -22,7 +22,7 @@ class V8_EXPORT_PRIVATE LookupIterator final BASE_EMBEDDED {
|
||||||
|
kInterceptor = 1 << 0,
|
||||||
|
kPrototypeChain = 1 << 1,
|
||||||
|
|
||||||
|
- // Convience combinations of bits.
|
||||||
|
+ // Convenience combinations of bits.
|
||||||
|
OWN_SKIP_INTERCEPTOR = 0,
|
||||||
|
OWN = kInterceptor,
|
||||||
|
PROTOTYPE_CHAIN_SKIP_INTERCEPTOR = kPrototypeChain,
|
||||||
|
diff --git a/src/objects.cc b/src/objects.cc
|
||||||
|
index c1a2e41bf1..28c1cd681f 100644
|
||||||
|
--- a/src/objects.cc
|
||||||
|
+++ b/src/objects.cc
|
||||||
|
@@ -6713,17 +6713,6 @@ Maybe<bool> JSReceiver::OrdinaryDefineOwnProperty(Isolate* isolate,
|
||||||
|
it.Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
- // Handle interceptor
|
||||||
|
- if (it.state() == LookupIterator::INTERCEPTOR) {
|
||||||
|
- if (it.HolderIsReceiverOrHiddenPrototype()) {
|
||||||
|
- Maybe<bool> result = DefinePropertyWithInterceptorInternal(
|
||||||
|
- &it, it.GetInterceptor(), should_throw, *desc);
|
||||||
|
- if (result.IsNothing() || result.FromJust()) {
|
||||||
|
- return result;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
return OrdinaryDefineOwnProperty(&it, desc, should_throw);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -6739,6 +6728,20 @@ Maybe<bool> JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it,
|
||||||
|
PropertyDescriptor current;
|
||||||
|
MAYBE_RETURN(GetOwnPropertyDescriptor(it, ¤t), Nothing<bool>());
|
||||||
|
|
||||||
|
+ it->Restart();
|
||||||
|
+ // Handle interceptor
|
||||||
|
+ for (; it->IsFound(); it->Next()) {
|
||||||
|
+ if (it->state() == LookupIterator::INTERCEPTOR) {
|
||||||
|
+ if (it->HolderIsReceiverOrHiddenPrototype()) {
|
||||||
|
+ Maybe<bool> result = DefinePropertyWithInterceptorInternal(
|
||||||
|
+ it, it->GetInterceptor(), should_throw, *desc);
|
||||||
|
+ if (result.IsNothing() || result.FromJust()) {
|
||||||
|
+ return result;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
// TODO(jkummerow/verwaest): It would be nice if we didn't have to reset
|
||||||
|
// the iterator every time. Currently, the reasons why we need it are:
|
||||||
|
// - handle interceptors correctly
|
||||||
|
diff --git a/test/cctest/test-api-interceptors.cc b/test/cctest/test-api-interceptors.cc
|
||||||
|
index 265698d131..ca9b18016d 100644
|
||||||
|
--- a/test/cctest/test-api-interceptors.cc
|
||||||
|
+++ b/test/cctest/test-api-interceptors.cc
|
||||||
|
@@ -716,20 +716,21 @@ bool define_was_called_in_order = false;
|
||||||
|
void GetterCallbackOrder(Local<Name> property,
|
||||||
|
const v8::PropertyCallbackInfo<v8::Value>& info) {
|
||||||
|
get_was_called_in_order = true;
|
||||||
|
- CHECK(define_was_called_in_order);
|
||||||
|
+ CHECK(!define_was_called_in_order);
|
||||||
|
info.GetReturnValue().Set(property);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefinerCallbackOrder(Local<Name> property,
|
||||||
|
const v8::PropertyDescriptor& desc,
|
||||||
|
const v8::PropertyCallbackInfo<v8::Value>& info) {
|
||||||
|
- CHECK(!get_was_called_in_order); // Define called before get.
|
||||||
|
+ // Get called before DefineProperty because we query the descriptor first.
|
||||||
|
+ CHECK(get_was_called_in_order);
|
||||||
|
define_was_called_in_order = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
-// Check that definer callback is called before getter callback.
|
||||||
|
+// Check that getter callback is called before definer callback.
|
||||||
|
THREADED_TEST(DefinerCallbackGetAndDefine) {
|
||||||
|
v8::HandleScope scope(CcTest::isolate());
|
||||||
|
v8::Local<v8::FunctionTemplate> templ =
|
|
@ -0,0 +1,33 @@
|
||||||
|
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
|
||||||
|
index 2e6cfab292..61e15efd53 100644
|
||||||
|
--- a/src/heap/heap.cc
|
||||||
|
+++ b/src/heap/heap.cc
|
||||||
|
@@ -1885,6 +1885,12 @@ void Heap::Scavenge() {
|
||||||
|
IncrementalMarking::PauseBlackAllocationScope pause_black_allocation(
|
||||||
|
incremental_marking());
|
||||||
|
|
||||||
|
+ if (mark_compact_collector()->sweeper().sweeping_in_progress() &&
|
||||||
|
+ memory_allocator_->unmapper()->NumberOfDelayedChunks() >
|
||||||
|
+ kMaxSemiSpaceSizeInKB / Page::kPageSize) {
|
||||||
|
+ mark_compact_collector()->EnsureSweepingCompleted();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
mark_compact_collector()->sweeper().EnsureNewSpaceCompleted();
|
||||||
|
|
||||||
|
SetGCState(SCAVENGE);
|
||||||
|
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
|
||||||
|
index d5dc5b1115..230a127809 100644
|
||||||
|
--- a/src/heap/spaces.h
|
||||||
|
+++ b/src/heap/spaces.h
|
||||||
|
@@ -1199,6 +1199,11 @@ class V8_EXPORT_PRIVATE MemoryAllocator {
|
||||||
|
|
||||||
|
bool has_delayed_chunks() { return delayed_regular_chunks_.size() > 0; }
|
||||||
|
|
||||||
|
+ int NumberOfDelayedChunks() {
|
||||||
|
+ base::LockGuard<base::Mutex> guard(&mutex_);
|
||||||
|
+ return static_cast<int>(delayed_regular_chunks_.size());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
private:
|
||||||
|
static const int kReservedQueueingSlots = 64;
|
||||||
|
static const int kMaxUnmapperTasks = 24;
|
|
@ -0,0 +1,13 @@
|
||||||
|
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
|
||||||
|
index 61e15efd53..e6762df913 100644
|
||||||
|
--- a/src/heap/heap.cc
|
||||||
|
+++ b/src/heap/heap.cc
|
||||||
|
@@ -1887,7 +1887,7 @@ void Heap::Scavenge() {
|
||||||
|
|
||||||
|
if (mark_compact_collector()->sweeper().sweeping_in_progress() &&
|
||||||
|
memory_allocator_->unmapper()->NumberOfDelayedChunks() >
|
||||||
|
- kMaxSemiSpaceSizeInKB / Page::kPageSize) {
|
||||||
|
+ static_cast<int>(new_space_->MaximumCapacity() / Page::kPageSize)) {
|
||||||
|
mark_compact_collector()->EnsureSweepingCompleted();
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
diff --git a/src/heap/gc-tracer.cc b/src/heap/gc-tracer.cc
|
||||||
|
index ddfcd07cc1..e14fbb4862 100644
|
||||||
|
--- a/src/heap/gc-tracer.cc
|
||||||
|
+++ b/src/heap/gc-tracer.cc
|
||||||
|
@@ -490,6 +490,8 @@ void GCTracer::PrintNVP() const {
|
||||||
|
"promotion_rate=%.1f%% "
|
||||||
|
"semi_space_copy_rate=%.1f%% "
|
||||||
|
"new_space_allocation_throughput=%.1f "
|
||||||
|
+ "unmapper_chunks=%d "
|
||||||
|
+ "unmapper_delayed_chunks=%d "
|
||||||
|
"context_disposal_rate=%.1f\n",
|
||||||
|
duration, spent_in_mutator, current_.TypeName(true),
|
||||||
|
current_.reduce_memory, current_.scopes[Scope::HEAP_PROLOGUE],
|
||||||
|
@@ -520,6 +522,8 @@ void GCTracer::PrintNVP() const {
|
||||||
|
AverageSurvivalRatio(), heap_->promotion_rate_,
|
||||||
|
heap_->semi_space_copied_rate_,
|
||||||
|
NewSpaceAllocationThroughputInBytesPerMillisecond(),
|
||||||
|
+ heap_->memory_allocator()->unmapper()->NumberOfChunks(),
|
||||||
|
+ heap_->memory_allocator()->unmapper()->NumberOfDelayedChunks(),
|
||||||
|
ContextDisposalRateInMilliseconds());
|
||||||
|
break;
|
||||||
|
case Event::MINOR_MARK_COMPACTOR:
|
||||||
|
@@ -654,6 +658,8 @@ void GCTracer::PrintNVP() const {
|
||||||
|
"promotion_rate=%.1f%% "
|
||||||
|
"semi_space_copy_rate=%.1f%% "
|
||||||
|
"new_space_allocation_throughput=%.1f "
|
||||||
|
+ "unmapper_chunks=%d "
|
||||||
|
+ "unmapper_delayed_chunks=%d "
|
||||||
|
"context_disposal_rate=%.1f "
|
||||||
|
"compaction_speed=%.f\n",
|
||||||
|
duration, spent_in_mutator, current_.TypeName(true),
|
||||||
|
@@ -731,6 +737,8 @@ void GCTracer::PrintNVP() const {
|
||||||
|
AverageSurvivalRatio(), heap_->promotion_rate_,
|
||||||
|
heap_->semi_space_copied_rate_,
|
||||||
|
NewSpaceAllocationThroughputInBytesPerMillisecond(),
|
||||||
|
+ heap_->memory_allocator()->unmapper()->NumberOfChunks(),
|
||||||
|
+ heap_->memory_allocator()->unmapper()->NumberOfDelayedChunks(),
|
||||||
|
ContextDisposalRateInMilliseconds(),
|
||||||
|
CompactionSpeedInBytesPerMillisecond());
|
||||||
|
break;
|
||||||
|
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
|
||||||
|
index 66c63e5863..74fee75673 100644
|
||||||
|
--- a/src/heap/spaces.cc
|
||||||
|
+++ b/src/heap/spaces.cc
|
||||||
|
@@ -408,6 +408,15 @@ void MemoryAllocator::Unmapper::ReconsiderDelayedChunks() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+int MemoryAllocator::Unmapper::NumberOfChunks() {
|
||||||
|
+ base::LockGuard<base::Mutex> guard(&mutex_);
|
||||||
|
+ size_t result = 0;
|
||||||
|
+ for (int i = 0; i < kNumberOfChunkQueues; i++) {
|
||||||
|
+ result += chunks_[i].size();
|
||||||
|
+ }
|
||||||
|
+ return static_cast<int>(result);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
bool MemoryAllocator::CanFreeMemoryChunk(MemoryChunk* chunk) {
|
||||||
|
MarkCompactCollector* mc = isolate_->heap()->mark_compact_collector();
|
||||||
|
// We cannot free a memory chunk in new space while the sweeper is running
|
||||||
|
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
|
||||||
|
index 230a127809..4f4de139e4 100644
|
||||||
|
--- a/src/heap/spaces.h
|
||||||
|
+++ b/src/heap/spaces.h
|
||||||
|
@@ -1204,6 +1204,8 @@ class V8_EXPORT_PRIVATE MemoryAllocator {
|
||||||
|
return static_cast<int>(delayed_regular_chunks_.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
+ int NumberOfChunks();
|
||||||
|
+
|
||||||
|
private:
|
||||||
|
static const int kReservedQueueingSlots = 64;
|
||||||
|
static const int kMaxUnmapperTasks = 24;
|
|
@ -0,0 +1,111 @@
|
||||||
|
diff --git a/include/v8-inspector.h b/include/v8-inspector.h
|
||||||
|
index 43bf3b4f60..d0bb9b47fe 100644
|
||||||
|
--- a/include/v8-inspector.h
|
||||||
|
+++ b/include/v8-inspector.h
|
||||||
|
@@ -211,6 +211,8 @@ class V8_EXPORT V8InspectorClient {
|
||||||
|
// TODO(dgozman): this was added to support service worker shadow page. We
|
||||||
|
// should not connect at all.
|
||||||
|
virtual bool canExecuteScripts(int contextGroupId) { return true; }
|
||||||
|
+
|
||||||
|
+ virtual void maxAsyncCallStackDepthChanged(int depth) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class V8_EXPORT V8Inspector {
|
||||||
|
diff --git a/src/inspector/v8-debugger.cc b/src/inspector/v8-debugger.cc
|
||||||
|
index acd778b2b6..bc5437c6d4 100644
|
||||||
|
--- a/src/inspector/v8-debugger.cc
|
||||||
|
+++ b/src/inspector/v8-debugger.cc
|
||||||
|
@@ -726,6 +726,8 @@ void V8Debugger::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int depth) {
|
||||||
|
if (m_maxAsyncCallStackDepth == maxAsyncCallStackDepth) return;
|
||||||
|
// TODO(dgozman): ideally, this should be per context group.
|
||||||
|
m_maxAsyncCallStackDepth = maxAsyncCallStackDepth;
|
||||||
|
+ m_inspector->client()->maxAsyncCallStackDepthChanged(
|
||||||
|
+ m_maxAsyncCallStackDepth);
|
||||||
|
if (!maxAsyncCallStackDepth) allAsyncTasksCanceled();
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/test/inspector/inspector-test.cc b/test/inspector/inspector-test.cc
|
||||||
|
index dcaf5823ef..de89271fbf 100644
|
||||||
|
--- a/test/inspector/inspector-test.cc
|
||||||
|
+++ b/test/inspector/inspector-test.cc
|
||||||
|
@@ -299,6 +299,10 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||||
|
utils->Set(ToV8String(isolate, "setLogConsoleApiMessageCalls"),
|
||||||
|
v8::FunctionTemplate::New(
|
||||||
|
isolate, &UtilsExtension::SetLogConsoleApiMessageCalls));
|
||||||
|
+ utils->Set(
|
||||||
|
+ ToV8String(isolate, "setLogMaxAsyncCallStackDepthChanged"),
|
||||||
|
+ v8::FunctionTemplate::New(
|
||||||
|
+ isolate, &UtilsExtension::SetLogMaxAsyncCallStackDepthChanged));
|
||||||
|
utils->Set(ToV8String(isolate, "createContextGroup"),
|
||||||
|
v8::FunctionTemplate::New(isolate,
|
||||||
|
&UtilsExtension::CreateContextGroup));
|
||||||
|
@@ -486,6 +490,17 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
|
||||||
|
args[0].As<v8::Boolean>()->Value());
|
||||||
|
}
|
||||||
|
|
||||||
|
+ static void SetLogMaxAsyncCallStackDepthChanged(
|
||||||
|
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
|
+ if (args.Length() != 1 || !args[0]->IsBoolean()) {
|
||||||
|
+ fprintf(stderr,
|
||||||
|
+ "Internal error: setLogMaxAsyncCallStackDepthChanged(bool).");
|
||||||
|
+ Exit();
|
||||||
|
+ }
|
||||||
|
+ backend_runner_->data()->SetLogMaxAsyncCallStackDepthChanged(
|
||||||
|
+ args[0].As<v8::Boolean>()->Value());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
static void CreateContextGroup(
|
||||||
|
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
|
if (args.Length() != 0) {
|
||||||
|
diff --git a/test/inspector/isolate-data.cc b/test/inspector/isolate-data.cc
|
||||||
|
index 82a5cc0483..4c1d81670f 100644
|
||||||
|
--- a/test/inspector/isolate-data.cc
|
||||||
|
+++ b/test/inspector/isolate-data.cc
|
||||||
|
@@ -370,6 +370,10 @@ void IsolateData::SetLogConsoleApiMessageCalls(bool log) {
|
||||||
|
log_console_api_message_calls_ = log;
|
||||||
|
}
|
||||||
|
|
||||||
|
+void IsolateData::SetLogMaxAsyncCallStackDepthChanged(bool log) {
|
||||||
|
+ log_max_async_call_stack_depth_changed_ = log;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
v8::MaybeLocal<v8::Value> IsolateData::memoryInfo(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Context>) {
|
||||||
|
if (memory_info_.IsEmpty()) return v8::MaybeLocal<v8::Value>();
|
||||||
|
@@ -396,3 +400,8 @@ void IsolateData::consoleAPIMessage(int contextGroupId,
|
||||||
|
Print(isolate_, stack->toString()->string());
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+void IsolateData::maxAsyncCallStackDepthChanged(int depth) {
|
||||||
|
+ if (!log_max_async_call_stack_depth_changed_) return;
|
||||||
|
+ fprintf(stdout, "maxAsyncCallStackDepthChanged: %d\n", depth);
|
||||||
|
+}
|
||||||
|
diff --git a/test/inspector/isolate-data.h b/test/inspector/isolate-data.h
|
||||||
|
index b8f3b9e76c..455b44b49b 100644
|
||||||
|
--- a/test/inspector/isolate-data.h
|
||||||
|
+++ b/test/inspector/isolate-data.h
|
||||||
|
@@ -64,6 +64,7 @@ class IsolateData : public v8_inspector::V8InspectorClient {
|
||||||
|
void SetCurrentTimeMS(double time);
|
||||||
|
void SetMemoryInfo(v8::Local<v8::Value> memory_info);
|
||||||
|
void SetLogConsoleApiMessageCalls(bool log);
|
||||||
|
+ void SetLogMaxAsyncCallStackDepthChanged(bool log);
|
||||||
|
void SetMaxAsyncTaskStacksForTest(int limit);
|
||||||
|
void DumpAsyncTaskStacksStateForTest();
|
||||||
|
void FireContextCreated(v8::Local<v8::Context> context, int context_group_id);
|
||||||
|
@@ -106,6 +107,7 @@ class IsolateData : public v8_inspector::V8InspectorClient {
|
||||||
|
unsigned lineNumber, unsigned columnNumber,
|
||||||
|
v8_inspector::V8StackTrace*) override;
|
||||||
|
bool isInspectableHeapObject(v8::Local<v8::Object>) override;
|
||||||
|
+ void maxAsyncCallStackDepthChanged(int depth) override;
|
||||||
|
|
||||||
|
TaskRunner* task_runner_;
|
||||||
|
SetupGlobalTasks setup_global_tasks_;
|
||||||
|
@@ -123,6 +125,7 @@ class IsolateData : public v8_inspector::V8InspectorClient {
|
||||||
|
bool current_time_set_ = false;
|
||||||
|
double current_time_ = 0.0;
|
||||||
|
bool log_console_api_message_calls_ = false;
|
||||||
|
+ bool log_max_async_call_stack_depth_changed_ = false;
|
||||||
|
v8::Global<v8::Private> not_inspectable_private_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(IsolateData);
|
|
@ -0,0 +1,15 @@
|
||||||
|
diff --git a/src/inspector/inspector.gypi b/src/inspector/inspector.gypi
|
||||||
|
index a08a041012..bb96b0f610 100644
|
||||||
|
--- a/src/inspector/inspector.gypi
|
||||||
|
+++ b/src/inspector/inspector.gypi
|
||||||
|
@@ -31,8 +31,8 @@
|
||||||
|
'inspector_all_sources': [
|
||||||
|
'<@(inspector_generated_sources)',
|
||||||
|
'<(inspector_generated_injected_script)',
|
||||||
|
- '../../include/v8-inspector.h',
|
||||||
|
- '../../include/v8-inspector-protocol.h',
|
||||||
|
+ '../include/v8-inspector.h',
|
||||||
|
+ '../include/v8-inspector-protocol.h',
|
||||||
|
'inspector/injected-script.cc',
|
||||||
|
'inspector/injected-script.h',
|
||||||
|
'inspector/inspected-context.cc',
|
|
@ -0,0 +1,13 @@
|
||||||
|
diff --git a/test/message/testcfg.py b/test/message/testcfg.py
|
||||||
|
index 0576458af2..1bbb2b16d8 100644
|
||||||
|
--- a/test/message/testcfg.py
|
||||||
|
+++ b/test/message/testcfg.py
|
||||||
|
@@ -107,7 +107,7 @@ class MessageTestSuite(testsuite.TestSuite):
|
||||||
|
expected_lines, actual_lines, fillvalue=''):
|
||||||
|
pattern = re.escape(expected.rstrip() % env)
|
||||||
|
pattern = pattern.replace("\\*", ".*")
|
||||||
|
- pattern = pattern.replace("\\{NUMBER\\}", "\d(?:\.\d*)?")
|
||||||
|
+ pattern = pattern.replace("\\{NUMBER\\}", "\d+(?:\.\d*)?")
|
||||||
|
pattern = "^%s$" % pattern
|
||||||
|
if not re.match(pattern, actual):
|
||||||
|
return True
|
|
@ -0,0 +1,75 @@
|
||||||
|
diff --git a/src/builtins/builtins-collections-gen.cc b/src/builtins/builtins-collections-gen.cc
|
||||||
|
index 3cb20cd8df..acb4c949ae 100644
|
||||||
|
--- a/src/builtins/builtins-collections-gen.cc
|
||||||
|
+++ b/src/builtins/builtins-collections-gen.cc
|
||||||
|
@@ -302,10 +302,11 @@ TF_BUILTIN(MapConstructor, CollectionsBuiltinsAssembler) {
|
||||||
|
|
||||||
|
BIND(&if_notobject);
|
||||||
|
{
|
||||||
|
- Node* const exception = MakeTypeError(
|
||||||
|
- MessageTemplate::kIteratorValueNotAnObject, context, next_value);
|
||||||
|
- var_exception.Bind(exception);
|
||||||
|
- Goto(&if_exception);
|
||||||
|
+ Node* ret = CallRuntime(
|
||||||
|
+ Runtime::kThrowTypeError, context,
|
||||||
|
+ SmiConstant(MessageTemplate::kIteratorValueNotAnObject), next_value);
|
||||||
|
+ GotoIfException(ret, &if_exception, &var_exception);
|
||||||
|
+ Unreachable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/test/inspector/debugger/caught-uncaught-exceptions-expected.txt b/test/inspector/debugger/caught-uncaught-exceptions-expected.txt
|
||||||
|
index b784fa549e..9c40b1c556 100644
|
||||||
|
--- a/test/inspector/debugger/caught-uncaught-exceptions-expected.txt
|
||||||
|
+++ b/test/inspector/debugger/caught-uncaught-exceptions-expected.txt
|
||||||
|
@@ -3,3 +3,11 @@ paused in throwCaught
|
||||||
|
uncaught: false
|
||||||
|
paused in throwUncaught
|
||||||
|
uncaught: true
|
||||||
|
+paused in throwInPromiseCaught
|
||||||
|
+uncaught: false
|
||||||
|
+paused in promiseUncaught
|
||||||
|
+uncaught: true
|
||||||
|
+paused in throwInMapConstructor
|
||||||
|
+uncaught: true
|
||||||
|
+paused in throwInAsyncIterator
|
||||||
|
+uncaught: true
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/test/inspector/debugger/caught-uncaught-exceptions.js b/test/inspector/debugger/caught-uncaught-exceptions.js
|
||||||
|
index 38b622d3db..b7c4bd4ab7 100644
|
||||||
|
--- a/test/inspector/debugger/caught-uncaught-exceptions.js
|
||||||
|
+++ b/test/inspector/debugger/caught-uncaught-exceptions.js
|
||||||
|
@@ -7,6 +7,19 @@ let {session, contextGroup, Protocol} = InspectorTest.start("Check that inspecto
|
||||||
|
contextGroup.addScript(
|
||||||
|
`function throwCaught() { try { throw new Error(); } catch (_) {} }
|
||||||
|
function throwUncaught() { throw new Error(); }
|
||||||
|
+ function throwInPromiseCaught() {
|
||||||
|
+ var reject;
|
||||||
|
+ new Promise(function(res, rej) { reject = rej; }).catch(() => {});
|
||||||
|
+ reject();
|
||||||
|
+ }
|
||||||
|
+ function throwInPromiseUncaught() {
|
||||||
|
+ new Promise(function promiseUncaught() { throw new Error(); });
|
||||||
|
+ }
|
||||||
|
+ function throwInMapConstructor() { new Map('a'); }
|
||||||
|
+ function throwInAsyncIterator() {
|
||||||
|
+ let it = (async function*() {})();
|
||||||
|
+ it.next.call({});
|
||||||
|
+ }
|
||||||
|
function schedule(f) { setTimeout(f, 0); }
|
||||||
|
`);
|
||||||
|
|
||||||
|
@@ -22,4 +35,12 @@ Protocol.Debugger.onPaused(message => {
|
||||||
|
Protocol.Runtime.evaluate({ "expression": "schedule(throwCaught);" })
|
||||||
|
.then(() => Protocol.Runtime.evaluate(
|
||||||
|
{ "expression": "schedule(throwUncaught);" }))
|
||||||
|
- .then(() => InspectorTest.completeTest());
|
||||||
|
+ .then(() => Protocol.Runtime.evaluate(
|
||||||
|
+ { "expression": "schedule(throwInPromiseCaught);"}))
|
||||||
|
+ .then(() => Protocol.Runtime.evaluate(
|
||||||
|
+ { "expression": "schedule(throwInPromiseUncaught);"}))
|
||||||
|
+ .then(() => Protocol.Runtime.evaluate(
|
||||||
|
+ { "expression": "schedule(throwInMapConstructor);"}))
|
||||||
|
+ .then(() => Protocol.Runtime.evaluate(
|
||||||
|
+ { "expression": "schedule(throwInAsyncIterator);"}))
|
||||||
|
+ .then(() => InspectorTest.completeTest());
|
Загрузка…
Ссылка в новой задаче