*/
void GetHeapStatistics(HeapStatistics* heap_statistics);
+ /**
+ * Adjusts the amount of registered external memory. Used to give V8 an
+ * indication of the amount of externally allocated memory that is kept alive
+ * by JavaScript objects. V8 uses this to decide when to perform global
+ * garbage collections. Registering externally allocated memory will trigger
+ * global garbage collections more often than it would otherwise in an attempt
+ * to garbage collect the JavaScript objects that keep the externally
+ * allocated memory alive.
+ *
+ * \param change_in_bytes the change in externally allocated memory that is
+ * kept alive by JavaScript objects.
+ * \returns the adjusted value.
+ */
+ intptr_t AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes);
+
private:
Isolate();
Isolate(const Isolate&);
static void SetJitCodeEventHandler(JitCodeEventOptions options,
JitCodeEventHandler event_handler);
- /**
- * Adjusts the amount of registered external memory. Used to give
- * V8 an indication of the amount of externally allocated memory
- * that is kept alive by JavaScript objects. V8 uses this to decide
- * when to perform global garbage collections. Registering
- * externally allocated memory will trigger global garbage
- * collections more often than otherwise in an attempt to garbage
- * collect the JavaScript objects keeping the externally allocated
- * memory alive.
- *
- * \param change_in_bytes the change in externally allocated memory
- * that is kept alive by JavaScript objects.
- * \returns the adjusted value.
- */
+ // TODO(svenpanne) Really deprecate me when Chrome is fixed.
+ /** Deprecated. Use Isolate::AdjustAmountOfExternalAllocatedMemory instead. */
static intptr_t AdjustAmountOfExternalAllocatedMemory(
intptr_t change_in_bytes);
}
+intptr_t Isolate::AdjustAmountOfExternalAllocatedMemory(
+ intptr_t change_in_bytes) {
+ i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
+ return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
+}
+
+
intptr_t V8::AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes) {
i::Isolate* isolate = i::Isolate::UncheckedCurrent();
if (isolate == NULL || !isolate->IsInitialized() ||
IsDeadCheck(isolate, "v8::V8::AdjustAmountOfExternalAllocatedMemory()")) {
return 0;
}
- return isolate->heap()->AdjustAmountOfExternalAllocatedMemory(
- change_in_bytes);
+ Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate);
+ return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
}
Persistent<Object>::New(isolate, buffer);
persistent_array.MakeWeak(isolate, data, ExternalArrayWeakCallback);
persistent_array.MarkIndependent(isolate);
- V8::AdjustAmountOfExternalAllocatedMemory(length);
+ isolate->AdjustAmountOfExternalAllocatedMemory(length);
buffer->SetIndexedPropertiesToExternalArrayData(
data, v8::kExternalByteArray, length);
HandleScope scope;
int32_t length =
object->ToObject()->Get(Symbols::byteLength(isolate))->Uint32Value();
- V8::AdjustAmountOfExternalAllocatedMemory(-length);
+ isolate->AdjustAmountOfExternalAllocatedMemory(-length);
delete[] static_cast<uint8_t*>(data);
object.Dispose(isolate);
}
Persistent<Object>::New(isolate, buffer);
persistent_buffer.MakeWeak(isolate, data, ExternalArrayWeakCallback);
persistent_buffer.MarkIndependent(isolate);
- V8::AdjustAmountOfExternalAllocatedMemory(length);
+ isolate->AdjustAmountOfExternalAllocatedMemory(length);
buffer->SetIndexedPropertiesToExternalArrayData(
data, kExternalUnsignedByteArray, length);
v8::Persistent<Context> env(Context::New());
CHECK(!env.IsEmpty());
const intptr_t kSize = 1024*1024;
- CHECK_EQ(cast(v8::V8::AdjustAmountOfExternalAllocatedMemory(kSize)),
+ v8::Isolate* isolate = env->GetIsolate();
+ CHECK_EQ(cast(isolate->AdjustAmountOfExternalAllocatedMemory(kSize)),
cast(kSize));
- CHECK_EQ(cast(v8::V8::AdjustAmountOfExternalAllocatedMemory(-kSize)),
+ CHECK_EQ(cast(isolate->AdjustAmountOfExternalAllocatedMemory(-kSize)),
cast(0));
}