diff --git a/patches/common/v8/.patches b/patches/common/v8/.patches index bd585ab88716..daf9f50f8961 100644 --- a/patches/common/v8/.patches +++ b/patches/common/v8/.patches @@ -1,11 +1,8 @@ add_realloc.patch build_gn.patch expose_mksnapshot.patch -revert_api_remove_deprecated_conversion_functions.patch deps_provide_more_v8_backwards_compatibility.patch dcheck.patch -revert_reland_api_heap_remove_deprecated_persistent_apis.patch -fixme_revert_heap_api_remove_deprecated_apis.patch revert_cctest_add_v8_export_private_to_arm_arm64_ports.patch export_symbols_needed_for_windows_build.patch workaround_an_undefined_symbol_error.patch diff --git a/patches/common/v8/dcheck.patch b/patches/common/v8/dcheck.patch index 47aaa7c01472..750693d95013 100644 --- a/patches/common/v8/dcheck.patch +++ b/patches/common/v8/dcheck.patch @@ -5,10 +5,10 @@ Subject: dcheck.patch diff --git a/src/api.cc b/src/api.cc -index a91a11b9dedf375b7d3950dfd6eab3f63b23e0ca..1102e5d9ca745ec57257379acef92a17d374362d 100644 +index 679f7db6724976ae960182e838133d672c17f312..bd7cfa48aa219263551b7a9e523ae82324cac492 100644 --- a/src/api.cc +++ b/src/api.cc -@@ -8633,7 +8633,7 @@ void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { +@@ -8592,7 +8592,7 @@ void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { void Isolate::RunMicrotasks() { @@ -18,10 +18,10 @@ index a91a11b9dedf375b7d3950dfd6eab3f63b23e0ca..1102e5d9ca745ec57257379acef92a17 isolate->default_microtask_queue()->RunMicrotasks(isolate); } diff --git a/src/heap/heap.cc b/src/heap/heap.cc -index c1bbe6ee3e8fd8e93a49200e3369be98b340a889..0750431050b07ac38c8f9c341ea4ec13ad5a2586 100644 +index 4e1b1b8429b42f9d6b20faf60e45911656699021..c734ef5cb206a2d74c64f385ec45cb45fe38cef1 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc -@@ -4943,9 +4943,9 @@ void Heap::TearDown() { +@@ -4944,9 +4944,9 @@ void Heap::TearDown() { void Heap::AddGCPrologueCallback(v8::Isolate::GCCallbackWithData callback, GCType gc_type, void* data) { DCHECK_NOT_NULL(callback); diff --git a/patches/common/v8/deps_provide_more_v8_backwards_compatibility.patch b/patches/common/v8/deps_provide_more_v8_backwards_compatibility.patch index c085263faf9d..fff12a944d2f 100644 --- a/patches/common/v8/deps_provide_more_v8_backwards_compatibility.patch +++ b/patches/common/v8/deps_provide_more_v8_backwards_compatibility.patch @@ -22,7 +22,7 @@ Reviewed-By: Yang Guo Reviewed-By: Michaƫl Zasso diff --git a/include/v8.h b/include/v8.h -index 4a3b94897f01f7d770770abc26b030f54060d3de..26ac2cb01da36529e99dcd5cc878523601addc0d 100644 +index 0e21793b1214c681770b72f64b9f0d6188c6a385..b5af3e191886db921ae811ef5f5db4aab39d6533 100644 --- a/include/v8.h +++ b/include/v8.h @@ -1109,6 +1109,10 @@ class V8_EXPORT PrimitiveArray { @@ -45,9 +45,9 @@ index 4a3b94897f01f7d770770abc26b030f54060d3de..26ac2cb01da36529e99dcd5cc8785236 Local GetFrame(Isolate* isolate, uint32_t index) const; /** -@@ -2518,6 +2524,13 @@ class V8_EXPORT Value : public Data { - V8_DEPRECATED("Use maybe version", - Local ToInt32(Isolate* isolate) const); +@@ -2505,6 +2511,13 @@ class V8_EXPORT Value : public Data { + + Local ToBoolean(Isolate* isolate) const; + inline V8_DEPRECATED("Use maybe version", + Local ToBoolean() const); @@ -59,7 +59,7 @@ index 4a3b94897f01f7d770770abc26b030f54060d3de..26ac2cb01da36529e99dcd5cc8785236 /** * Attempts to convert a string to an array index. * Returns an empty handle if the conversion fails. -@@ -2537,7 +2550,14 @@ class V8_EXPORT Value : public Data { +@@ -2521,7 +2534,14 @@ class V8_EXPORT Value : public Data { Local context) const; V8_WARN_UNUSED_RESULT Maybe Int32Value(Local context) const; @@ -74,7 +74,7 @@ index 4a3b94897f01f7d770770abc26b030f54060d3de..26ac2cb01da36529e99dcd5cc8785236 V8_WARN_UNUSED_RESULT Maybe Equals(Local context, Local that) const; bool StrictEquals(Local that) const; -@@ -2644,6 +2664,8 @@ class V8_EXPORT String : public Name { +@@ -2628,6 +2648,8 @@ class V8_EXPORT String : public Name { * Returns the number of bytes in the UTF-8 encoded * representation of this string. */ @@ -83,7 +83,7 @@ index 4a3b94897f01f7d770770abc26b030f54060d3de..26ac2cb01da36529e99dcd5cc8785236 int Utf8Length(Isolate* isolate) const; /** -@@ -2700,12 +2722,23 @@ class V8_EXPORT String : public Name { +@@ -2684,12 +2706,23 @@ class V8_EXPORT String : public Name { // 16-bit character codes. int Write(Isolate* isolate, uint16_t* buffer, int start = 0, int length = -1, int options = NO_OPTIONS) const; @@ -107,7 +107,7 @@ index 4a3b94897f01f7d770770abc26b030f54060d3de..26ac2cb01da36529e99dcd5cc8785236 /** * A zero length string. -@@ -2893,6 +2926,9 @@ class V8_EXPORT String : public Name { +@@ -2877,6 +2910,9 @@ class V8_EXPORT String : public Name { */ static Local Concat(Isolate* isolate, Local left, Local right); @@ -117,7 +117,7 @@ index 4a3b94897f01f7d770770abc26b030f54060d3de..26ac2cb01da36529e99dcd5cc8785236 /** * Creates a new external string using the data defined in the given -@@ -2961,6 +2997,8 @@ class V8_EXPORT String : public Name { +@@ -2945,6 +2981,8 @@ class V8_EXPORT String : public Name { */ class V8_EXPORT Utf8Value { public: @@ -126,7 +126,7 @@ index 4a3b94897f01f7d770770abc26b030f54060d3de..26ac2cb01da36529e99dcd5cc8785236 Utf8Value(Isolate* isolate, Local obj); ~Utf8Value(); char* operator*() { return str_; } -@@ -2984,6 +3022,7 @@ class V8_EXPORT String : public Name { +@@ -2968,6 +3006,7 @@ class V8_EXPORT String : public Name { */ class V8_EXPORT Value { public: @@ -134,7 +134,7 @@ index 4a3b94897f01f7d770770abc26b030f54060d3de..26ac2cb01da36529e99dcd5cc8785236 Value(Isolate* isolate, Local obj); ~Value(); uint16_t* operator*() { return str_; } -@@ -5352,6 +5391,8 @@ class V8_EXPORT BooleanObject : public Object { +@@ -5336,6 +5375,8 @@ class V8_EXPORT BooleanObject : public Object { class V8_EXPORT StringObject : public Object { public: static Local New(Isolate* isolate, Local value); @@ -143,13 +143,12 @@ index 4a3b94897f01f7d770770abc26b030f54060d3de..26ac2cb01da36529e99dcd5cc8785236 Local ValueOf() const; -@@ -10457,6 +10498,30 @@ template Value* Value::Cast(T* value) { +@@ -10441,6 +10482,29 @@ template Value* Value::Cast(T* value) { } +Local Value::ToBoolean() const { -+ return ToBoolean(Isolate::GetCurrent()->GetCurrentContext()) -+ .FromMaybe(Local()); ++ return ToBoolean(Isolate::GetCurrent()); +} + + @@ -175,7 +174,7 @@ index 4a3b94897f01f7d770770abc26b030f54060d3de..26ac2cb01da36529e99dcd5cc8785236 #ifdef V8_ENABLE_CHECKS CheckCast(value); diff --git a/src/api.cc b/src/api.cc -index 9124d03fa6195269eaf851591bb95125c2081e2f..a91a11b9dedf375b7d3950dfd6eab3f63b23e0ca 100644 +index c2fc1fc9827f896c521606a75baecef6c60e8f8a..679f7db6724976ae960182e838133d672c17f312 100644 --- a/src/api.cc +++ b/src/api.cc @@ -2227,6 +2227,10 @@ int PrimitiveArray::Length() const { @@ -211,13 +210,12 @@ index 9124d03fa6195269eaf851591bb95125c2081e2f..a91a11b9dedf375b7d3950dfd6eab3f6 Local StackTrace::GetFrame(Isolate* v8_isolate, uint32_t index) const { i::Isolate* isolate = reinterpret_cast(v8_isolate); -@@ -3908,6 +3920,34 @@ void v8::RegExp::CheckCast(v8::Value* that) { - "Could not convert to regular expression"); +@@ -3570,6 +3582,34 @@ MaybeLocal Value::ToBigInt(Local context) const { + RETURN_ESCAPED(result); } +bool Value::BooleanValue() const { -+ return BooleanValue(Isolate::GetCurrent()->GetCurrentContext()) -+ .FromJust(); ++ return BooleanValue(Isolate::GetCurrent()); +} + + @@ -243,10 +241,11 @@ index 9124d03fa6195269eaf851591bb95125c2081e2f..a91a11b9dedf375b7d3950dfd6eab3f6 + return Int32Value(Isolate::GetCurrent()->GetCurrentContext()) + .FromMaybe(0); +} - - Maybe Value::BooleanValue(Local context) const { - i::Isolate* isolate = reinterpret_cast(context->GetIsolate()); -@@ -3997,6 +4037,12 @@ MaybeLocal Value::ToArrayIndex(Local context) const { ++ + bool Value::BooleanValue(Isolate* v8_isolate) const { + return Utils::OpenHandle(this)->BooleanValue( + reinterpret_cast(v8_isolate)); +@@ -3956,6 +3996,12 @@ MaybeLocal Value::ToArrayIndex(Local context) const { } @@ -259,7 +258,7 @@ index 9124d03fa6195269eaf851591bb95125c2081e2f..a91a11b9dedf375b7d3950dfd6eab3f6 Maybe Value::Equals(Local context, Local that) const { i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); auto self = Utils::OpenHandle(this); -@@ -5275,6 +5321,10 @@ bool String::ContainsOnlyOneByte() const { +@@ -5234,6 +5280,10 @@ bool String::ContainsOnlyOneByte() const { return helper.Check(*str); } @@ -270,7 +269,7 @@ index 9124d03fa6195269eaf851591bb95125c2081e2f..a91a11b9dedf375b7d3950dfd6eab3f6 int String::Utf8Length(Isolate* isolate) const { i::Handle str = Utils::OpenHandle(this); str = i::String::Flatten(reinterpret_cast(isolate), str); -@@ -5427,6 +5477,14 @@ static int WriteUtf8Impl(i::Vector string, char* write_start, +@@ -5386,6 +5436,14 @@ static int WriteUtf8Impl(i::Vector string, char* write_start, } } // anonymous namespace @@ -285,7 +284,7 @@ index 9124d03fa6195269eaf851591bb95125c2081e2f..a91a11b9dedf375b7d3950dfd6eab3f6 int String::WriteUtf8(Isolate* v8_isolate, char* buffer, int capacity, int* nchars_ref, int options) const { i::Handle str = Utils::OpenHandle(this); -@@ -5467,6 +5525,18 @@ static inline int WriteHelper(i::Isolate* isolate, const String* string, +@@ -5426,6 +5484,18 @@ static inline int WriteHelper(i::Isolate* isolate, const String* string, } @@ -304,7 +303,7 @@ index 9124d03fa6195269eaf851591bb95125c2081e2f..a91a11b9dedf375b7d3950dfd6eab3f6 int String::WriteOneByte(Isolate* isolate, uint8_t* buffer, int start, int length, int options) const { return WriteHelper(reinterpret_cast(isolate), this, buffer, -@@ -6434,6 +6504,11 @@ MaybeLocal String::NewFromTwoByte(Isolate* isolate, +@@ -6393,6 +6463,11 @@ MaybeLocal String::NewFromTwoByte(Isolate* isolate, return result; } @@ -316,7 +315,7 @@ index 9124d03fa6195269eaf851591bb95125c2081e2f..a91a11b9dedf375b7d3950dfd6eab3f6 Local v8::String::Concat(Isolate* v8_isolate, Local left, Local right) { i::Isolate* isolate = reinterpret_cast(v8_isolate); -@@ -6716,6 +6791,11 @@ bool v8::BooleanObject::ValueOf() const { +@@ -6675,6 +6750,11 @@ bool v8::BooleanObject::ValueOf() const { } @@ -328,7 +327,7 @@ index 9124d03fa6195269eaf851591bb95125c2081e2f..a91a11b9dedf375b7d3950dfd6eab3f6 Local v8::StringObject::New(Isolate* v8_isolate, Local value) { i::Handle string = Utils::OpenHandle(*value); -@@ -8998,6 +9078,9 @@ bool MicrotasksScope::IsRunningMicrotasks(Isolate* v8_isolate) { +@@ -8957,6 +9037,9 @@ bool MicrotasksScope::IsRunningMicrotasks(Isolate* v8_isolate) { return microtask_queue->IsRunningMicrotasks(); } @@ -338,7 +337,7 @@ index 9124d03fa6195269eaf851591bb95125c2081e2f..a91a11b9dedf375b7d3950dfd6eab3f6 String::Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Local obj) : str_(nullptr), length_(0) { if (obj.IsEmpty()) return; -@@ -9017,6 +9100,9 @@ String::Utf8Value::~Utf8Value() { +@@ -8976,6 +9059,9 @@ String::Utf8Value::~Utf8Value() { i::DeleteArray(str_); } diff --git a/patches/common/v8/fixme_revert_heap_api_remove_deprecated_apis.patch b/patches/common/v8/fixme_revert_heap_api_remove_deprecated_apis.patch deleted file mode 100644 index 8426fdf7197d..000000000000 --- a/patches/common/v8/fixme_revert_heap_api_remove_deprecated_apis.patch +++ /dev/null @@ -1,261 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samuel Attard -Date: Thu, 21 Mar 2019 22:29:55 -0700 -Subject: fixme: Revert "[heap,api] Remove deprecated APIs" - -This reverts commit f4b860d9b81956fb9d6815932522f4043fef56fa. - -This commit removes deprecated APIs that nan relies on, temporarily -reverting but we need to solve this with nan upstream - -diff --git a/include/v8-internal.h b/include/v8-internal.h -index 8e700a4d4d401bb58cdc6128e3e96dbf2d791d5c..94a6e3c1932a06ef1eee1be403b031f50d0d7baf 100644 ---- a/include/v8-internal.h -+++ b/include/v8-internal.h -@@ -165,6 +165,7 @@ class Internals { - static const int kNodeStateMask = 0x7; - static const int kNodeStateIsWeakValue = 2; - static const int kNodeStateIsPendingValue = 3; -+ static const int kNodeStateIsNearDeathValue = 4; - static const int kNodeIsIndependentShift = 3; - static const int kNodeIsActiveShift = 4; - -diff --git a/include/v8.h b/include/v8.h -index c5e22bb14043ade00b4ecf73b6115e747d5232ad..b96cbdee06a305776e062f5b8362e1b17106e1dd 100644 ---- a/include/v8.h -+++ b/include/v8.h -@@ -577,6 +577,10 @@ template class PersistentBase { - - V8_DEPRECATED("See MarkIndependent.", V8_INLINE bool IsIndependent() const); - -+ /** Checks if the handle holds the only reference to an object. */ -+ V8_DEPRECATED("Garbage collection internal state should not be relied on.", -+ V8_INLINE bool IsNearDeath() const); -+ - /** Returns true if the handle's reference is weak. */ - V8_INLINE bool IsWeak() const; - -@@ -8596,6 +8600,17 @@ class V8_EXPORT Isolate { - */ - void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor); - -+ /** -+ * Iterates through all the persistent handles in the current isolate's heap -+ * that have class_ids and are candidates to be marked as partially dependent -+ * handles. This will visit handles to young objects created since the last -+ * garbage collection but is free to visit an arbitrary superset of these -+ * objects. -+ */ -+ V8_DEPRECATED( -+ "Use VisitHandlesWithClassIds", -+ void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor)); -+ - /** - * Iterates through all the persistent handles in the current isolate's heap - * that have class_ids and are weak to be marked as inactive if there is no -@@ -9867,6 +9882,17 @@ bool PersistentBase::IsIndependent() const { - I::kNodeIsIndependentShift); - } - -+template -+bool PersistentBase::IsNearDeath() const { -+ typedef internal::Internals I; -+ if (this->IsEmpty()) return false; -+ uint8_t node_state = -+ I::GetNodeState(reinterpret_cast(this->val_)); -+ return node_state == I::kNodeStateIsNearDeathValue || -+ node_state == I::kNodeStateIsPendingValue; -+} -+ -+ - template - bool PersistentBase::IsWeak() const { - typedef internal::Internals I; -diff --git a/src/api.cc b/src/api.cc -index 2a2311454ba37e557b1c1f046f46e7f5881516b9..10553d5bc638ceb81f4dd14d5231df3e9ae887dc 100644 ---- a/src/api.cc -+++ b/src/api.cc -@@ -8989,6 +8989,15 @@ void Isolate::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) { - isolate->global_handles()->IterateAllRootsWithClassIds(visitor); - } - -+ -+void Isolate::VisitHandlesForPartialDependence( -+ PersistentHandleVisitor* visitor) { -+ i::Isolate* isolate = reinterpret_cast(this); -+ i::DisallowHeapAllocation no_allocation; -+ isolate->global_handles()->IterateAllYoungRootsWithClassIds(visitor); -+} -+ -+ - void Isolate::VisitWeakHandles(PersistentHandleVisitor* visitor) { - i::Isolate* isolate = reinterpret_cast(this); - i::DisallowHeapAllocation no_allocation; -diff --git a/src/global-handles.cc b/src/global-handles.cc -index 350380b23ce6f4fe89e628285d2e69fb1cac88ee..5eb3d93f142ea4d6ec88a4468b6390ec5387da84 100644 ---- a/src/global-handles.cc -+++ b/src/global-handles.cc -@@ -379,6 +379,7 @@ class GlobalHandles::Node final : public NodeBase { - Internals::kNodeStateMask); - STATIC_ASSERT(WEAK == Internals::kNodeStateIsWeakValue); - STATIC_ASSERT(PENDING == Internals::kNodeStateIsPendingValue); -+ STATIC_ASSERT(NEAR_DEATH == Internals::kNodeStateIsNearDeathValue); - STATIC_ASSERT(static_cast(IsIndependent::kShift) == - Internals::kNodeIsIndependentShift); - STATIC_ASSERT(static_cast(IsActive::kShift) == -@@ -426,6 +427,11 @@ class GlobalHandles::Node final : public NodeBase { - flags_ = NodeWeaknessType::update(flags_, weakness_type); - } - -+ bool IsNearDeath() const { -+ // Check for PENDING to ensure correct answer when processing callbacks. -+ return state() == PENDING || state() == NEAR_DEATH; -+ } -+ - bool IsWeak() const { return state() == WEAK; } - - bool IsInUse() const { return state() != FREE; } -@@ -813,6 +819,10 @@ void GlobalHandles::AnnotateStrongRetainer(Address* location, - Node::FromLocation(location)->AnnotateStrongRetainer(label); - } - -+bool GlobalHandles::IsNearDeath(Address* location) { -+ return Node::FromLocation(location)->IsNearDeath(); -+} -+ - bool GlobalHandles::IsWeak(Address* location) { - return Node::FromLocation(location)->IsWeak(); - } -diff --git a/src/global-handles.h b/src/global-handles.h -index 6b8ca0c93fa344ed0155106fef3a0aabf13bdf44..f5f51bb00761f37b7182e0be5e8783831bff3217 100644 ---- a/src/global-handles.h -+++ b/src/global-handles.h -@@ -73,6 +73,9 @@ class V8_EXPORT_PRIVATE GlobalHandles final { - // Clear the weakness of a global handle. - static void* ClearWeakness(Address* location); - -+ // Tells whether global handle is near death. -+ static bool IsNearDeath(Address* location); -+ - // Tells whether global handle is weak. - static bool IsWeak(Address* location); - -diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc -index 4c791d128e6126ea67c3240ee48ac689a55fd29a..03d702487091c40f575e8028f97849d5f6e6c92f 100644 ---- a/test/cctest/heap/test-heap.cc -+++ b/test/cctest/heap/test-heap.cc -@@ -528,9 +528,14 @@ TEST(WeakGlobalHandlesScavenge) { - - // Scavenge treats weak pointers as normal roots. - CcTest::CollectGarbage(NEW_SPACE); -+ - CHECK((*h1)->IsString()); - CHECK((*h2)->IsHeapNumber()); -+ - CHECK(!WeakPointerCleared); -+ CHECK(!global_handles->IsNearDeath(h2.location())); -+ CHECK(!global_handles->IsNearDeath(h1.location())); -+ - GlobalHandles::Destroy(h1.location()); - GlobalHandles::Destroy(h2.location()); - } -@@ -568,8 +573,11 @@ TEST(WeakGlobalUnmodifiedApiHandlesScavenge) { - &TestWeakGlobalHandleCallback, v8::WeakCallbackType::kParameter); - - CcTest::CollectGarbage(NEW_SPACE); -+ - CHECK((*h1)->IsHeapNumber()); - CHECK(WeakPointerCleared); -+ CHECK(!global_handles->IsNearDeath(h1.location())); -+ - GlobalHandles::Destroy(h1.location()); - } - -@@ -606,7 +614,10 @@ TEST(WeakGlobalApiHandleModifiedMapScavenge) { - &TestWeakGlobalHandleCallback, v8::WeakCallbackType::kParameter); - - CcTest::CollectGarbage(NEW_SPACE); -+ - CHECK(!WeakPointerCleared); -+ CHECK(!global_handles->IsNearDeath(h1.location())); -+ - GlobalHandles::Destroy(h1.location()); - } - -@@ -647,7 +658,10 @@ TEST(WeakGlobalApiHandleWithElementsScavenge) { - &TestWeakGlobalHandleCallback, v8::WeakCallbackType::kParameter); - - CcTest::CollectGarbage(NEW_SPACE); -+ - CHECK(!WeakPointerCleared); -+ CHECK(!global_handles->IsNearDeath(h1.location())); -+ - GlobalHandles::Destroy(h1.location()); - } - -@@ -682,11 +696,17 @@ TEST(WeakGlobalHandlesMark) { - GlobalHandles::MakeWeak( - h2.location(), reinterpret_cast(&handle_and_id), - &TestWeakGlobalHandleCallback, v8::WeakCallbackType::kParameter); -+ CHECK(!GlobalHandles::IsNearDeath(h1.location())); -+ CHECK(!GlobalHandles::IsNearDeath(h2.location())); - - // Incremental marking potentially marked handles before they turned weak. - CcTest::CollectAllGarbage(); -+ - CHECK((*h1)->IsString()); -+ - CHECK(WeakPointerCleared); -+ CHECK(!GlobalHandles::IsNearDeath(h1.location())); -+ - GlobalHandles::Destroy(h1.location()); - } - -diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc -index 2e097336572cbd82e6d9dba69c8388904f8ecaee..ebcdab3c27e8fb0b4ccfae9e0aab7bb8a4f10ce2 100644 ---- a/test/cctest/test-api.cc -+++ b/test/cctest/test-api.cc -@@ -20472,6 +20472,43 @@ TEST(WrapperClassId) { - object.Reset(); - } - -+ -+TEST(PersistentHandleInNewSpaceVisitor) { -+ LocalContext context; -+ v8::Isolate* isolate = context->GetIsolate(); -+ v8::HandleScope scope(isolate); -+ v8::Persistent object1(isolate, v8::Object::New(isolate)); -+ CHECK_EQ(0, object1.WrapperClassId()); -+ object1.SetWrapperClassId(42); -+ CHECK_EQ(42, object1.WrapperClassId()); -+ -+ CcTest::CollectAllGarbage(); -+ CcTest::CollectAllGarbage(); -+ -+ v8::Persistent object2(isolate, v8::Object::New(isolate)); -+ CHECK_EQ(0, object2.WrapperClassId()); -+ object2.SetWrapperClassId(42); -+ CHECK_EQ(42, object2.WrapperClassId()); -+ -+ Visitor42 visitor(&object2); -+#if __clang__ -+#pragma clang diagnostic push -+#pragma clang diagnostic ignored "-Wdeprecated" -+#endif -+ // VisitHandlesForPartialDependence is marked deprecated. This test will be -+ // removed with the API method. -+ isolate->VisitHandlesForPartialDependence(&visitor); -+#if __clang__ -+#pragma clang diagnostic pop -+#endif -+ -+ CHECK_EQ(1, visitor.counter_); -+ -+ object1.Reset(); -+ object2.Reset(); -+} -+ -+ - TEST(RegExp) { - LocalContext context; - v8::HandleScope scope(context->GetIsolate()); diff --git a/patches/common/v8/revert_api_remove_deprecated_conversion_functions.patch b/patches/common/v8/revert_api_remove_deprecated_conversion_functions.patch deleted file mode 100644 index b8b5cf7b3e8f..000000000000 --- a/patches/common/v8/revert_api_remove_deprecated_conversion_functions.patch +++ /dev/null @@ -1,142 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jeremy Apthorp -Date: Mon, 29 Apr 2019 14:16:31 -0700 -Subject: Revert "[api] Remove deprecated conversion functions" - -This reverts commit c76f377a990343b18953123c2726337b38c59812. - -diff --git a/include/v8.h b/include/v8.h -index 0e21793b1214c681770b72f64b9f0d6188c6a385..4a3b94897f01f7d770770abc26b030f54060d3de 100644 ---- a/include/v8.h -+++ b/include/v8.h -@@ -2489,6 +2489,9 @@ class V8_EXPORT Value : public Data { - - V8_WARN_UNUSED_RESULT MaybeLocal ToBigInt( - Local context) const; -+ V8_DEPRECATED("ToBoolean can never throw. Use Local version.", -+ V8_WARN_UNUSED_RESULT MaybeLocal ToBoolean( -+ Local context) const); - V8_WARN_UNUSED_RESULT MaybeLocal ToNumber( - Local context) const; - V8_WARN_UNUSED_RESULT MaybeLocal ToString( -@@ -2504,6 +2507,16 @@ class V8_EXPORT Value : public Data { - V8_WARN_UNUSED_RESULT MaybeLocal ToInt32(Local context) const; - - Local ToBoolean(Isolate* isolate) const; -+ V8_DEPRECATED("Use maybe version", -+ Local ToNumber(Isolate* isolate) const); -+ V8_DEPRECATED("Use maybe version", -+ Local ToString(Isolate* isolate) const); -+ V8_DEPRECATED("Use maybe version", -+ Local ToObject(Isolate* isolate) const); -+ V8_DEPRECATED("Use maybe version", -+ Local ToInteger(Isolate* isolate) const); -+ V8_DEPRECATED("Use maybe version", -+ Local ToInt32(Isolate* isolate) const); - - /** - * Attempts to convert a string to an array index. -@@ -2514,6 +2527,9 @@ class V8_EXPORT Value : public Data { - - bool BooleanValue(Isolate* isolate) const; - -+ V8_DEPRECATED("BooleanValue can never throw. Use Isolate version.", -+ V8_WARN_UNUSED_RESULT Maybe BooleanValue( -+ Local context) const); - V8_WARN_UNUSED_RESULT Maybe NumberValue(Local context) const; - V8_WARN_UNUSED_RESULT Maybe IntegerValue( - Local context) const; -diff --git a/src/api.cc b/src/api.cc -index c2fc1fc9827f896c521606a75baecef6c60e8f8a..9124d03fa6195269eaf851591bb95125c2081e2f 100644 ---- a/src/api.cc -+++ b/src/api.cc -@@ -3537,6 +3537,12 @@ MaybeLocal Value::ToString(Local context) const { - RETURN_ESCAPED(result); - } - -+ -+Local Value::ToString(Isolate* isolate) const { -+ RETURN_TO_LOCAL_UNCHECKED(ToString(isolate->GetCurrentContext()), String); -+} -+ -+ - MaybeLocal Value::ToDetailString(Local context) const { - i::Handle obj = Utils::OpenHandle(this); - if (obj->IsString()) return ToApiHandle(obj); -@@ -3559,6 +3565,11 @@ MaybeLocal Value::ToObject(Local context) const { - RETURN_ESCAPED(result); - } - -+ -+Local Value::ToObject(Isolate* isolate) const { -+ RETURN_TO_LOCAL_UNCHECKED(ToObject(isolate->GetCurrentContext()), Object); -+} -+ - MaybeLocal Value::ToBigInt(Local context) const { - i::Handle obj = Utils::OpenHandle(this); - if (obj->IsBigInt()) return ToApiHandle(obj); -@@ -3575,6 +3586,11 @@ bool Value::BooleanValue(Isolate* v8_isolate) const { - reinterpret_cast(v8_isolate)); - } - -+MaybeLocal Value::ToBoolean(Local context) const { -+ return ToBoolean(context->GetIsolate()); -+} -+ -+ - Local Value::ToBoolean(Isolate* v8_isolate) const { - auto isolate = reinterpret_cast(v8_isolate); - return ToApiHandle( -@@ -3593,6 +3609,12 @@ MaybeLocal Value::ToNumber(Local context) const { - RETURN_ESCAPED(result); - } - -+ -+Local Value::ToNumber(Isolate* isolate) const { -+ RETURN_TO_LOCAL_UNCHECKED(ToNumber(isolate->GetCurrentContext()), Number); -+} -+ -+ - MaybeLocal Value::ToInteger(Local context) const { - auto obj = Utils::OpenHandle(this); - if (obj->IsSmi()) return ToApiHandle(obj); -@@ -3604,6 +3626,12 @@ MaybeLocal Value::ToInteger(Local context) const { - RETURN_ESCAPED(result); - } - -+ -+Local Value::ToInteger(Isolate* isolate) const { -+ RETURN_TO_LOCAL_UNCHECKED(ToInteger(isolate->GetCurrentContext()), Integer); -+} -+ -+ - MaybeLocal Value::ToInt32(Local context) const { - auto obj = Utils::OpenHandle(this); - if (obj->IsSmi()) return ToApiHandle(obj); -@@ -3615,6 +3643,12 @@ MaybeLocal Value::ToInt32(Local context) const { - RETURN_ESCAPED(result); - } - -+ -+Local Value::ToInt32(Isolate* isolate) const { -+ RETURN_TO_LOCAL_UNCHECKED(ToInt32(isolate->GetCurrentContext()), Int32); -+} -+ -+ - MaybeLocal Value::ToUint32(Local context) const { - auto obj = Utils::OpenHandle(this); - if (obj->IsSmi()) return ToApiHandle(obj); -@@ -3874,6 +3908,13 @@ void v8::RegExp::CheckCast(v8::Value* that) { - "Could not convert to regular expression"); - } - -+ -+Maybe Value::BooleanValue(Local context) const { -+ i::Isolate* isolate = reinterpret_cast(context->GetIsolate()); -+ return Just(Utils::OpenHandle(this)->BooleanValue(isolate)); -+} -+ -+ - Maybe Value::NumberValue(Local context) const { - auto obj = Utils::OpenHandle(this); - if (obj->IsNumber()) return Just(obj->Number()); diff --git a/patches/common/v8/revert_cctest_add_v8_export_private_to_arm_arm64_ports.patch b/patches/common/v8/revert_cctest_add_v8_export_private_to_arm_arm64_ports.patch index 3fb56017a945..0a3263d02bbf 100644 --- a/patches/common/v8/revert_cctest_add_v8_export_private_to_arm_arm64_ports.patch +++ b/patches/common/v8/revert_cctest_add_v8_export_private_to_arm_arm64_ports.patch @@ -6,7 +6,7 @@ Subject: Revert "[cctest] Add V8_EXPORT_PRIVATE to arm/arm64 ports" This reverts commit 1a7d847cfac9a7363c59c980e47a7b7ff416e6da. diff --git a/src/arm/assembler-arm.h b/src/arm/assembler-arm.h -index c62c6041775206a7f222febf2950d6829e0299b7..4528b8efb1712683adc9403e4cf74bcab5fb1bbe 100644 +index 852b983ac4a40c33d23dba77e9c2b48f653d1b4f..b78a7651d1e5c54e32e08ecb6483e7ad9a734ee7 100644 --- a/src/arm/assembler-arm.h +++ b/src/arm/assembler-arm.h @@ -79,7 +79,7 @@ enum Coprocessor { @@ -59,7 +59,7 @@ index c62c6041775206a7f222febf2950d6829e0299b7..4528b8efb1712683adc9403e4cf74bca explicit UseScratchRegisterScope(Assembler* assembler); ~UseScratchRegisterScope(); diff --git a/src/arm64/assembler-arm64.h b/src/arm64/assembler-arm64.h -index 7dd97809e3e3d4a43f6595bb0fb9a5b7b916d8be..586eff1241fed0a5f6a6fbc9b858981058a75feb 100644 +index 8db1a571b7d198c03a6cb6f1a8ab04597bea2776..8614975a1dbe54fe655f5e050742ccc76faa21da 100644 --- a/src/arm64/assembler-arm64.h +++ b/src/arm64/assembler-arm64.h @@ -49,7 +49,7 @@ class Immediate { diff --git a/patches/common/v8/revert_reland_api_heap_remove_deprecated_persistent_apis.patch b/patches/common/v8/revert_reland_api_heap_remove_deprecated_persistent_apis.patch deleted file mode 100644 index 94d848e76e6e..000000000000 --- a/patches/common/v8/revert_reland_api_heap_remove_deprecated_persistent_apis.patch +++ /dev/null @@ -1,1159 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jeremy Apthorp -Date: Mon, 29 Apr 2019 13:52:07 -0700 -Subject: Revert "Reland "[api,heap] Remove deprecated Persistent APIs"" - -This reverts commit 4214933c6bb4d1815f07a40eaf008cb1e37ef217. - -diff --git a/include/v8-internal.h b/include/v8-internal.h -index 61bdb58c1a967d58faf3bb3ccbe1c90942b413f8..8e700a4d4d401bb58cdc6128e3e96dbf2d791d5c 100644 ---- a/include/v8-internal.h -+++ b/include/v8-internal.h -@@ -165,6 +165,8 @@ class Internals { - static const int kNodeStateMask = 0x7; - static const int kNodeStateIsWeakValue = 2; - static const int kNodeStateIsPendingValue = 3; -+ static const int kNodeIsIndependentShift = 3; -+ static const int kNodeIsActiveShift = 4; - - static const int kFirstNonstringType = 0x40; - static const int kOddballType = 0x43; -diff --git a/include/v8-util.h b/include/v8-util.h -index 29d813e4274d16939b77e5e1d13f097c5e08b0af..24962607076f780105365700d5aff10336eb1dac 100644 ---- a/include/v8-util.h -+++ b/include/v8-util.h -@@ -194,6 +194,14 @@ class PersistentValueMapBase { - return SetReturnValueFromVal(&returnValue, Traits::Get(&impl_, key)); - } - -+ /** -+ * Call V8::RegisterExternallyReferencedObject with the map value for given -+ * key. -+ */ -+ V8_DEPRECATED( -+ "Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference", -+ inline void RegisterExternallyReferencedObject(K& key)); -+ - /** - * Return value for key and remove it from the map. - */ -@@ -344,6 +352,16 @@ class PersistentValueMapBase { - const char* label_; - }; - -+template -+inline void -+PersistentValueMapBase::RegisterExternallyReferencedObject( -+ K& key) { -+ assert(Contains(key)); -+ V8::RegisterExternallyReferencedObject( -+ reinterpret_cast(FromVal(Traits::Get(&impl_, key))), -+ reinterpret_cast(GetIsolate())); -+} -+ - template - class PersistentValueMap : public PersistentValueMapBase { - public: -diff --git a/include/v8.h b/include/v8.h -index 26ac2cb01da36529e99dcd5cc878523601addc0d..c5e22bb14043ade00b4ecf73b6115e747d5232ad 100644 ---- a/include/v8.h -+++ b/include/v8.h -@@ -545,6 +545,38 @@ template class PersistentBase { - */ - V8_INLINE void AnnotateStrongRetainer(const char* label); - -+ /** -+ * Allows the embedder to tell the v8 garbage collector that a certain object -+ * is alive. Only allowed when the embedder is asked to trace its heap by -+ * EmbedderHeapTracer. -+ */ -+ V8_DEPRECATED( -+ "Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference", -+ V8_INLINE void RegisterExternalReference(Isolate* isolate) const); -+ -+ /** -+ * Marks the reference to this object independent. Garbage collector is free -+ * to ignore any object groups containing this object. Weak callback for an -+ * independent handle should not assume that it will be preceded by a global -+ * GC prologue callback or followed by a global GC epilogue callback. -+ */ -+ V8_DEPRECATED( -+ "Weak objects are always considered independent. " -+ "Use TracedGlobal when trying to use EmbedderHeapTracer. " -+ "Use a strong handle when trying to keep an object alive.", -+ V8_INLINE void MarkIndependent()); -+ -+ /** -+ * Marks the reference to this object as active. The scavenge garbage -+ * collection should not reclaim the objects marked as active, even if the -+ * object held by the handle is otherwise unreachable. -+ * -+ * This bit is cleared after the each garbage collection pass. -+ */ -+ V8_DEPRECATED("Use TracedGlobal.", V8_INLINE void MarkActive()); -+ -+ V8_DEPRECATED("See MarkIndependent.", V8_INLINE bool IsIndependent() const); -+ - /** Returns true if the handle's reference is weak. */ - V8_INLINE bool IsWeak() const; - -@@ -8878,6 +8910,9 @@ class V8_EXPORT V8 { - const char* label); - static Value* Eternalize(Isolate* isolate, Value* handle); - -+ static void RegisterExternallyReferencedObject(internal::Address* location, -+ internal::Isolate* isolate); -+ - template - friend class PersistentValueMapBase; - -@@ -9824,6 +9859,14 @@ void Persistent::Copy(const Persistent& that) { - M::Copy(that, this); - } - -+template -+bool PersistentBase::IsIndependent() const { -+ typedef internal::Internals I; -+ if (this->IsEmpty()) return false; -+ return I::GetNodeFlag(reinterpret_cast(this->val_), -+ I::kNodeIsIndependentShift); -+} -+ - template - bool PersistentBase::IsWeak() const { - typedef internal::Internals I; -@@ -9890,6 +9933,31 @@ void PersistentBase::AnnotateStrongRetainer(const char* label) { - label); - } - -+template -+void PersistentBase::RegisterExternalReference(Isolate* isolate) const { -+ if (IsEmpty()) return; -+ V8::RegisterExternallyReferencedObject( -+ reinterpret_cast(this->val_), -+ reinterpret_cast(isolate)); -+} -+ -+template -+void PersistentBase::MarkIndependent() { -+ typedef internal::Internals I; -+ if (this->IsEmpty()) return; -+ I::UpdateNodeFlag(reinterpret_cast(this->val_), true, -+ I::kNodeIsIndependentShift); -+} -+ -+template -+void PersistentBase::MarkActive() { -+ typedef internal::Internals I; -+ if (this->IsEmpty()) return; -+ I::UpdateNodeFlag(reinterpret_cast(this->val_), true, -+ I::kNodeIsActiveShift); -+} -+ -+ - template - void PersistentBase::SetWrapperClassId(uint16_t class_id) { - typedef internal::Internals I; -diff --git a/src/api.cc b/src/api.cc -index 1102e5d9ca745ec57257379acef92a17d374362d..2a2311454ba37e557b1c1f046f46e7f5881516b9 100644 ---- a/src/api.cc -+++ b/src/api.cc -@@ -1049,6 +1049,11 @@ void V8::MoveTracedGlobalReference(internal::Address** from, - i::GlobalHandles::MoveTracedGlobal(from, to); - } - -+void V8::RegisterExternallyReferencedObject(i::Address* location, -+ i::Isolate* isolate) { -+ isolate->heap()->RegisterExternallyReferencedObject(location); -+} -+ - void V8::MakeWeak(i::Address* location, void* parameter, - WeakCallbackInfo::Callback weak_callback, - WeakCallbackType type) { -diff --git a/src/global-handles.cc b/src/global-handles.cc -index fb5087b8a781cce05839dbbb79c5beaf2fddaa06..350380b23ce6f4fe89e628285d2e69fb1cac88ee 100644 ---- a/src/global-handles.cc -+++ b/src/global-handles.cc -@@ -379,6 +379,10 @@ class GlobalHandles::Node final : public NodeBase { - Internals::kNodeStateMask); - STATIC_ASSERT(WEAK == Internals::kNodeStateIsWeakValue); - STATIC_ASSERT(PENDING == Internals::kNodeStateIsPendingValue); -+ STATIC_ASSERT(static_cast(IsIndependent::kShift) == -+ Internals::kNodeIsIndependentShift); -+ STATIC_ASSERT(static_cast(IsActive::kShift) == -+ Internals::kNodeIsActiveShift); - set_in_young_list(false); - } - -@@ -402,6 +406,16 @@ class GlobalHandles::Node final : public NodeBase { - flags_ = NodeState::update(flags_, state); - } - -+ bool is_independent() { return IsIndependent::decode(flags_); } -+ void set_independent(bool v) { flags_ = IsIndependent::update(flags_, v); } -+ -+ bool is_active() { -+ return IsActive::decode(flags_); -+ } -+ void set_active(bool v) { -+ flags_ = IsActive::update(flags_, v); -+ } -+ - bool is_in_young_list() const { return IsInYoungList::decode(flags_); } - void set_in_young_list(bool v) { flags_ = IsInYoungList::update(flags_, v); } - -@@ -548,6 +562,7 @@ class GlobalHandles::Node final : public NodeBase { - // This method invokes a finalizer. Updating the method name would require - // adjusting CFI blacklist as weak_callback_ is invoked on the wrong type. - CHECK(IsPendingFinalizer()); -+ CHECK(!is_active()); - set_state(NEAR_DEATH); - // Check that we are not passing a finalized external string to - // the callback. -@@ -578,17 +593,24 @@ class GlobalHandles::Node final : public NodeBase { - private: - // Fields that are not used for managing node memory. - void ClearImplFields() { -+ set_independent(false); -+ set_active(false); - weak_callback_ = nullptr; - } - - void CheckImplFieldsAreCleared() { -+ DCHECK(!is_independent()); -+ DCHECK(!is_active()); - DCHECK_EQ(nullptr, weak_callback_); - } - - // This stores three flags (independent, partially_dependent and - // in_young_list) and a State. - class NodeState : public BitField8 {}; -- class IsInYoungList : public BitField8 {}; -+ class IsIndependent : public BitField8 {}; -+ // The following two fields are mutually exclusive -+ class IsActive : public BitField8 {}; -+ class IsInYoungList : public BitField8 {}; - class NodeWeaknessType - : public BitField8 {}; - -@@ -851,6 +873,12 @@ void GlobalHandles::IterateWeakRootsIdentifyFinalizers( - - void GlobalHandles::IdentifyWeakUnmodifiedObjects( - WeakSlotCallback is_unmodified) { -+ for (Node* node : young_nodes_) { -+ if (node->IsWeak() && !is_unmodified(node->location())) { -+ node->set_active(true); -+ } -+ } -+ - LocalEmbedderHeapTracer* const tracer = - isolate()->heap()->local_embedder_heap_tracer(); - for (TracedNode* node : traced_young_nodes_) { -@@ -867,7 +895,9 @@ void GlobalHandles::IdentifyWeakUnmodifiedObjects( - - void GlobalHandles::IterateYoungStrongAndDependentRoots(RootVisitor* v) { - for (Node* node : young_nodes_) { -- if (node->IsStrongRetainer()) { -+ if (node->IsStrongRetainer() || -+ (node->IsWeakRetainer() && !node->is_independent() && -+ node->is_active())) { - v->VisitRootPointer(Root::kGlobalHandles, node->label(), - node->location()); - } -@@ -883,7 +913,8 @@ void GlobalHandles::MarkYoungWeakUnmodifiedObjectsPending( - WeakSlotCallbackWithHeap is_dead) { - for (Node* node : young_nodes_) { - DCHECK(node->is_in_young_list()); -- if (node->IsWeak() && is_dead(isolate_->heap(), node->location())) { -+ if ((node->is_independent() || !node->is_active()) && node->IsWeak() && -+ is_dead(isolate_->heap(), node->location())) { - if (!node->IsPhantomCallback() && !node->IsPhantomResetHandle()) { - node->MarkPending(); - } -@@ -895,7 +926,8 @@ void GlobalHandles::IterateYoungWeakUnmodifiedRootsForFinalizers( - RootVisitor* v) { - for (Node* node : young_nodes_) { - DCHECK(node->is_in_young_list()); -- if (node->IsWeakRetainer() && (node->state() == Node::PENDING)) { -+ if ((node->is_independent() || !node->is_active()) && -+ node->IsWeakRetainer() && (node->state() == Node::PENDING)) { - DCHECK(!node->IsPhantomCallback()); - DCHECK(!node->IsPhantomResetHandle()); - // Finalizers need to survive. -@@ -909,7 +941,8 @@ void GlobalHandles::IterateYoungWeakUnmodifiedRootsForPhantomHandles( - RootVisitor* v, WeakSlotCallbackWithHeap should_reset_handle) { - for (Node* node : young_nodes_) { - DCHECK(node->is_in_young_list()); -- if (node->IsWeakRetainer() && (node->state() != Node::PENDING)) { -+ if ((node->is_independent() || !node->is_active()) && -+ node->IsWeakRetainer() && (node->state() != Node::PENDING)) { - if (should_reset_handle(isolate_->heap(), node->location())) { - DCHECK(node->IsPhantomResetHandle() || node->IsPhantomCallback()); - if (node->IsPhantomResetHandle()) { -@@ -975,6 +1008,9 @@ size_t GlobalHandles::PostScavengeProcessing(unsigned post_processing_count) { - // Filter free nodes. - if (!node->IsRetainer()) continue; - -+ // Reset active state for all affected nodes. -+ node->set_active(false); -+ - if (node->IsPending()) { - DCHECK(node->has_callback()); - DCHECK(node->IsPendingFinalizer()); -@@ -993,6 +1029,9 @@ size_t GlobalHandles::PostMarkSweepProcessing(unsigned post_processing_count) { - // Filter free nodes. - if (!node->IsRetainer()) continue; - -+ // Reset active state for all affected nodes. -+ node->set_active(false); -+ - if (node->IsPending()) { - DCHECK(node->has_callback()); - DCHECK(node->IsPendingFinalizer()); -diff --git a/src/profiler/sampling-heap-profiler.cc b/src/profiler/sampling-heap-profiler.cc -index a13dd2916a535aee0b7a95fd89abd2c545eb2f13..659ed25c00d35d69b9353e3dc693f865cbe89715 100644 ---- a/src/profiler/sampling-heap-profiler.cc -+++ b/src/profiler/sampling-heap-profiler.cc -@@ -97,6 +97,16 @@ void SamplingHeapProfiler::SampleObject(Address soon_object, size_t size) { - base::make_unique(size, node, loc, this, next_sample_id()); - sample->global.SetWeak(sample.get(), OnWeakCallback, - WeakCallbackType::kParameter); -+#if __clang__ -+#pragma clang diagnostic push -+#pragma clang diagnostic ignored "-Wdeprecated" -+#endif -+ // MarkIndependent is marked deprecated but we still rely on it here -+ // temporarily. -+ sample->global.MarkIndependent(); -+#if __clang__ -+#pragma clang diagnostic pop -+#endif - samples_.emplace(sample.get(), std::move(sample)); - } - -diff --git a/test/cctest/heap/heap-utils.h b/test/cctest/heap/heap-utils.h -index 082d255a3fdc889ba86d5117bc234f70f0525aad..dbe8e30a495b8af53451f5692810128e8b52453e 100644 ---- a/test/cctest/heap/heap-utils.h -+++ b/test/cctest/heap/heap-utils.h -@@ -12,22 +12,6 @@ namespace v8 { - namespace internal { - namespace heap { - --class TemporaryEmbedderHeapTracerScope { -- public: -- TemporaryEmbedderHeapTracerScope(v8::Isolate* isolate, -- v8::EmbedderHeapTracer* tracer) -- : isolate_(isolate) { -- isolate_->SetEmbedderHeapTracer(tracer); -- } -- -- ~TemporaryEmbedderHeapTracerScope() { -- isolate_->SetEmbedderHeapTracer(nullptr); -- } -- -- private: -- v8::Isolate* const isolate_; --}; -- - void SealCurrentObjects(Heap* heap); - - int FixedArrayLenFromSize(int size); -diff --git a/test/cctest/heap/test-embedder-tracing.cc b/test/cctest/heap/test-embedder-tracing.cc -index 9ca2509e6c0913ad946cf3879d2f5fe69d301075..3d19538a180243cfdfcdfb9a496fa3471e8e9435 100644 ---- a/test/cctest/heap/test-embedder-tracing.cc -+++ b/test/cctest/heap/test-embedder-tracing.cc -@@ -103,6 +103,22 @@ class TestEmbedderHeapTracer final : public v8::EmbedderHeapTracer { - v8::Global array_; - }; - -+class TemporaryEmbedderHeapTracerScope { -+ public: -+ TemporaryEmbedderHeapTracerScope(v8::Isolate* isolate, -+ EmbedderHeapTracer* tracer) -+ : isolate_(isolate) { -+ isolate_->SetEmbedderHeapTracer(tracer); -+ } -+ -+ ~TemporaryEmbedderHeapTracerScope() { -+ isolate_->SetEmbedderHeapTracer(nullptr); -+ } -+ -+ private: -+ v8::Isolate* const isolate_; -+}; -+ - } // namespace - - TEST(V8RegisteringEmbedderReference) { -@@ -112,7 +128,7 @@ TEST(V8RegisteringEmbedderReference) { - CcTest::InitializeVM(); - v8::Isolate* isolate = CcTest::isolate(); - TestEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - v8::HandleScope scope(isolate); - v8::Local context = v8::Context::New(isolate); - v8::Context::Scope context_scope(context); -@@ -132,7 +148,7 @@ TEST(EmbedderRegisteringV8Reference) { - CcTest::InitializeVM(); - v8::Isolate* isolate = CcTest::isolate(); - TestEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - v8::HandleScope scope(isolate); - v8::Local context = v8::Context::New(isolate); - v8::Context::Scope context_scope(context); -@@ -165,7 +181,7 @@ TEST(TracingInRevivedSubgraph) { - CcTest::InitializeVM(); - v8::Isolate* isolate = CcTest::isolate(); - TestEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - v8::HandleScope scope(isolate); - v8::Local context = v8::Context::New(isolate); - v8::Context::Scope context_scope(context); -@@ -193,7 +209,7 @@ TEST(TracingInEphemerons) { - CcTest::InitializeVM(); - v8::Isolate* isolate = CcTest::isolate(); - TestEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - v8::HandleScope scope(isolate); - v8::Local context = v8::Context::New(isolate); - v8::Context::Scope context_scope(context); -@@ -224,7 +240,7 @@ TEST(FinalizeTracingIsNoopWhenNotMarking) { - v8::Isolate* isolate = CcTest::isolate(); - Isolate* i_isolate = CcTest::i_isolate(); - TestEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - - // Finalize a potentially running garbage collection. - i_isolate->heap()->CollectGarbage(OLD_SPACE, -@@ -243,7 +259,7 @@ TEST(FinalizeTracingWhenMarking) { - v8::Isolate* isolate = CcTest::isolate(); - Isolate* i_isolate = CcTest::i_isolate(); - TestEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - - // Finalize a potentially running garbage collection. - i_isolate->heap()->CollectGarbage(OLD_SPACE, -@@ -268,7 +284,7 @@ TEST(GarbageCollectionForTesting) { - v8::Isolate* isolate = CcTest::isolate(); - Isolate* i_isolate = CcTest::i_isolate(); - TestEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - - int saved_gc_counter = i_isolate->heap()->gc_count(); - tracer.GarbageCollectionForTesting(EmbedderHeapTracer::kUnknown); -@@ -398,7 +414,7 @@ TEST(TracedGlobalToUnmodifiedJSObjectSurvivesScavengeWhenExcludedFromRoots) { - CcTest::InitializeVM(); - v8::Isolate* isolate = CcTest::isolate(); - TestEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - tracer.ConsiderTracedGlobalAsRoot(false); - TracedGlobalTest( - CcTest::isolate(), ConstructJSObject, -@@ -411,7 +427,7 @@ TEST(TracedGlobalToUnmodifiedJSApiObjectSurvivesScavengePerDefault) { - CcTest::InitializeVM(); - v8::Isolate* isolate = CcTest::isolate(); - TestEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - tracer.ConsiderTracedGlobalAsRoot(true); - TracedGlobalTest( - CcTest::isolate(), ConstructJSApiObject, -@@ -424,7 +440,7 @@ TEST(TracedGlobalToUnmodifiedJSApiObjectDiesOnScavengeWhenExcludedFromRoots) { - CcTest::InitializeVM(); - v8::Isolate* isolate = CcTest::isolate(); - TestEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - tracer.ConsiderTracedGlobalAsRoot(false); - TracedGlobalTest( - CcTest::isolate(), ConstructJSApiObject, -@@ -438,7 +454,7 @@ TEST(TracedGlobalWrapperClassId) { - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope scope(isolate); - TestEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - - v8::TracedGlobal traced; - ConstructJSObject(isolate, isolate->GetCurrentContext(), &traced); -@@ -473,7 +489,7 @@ TEST(TracedGlobalIteration) { - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope scope(isolate); - TestEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - - v8::TracedGlobal traced; - ConstructJSObject(isolate, isolate->GetCurrentContext(), &traced); -@@ -506,7 +522,7 @@ TEST(TracedGlobalSetFinalizationCallbackScavenge) { - v8::HandleScope scope(isolate); - TestEmbedderHeapTracer tracer; - tracer.ConsiderTracedGlobalAsRoot(false); -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - - v8::TracedGlobal traced; - ConstructJSApiObject(isolate, isolate->GetCurrentContext(), &traced); -@@ -528,7 +544,7 @@ TEST(TracedGlobalSetFinalizationCallbackMarkSweep) { - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope scope(isolate); - TestEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - - v8::TracedGlobal traced; - ConstructJSApiObject(isolate, isolate->GetCurrentContext(), &traced); -@@ -558,7 +574,7 @@ TEST(TracePrologueCallingIntoV8WriteBarrier) { - } - TestEmbedderHeapTracer tracer(TracePrologueBehavior::kCallV8WriteBarrier, - std::move(global)); -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -+ TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); - SimulateIncrementalMarking(CcTest::i_isolate()->heap()); - } - -diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc -index 770452bacd8bbfae833439f68efc518056d97ead..4c791d128e6126ea67c3240ee48ac689a55fd29a 100644 ---- a/test/cctest/heap/test-heap.cc -+++ b/test/cctest/heap/test-heap.cc -@@ -497,6 +497,44 @@ static void TestWeakGlobalHandleCallback( - p->first->Reset(); - } - -+ -+TEST(WeakGlobalHandlesScavenge) { -+ FLAG_stress_compaction = false; -+ FLAG_stress_incremental_marking = false; -+ CcTest::InitializeVM(); -+ Isolate* isolate = CcTest::i_isolate(); -+ Factory* factory = isolate->factory(); -+ GlobalHandles* global_handles = isolate->global_handles(); -+ -+ WeakPointerCleared = false; -+ -+ Handle h1; -+ Handle h2; -+ -+ { -+ HandleScope scope(isolate); -+ -+ Handle i = factory->NewStringFromStaticChars("fisk"); -+ Handle u = factory->NewNumber(1.12344); -+ -+ h1 = global_handles->Create(*i); -+ h2 = global_handles->Create(*u); -+ } -+ -+ std::pair*, int> handle_and_id(&h2, 1234); -+ GlobalHandles::MakeWeak( -+ h2.location(), reinterpret_cast(&handle_and_id), -+ &TestWeakGlobalHandleCallback, v8::WeakCallbackType::kParameter); -+ -+ // Scavenge treats weak pointers as normal roots. -+ CcTest::CollectGarbage(NEW_SPACE); -+ CHECK((*h1)->IsString()); -+ CHECK((*h2)->IsHeapNumber()); -+ CHECK(!WeakPointerCleared); -+ GlobalHandles::Destroy(h1.location()); -+ GlobalHandles::Destroy(h2.location()); -+} -+ - TEST(WeakGlobalUnmodifiedApiHandlesScavenge) { - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); -@@ -535,6 +573,84 @@ TEST(WeakGlobalUnmodifiedApiHandlesScavenge) { - GlobalHandles::Destroy(h1.location()); - } - -+TEST(WeakGlobalApiHandleModifiedMapScavenge) { -+ CcTest::InitializeVM(); -+ Isolate* isolate = CcTest::i_isolate(); -+ LocalContext context; -+ GlobalHandles* global_handles = isolate->global_handles(); -+ -+ WeakPointerCleared = false; -+ -+ Handle h1; -+ -+ { -+ HandleScope scope(isolate); -+ -+ // Create an API object which does not have the same map as constructor. -+ auto function_template = FunctionTemplate::New(context->GetIsolate()); -+ auto instance_t = function_template->InstanceTemplate(); -+ instance_t->Set(v8::String::NewFromUtf8(context->GetIsolate(), "a", -+ NewStringType::kNormal) -+ .ToLocalChecked(), -+ v8::Number::New(context->GetIsolate(), 10)); -+ auto function = -+ function_template->GetFunction(context.local()).ToLocalChecked(); -+ auto i = function->NewInstance(context.local()).ToLocalChecked(); -+ -+ h1 = global_handles->Create(*(reinterpret_cast(*i))); -+ } -+ -+ std::pair*, int> handle_and_id(&h1, 1234); -+ GlobalHandles::MakeWeak( -+ h1.location(), reinterpret_cast(&handle_and_id), -+ &TestWeakGlobalHandleCallback, v8::WeakCallbackType::kParameter); -+ -+ CcTest::CollectGarbage(NEW_SPACE); -+ CHECK(!WeakPointerCleared); -+ GlobalHandles::Destroy(h1.location()); -+} -+ -+TEST(WeakGlobalApiHandleWithElementsScavenge) { -+ CcTest::InitializeVM(); -+ Isolate* isolate = CcTest::i_isolate(); -+ LocalContext context; -+ GlobalHandles* global_handles = isolate->global_handles(); -+ -+ WeakPointerCleared = false; -+ -+ Handle h1; -+ -+ { -+ HandleScope scope(isolate); -+ -+ // Create an API object which has elements. -+ auto function_template = FunctionTemplate::New(context->GetIsolate()); -+ auto instance_t = function_template->InstanceTemplate(); -+ instance_t->Set(v8::String::NewFromUtf8(context->GetIsolate(), "1", -+ NewStringType::kNormal) -+ .ToLocalChecked(), -+ v8::Number::New(context->GetIsolate(), 10)); -+ instance_t->Set(v8::String::NewFromUtf8(context->GetIsolate(), "2", -+ NewStringType::kNormal) -+ .ToLocalChecked(), -+ v8::Number::New(context->GetIsolate(), 10)); -+ auto function = -+ function_template->GetFunction(context.local()).ToLocalChecked(); -+ auto i = function->NewInstance(context.local()).ToLocalChecked(); -+ -+ h1 = global_handles->Create(*(reinterpret_cast(*i))); -+ } -+ -+ std::pair*, int> handle_and_id(&h1, 1234); -+ GlobalHandles::MakeWeak( -+ h1.location(), reinterpret_cast(&handle_and_id), -+ &TestWeakGlobalHandleCallback, v8::WeakCallbackType::kParameter); -+ -+ CcTest::CollectGarbage(NEW_SPACE); -+ CHECK(!WeakPointerCleared); -+ GlobalHandles::Destroy(h1.location()); -+} -+ - TEST(WeakGlobalHandlesMark) { - FLAG_stress_incremental_marking = false; - CcTest::InitializeVM(); -@@ -584,7 +700,9 @@ TEST(DeleteWeakGlobalHandle) { - GlobalHandles* global_handles = isolate->global_handles(); - - WeakPointerCleared = false; -+ - Handle h; -+ - { - HandleScope scope(isolate); - -@@ -596,8 +714,15 @@ TEST(DeleteWeakGlobalHandle) { - GlobalHandles::MakeWeak(h.location(), reinterpret_cast(&handle_and_id), - &TestWeakGlobalHandleCallback, - v8::WeakCallbackType::kParameter); -+ -+ // Scanvenge does not recognize weak reference. -+ CcTest::CollectGarbage(NEW_SPACE); -+ - CHECK(!WeakPointerCleared); -+ -+ // Mark-compact treats weak reference properly. - CcTest::CollectGarbage(OLD_SPACE); -+ - CHECK(WeakPointerCleared); - } - -diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc -index e3f036ee9028513924846295239d76859909f454..2e097336572cbd82e6d9dba69c8388904f8ecaee 100644 ---- a/test/cctest/test-api.cc -+++ b/test/cctest/test-api.cc -@@ -7956,6 +7956,18 @@ static void IndependentWeakHandle(bool global_gc, bool interlinked) { - v8::WeakCallbackType::kParameter); - object_b.handle.SetWeak(&object_b, &SetFlag, - v8::WeakCallbackType::kParameter); -+#if __clang__ -+#pragma clang diagnostic push -+#pragma clang diagnostic ignored "-Wdeprecated" -+#endif -+ // MarkIndependent is marked deprecated but we still rely on it temporarily. -+ CHECK(!object_b.handle.IsIndependent()); -+ object_a.handle.MarkIndependent(); -+ object_b.handle.MarkIndependent(); -+ CHECK(object_b.handle.IsIndependent()); -+#if __clang__ -+#pragma clang diagnostic pop -+#endif - if (global_gc) { - CcTest::CollectAllGarbage(); - } else { -@@ -8106,6 +8118,19 @@ void v8::internal::heap::HeapTester::ResetWeakHandle(bool global_gc) { - v8::WeakCallbackType::kParameter); - object_b.handle.SetWeak(&object_b, &ResetUseValueAndSetFlag, - v8::WeakCallbackType::kParameter); -+ if (!global_gc) { -+#if __clang__ -+#pragma clang diagnostic push -+#pragma clang diagnostic ignored "-Wdeprecated" -+#endif -+ // MarkIndependent is marked deprecated but we still rely on it temporarily. -+ object_a.handle.MarkIndependent(); -+ object_b.handle.MarkIndependent(); -+ CHECK(object_b.handle.IsIndependent()); -+#if __clang__ -+#pragma clang diagnostic pop -+#endif -+ } - if (global_gc) { - CcTest::PreciseCollectAllGarbage(); - } else { -@@ -8173,6 +8198,16 @@ THREADED_TEST(GCFromWeakCallbacks) { - object.flag = false; - object.handle.SetWeak(&object, gc_forcing_callback[inner_gc], - v8::WeakCallbackType::kParameter); -+#if __clang__ -+#pragma clang diagnostic push -+#pragma clang diagnostic ignored "-Wdeprecated" -+#endif -+ // MarkIndependent is marked deprecated but we still rely on it -+ // temporarily. -+ object.handle.MarkIndependent(); -+#if __clang__ -+#pragma clang diagnostic pop -+#endif - invoke_gc[outer_gc](); - EmptyMessageQueues(isolate); - CHECK(object.flag); -diff --git a/test/cctest/test-global-handles.cc b/test/cctest/test-global-handles.cc -index 75ad7035f15e03f9b8b19917998e21bfea560440..2c620b4963623e4ae4c589832963dbd03cb36296 100644 ---- a/test/cctest/test-global-handles.cc -+++ b/test/cctest/test-global-handles.cc -@@ -39,25 +39,6 @@ namespace internal { - - namespace { - --// Empty v8::EmbedderHeapTracer that never keeps objects alive on Scavenge. See --// |IsRootForNonTracingGC|. --class NonRootingEmbedderHeapTracer final : public v8::EmbedderHeapTracer { -- public: -- NonRootingEmbedderHeapTracer() = default; -- -- void RegisterV8References( -- const std::vector>& embedder_fields) final {} -- bool AdvanceTracing(double deadline_in_ms) final { return true; } -- bool IsTracingDone() final { return true; } -- void TracePrologue() final {} -- void TraceEpilogue() final {} -- void EnterFinalPause(EmbedderStackState) final {} -- -- bool IsRootForNonTracingGC(const v8::TracedGlobal& handle) final { -- return false; -- } --}; -- - void InvokeScavenge() { CcTest::CollectGarbage(i::NEW_SPACE); } - - void InvokeMarkSweep() { CcTest::CollectAllGarbage(); } -@@ -66,23 +47,23 @@ void SimpleCallback(const v8::FunctionCallbackInfo& info) { - info.GetReturnValue().Set(v8_num(0)); - } - --struct FlagAndGlobal { -+struct FlagAndPersistent { - bool flag; - v8::Global handle; - }; - --struct TracedGlobalWrapper { -- v8::TracedGlobal handle; --}; -- --void ResetHandleAndSetFlag(const v8::WeakCallbackInfo& data) { -+void ResetHandleAndSetFlag( -+ const v8::WeakCallbackInfo& data) { - data.GetParameter()->handle.Reset(); - data.GetParameter()->flag = true; - } - --template -+using ConstructFunction = void (*)(v8::Isolate* isolate, -+ v8::Local context, -+ FlagAndPersistent* flag_and_persistent); -+ - void ConstructJSObject(v8::Isolate* isolate, v8::Local context, -- HandleContainer* flag_and_persistent) { -+ FlagAndPersistent* flag_and_persistent) { - v8::HandleScope handle_scope(isolate); - v8::Local object(v8::Object::New(isolate)); - CHECK(!object.IsEmpty()); -@@ -98,9 +79,8 @@ void ConstructJSObject(v8::Isolate* isolate, v8::Global* global) { - CHECK(!global->IsEmpty()); - } - --template - void ConstructJSApiObject(v8::Isolate* isolate, v8::Local context, -- HandleContainer* flag_and_persistent) { -+ FlagAndPersistent* flag_and_persistent) { - v8::HandleScope handle_scope(isolate); - v8::Local fun = - v8::FunctionTemplate::New(isolate, SimpleCallback); -@@ -115,8 +95,7 @@ void ConstructJSApiObject(v8::Isolate* isolate, v8::Local context, - - enum class SurvivalMode { kSurvives, kDies }; - --template -+template - void WeakHandleTest(v8::Isolate* isolate, ConstructFunction construct_function, - ModifierFunction modifier_function, GCFunction gc_function, - SurvivalMode survives) { -@@ -124,7 +103,7 @@ void WeakHandleTest(v8::Isolate* isolate, ConstructFunction construct_function, - v8::Local context = v8::Context::New(isolate); - v8::Context::Scope context_scope(context); - -- FlagAndGlobal fp; -+ FlagAndPersistent fp; - construct_function(isolate, context, &fp); - CHECK(heap::InYoungGeneration(isolate, fp.handle)); - fp.handle.SetWeak(&fp, &ResetHandleAndSetFlag, -@@ -136,28 +115,6 @@ void WeakHandleTest(v8::Isolate* isolate, ConstructFunction construct_function, - CHECK_IMPLIES(survives == SurvivalMode::kDies, fp.flag); - } - --template --void TracedGlobalTest(v8::Isolate* isolate, -- ConstructFunction construct_function, -- ModifierFunction modifier_function, -- GCFunction gc_function, SurvivalMode survives) { -- v8::HandleScope scope(isolate); -- v8::Local context = v8::Context::New(isolate); -- v8::Context::Scope context_scope(context); -- -- NonRootingEmbedderHeapTracer tracer; -- heap::TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); -- -- TracedGlobalWrapper fp; -- construct_function(isolate, context, &fp); -- CHECK(heap::InYoungGeneration(isolate, fp.handle)); -- modifier_function(&fp); -- gc_function(); -- CHECK_IMPLIES(survives == SurvivalMode::kSurvives, !fp.handle.IsEmpty()); -- CHECK_IMPLIES(survives == SurvivalMode::kDies, fp.handle.IsEmpty()); --} -- - void ResurrectingFinalizer( - const v8::WeakCallbackInfo>& data) { - data.GetParameter()->ClearWeak(); -@@ -320,36 +277,25 @@ TEST(PhatomHandlesWithoutCallbacks) { - CHECK_EQ(0u, isolate->NumberOfPhantomHandleResetsSinceLastCall()); - } - --TEST(WeakHandleToUnmodifiedJSObjectDiesOnScavenge) { -+TEST(WeakHandleToUnmodifiedJSObjectSurvivesScavenge) { - CcTest::InitializeVM(); - WeakHandleTest( -- CcTest::isolate(), &ConstructJSObject, -- [](FlagAndGlobal* fp) {}, []() { InvokeScavenge(); }, -- SurvivalMode::kDies); --} -- --TEST(TracedGlobalToUnmodifiedJSObjectSurvivesScavenge) { -- ManualGCScope manual_gc; -- CcTest::InitializeVM(); -- TracedGlobalTest( -- CcTest::isolate(), &ConstructJSObject, -- [](TracedGlobalWrapper* fp) {}, []() { InvokeScavenge(); }, -- SurvivalMode::kSurvives); -+ CcTest::isolate(), &ConstructJSObject, [](FlagAndPersistent* fp) {}, -+ []() { InvokeScavenge(); }, SurvivalMode::kSurvives); - } - - TEST(WeakHandleToUnmodifiedJSObjectDiesOnMarkCompact) { - CcTest::InitializeVM(); - WeakHandleTest( -- CcTest::isolate(), &ConstructJSObject, -- [](FlagAndGlobal* fp) {}, []() { InvokeMarkSweep(); }, -- SurvivalMode::kDies); -+ CcTest::isolate(), &ConstructJSObject, [](FlagAndPersistent* fp) {}, -+ []() { InvokeMarkSweep(); }, SurvivalMode::kDies); - } - - TEST(WeakHandleToUnmodifiedJSObjectSurvivesMarkCompactWhenInHandle) { - CcTest::InitializeVM(); - WeakHandleTest( -- CcTest::isolate(), &ConstructJSObject, -- [](FlagAndGlobal* fp) { -+ CcTest::isolate(), &ConstructJSObject, -+ [](FlagAndPersistent* fp) { - v8::Local handle = - v8::Local::New(CcTest::isolate(), fp->handle); - USE(handle); -@@ -360,30 +306,19 @@ TEST(WeakHandleToUnmodifiedJSObjectSurvivesMarkCompactWhenInHandle) { - TEST(WeakHandleToUnmodifiedJSApiObjectDiesOnScavenge) { - CcTest::InitializeVM(); - WeakHandleTest( -- CcTest::isolate(), &ConstructJSApiObject, -- [](FlagAndGlobal* fp) {}, []() { InvokeScavenge(); }, -- SurvivalMode::kDies); --} -- --TEST(TracedGlobalToUnmodifiedJSApiObjectDiesOnScavenge) { -- ManualGCScope manual_gc; -- CcTest::InitializeVM(); -- TracedGlobalTest( -- CcTest::isolate(), &ConstructJSApiObject, -- [](TracedGlobalWrapper* fp) {}, []() { InvokeScavenge(); }, -- SurvivalMode::kDies); -+ CcTest::isolate(), &ConstructJSApiObject, [](FlagAndPersistent* fp) {}, -+ []() { InvokeScavenge(); }, SurvivalMode::kDies); - } - --TEST(TracedGlobalToJSApiObjectWithIdentityHashSurvivesScavenge) { -- ManualGCScope manual_gc; -+TEST(WeakHandleToJSApiObjectWithIdentityHashSurvivesScavenge) { - CcTest::InitializeVM(); - Isolate* i_isolate = CcTest::i_isolate(); - HandleScope scope(i_isolate); - Handle weakmap = i_isolate->factory()->NewJSWeakMap(); - -- TracedGlobalTest( -- CcTest::isolate(), &ConstructJSApiObject, -- [&weakmap, i_isolate](TracedGlobalWrapper* fp) { -+ WeakHandleTest( -+ CcTest::isolate(), &ConstructJSApiObject, -+ [&weakmap, i_isolate](FlagAndPersistent* fp) { - v8::HandleScope scope(CcTest::isolate()); - Handle key = - Utils::OpenHandle(*fp->handle.Get(CcTest::isolate())); -@@ -397,8 +332,8 @@ TEST(TracedGlobalToJSApiObjectWithIdentityHashSurvivesScavenge) { - TEST(WeakHandleToUnmodifiedJSApiObjectSurvivesScavengeWhenInHandle) { - CcTest::InitializeVM(); - WeakHandleTest( -- CcTest::isolate(), &ConstructJSApiObject, -- [](FlagAndGlobal* fp) { -+ CcTest::isolate(), &ConstructJSApiObject, -+ [](FlagAndPersistent* fp) { - v8::Local handle = - v8::Local::New(CcTest::isolate(), fp->handle); - USE(handle); -@@ -409,16 +344,15 @@ TEST(WeakHandleToUnmodifiedJSApiObjectSurvivesScavengeWhenInHandle) { - TEST(WeakHandleToUnmodifiedJSApiObjectDiesOnMarkCompact) { - CcTest::InitializeVM(); - WeakHandleTest( -- CcTest::isolate(), &ConstructJSApiObject, -- [](FlagAndGlobal* fp) {}, []() { InvokeMarkSweep(); }, -- SurvivalMode::kDies); -+ CcTest::isolate(), &ConstructJSApiObject, [](FlagAndPersistent* fp) {}, -+ []() { InvokeMarkSweep(); }, SurvivalMode::kDies); - } - - TEST(WeakHandleToUnmodifiedJSApiObjectSurvivesMarkCompactWhenInHandle) { - CcTest::InitializeVM(); - WeakHandleTest( -- CcTest::isolate(), &ConstructJSApiObject, -- [](FlagAndGlobal* fp) { -+ CcTest::isolate(), &ConstructJSApiObject, -+ [](FlagAndPersistent* fp) { - v8::Local handle = - v8::Local::New(CcTest::isolate(), fp->handle); - USE(handle); -@@ -426,57 +360,58 @@ TEST(WeakHandleToUnmodifiedJSApiObjectSurvivesMarkCompactWhenInHandle) { - []() { InvokeMarkSweep(); }, SurvivalMode::kSurvives); - } - --TEST(TracedGlobalToJSApiObjectWithModifiedMapSurvivesScavenge) { -+TEST(WeakHandleToActiveUnmodifiedJSApiObjectSurvivesScavenge) { - CcTest::InitializeVM(); -- v8::Isolate* isolate = CcTest::isolate(); -- LocalContext context; -- -- TracedGlobal handle; -- { -- v8::HandleScope scope(isolate); -- // Create an API object which does not have the same map as constructor. -- auto function_template = FunctionTemplate::New(isolate); -- auto instance_t = function_template->InstanceTemplate(); -- instance_t->Set( -- v8::String::NewFromUtf8(isolate, "a", NewStringType::kNormal) -- .ToLocalChecked(), -- v8::Number::New(isolate, 10)); -- auto function = -- function_template->GetFunction(context.local()).ToLocalChecked(); -- auto i = function->NewInstance(context.local()).ToLocalChecked(); -- handle.Reset(isolate, i); -- } -- InvokeScavenge(); -- CHECK(!handle.IsEmpty()); -+ WeakHandleTest( -+ CcTest::isolate(), &ConstructJSApiObject, -+ [](FlagAndPersistent* fp) { -+#if __clang__ -+#pragma clang diagnostic push -+#pragma clang diagnostic ignored "-Wdeprecated" -+#endif -+ fp->handle.MarkActive(); -+#if __clang__ -+#pragma clang diagnostic pop -+#endif -+ }, -+ []() { InvokeScavenge(); }, SurvivalMode::kSurvives); - } - --TEST(TracedGlobalTOJsApiObjectWithElementsSurvivesScavenge) { -+TEST(WeakHandleToActiveUnmodifiedJSApiObjectDiesOnMarkCompact) { - CcTest::InitializeVM(); -- v8::Isolate* isolate = CcTest::isolate(); -- LocalContext context; -- -- TracedGlobal handle; -- { -- v8::HandleScope scope(isolate); -+ WeakHandleTest( -+ CcTest::isolate(), &ConstructJSApiObject, -+ [](FlagAndPersistent* fp) { -+#if __clang__ -+#pragma clang diagnostic push -+#pragma clang diagnostic ignored "-Wdeprecated" -+#endif -+ fp->handle.MarkActive(); -+#if __clang__ -+#pragma clang diagnostic pop -+#endif -+ }, -+ []() { InvokeMarkSweep(); }, SurvivalMode::kDies); -+} - -- // Create an API object which has elements. -- auto function_template = FunctionTemplate::New(isolate); -- auto instance_t = function_template->InstanceTemplate(); -- instance_t->Set( -- v8::String::NewFromUtf8(isolate, "1", NewStringType::kNormal) -- .ToLocalChecked(), -- v8::Number::New(isolate, 10)); -- instance_t->Set( -- v8::String::NewFromUtf8(isolate, "2", NewStringType::kNormal) -- .ToLocalChecked(), -- v8::Number::New(isolate, 10)); -- auto function = -- function_template->GetFunction(context.local()).ToLocalChecked(); -- auto i = function->NewInstance(context.local()).ToLocalChecked(); -- handle.Reset(isolate, i); -- } -- InvokeScavenge(); -- CHECK(!handle.IsEmpty()); -+TEST(WeakHandleToActiveUnmodifiedJSApiObjectSurvivesMarkCompactWhenInHandle) { -+ CcTest::InitializeVM(); -+ WeakHandleTest( -+ CcTest::isolate(), &ConstructJSApiObject, -+ [](FlagAndPersistent* fp) { -+#if __clang__ -+#pragma clang diagnostic push -+#pragma clang diagnostic ignored "-Wdeprecated" -+#endif -+ fp->handle.MarkActive(); -+#if __clang__ -+#pragma clang diagnostic pop -+#endif -+ v8::Local handle = -+ v8::Local::New(CcTest::isolate(), fp->handle); -+ USE(handle); -+ }, -+ []() { InvokeMarkSweep(); }, SurvivalMode::kSurvives); - } - - TEST(FinalizerOnUnmodifiedJSApiObjectDoesNotCrash) { -@@ -487,7 +422,8 @@ TEST(FinalizerOnUnmodifiedJSApiObjectDoesNotCrash) { - v8::Local context = v8::Context::New(isolate); - v8::Context::Scope context_scope(context); - -- FlagAndGlobal fp; -+ FlagAndPersistent fp; -+ // Could use a regular object and MarkIndependent too. - ConstructJSApiObject(isolate, context, &fp); - fp.handle.SetWeak(&fp, &ResetHandleAndSetFlag, - v8::WeakCallbackType::kFinalizer); -@@ -559,22 +495,22 @@ TEST(FinalizerDiesAndKeepsPhantomAliveOnMarkCompact) { - - namespace { - --void ForceScavenge2(const v8::WeakCallbackInfo& data) { -+void ForceScavenge2(const v8::WeakCallbackInfo& data) { - data.GetParameter()->flag = true; - InvokeScavenge(); - } - --void ForceScavenge1(const v8::WeakCallbackInfo& data) { -+void ForceScavenge1(const v8::WeakCallbackInfo& data) { - data.GetParameter()->handle.Reset(); - data.SetSecondPassCallback(ForceScavenge2); - } - --void ForceMarkSweep2(const v8::WeakCallbackInfo& data) { -+void ForceMarkSweep2(const v8::WeakCallbackInfo& data) { - data.GetParameter()->flag = true; - InvokeMarkSweep(); - } - --void ForceMarkSweep1(const v8::WeakCallbackInfo& data) { -+void ForceMarkSweep1(const v8::WeakCallbackInfo& data) { - data.GetParameter()->handle.Reset(); - data.SetSecondPassCallback(ForceMarkSweep2); - } -@@ -589,7 +525,7 @@ TEST(GCFromWeakCallbacks) { - v8::Context::Scope context_scope(context); - - static const int kNumberOfGCTypes = 2; -- typedef v8::WeakCallbackInfo::Callback Callback; -+ typedef v8::WeakCallbackInfo::Callback Callback; - Callback gc_forcing_callback[kNumberOfGCTypes] = {&ForceScavenge1, - &ForceMarkSweep1}; - -@@ -598,7 +534,7 @@ TEST(GCFromWeakCallbacks) { - - for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) { - for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) { -- FlagAndGlobal fp; -+ FlagAndPersistent fp; - ConstructJSApiObject(isolate, context, &fp); - CHECK(heap::InYoungGeneration(isolate, fp.handle)); - fp.flag = false; -@@ -613,11 +549,11 @@ TEST(GCFromWeakCallbacks) { - - namespace { - --void SecondPassCallback(const v8::WeakCallbackInfo& data) { -+void SecondPassCallback(const v8::WeakCallbackInfo& data) { - data.GetParameter()->flag = true; - } - --void FirstPassCallback(const v8::WeakCallbackInfo& data) { -+void FirstPassCallback(const v8::WeakCallbackInfo& data) { - data.GetParameter()->handle.Reset(); - data.SetSecondPassCallback(SecondPassCallback); - } -@@ -630,7 +566,7 @@ TEST(SecondPassPhantomCallbacks) { - v8::HandleScope scope(isolate); - v8::Local context = v8::Context::New(isolate); - v8::Context::Scope context_scope(context); -- FlagAndGlobal fp; -+ FlagAndPersistent fp; - ConstructJSApiObject(isolate, context, &fp); - fp.flag = false; - fp.handle.SetWeak(&fp, FirstPassCallback, v8::WeakCallbackType::kParameter); diff --git a/patches/common/v8/workaround_an_undefined_symbol_error.patch b/patches/common/v8/workaround_an_undefined_symbol_error.patch index 43ad5010e528..7f8aa5d98502 100644 --- a/patches/common/v8/workaround_an_undefined_symbol_error.patch +++ b/patches/common/v8/workaround_an_undefined_symbol_error.patch @@ -12,7 +12,7 @@ By moving some functions out of the the arm64-assembler header file, this error no longer seems to happen. diff --git a/src/arm64/assembler-arm64.cc b/src/arm64/assembler-arm64.cc -index 5fd50f3643e8999423a77062ef353cd4eeeff0fd..ea907a59f7ad0c73287698a0600ce11a3629dafd 100644 +index eaafa2375b2746fb7a9f63a1fc6703660b2b123c..fa83830f21b068ff79872e5d9eb6031bffd84028 100644 --- a/src/arm64/assembler-arm64.cc +++ b/src/arm64/assembler-arm64.cc @@ -4013,6 +4013,22 @@ void Assembler::MoveWide(const Register& rd, uint64_t imm, int shift, @@ -39,10 +39,10 @@ index 5fd50f3643e8999423a77062ef353cd4eeeff0fd..ea907a59f7ad0c73287698a0600ce11a const Operand& operand, FlagsUpdate S, AddSubOp op) { DCHECK_EQ(rd.SizeInBits(), rn.SizeInBits()); diff --git a/src/arm64/assembler-arm64.h b/src/arm64/assembler-arm64.h -index 586eff1241fed0a5f6a6fbc9b858981058a75feb..30b8586f69c51c4a6bad82faf4e02f823838f15b 100644 +index 8614975a1dbe54fe655f5e050742ccc76faa21da..1e0379b851a062c580cb5884176c3d4833ae5ea8 100644 --- a/src/arm64/assembler-arm64.h +++ b/src/arm64/assembler-arm64.h -@@ -2232,11 +2232,7 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { +@@ -2234,11 +2234,7 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { return rm.code() << Rm_offset; } @@ -55,7 +55,7 @@ index 586eff1241fed0a5f6a6fbc9b858981058a75feb..30b8586f69c51c4a6bad82faf4e02f82 static Instr Ra(CPURegister ra) { DCHECK_NE(ra.code(), kSPRegInternalCode); -@@ -2260,15 +2256,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { +@@ -2262,15 +2258,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { // These encoding functions allow the stack pointer to be encoded, and // disallow the zero register.