Commit 07fadde8 authored by mlippautz's avatar mlippautz Committed by Commit bot

[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}
parent ecb2ec8f
......@@ -5050,10 +5050,6 @@ enum ObjectSpace {
kAllocationActionAll = kAllocationActionAllocate | kAllocationActionFree
};
typedef void (*MemoryAllocationCallback)(ObjectSpace space,
AllocationAction action,
int size);
// --- Enter/Leave Script Callback ---
typedef void (*BeforeCallEnteredCallback)(Isolate*);
typedef void (*CallCompletedCallback)(Isolate*);
......@@ -6307,22 +6303,6 @@ class V8_EXPORT Isolate {
bool capture, int frame_limit = 10,
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
* heap. GC is not invoked prior to iterating, therefore there is no
......
......@@ -7186,22 +7186,6 @@ void Isolate::SetEmbedderHeapTracer(EmbedderHeapTracer* 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() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
isolate->stack_guard()->RequestTerminateExecution();
......
......@@ -723,10 +723,6 @@ MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size,
static_cast<int>(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
// 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) {
DCHECK(!chunk->IsFlagSet(MemoryChunk::PRE_FREED));
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),
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
void MemoryAllocator::ReportStatistics() {
intptr_t size = Size();
......@@ -2988,10 +2933,6 @@ void LargeObjectSpace::TearDown() {
LargePage* page = first_page_;
first_page_ = first_page_->next_page();
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);
}
SetUp();
......
......@@ -1456,16 +1456,6 @@ class MemoryAllocator {
// filling it up with a recognizable non-NULL bit pattern.
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 CodePageGuardSize();
......@@ -1526,19 +1516,6 @@ class MemoryAllocator {
base::AtomicValue<void*> lowest_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.
// This function and GetChunkId() are provided for the mark-compact
// collector to rebuild page headers in the from space, which is
......
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