[api] Remove deprectated memory allocation callback API
Users of this api should use a combination of |RequestInterrupt| and |GCCallback| (see |AddGCPrologueCallback| and friends) to keep track allocated memory. BUG=v8:4813 LOG=Y R=jochen@chromium.org Review-Url: https://codereview.chromium.org/1991293002 Cr-Commit-Position: refs/heads/master@{#36594}
This commit is contained in:
parent
ecb2ec8ff3
commit
07fadde87c
20
include/v8.h
20
include/v8.h
@ -5050,10 +5050,6 @@ enum ObjectSpace {
|
|||||||
kAllocationActionAll = kAllocationActionAllocate | kAllocationActionFree
|
kAllocationActionAll = kAllocationActionAllocate | kAllocationActionFree
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*MemoryAllocationCallback)(ObjectSpace space,
|
|
||||||
AllocationAction action,
|
|
||||||
int size);
|
|
||||||
|
|
||||||
// --- Enter/Leave Script Callback ---
|
// --- Enter/Leave Script Callback ---
|
||||||
typedef void (*BeforeCallEnteredCallback)(Isolate*);
|
typedef void (*BeforeCallEnteredCallback)(Isolate*);
|
||||||
typedef void (*CallCompletedCallback)(Isolate*);
|
typedef void (*CallCompletedCallback)(Isolate*);
|
||||||
@ -6307,22 +6303,6 @@ class V8_EXPORT Isolate {
|
|||||||
bool capture, int frame_limit = 10,
|
bool capture, int frame_limit = 10,
|
||||||
StackTrace::StackTraceOptions options = StackTrace::kOverview);
|
StackTrace::StackTraceOptions options = StackTrace::kOverview);
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables the host application to provide a mechanism to be notified
|
|
||||||
* and perform custom logging when V8 Allocates Executable Memory.
|
|
||||||
*/
|
|
||||||
void V8_DEPRECATED(
|
|
||||||
"Use a combination of RequestInterrupt and GCCallback instead",
|
|
||||||
AddMemoryAllocationCallback(MemoryAllocationCallback callback,
|
|
||||||
ObjectSpace space, AllocationAction action));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes callback that was installed by AddMemoryAllocationCallback.
|
|
||||||
*/
|
|
||||||
void V8_DEPRECATED(
|
|
||||||
"Use a combination of RequestInterrupt and GCCallback instead",
|
|
||||||
RemoveMemoryAllocationCallback(MemoryAllocationCallback callback));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates through all external resources referenced from current isolate
|
* Iterates through all external resources referenced from current isolate
|
||||||
* heap. GC is not invoked prior to iterating, therefore there is no
|
* heap. GC is not invoked prior to iterating, therefore there is no
|
||||||
|
16
src/api.cc
16
src/api.cc
@ -7186,22 +7186,6 @@ void Isolate::SetEmbedderHeapTracer(EmbedderHeapTracer* tracer) {
|
|||||||
isolate->heap()->SetEmbedderHeapTracer(tracer);
|
isolate->heap()->SetEmbedderHeapTracer(tracer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Isolate::AddMemoryAllocationCallback(MemoryAllocationCallback callback,
|
|
||||||
ObjectSpace space,
|
|
||||||
AllocationAction action) {
|
|
||||||
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
|
||||||
isolate->heap()->memory_allocator()->AddMemoryAllocationCallback(
|
|
||||||
callback, space, action);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Isolate::RemoveMemoryAllocationCallback(
|
|
||||||
MemoryAllocationCallback callback) {
|
|
||||||
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
|
||||||
isolate->heap()->memory_allocator()->RemoveMemoryAllocationCallback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Isolate::TerminateExecution() {
|
void Isolate::TerminateExecution() {
|
||||||
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
||||||
isolate->stack_guard()->RequestTerminateExecution();
|
isolate->stack_guard()->RequestTerminateExecution();
|
||||||
|
@ -723,10 +723,6 @@ MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size,
|
|||||||
static_cast<int>(chunk_size));
|
static_cast<int>(chunk_size));
|
||||||
|
|
||||||
LOG(isolate_, NewEvent("MemoryChunk", base, chunk_size));
|
LOG(isolate_, NewEvent("MemoryChunk", base, chunk_size));
|
||||||
if (owner != NULL) {
|
|
||||||
ObjectSpace space = static_cast<ObjectSpace>(1 << owner->identity());
|
|
||||||
PerformAllocationCallback(space, kAllocationActionAllocate, chunk_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We cannot use the last chunk in the address space because we would
|
// We cannot use the last chunk in the address space because we would
|
||||||
// overflow when comparing top and limit if this chunk is used for a
|
// overflow when comparing top and limit if this chunk is used for a
|
||||||
@ -758,11 +754,6 @@ void Page::ResetFreeListStatistics() {
|
|||||||
void MemoryAllocator::PreFreeMemory(MemoryChunk* chunk) {
|
void MemoryAllocator::PreFreeMemory(MemoryChunk* chunk) {
|
||||||
DCHECK(!chunk->IsFlagSet(MemoryChunk::PRE_FREED));
|
DCHECK(!chunk->IsFlagSet(MemoryChunk::PRE_FREED));
|
||||||
LOG(isolate_, DeleteEvent("MemoryChunk", chunk));
|
LOG(isolate_, DeleteEvent("MemoryChunk", chunk));
|
||||||
if (chunk->owner() != NULL) {
|
|
||||||
ObjectSpace space =
|
|
||||||
static_cast<ObjectSpace>(1 << chunk->owner()->identity());
|
|
||||||
PerformAllocationCallback(space, kAllocationActionFree, chunk->size());
|
|
||||||
}
|
|
||||||
|
|
||||||
isolate_->heap()->RememberUnmappedPage(reinterpret_cast<Address>(chunk),
|
isolate_->heap()->RememberUnmappedPage(reinterpret_cast<Address>(chunk),
|
||||||
chunk->IsEvacuationCandidate());
|
chunk->IsEvacuationCandidate());
|
||||||
@ -911,52 +902,6 @@ void MemoryAllocator::ZapBlock(Address start, size_t size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MemoryAllocator::PerformAllocationCallback(ObjectSpace space,
|
|
||||||
AllocationAction action,
|
|
||||||
size_t size) {
|
|
||||||
for (int i = 0; i < memory_allocation_callbacks_.length(); ++i) {
|
|
||||||
MemoryAllocationCallbackRegistration registration =
|
|
||||||
memory_allocation_callbacks_[i];
|
|
||||||
if ((registration.space & space) == space &&
|
|
||||||
(registration.action & action) == action)
|
|
||||||
registration.callback(space, action, static_cast<int>(size));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool MemoryAllocator::MemoryAllocationCallbackRegistered(
|
|
||||||
MemoryAllocationCallback callback) {
|
|
||||||
for (int i = 0; i < memory_allocation_callbacks_.length(); ++i) {
|
|
||||||
if (memory_allocation_callbacks_[i].callback == callback) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MemoryAllocator::AddMemoryAllocationCallback(
|
|
||||||
MemoryAllocationCallback callback, ObjectSpace space,
|
|
||||||
AllocationAction action) {
|
|
||||||
DCHECK(callback != NULL);
|
|
||||||
MemoryAllocationCallbackRegistration registration(callback, space, action);
|
|
||||||
DCHECK(!MemoryAllocator::MemoryAllocationCallbackRegistered(callback));
|
|
||||||
return memory_allocation_callbacks_.Add(registration);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MemoryAllocator::RemoveMemoryAllocationCallback(
|
|
||||||
MemoryAllocationCallback callback) {
|
|
||||||
DCHECK(callback != NULL);
|
|
||||||
for (int i = 0; i < memory_allocation_callbacks_.length(); ++i) {
|
|
||||||
if (memory_allocation_callbacks_[i].callback == callback) {
|
|
||||||
memory_allocation_callbacks_.Remove(i);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UNREACHABLE();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void MemoryAllocator::ReportStatistics() {
|
void MemoryAllocator::ReportStatistics() {
|
||||||
intptr_t size = Size();
|
intptr_t size = Size();
|
||||||
@ -2988,10 +2933,6 @@ void LargeObjectSpace::TearDown() {
|
|||||||
LargePage* page = first_page_;
|
LargePage* page = first_page_;
|
||||||
first_page_ = first_page_->next_page();
|
first_page_ = first_page_->next_page();
|
||||||
LOG(heap()->isolate(), DeleteEvent("LargeObjectChunk", page->address()));
|
LOG(heap()->isolate(), DeleteEvent("LargeObjectChunk", page->address()));
|
||||||
|
|
||||||
ObjectSpace space = static_cast<ObjectSpace>(1 << identity());
|
|
||||||
heap()->memory_allocator()->PerformAllocationCallback(
|
|
||||||
space, kAllocationActionFree, page->size());
|
|
||||||
heap()->memory_allocator()->Free<MemoryAllocator::kFull>(page);
|
heap()->memory_allocator()->Free<MemoryAllocator::kFull>(page);
|
||||||
}
|
}
|
||||||
SetUp();
|
SetUp();
|
||||||
|
@ -1456,16 +1456,6 @@ class MemoryAllocator {
|
|||||||
// filling it up with a recognizable non-NULL bit pattern.
|
// filling it up with a recognizable non-NULL bit pattern.
|
||||||
void ZapBlock(Address start, size_t size);
|
void ZapBlock(Address start, size_t size);
|
||||||
|
|
||||||
void PerformAllocationCallback(ObjectSpace space, AllocationAction action,
|
|
||||||
size_t size);
|
|
||||||
|
|
||||||
void AddMemoryAllocationCallback(MemoryAllocationCallback callback,
|
|
||||||
ObjectSpace space, AllocationAction action);
|
|
||||||
|
|
||||||
void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback);
|
|
||||||
|
|
||||||
bool MemoryAllocationCallbackRegistered(MemoryAllocationCallback callback);
|
|
||||||
|
|
||||||
static int CodePageGuardStartOffset();
|
static int CodePageGuardStartOffset();
|
||||||
|
|
||||||
static int CodePageGuardSize();
|
static int CodePageGuardSize();
|
||||||
@ -1526,19 +1516,6 @@ class MemoryAllocator {
|
|||||||
base::AtomicValue<void*> lowest_ever_allocated_;
|
base::AtomicValue<void*> lowest_ever_allocated_;
|
||||||
base::AtomicValue<void*> highest_ever_allocated_;
|
base::AtomicValue<void*> highest_ever_allocated_;
|
||||||
|
|
||||||
struct MemoryAllocationCallbackRegistration {
|
|
||||||
MemoryAllocationCallbackRegistration(MemoryAllocationCallback callback,
|
|
||||||
ObjectSpace space,
|
|
||||||
AllocationAction action)
|
|
||||||
: callback(callback), space(space), action(action) {}
|
|
||||||
MemoryAllocationCallback callback;
|
|
||||||
ObjectSpace space;
|
|
||||||
AllocationAction action;
|
|
||||||
};
|
|
||||||
|
|
||||||
// A List of callback that are triggered when memory is allocated or free'd
|
|
||||||
List<MemoryAllocationCallbackRegistration> memory_allocation_callbacks_;
|
|
||||||
|
|
||||||
// Initializes pages in a chunk. Returns the first page address.
|
// Initializes pages in a chunk. Returns the first page address.
|
||||||
// This function and GetChunkId() are provided for the mark-compact
|
// This function and GetChunkId() are provided for the mark-compact
|
||||||
// collector to rebuild page headers in the from space, which is
|
// collector to rebuild page headers in the from space, which is
|
||||||
|
Loading…
Reference in New Issue
Block a user