Revert "[in-place weak refs] Use WeakArrayList in Heap::noscript_list."
This reverts commit 6755b95631
.
Reason for revert: Causing test failures on gc-stress bot:
https://logs.chromium.org/logs/v8/buildbucket/cr-buildbucket.appspot.com/8940015537308234128/+/steps/Mjsunit_-_slow_path/0/logs/array-multiple-receiv../0
Original change's description:
> [in-place weak refs] Use WeakArrayList in Heap::noscript_list.
>
> BUG=v8:7308
>
> Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
> Change-Id: Ia53233a3a0ba13b8019f2fda4bc4876ebf4feb76
> Reviewed-on: https://chromium-review.googlesource.com/1149367
> Commit-Queue: Marja Hölttä <marja@chromium.org>
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#54700}
TBR=marja@chromium.org,mlippautz@chromium.org
Change-Id: I5e9b916a910b812c3cb50be18416c9e9e8ac7b24
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:7308
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/1150125
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54701}
This commit is contained in:
parent
6755b95631
commit
69b8273bb5
@ -765,7 +765,7 @@ StartupData SnapshotCreator::CreateBlob(
|
||||
i::GarbageCollectionReason::kSnapshotCreator);
|
||||
{
|
||||
i::HandleScope scope(isolate);
|
||||
isolate->heap()->CompactWeakArrayLists();
|
||||
isolate->heap()->CompactFixedArraysOfWeakCells();
|
||||
}
|
||||
|
||||
isolate->heap()->read_only_space()->ClearStringPaddingIfNeeded();
|
||||
|
@ -3541,10 +3541,9 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
|
||||
share->clear_padding();
|
||||
}
|
||||
// Link into the list.
|
||||
Handle<WeakArrayList> noscript_list = noscript_shared_function_infos();
|
||||
noscript_list = WeakArrayList::AddToEnd(isolate(), noscript_list,
|
||||
MaybeObjectHandle::Weak(share));
|
||||
isolate()->heap()->set_noscript_shared_function_infos(*noscript_list);
|
||||
Handle<Object> new_noscript_list = FixedArrayOfWeakCells::Add(
|
||||
isolate(), noscript_shared_function_infos(), share);
|
||||
isolate()->heap()->set_noscript_shared_function_infos(*new_noscript_list);
|
||||
|
||||
#ifdef VERIFY_HEAP
|
||||
share->SharedFunctionInfoVerify(isolate());
|
||||
|
@ -4978,6 +4978,13 @@ void Heap::RemoveGCEpilogueCallback(v8::Isolate::GCCallbackWithData callback,
|
||||
}
|
||||
|
||||
namespace {
|
||||
void CompactFixedArrayOfWeakCells(Isolate* isolate, Object* object) {
|
||||
if (object->IsFixedArrayOfWeakCells()) {
|
||||
FixedArrayOfWeakCells* array = FixedArrayOfWeakCells::cast(object);
|
||||
array->Compact<FixedArrayOfWeakCells::NullCallback>(isolate);
|
||||
}
|
||||
}
|
||||
|
||||
Handle<WeakArrayList> CompactWeakArrayList(Heap* heap,
|
||||
Handle<WeakArrayList> array) {
|
||||
if (array->length() == 0) {
|
||||
@ -5007,7 +5014,7 @@ Handle<WeakArrayList> CompactWeakArrayList(Heap* heap,
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void Heap::CompactWeakArrayLists() {
|
||||
void Heap::CompactFixedArraysOfWeakCells() {
|
||||
// Find known PrototypeUsers and compact them.
|
||||
std::vector<Handle<PrototypeInfo>> prototype_infos;
|
||||
{
|
||||
@ -5029,15 +5036,13 @@ void Heap::CompactWeakArrayLists() {
|
||||
prototype_info->set_prototype_users(new_array);
|
||||
}
|
||||
|
||||
// Find known FixedArrayOfWeakCells and compact them.
|
||||
CompactFixedArrayOfWeakCells(isolate(), noscript_shared_function_infos());
|
||||
|
||||
// Find known WeakArrayLists and compact them.
|
||||
Handle<WeakArrayList> scripts(script_list(), isolate());
|
||||
scripts = CompactWeakArrayList(this, scripts);
|
||||
set_script_list(*scripts);
|
||||
|
||||
Handle<WeakArrayList> no_script_list(noscript_shared_function_infos(),
|
||||
isolate());
|
||||
no_script_list = CompactWeakArrayList(this, no_script_list);
|
||||
set_noscript_shared_function_infos(*no_script_list);
|
||||
}
|
||||
|
||||
void Heap::AddRetainedMap(Handle<Map> map) {
|
||||
|
@ -678,7 +678,7 @@ class Heap {
|
||||
external_memory_concurrently_freed_ = 0;
|
||||
}
|
||||
|
||||
void CompactWeakArrayLists();
|
||||
void CompactFixedArraysOfWeakCells();
|
||||
|
||||
void AddRetainedMap(Handle<Map> map);
|
||||
|
||||
|
@ -706,7 +706,8 @@ void ObjectStatsCollectorImpl::CollectGlobalStatistics() {
|
||||
|
||||
// FixedArrayOfWeakCells.
|
||||
RecordSimpleVirtualObjectStats(
|
||||
nullptr, WeakArrayList::cast(heap_->noscript_shared_function_infos()),
|
||||
nullptr,
|
||||
FixedArrayOfWeakCells::cast(heap_->noscript_shared_function_infos()),
|
||||
ObjectStats::NOSCRIPT_SHARED_FUNCTION_INFOS_TYPE);
|
||||
RecordSimpleVirtualObjectStats(nullptr,
|
||||
WeakArrayList::cast(heap_->script_list()),
|
||||
|
@ -866,7 +866,7 @@ void Heap::CreateInitialObjects() {
|
||||
set_serialized_objects(roots.empty_fixed_array());
|
||||
set_serialized_global_proxy_sizes(roots.empty_fixed_array());
|
||||
|
||||
set_noscript_shared_function_infos(roots.empty_weak_array_list());
|
||||
set_noscript_shared_function_infos(Smi::kZero);
|
||||
|
||||
STATIC_ASSERT(interpreter::BytecodeOperands::kOperandScaleCount == 3);
|
||||
set_deserialize_lazy_handler(Smi::kZero);
|
||||
|
@ -10581,22 +10581,6 @@ int WeakArrayList::CountLiveWeakReferences() const {
|
||||
return live_weak_references;
|
||||
}
|
||||
|
||||
bool WeakArrayList::RemoveOne(MaybeObjectHandle value) {
|
||||
if (length() == 0) return false;
|
||||
// Optimize for the most recently added element to be removed again.
|
||||
for (int i = length() - 1; i >= 0; --i) {
|
||||
if (Get(i) == *value) {
|
||||
// Users should make sure that there are no duplicates.
|
||||
Set(i, HeapObjectReference::ClearedValue());
|
||||
if (i == length() - 1) {
|
||||
set_length(length() - 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
Handle<WeakArrayList> PrototypeUsers::Add(Isolate* isolate,
|
||||
Handle<WeakArrayList> array,
|
||||
@ -13911,11 +13895,11 @@ SharedFunctionInfo::GlobalIterator::GlobalIterator(Isolate* isolate)
|
||||
sfi_iterator_(isolate, script_iterator_.Next()) {}
|
||||
|
||||
SharedFunctionInfo* SharedFunctionInfo::GlobalIterator::Next() {
|
||||
HeapObject* next = noscript_sfi_iterator_.Next();
|
||||
if (next != nullptr) return SharedFunctionInfo::cast(next);
|
||||
SharedFunctionInfo* next = noscript_sfi_iterator_.Next<SharedFunctionInfo>();
|
||||
if (next != nullptr) return next;
|
||||
for (;;) {
|
||||
next = sfi_iterator_.Next();
|
||||
if (next != nullptr) return SharedFunctionInfo::cast(next);
|
||||
if (next != nullptr) return next;
|
||||
Script* next_script = script_iterator_.Next();
|
||||
if (next_script == nullptr) return nullptr;
|
||||
sfi_iterator_.Reset(next_script);
|
||||
@ -13952,21 +13936,19 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
|
||||
#endif
|
||||
list->Set(function_literal_id, HeapObjectReference::Weak(*shared));
|
||||
} else {
|
||||
Handle<WeakArrayList> list =
|
||||
isolate->factory()->noscript_shared_function_infos();
|
||||
Handle<Object> list = isolate->factory()->noscript_shared_function_infos();
|
||||
|
||||
#ifdef DEBUG
|
||||
if (FLAG_enable_slow_asserts) {
|
||||
WeakArrayList::Iterator iterator(*list);
|
||||
HeapObject* next;
|
||||
while ((next = iterator.Next()) != nullptr) {
|
||||
FixedArrayOfWeakCells::Iterator iterator(*list);
|
||||
SharedFunctionInfo* next;
|
||||
while ((next = iterator.Next<SharedFunctionInfo>()) != nullptr) {
|
||||
DCHECK_NE(next, *shared);
|
||||
}
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
list =
|
||||
WeakArrayList::AddToEnd(isolate, list, MaybeObjectHandle::Weak(shared));
|
||||
list = FixedArrayOfWeakCells::Add(isolate, list, shared);
|
||||
|
||||
isolate->heap()->SetRootNoScriptSharedFunctionInfos(*list);
|
||||
}
|
||||
@ -13990,8 +13972,8 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
|
||||
}
|
||||
} else {
|
||||
// Remove shared function info from root array.
|
||||
WeakArrayList* list = isolate->heap()->noscript_shared_function_infos();
|
||||
CHECK(list->RemoveOne(MaybeObjectHandle::Weak(shared)));
|
||||
Object* list = isolate->heap()->noscript_shared_function_infos();
|
||||
CHECK(FixedArrayOfWeakCells::cast(list)->Remove(shared));
|
||||
}
|
||||
|
||||
// Finally set new script.
|
||||
|
@ -370,9 +370,6 @@ class WeakArrayList : public HeapObject {
|
||||
// Returns the number of non-cleaned weak references in the array.
|
||||
int CountLiveWeakReferences() const;
|
||||
|
||||
// Returns whether an entry was found and removed.
|
||||
bool RemoveOne(MaybeObjectHandle value);
|
||||
|
||||
class Iterator {
|
||||
public:
|
||||
explicit Iterator(WeakArrayList* array) : index_(0), array_(array) {}
|
||||
|
@ -574,7 +574,7 @@ class SharedFunctionInfo : public HeapObject, public NeverReadOnlySpaceObject {
|
||||
|
||||
private:
|
||||
Script::Iterator script_iterator_;
|
||||
WeakArrayList::Iterator noscript_sfi_iterator_;
|
||||
FixedArrayOfWeakCells::Iterator noscript_sfi_iterator_;
|
||||
SharedFunctionInfo::ScriptIterator sfi_iterator_;
|
||||
DisallowHeapAllocation no_gc_;
|
||||
DISALLOW_COPY_AND_ASSIGN(GlobalIterator);
|
||||
|
@ -244,8 +244,7 @@ namespace internal {
|
||||
/* Feedback vectors that we need for code coverage or type profile */ \
|
||||
V(Object, feedback_vectors_for_profiling_tools, \
|
||||
FeedbackVectorsForProfilingTools) \
|
||||
V(WeakArrayList, noscript_shared_function_infos, \
|
||||
NoScriptSharedFunctionInfos) \
|
||||
V(Object, noscript_shared_function_infos, NoScriptSharedFunctionInfos) \
|
||||
V(FixedArray, serialized_objects, SerializedObjects) \
|
||||
V(FixedArray, serialized_global_proxy_sizes, SerializedGlobalProxySizes) \
|
||||
V(TemplateList, message_listeners, MessageListeners) \
|
||||
|
@ -83,7 +83,6 @@ bool IsInitiallyMutable(Factory* factory, Address object_address) {
|
||||
V(feedback_vectors_for_profiling_tools) \
|
||||
V(materialized_objects) \
|
||||
V(microtask_queue) \
|
||||
V(noscript_shared_function_infos) \
|
||||
V(retained_maps) \
|
||||
V(retaining_path_targets) \
|
||||
V(serialized_global_proxy_sizes) \
|
||||
|
Loading…
Reference in New Issue
Block a user