Commit b4f0e76e authored by Shu-yu Guo's avatar Shu-yu Guo Committed by Commit Bot

[weakrefs] Torqueify JSFinalizationRegistry flags

Bug: v8:8179
Change-Id: Ic8ae1fcbfaf7d71a4f9924266670fbf1c24cd63e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2129246Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66995}
parent 4a2ef63c
...@@ -36,7 +36,7 @@ BUILTIN(FinalizationRegistryConstructor) { ...@@ -36,7 +36,7 @@ BUILTIN(FinalizationRegistryConstructor) {
finalization_registry->set_native_context(*isolate->native_context()); finalization_registry->set_native_context(*isolate->native_context());
finalization_registry->set_cleanup(*cleanup); finalization_registry->set_cleanup(*cleanup);
finalization_registry->set_flags( finalization_registry->set_flags(
JSFinalizationRegistry::ScheduledForCleanupField::encode(false)); JSFinalizationRegistry::ScheduledForCleanupBit::encode(false));
DCHECK(finalization_registry->active_cells().IsUndefined(isolate)); DCHECK(finalization_registry->active_cells().IsUndefined(isolate));
DCHECK(finalization_registry->cleared_cells().IsUndefined(isolate)); DCHECK(finalization_registry->cleared_cells().IsUndefined(isolate));
......
...@@ -33,6 +33,9 @@ SMI_ACCESSORS(JSFinalizationRegistry, flags, kFlagsOffset) ...@@ -33,6 +33,9 @@ SMI_ACCESSORS(JSFinalizationRegistry, flags, kFlagsOffset)
ACCESSORS(JSFinalizationRegistry, next_dirty, Object, kNextDirtyOffset) ACCESSORS(JSFinalizationRegistry, next_dirty, Object, kNextDirtyOffset)
CAST_ACCESSOR(JSFinalizationRegistry) CAST_ACCESSOR(JSFinalizationRegistry)
BIT_FIELD_ACCESSORS(JSFinalizationRegistry, flags, scheduled_for_cleanup,
JSFinalizationRegistry::ScheduledForCleanupBit)
void JSFinalizationRegistry::Register( void JSFinalizationRegistry::Register(
Handle<JSFinalizationRegistry> finalization_registry, Handle<JSFinalizationRegistry> finalization_registry,
Handle<JSReceiver> target, Handle<Object> holdings, Handle<JSReceiver> target, Handle<Object> holdings,
...@@ -175,15 +178,6 @@ bool JSFinalizationRegistry::NeedsCleanup() const { ...@@ -175,15 +178,6 @@ bool JSFinalizationRegistry::NeedsCleanup() const {
return cleared_cells().IsWeakCell(); return cleared_cells().IsWeakCell();
} }
bool JSFinalizationRegistry::scheduled_for_cleanup() const {
return ScheduledForCleanupField::decode(flags());
}
void JSFinalizationRegistry::set_scheduled_for_cleanup(
bool scheduled_for_cleanup) {
set_flags(ScheduledForCleanupField::update(flags(), scheduled_for_cleanup));
}
Object JSFinalizationRegistry::PopClearedCellHoldings( Object JSFinalizationRegistry::PopClearedCellHoldings(
Handle<JSFinalizationRegistry> finalization_registry, Isolate* isolate) { Handle<JSFinalizationRegistry> finalization_registry, Isolate* isolate) {
Handle<WeakCell> weak_cell = Handle<WeakCell> weak_cell =
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define V8_OBJECTS_JS_WEAK_REFS_H_ #define V8_OBJECTS_JS_WEAK_REFS_H_
#include "src/objects/js-objects.h" #include "src/objects/js-objects.h"
#include "torque-generated/bit-fields-tq.h"
// Has to be the last include (doesn't have include guards): // Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h" #include "src/objects/object-macros.h"
...@@ -35,6 +36,8 @@ class JSFinalizationRegistry : public JSObject { ...@@ -35,6 +36,8 @@ class JSFinalizationRegistry : public JSObject {
DECL_INT_ACCESSORS(flags) DECL_INT_ACCESSORS(flags)
DECL_BOOLEAN_ACCESSORS(scheduled_for_cleanup)
class BodyDescriptor; class BodyDescriptor;
inline static void Register( inline static void Register(
...@@ -58,9 +61,6 @@ class JSFinalizationRegistry : public JSObject { ...@@ -58,9 +61,6 @@ class JSFinalizationRegistry : public JSObject {
// Returns true if the cleared_cells list is non-empty. // Returns true if the cleared_cells list is non-empty.
inline bool NeedsCleanup() const; inline bool NeedsCleanup() const;
inline bool scheduled_for_cleanup() const;
inline void set_scheduled_for_cleanup(bool scheduled_for_cleanup);
// Remove the first cleared WeakCell from the cleared_cells // Remove the first cleared WeakCell from the cleared_cells
// list (assumes there is one) and return its holdings. // list (assumes there is one) and return its holdings.
inline static Object PopClearedCellHoldings( inline static Object PopClearedCellHoldings(
...@@ -79,7 +79,7 @@ class JSFinalizationRegistry : public JSObject { ...@@ -79,7 +79,7 @@ class JSFinalizationRegistry : public JSObject {
JSObject::kHeaderSize, TORQUE_GENERATED_JS_FINALIZATION_REGISTRY_FIELDS) JSObject::kHeaderSize, TORQUE_GENERATED_JS_FINALIZATION_REGISTRY_FIELDS)
// Bitfields in flags. // Bitfields in flags.
using ScheduledForCleanupField = base::BitField<bool, 0, 1>; DEFINE_TORQUE_GENERATED_FINALIZATION_REGISTRY_FLAGS()
OBJECT_CONSTRUCTORS(JSFinalizationRegistry, JSObject); OBJECT_CONSTRUCTORS(JSFinalizationRegistry, JSObject);
}; };
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
bitfield struct FinalizationRegistryFlags extends uint31 {
scheduled_for_cleanup: bool: 1 bit;
}
extern class JSFinalizationRegistry extends JSObject { extern class JSFinalizationRegistry extends JSObject {
native_context: NativeContext; native_context: NativeContext;
cleanup: Object; cleanup: Object;
...@@ -11,7 +15,7 @@ extern class JSFinalizationRegistry extends JSObject { ...@@ -11,7 +15,7 @@ extern class JSFinalizationRegistry extends JSObject {
// For the linked list of FinalizationRegistries that need cleanup. This // For the linked list of FinalizationRegistries that need cleanup. This
// link is weak. // link is weak.
next_dirty: Undefined|JSFinalizationRegistry; next_dirty: Undefined|JSFinalizationRegistry;
flags: Smi; flags: SmiTagged<FinalizationRegistryFlags>;
} }
@generateCppClass @generateCppClass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment