Commit e95a3e31 authored by JianxiaoLuIntel's avatar JianxiaoLuIntel Committed by V8 LUCI CQ

heap:Remove cache dependencies from MarkCompactCollector

Bug: v8:12833
Change-Id: I91e4dd6afb4c5b53a43067912a2d0cf0f4c9170a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3719685Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Jianxiao Lu <jianxiao.lu@intel.com>
Cr-Commit-Position: refs/heads/main@{#81351}
parent 1fed3177
......@@ -23,8 +23,21 @@ class InnerPointerToCodeCache {
SafepointEntry safepoint_entry;
};
static void FlushCallback(v8::Isolate* isolate, v8::GCType type,
v8::GCCallbackFlags flags, void* data) {
InnerPointerToCodeCache* cache =
static_cast<InnerPointerToCodeCache*>(data);
cache->Flush();
}
explicit InnerPointerToCodeCache(Isolate* isolate) : isolate_(isolate) {
Flush();
isolate_->heap()->AddGCEpilogueCallback(FlushCallback,
kGCTypeMarkSweepCompact, this);
}
~InnerPointerToCodeCache() {
isolate_->heap()->RemoveGCEpilogueCallback(FlushCallback, this);
}
InnerPointerToCodeCache(const InnerPointerToCodeCache&) = delete;
......
......@@ -52,7 +52,6 @@
#include "src/heap/spaces-inl.h"
#include "src/heap/sweeper.h"
#include "src/heap/weak-object-worklists.h"
#include "src/ic/stub-cache.h"
#include "src/init/v8.h"
#include "src/logging/tracing-flags.h"
#include "src/objects/embedder-data-array-inl.h"
......@@ -1114,14 +1113,6 @@ void MarkCompactCollector::Finish() {
DCHECK(state_ == SWEEP_SPACES || state_ == RELOCATE_OBJECTS);
state_ = IDLE;
#endif
heap_->isolate()->inner_pointer_to_code_cache()->Flush();
// The stub caches are not traversed during GC; clear them to force
// their lazy re-initialization. This must be done after the
// GC, because it relies on the new address of certain old space
// objects (empty string, illegal builtin).
isolate()->load_stub_cache()->Clear();
isolate()->store_stub_cache()->Clear();
if (have_code_to_deoptimize_) {
// Some code objects were marked for deoptimization during the GC.
......
......@@ -14,10 +14,29 @@
namespace v8 {
namespace internal {
// static
void StubCache::ClearCallback(v8::Isolate* isolate, v8::GCType type,
v8::GCCallbackFlags flags, void* data) {
StubCache* cache = static_cast<StubCache*>(data);
cache->Clear();
}
StubCache::StubCache(Isolate* isolate) : isolate_(isolate) {
// Ensure the nullptr (aka Smi::zero()) which StubCache::Get() returns
// when the entry is not found is not considered as a handler.
DCHECK(!IC::IsHandler(MaybeObject()));
// The stub caches are not traversed during GC; clear them to force
// their lazy re-initialization. This must be done after the
// GC, because it relies on the new address of certain old space
// objects (empty string, illegal builtin).
isolate_->heap()->AddGCEpilogueCallback(ClearCallback,
kGCTypeMarkSweepCompact, this);
}
StubCache::~StubCache() {
isolate_->heap()->RemoveGCEpilogueCallback(ClearCallback, this);
}
void StubCache::Initialize() {
......
......@@ -5,6 +5,7 @@
#ifndef V8_IC_STUB_CACHE_H_
#define V8_IC_STUB_CACHE_H_
#include "include/v8-callbacks.h"
#include "src/objects/name.h"
#include "src/objects/tagged-value.h"
......@@ -16,7 +17,6 @@ namespace internal {
// need explicit invalidation when a prototype chain is modified, since the
// handlers verify the chain.
class SCTableReference {
public:
Address address() const { return address_; }
......@@ -98,8 +98,12 @@ class V8_EXPORT_PRIVATE StubCache {
static int PrimaryOffsetForTesting(Name name, Map map);
static int SecondaryOffsetForTesting(Name name, Map map);
static void ClearCallback(v8::Isolate* isolate, v8::GCType type,
v8::GCCallbackFlags flags, void* data);
// The constructor is made public only for the purposes of testing.
explicit StubCache(Isolate* isolate);
~StubCache();
StubCache(const StubCache&) = delete;
StubCache& operator=(const StubCache&) = delete;
......
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