Skip to content

Commit 4214933

Browse files
mlippautzCommit Bot
authored andcommitted
Reland "[api,heap] Remove deprecated Persistent APIs"
Removes APIs: - MarkIndependent - IsIndependent - MarkActive - RegisterExternalReference All weak persistent handles are now treated as independent. Users of traced handles should already use v8::EmbedderHeapTracer. This reverts commit 49954eb. Bug: chromium:923361 Change-Id: I0b9fcd678964331f926f6b725f70eb64268ca33f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1578462 Auto-Submit: Michael Lippautz <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Commit-Queue: Michael Lippautz <[email protected]> Cr-Commit-Position: refs/heads/master@{#60971}
1 parent 65a6dae commit 4214933

11 files changed

Lines changed: 188 additions & 426 deletions

File tree

include/v8-internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ class Internals {
165165
static const int kNodeStateMask = 0x7;
166166
static const int kNodeStateIsWeakValue = 2;
167167
static const int kNodeStateIsPendingValue = 3;
168-
static const int kNodeIsIndependentShift = 3;
169-
static const int kNodeIsActiveShift = 4;
170168

171169
static const int kFirstNonstringType = 0x40;
172170
static const int kOddballType = 0x43;

include/v8-util.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,6 @@ class PersistentValueMapBase {
194194
return SetReturnValueFromVal(&returnValue, Traits::Get(&impl_, key));
195195
}
196196

197-
/**
198-
* Call V8::RegisterExternallyReferencedObject with the map value for given
199-
* key.
200-
*/
201-
V8_DEPRECATED(
202-
"Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference",
203-
inline void RegisterExternallyReferencedObject(K& key));
204-
205197
/**
206198
* Return value for key and remove it from the map.
207199
*/
@@ -352,16 +344,6 @@ class PersistentValueMapBase {
352344
const char* label_;
353345
};
354346

355-
template <typename K, typename V, typename Traits>
356-
inline void
357-
PersistentValueMapBase<K, V, Traits>::RegisterExternallyReferencedObject(
358-
K& key) {
359-
assert(Contains(key));
360-
V8::RegisterExternallyReferencedObject(
361-
reinterpret_cast<internal::Address*>(FromVal(Traits::Get(&impl_, key))),
362-
reinterpret_cast<internal::Isolate*>(GetIsolate()));
363-
}
364-
365347
template <typename K, typename V, typename Traits>
366348
class PersistentValueMap : public PersistentValueMapBase<K, V, Traits> {
367349
public:

include/v8.h

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -545,38 +545,6 @@ template <class T> class PersistentBase {
545545
*/
546546
V8_INLINE void AnnotateStrongRetainer(const char* label);
547547

548-
/**
549-
* Allows the embedder to tell the v8 garbage collector that a certain object
550-
* is alive. Only allowed when the embedder is asked to trace its heap by
551-
* EmbedderHeapTracer.
552-
*/
553-
V8_DEPRECATED(
554-
"Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference",
555-
V8_INLINE void RegisterExternalReference(Isolate* isolate) const);
556-
557-
/**
558-
* Marks the reference to this object independent. Garbage collector is free
559-
* to ignore any object groups containing this object. Weak callback for an
560-
* independent handle should not assume that it will be preceded by a global
561-
* GC prologue callback or followed by a global GC epilogue callback.
562-
*/
563-
V8_DEPRECATED(
564-
"Weak objects are always considered independent. "
565-
"Use TracedGlobal when trying to use EmbedderHeapTracer. "
566-
"Use a strong handle when trying to keep an object alive.",
567-
V8_INLINE void MarkIndependent());
568-
569-
/**
570-
* Marks the reference to this object as active. The scavenge garbage
571-
* collection should not reclaim the objects marked as active, even if the
572-
* object held by the handle is otherwise unreachable.
573-
*
574-
* This bit is cleared after the each garbage collection pass.
575-
*/
576-
V8_DEPRECATED("Use TracedGlobal.", V8_INLINE void MarkActive());
577-
578-
V8_DEPRECATED("See MarkIndependent.", V8_INLINE bool IsIndependent() const);
579-
580548
/** Returns true if the handle's reference is weak. */
581549
V8_INLINE bool IsWeak() const;
582550

@@ -8839,9 +8807,6 @@ class V8_EXPORT V8 {
88398807
const char* label);
88408808
static Value* Eternalize(Isolate* isolate, Value* handle);
88418809

8842-
static void RegisterExternallyReferencedObject(internal::Address* location,
8843-
internal::Isolate* isolate);
8844-
88458810
template <class K, class V, class T>
88468811
friend class PersistentValueMapBase;
88478812

@@ -9788,14 +9753,6 @@ void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
97889753
M::Copy(that, this);
97899754
}
97909755

9791-
template <class T>
9792-
bool PersistentBase<T>::IsIndependent() const {
9793-
typedef internal::Internals I;
9794-
if (this->IsEmpty()) return false;
9795-
return I::GetNodeFlag(reinterpret_cast<internal::Address*>(this->val_),
9796-
I::kNodeIsIndependentShift);
9797-
}
9798-
97999756
template <class T>
98009757
bool PersistentBase<T>::IsWeak() const {
98019758
typedef internal::Internals I;
@@ -9862,31 +9819,6 @@ void PersistentBase<T>::AnnotateStrongRetainer(const char* label) {
98629819
label);
98639820
}
98649821

9865-
template <class T>
9866-
void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const {
9867-
if (IsEmpty()) return;
9868-
V8::RegisterExternallyReferencedObject(
9869-
reinterpret_cast<internal::Address*>(this->val_),
9870-
reinterpret_cast<internal::Isolate*>(isolate));
9871-
}
9872-
9873-
template <class T>
9874-
void PersistentBase<T>::MarkIndependent() {
9875-
typedef internal::Internals I;
9876-
if (this->IsEmpty()) return;
9877-
I::UpdateNodeFlag(reinterpret_cast<internal::Address*>(this->val_), true,
9878-
I::kNodeIsIndependentShift);
9879-
}
9880-
9881-
template <class T>
9882-
void PersistentBase<T>::MarkActive() {
9883-
typedef internal::Internals I;
9884-
if (this->IsEmpty()) return;
9885-
I::UpdateNodeFlag(reinterpret_cast<internal::Address*>(this->val_), true,
9886-
I::kNodeIsActiveShift);
9887-
}
9888-
9889-
98909822
template <class T>
98919823
void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
98929824
typedef internal::Internals I;

src/api.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,11 +1037,6 @@ void V8::MoveTracedGlobalReference(internal::Address** from,
10371037
i::GlobalHandles::MoveTracedGlobal(from, to);
10381038
}
10391039

1040-
void V8::RegisterExternallyReferencedObject(i::Address* location,
1041-
i::Isolate* isolate) {
1042-
isolate->heap()->RegisterExternallyReferencedObject(location);
1043-
}
1044-
10451040
void V8::MakeWeak(i::Address* location, void* parameter,
10461041
WeakCallbackInfo<void>::Callback weak_callback,
10471042
WeakCallbackType type) {

src/global-handles.cc

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,6 @@ class GlobalHandles::Node final : public NodeBase<GlobalHandles::Node> {
379379
Internals::kNodeStateMask);
380380
STATIC_ASSERT(WEAK == Internals::kNodeStateIsWeakValue);
381381
STATIC_ASSERT(PENDING == Internals::kNodeStateIsPendingValue);
382-
STATIC_ASSERT(static_cast<int>(IsIndependent::kShift) ==
383-
Internals::kNodeIsIndependentShift);
384-
STATIC_ASSERT(static_cast<int>(IsActive::kShift) ==
385-
Internals::kNodeIsActiveShift);
386382
set_in_young_list(false);
387383
}
388384

@@ -406,16 +402,6 @@ class GlobalHandles::Node final : public NodeBase<GlobalHandles::Node> {
406402
flags_ = NodeState::update(flags_, state);
407403
}
408404

409-
bool is_independent() { return IsIndependent::decode(flags_); }
410-
void set_independent(bool v) { flags_ = IsIndependent::update(flags_, v); }
411-
412-
bool is_active() {
413-
return IsActive::decode(flags_);
414-
}
415-
void set_active(bool v) {
416-
flags_ = IsActive::update(flags_, v);
417-
}
418-
419405
bool is_in_young_list() const { return IsInYoungList::decode(flags_); }
420406
void set_in_young_list(bool v) { flags_ = IsInYoungList::update(flags_, v); }
421407

@@ -562,7 +548,6 @@ class GlobalHandles::Node final : public NodeBase<GlobalHandles::Node> {
562548
// This method invokes a finalizer. Updating the method name would require
563549
// adjusting CFI blacklist as weak_callback_ is invoked on the wrong type.
564550
CHECK(IsPendingFinalizer());
565-
CHECK(!is_active());
566551
set_state(NEAR_DEATH);
567552
// Check that we are not passing a finalized external string to
568553
// the callback.
@@ -593,24 +578,17 @@ class GlobalHandles::Node final : public NodeBase<GlobalHandles::Node> {
593578
private:
594579
// Fields that are not used for managing node memory.
595580
void ClearImplFields() {
596-
set_independent(false);
597-
set_active(false);
598581
weak_callback_ = nullptr;
599582
}
600583

601584
void CheckImplFieldsAreCleared() {
602-
DCHECK(!is_independent());
603-
DCHECK(!is_active());
604585
DCHECK_EQ(nullptr, weak_callback_);
605586
}
606587

607588
// This stores three flags (independent, partially_dependent and
608589
// in_young_list) and a State.
609590
class NodeState : public BitField8<State, 0, 3> {};
610-
class IsIndependent : public BitField8<bool, NodeState::kNext, 1> {};
611-
// The following two fields are mutually exclusive
612-
class IsActive : public BitField8<bool, IsIndependent::kNext, 1> {};
613-
class IsInYoungList : public BitField8<bool, IsActive::kNext, 1> {};
591+
class IsInYoungList : public BitField8<bool, NodeState::kNext, 1> {};
614592
class NodeWeaknessType
615593
: public BitField8<WeaknessType, IsInYoungList::kNext, 2> {};
616594

@@ -873,12 +851,6 @@ void GlobalHandles::IterateWeakRootsIdentifyFinalizers(
873851

874852
void GlobalHandles::IdentifyWeakUnmodifiedObjects(
875853
WeakSlotCallback is_unmodified) {
876-
for (Node* node : young_nodes_) {
877-
if (node->IsWeak() && !is_unmodified(node->location())) {
878-
node->set_active(true);
879-
}
880-
}
881-
882854
LocalEmbedderHeapTracer* const tracer =
883855
isolate()->heap()->local_embedder_heap_tracer();
884856
for (TracedNode* node : traced_young_nodes_) {
@@ -895,9 +867,7 @@ void GlobalHandles::IdentifyWeakUnmodifiedObjects(
895867

896868
void GlobalHandles::IterateYoungStrongAndDependentRoots(RootVisitor* v) {
897869
for (Node* node : young_nodes_) {
898-
if (node->IsStrongRetainer() ||
899-
(node->IsWeakRetainer() && !node->is_independent() &&
900-
node->is_active())) {
870+
if (node->IsStrongRetainer()) {
901871
v->VisitRootPointer(Root::kGlobalHandles, node->label(),
902872
node->location());
903873
}
@@ -913,8 +883,7 @@ void GlobalHandles::MarkYoungWeakUnmodifiedObjectsPending(
913883
WeakSlotCallbackWithHeap is_dead) {
914884
for (Node* node : young_nodes_) {
915885
DCHECK(node->is_in_young_list());
916-
if ((node->is_independent() || !node->is_active()) && node->IsWeak() &&
917-
is_dead(isolate_->heap(), node->location())) {
886+
if (node->IsWeak() && is_dead(isolate_->heap(), node->location())) {
918887
if (!node->IsPhantomCallback() && !node->IsPhantomResetHandle()) {
919888
node->MarkPending();
920889
}
@@ -926,8 +895,7 @@ void GlobalHandles::IterateYoungWeakUnmodifiedRootsForFinalizers(
926895
RootVisitor* v) {
927896
for (Node* node : young_nodes_) {
928897
DCHECK(node->is_in_young_list());
929-
if ((node->is_independent() || !node->is_active()) &&
930-
node->IsWeakRetainer() && (node->state() == Node::PENDING)) {
898+
if (node->IsWeakRetainer() && (node->state() == Node::PENDING)) {
931899
DCHECK(!node->IsPhantomCallback());
932900
DCHECK(!node->IsPhantomResetHandle());
933901
// Finalizers need to survive.
@@ -941,8 +909,7 @@ void GlobalHandles::IterateYoungWeakUnmodifiedRootsForPhantomHandles(
941909
RootVisitor* v, WeakSlotCallbackWithHeap should_reset_handle) {
942910
for (Node* node : young_nodes_) {
943911
DCHECK(node->is_in_young_list());
944-
if ((node->is_independent() || !node->is_active()) &&
945-
node->IsWeakRetainer() && (node->state() != Node::PENDING)) {
912+
if (node->IsWeakRetainer() && (node->state() != Node::PENDING)) {
946913
if (should_reset_handle(isolate_->heap(), node->location())) {
947914
DCHECK(node->IsPhantomResetHandle() || node->IsPhantomCallback());
948915
if (node->IsPhantomResetHandle()) {
@@ -1008,9 +975,6 @@ size_t GlobalHandles::PostScavengeProcessing(unsigned post_processing_count) {
1008975
// Filter free nodes.
1009976
if (!node->IsRetainer()) continue;
1010977

1011-
// Reset active state for all affected nodes.
1012-
node->set_active(false);
1013-
1014978
if (node->IsPending()) {
1015979
DCHECK(node->has_callback());
1016980
DCHECK(node->IsPendingFinalizer());
@@ -1029,9 +993,6 @@ size_t GlobalHandles::PostMarkSweepProcessing(unsigned post_processing_count) {
1029993
// Filter free nodes.
1030994
if (!node->IsRetainer()) continue;
1031995

1032-
// Reset active state for all affected nodes.
1033-
node->set_active(false);
1034-
1035996
if (node->IsPending()) {
1036997
DCHECK(node->has_callback());
1037998
DCHECK(node->IsPendingFinalizer());

src/profiler/sampling-heap-profiler.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,6 @@ void SamplingHeapProfiler::SampleObject(Address soon_object, size_t size) {
9797
base::make_unique<Sample>(size, node, loc, this, next_sample_id());
9898
sample->global.SetWeak(sample.get(), OnWeakCallback,
9999
WeakCallbackType::kParameter);
100-
#if __clang__
101-
#pragma clang diagnostic push
102-
#pragma clang diagnostic ignored "-Wdeprecated"
103-
#endif
104-
// MarkIndependent is marked deprecated but we still rely on it here
105-
// temporarily.
106-
sample->global.MarkIndependent();
107-
#if __clang__
108-
#pragma clang diagnostic pop
109-
#endif
110100
samples_.emplace(sample.get(), std::move(sample));
111101
}
112102

test/cctest/heap/heap-utils.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ namespace v8 {
1212
namespace internal {
1313
namespace heap {
1414

15+
class TemporaryEmbedderHeapTracerScope {
16+
public:
17+
TemporaryEmbedderHeapTracerScope(v8::Isolate* isolate,
18+
v8::EmbedderHeapTracer* tracer)
19+
: isolate_(isolate) {
20+
isolate_->SetEmbedderHeapTracer(tracer);
21+
}
22+
23+
~TemporaryEmbedderHeapTracerScope() {
24+
isolate_->SetEmbedderHeapTracer(nullptr);
25+
}
26+
27+
private:
28+
v8::Isolate* const isolate_;
29+
};
30+
1531
void SealCurrentObjects(Heap* heap);
1632

1733
int FixedArrayLenFromSize(int size);

0 commit comments

Comments
 (0)