Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Unified Diff: src/runtime.cc

Issue 16950013: Do not use weak handles for ArrayBuffers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 01165c8f19c10c4b6871b5258d42ffbf1d80f431..593276ef269cd22b759a4a27102a0d096f8f641c 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -650,23 +650,17 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) {
}
-static void ArrayBufferWeakCallback(v8::Isolate* external_isolate,
- Persistent<Value>* object,
- void* data) {
- Isolate* isolate = reinterpret_cast<Isolate*>(external_isolate);
- HandleScope scope(isolate);
- Handle<Object> internal_object = Utils::OpenPersistent(object);
- Handle<JSArrayBuffer> array_buffer(JSArrayBuffer::cast(*internal_object));
+void Runtime::FreeArrayBuffer(Isolate* isolate,
+ JSArrayBuffer* phantom_array_buffer) {
+ if (phantom_array_buffer->is_external()) return;
- if (!array_buffer->is_external()) {
- size_t allocated_length = NumberToSize(
- isolate, array_buffer->byte_length());
- isolate->heap()->AdjustAmountOfExternalAllocatedMemory(
- -static_cast<intptr_t>(allocated_length));
- CHECK(V8::ArrayBufferAllocator() != NULL);
- V8::ArrayBufferAllocator()->Free(data);
- }
- object->Dispose(external_isolate);
+ size_t allocated_length = NumberToSize(
+ isolate, phantom_array_buffer->byte_length());
+
+ isolate->heap()->AdjustAmountOfExternalAllocatedMemory(
+ -static_cast<intptr_t>(allocated_length));
+ CHECK(V8::ArrayBufferAllocator() != NULL);
+ V8::ArrayBufferAllocator()->Free(phantom_array_buffer->backing_store());
}
@@ -711,10 +705,6 @@ bool Runtime::SetupArrayBufferAllocatingData(
SetupArrayBuffer(isolate, array_buffer, false, data, allocated_length);
- Handle<Object> persistent = isolate->global_handles()->Create(*array_buffer);
- GlobalHandles::MakeWeak(persistent.location(), data, ArrayBufferWeakCallback);
- GlobalHandles::MarkIndependent(persistent.location());
-
isolate->heap()->AdjustAmountOfExternalAllocatedMemory(allocated_length);
return true;
« src/heap.cc ('K') | « src/runtime.h ('k') | test/cctest/test-weaktypedarrays.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698