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

Unified Diff: src/runtime/runtime-typedarray.cc

Issue 1115853004: Reland "Remove the weak list of array buffers" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: ignore empty array buffers Created 5 years, 8 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/runtime-typedarray.cc
diff --git a/src/runtime/runtime-typedarray.cc b/src/runtime/runtime-typedarray.cc
index 036ee41413d096a4382709ebb1349974e4b33a63..b95d20f1ddb7113af4d724a59b6aa9515aff7304 100644
--- a/src/runtime/runtime-typedarray.cc
+++ b/src/runtime/runtime-typedarray.cc
@@ -12,22 +12,6 @@
namespace v8 {
namespace internal {
-void Runtime::FreeArrayBuffer(Isolate* isolate,
- JSArrayBuffer* phantom_array_buffer) {
- if (phantom_array_buffer->is_external()) return;
-
- size_t allocated_length =
- NumberToSize(isolate, phantom_array_buffer->byte_length());
-
- reinterpret_cast<v8::Isolate*>(isolate)
- ->AdjustAmountOfExternalAllocatedMemory(
- -static_cast<int64_t>(allocated_length));
- CHECK(isolate->array_buffer_allocator() != NULL);
- isolate->array_buffer_allocator()->Free(phantom_array_buffer->backing_store(),
- allocated_length);
-}
-
-
void Runtime::SetupArrayBuffer(Isolate* isolate,
Handle<JSArrayBuffer> array_buffer,
bool is_external, void* data,
@@ -47,17 +31,8 @@ void Runtime::SetupArrayBuffer(Isolate* isolate,
CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber());
array_buffer->set_byte_length(*byte_length);
- if (isolate->heap()->InNewSpace(*array_buffer) ||
- isolate->heap()->array_buffers_list()->IsUndefined()) {
- array_buffer->set_weak_next(isolate->heap()->array_buffers_list());
- isolate->heap()->set_array_buffers_list(*array_buffer);
- if (isolate->heap()->last_array_buffer_in_list()->IsUndefined()) {
- isolate->heap()->set_last_array_buffer_in_list(*array_buffer);
- }
- } else {
- JSArrayBuffer::cast(isolate->heap()->last_array_buffer_in_list())
- ->set_weak_next(*array_buffer);
- isolate->heap()->set_last_array_buffer_in_list(*array_buffer);
+ if (data && !is_external) {
+ isolate->heap()->RegisterNewArrayBuffer(data, allocated_length);
}
}
@@ -83,10 +58,6 @@ bool Runtime::SetupArrayBufferAllocatingData(Isolate* isolate,
}
SetupArrayBuffer(isolate, array_buffer, false, data, allocated_length);
-
- reinterpret_cast<v8::Isolate*>(isolate)
- ->AdjustAmountOfExternalAllocatedMemory(allocated_length);
-
return true;
}
@@ -173,6 +144,7 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) {
size_t byte_length = NumberToSize(isolate, array_buffer->byte_length());
array_buffer->set_is_external(true);
Runtime::NeuterArrayBuffer(array_buffer);
+ isolate->heap()->UnregisterArrayBuffer(backing_store);
isolate->array_buffer_allocator()->Free(backing_store, byte_length);
return isolate->heap()->undefined_value();
}
« src/heap/heap.cc ('K') | « src/runtime/runtime.h ('k') | src/snapshot/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698