Revert "Fix JSArrayBufferView visitor template to fix ARM build."
and "Just visit young array buffers during scavenge. Additionally keep the views in new space in a separate global list and move them to the corresponding array buffers when they get promoted." This reverts commit295ab27830
and commitbd61a85faf
. TBR=hpayer@chromium.org NOTRY=true Review URL: https://codereview.chromium.org/929973002 Cr-Commit-Position: refs/heads/master@{#26653}
This commit is contained in:
parent
b8ec6fbf5d
commit
e66d39a6be
@ -1795,14 +1795,8 @@ void SetupArrayBufferView(i::Isolate* isolate,
|
||||
|
||||
obj->set_buffer(*buffer);
|
||||
|
||||
Heap* heap = isolate->heap();
|
||||
if (heap->InNewSpace(*obj)) {
|
||||
obj->set_weak_next(heap->new_array_buffer_views_list());
|
||||
heap->set_new_array_buffer_views_list(*obj);
|
||||
} else {
|
||||
obj->set_weak_next(buffer->weak_first_view());
|
||||
buffer->set_weak_first_view(*obj);
|
||||
}
|
||||
obj->set_weak_next(buffer->weak_first_view());
|
||||
buffer->set_weak_first_view(*obj);
|
||||
|
||||
i::Handle<i::Object> byte_offset_object =
|
||||
isolate->factory()->NewNumberFromSize(byte_offset);
|
||||
|
@ -141,8 +141,7 @@ Heap::Heap()
|
||||
external_string_table_(this),
|
||||
chunks_queued_for_free_(NULL),
|
||||
gc_callbacks_depth_(0),
|
||||
deserialization_complete_(false),
|
||||
promotion_failure_(false) {
|
||||
deserialization_complete_(false) {
|
||||
// Allow build-time customization of the max semispace size. Building
|
||||
// V8 with snapshots and a non-default max semispace size is much
|
||||
// easier if you can define it as part of the build environment.
|
||||
@ -729,7 +728,6 @@ void Heap::GarbageCollectionEpilogue() {
|
||||
// Remember the last top pointer so that we can later find out
|
||||
// whether we allocated in new space since the last GC.
|
||||
new_space_top_after_last_gc_ = new_space()->top();
|
||||
set_promotion_failure(false);
|
||||
}
|
||||
|
||||
|
||||
@ -1731,86 +1729,29 @@ void Heap::UpdateReferencesInExternalStringTable(
|
||||
|
||||
|
||||
void Heap::ProcessAllWeakReferences(WeakObjectRetainer* retainer) {
|
||||
ProcessArrayBuffers(retainer, false);
|
||||
ProcessNewArrayBufferViews(retainer);
|
||||
ProcessArrayBuffers(retainer);
|
||||
ProcessNativeContexts(retainer);
|
||||
ProcessAllocationSites(retainer);
|
||||
}
|
||||
|
||||
|
||||
void Heap::ProcessYoungWeakReferences(WeakObjectRetainer* retainer) {
|
||||
ProcessArrayBuffers(retainer, true);
|
||||
ProcessNewArrayBufferViews(retainer);
|
||||
ProcessArrayBuffers(retainer);
|
||||
ProcessNativeContexts(retainer);
|
||||
}
|
||||
|
||||
|
||||
void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer) {
|
||||
Object* head =
|
||||
VisitWeakList<Context>(this, native_contexts_list(), retainer, false);
|
||||
Object* head = VisitWeakList<Context>(this, native_contexts_list(), retainer);
|
||||
// Update the head of the list of contexts.
|
||||
set_native_contexts_list(head);
|
||||
}
|
||||
|
||||
|
||||
void Heap::ProcessArrayBuffers(WeakObjectRetainer* retainer,
|
||||
bool stop_after_young) {
|
||||
Object* array_buffer_obj = VisitWeakList<JSArrayBuffer>(
|
||||
this, array_buffers_list(), retainer, stop_after_young);
|
||||
void Heap::ProcessArrayBuffers(WeakObjectRetainer* retainer) {
|
||||
Object* array_buffer_obj =
|
||||
VisitWeakList<JSArrayBuffer>(this, array_buffers_list(), retainer);
|
||||
set_array_buffers_list(array_buffer_obj);
|
||||
|
||||
#ifdef DEBUG
|
||||
// Verify invariant that young array buffers come before old array buffers
|
||||
// in array buffers list if there was no promotion failure.
|
||||
Object* undefined = undefined_value();
|
||||
Object* next = array_buffers_list();
|
||||
bool old_objects_recorded = false;
|
||||
if (promotion_failure()) return;
|
||||
while (next != undefined) {
|
||||
if (!old_objects_recorded) {
|
||||
old_objects_recorded = !InNewSpace(next);
|
||||
}
|
||||
DCHECK((InNewSpace(next) && !old_objects_recorded) || !InNewSpace(next));
|
||||
next = JSArrayBuffer::cast(next)->weak_next();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Heap::ProcessNewArrayBufferViews(WeakObjectRetainer* retainer) {
|
||||
// Retain the list of new space views.
|
||||
Object* typed_array_obj = VisitWeakList<JSArrayBufferView>(
|
||||
this, new_array_buffer_views_list_, retainer, false);
|
||||
set_new_array_buffer_views_list(typed_array_obj);
|
||||
|
||||
// Some objects in the list may be in old space now. Find them
|
||||
// and move them to the corresponding array buffer.
|
||||
Object* undefined = undefined_value();
|
||||
Object* previous = undefined;
|
||||
Object* head = undefined;
|
||||
Object* next;
|
||||
for (Object* o = new_array_buffer_views_list(); o != undefined;) {
|
||||
JSArrayBufferView* view = JSArrayBufferView::cast(o);
|
||||
next = view->weak_next();
|
||||
if (!InNewSpace(view)) {
|
||||
if (previous != undefined) {
|
||||
// We are in the middle of the list, skip the old space element.
|
||||
JSArrayBufferView::cast(previous)->set_weak_next(next);
|
||||
}
|
||||
JSArrayBuffer* buffer = JSArrayBuffer::cast(view->buffer());
|
||||
view->set_weak_next(buffer->weak_first_view());
|
||||
buffer->set_weak_first_view(view);
|
||||
} else {
|
||||
// We found a valid new space view, remember it.
|
||||
previous = view;
|
||||
if (head == undefined) {
|
||||
// We are at the list head.
|
||||
head = view;
|
||||
}
|
||||
}
|
||||
o = next;
|
||||
}
|
||||
set_new_array_buffer_views_list(head);
|
||||
}
|
||||
|
||||
|
||||
@ -1826,8 +1767,8 @@ void Heap::TearDownArrayBuffers() {
|
||||
|
||||
|
||||
void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer) {
|
||||
Object* allocation_site_obj = VisitWeakList<AllocationSite>(
|
||||
this, allocation_sites_list(), retainer, false);
|
||||
Object* allocation_site_obj =
|
||||
VisitWeakList<AllocationSite>(this, allocation_sites_list(), retainer);
|
||||
set_allocation_sites_list(allocation_site_obj);
|
||||
}
|
||||
|
||||
@ -2260,7 +2201,6 @@ class ScavengingVisitor : public StaticVisitorBase {
|
||||
return;
|
||||
}
|
||||
|
||||
heap->set_promotion_failure(true);
|
||||
// If promotion failed, we try to copy the object to the other semi-space
|
||||
if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) return;
|
||||
|
||||
@ -5599,7 +5539,6 @@ bool Heap::CreateHeapObjects() {
|
||||
|
||||
set_native_contexts_list(undefined_value());
|
||||
set_array_buffers_list(undefined_value());
|
||||
set_new_array_buffer_views_list(undefined_value());
|
||||
set_allocation_sites_list(undefined_value());
|
||||
return true;
|
||||
}
|
||||
|
@ -859,13 +859,6 @@ class Heap {
|
||||
void set_array_buffers_list(Object* object) { array_buffers_list_ = object; }
|
||||
Object* array_buffers_list() const { return array_buffers_list_; }
|
||||
|
||||
void set_new_array_buffer_views_list(Object* object) {
|
||||
new_array_buffer_views_list_ = object;
|
||||
}
|
||||
Object* new_array_buffer_views_list() const {
|
||||
return new_array_buffer_views_list_;
|
||||
}
|
||||
|
||||
void set_allocation_sites_list(Object* object) {
|
||||
allocation_sites_list_ = object;
|
||||
}
|
||||
@ -1453,11 +1446,6 @@ class Heap {
|
||||
|
||||
bool deserialization_complete() const { return deserialization_complete_; }
|
||||
|
||||
bool promotion_failure() const { return promotion_failure_; }
|
||||
void set_promotion_failure(bool promotion_failure) {
|
||||
promotion_failure_ = promotion_failure;
|
||||
}
|
||||
|
||||
protected:
|
||||
// Methods made available to tests.
|
||||
|
||||
@ -1623,16 +1611,11 @@ class Heap {
|
||||
bool inline_allocation_disabled_;
|
||||
|
||||
// Weak list heads, threaded through the objects.
|
||||
// List heads are initialized lazily and contain the undefined_value at start.
|
||||
// List heads are initilized lazily and contain the undefined_value at start.
|
||||
Object* native_contexts_list_;
|
||||
Object* array_buffers_list_;
|
||||
Object* allocation_sites_list_;
|
||||
|
||||
// This is a global list of array buffer views in new space. When the views
|
||||
// get promoted, they are removed form the list and added to the corresponding
|
||||
// array buffer.
|
||||
Object* new_array_buffer_views_list_;
|
||||
|
||||
// List of encountered weak collections (JSWeakMap and JSWeakSet) during
|
||||
// marking. It is initialized during marking, destroyed after marking and
|
||||
// contains Smi(0) while marking is not active.
|
||||
@ -1965,8 +1948,7 @@ class Heap {
|
||||
void MarkCompactEpilogue();
|
||||
|
||||
void ProcessNativeContexts(WeakObjectRetainer* retainer);
|
||||
void ProcessArrayBuffers(WeakObjectRetainer* retainer, bool stop_after_young);
|
||||
void ProcessNewArrayBufferViews(WeakObjectRetainer* retainer);
|
||||
void ProcessArrayBuffers(WeakObjectRetainer* retainer);
|
||||
void ProcessAllocationSites(WeakObjectRetainer* retainer);
|
||||
|
||||
// Deopts all code that contains allocation instruction which are tenured or
|
||||
@ -2126,11 +2108,6 @@ class Heap {
|
||||
|
||||
bool deserialization_complete_;
|
||||
|
||||
// A promotion failure indicates that old space promotion failed during
|
||||
// gc, i.e., some objects that should have gotten promoted had to stay in
|
||||
// the new space (they were copied to the other semi-space).
|
||||
bool promotion_failure_;
|
||||
|
||||
friend class AlwaysAllocateScope;
|
||||
friend class Deserializer;
|
||||
friend class Factory;
|
||||
|
@ -1865,7 +1865,6 @@ int MarkCompactCollector::DiscoverAndEvacuateBlackObjectsOnPage(
|
||||
TryPromoteObject(object, size)) {
|
||||
continue;
|
||||
}
|
||||
heap()->set_promotion_failure(true);
|
||||
|
||||
AllocationResult allocation = new_space->AllocateRaw(size);
|
||||
if (allocation.IsRetry()) {
|
||||
|
@ -191,19 +191,15 @@ struct WeakListVisitor;
|
||||
|
||||
|
||||
template <class T>
|
||||
Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer,
|
||||
bool stop_after_young) {
|
||||
Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer) {
|
||||
Object* undefined = heap->undefined_value();
|
||||
Object* head = undefined;
|
||||
T* tail = NULL;
|
||||
MarkCompactCollector* collector = heap->mark_compact_collector();
|
||||
bool record_slots = MustRecordSlots(heap);
|
||||
|
||||
while (list != undefined) {
|
||||
// Check whether to keep the candidate in the list.
|
||||
T* candidate = reinterpret_cast<T*>(list);
|
||||
T* original_candidate = candidate;
|
||||
|
||||
Object* retained = retainer->RetainAs(list);
|
||||
if (retained != NULL) {
|
||||
if (head == undefined) {
|
||||
@ -224,19 +220,9 @@ Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer,
|
||||
candidate = reinterpret_cast<T*>(retained);
|
||||
tail = candidate;
|
||||
|
||||
|
||||
// tail is a live object, visit it.
|
||||
WeakListVisitor<T>::VisitLiveObject(heap, tail, retainer);
|
||||
|
||||
// The list of weak objects is usually order. It starts with objects
|
||||
// recently allocated in the young generation followed by objects
|
||||
// allocated in the old generation. When a promotion failure happens,
|
||||
// the list is not ordered until the next GC.
|
||||
// For young generation collections we just have to visit until the last
|
||||
// young generation objects.
|
||||
if (stop_after_young && !heap->promotion_failure() &&
|
||||
!heap->InNewSpace(original_candidate)) {
|
||||
return head;
|
||||
}
|
||||
} else {
|
||||
WeakListVisitor<T>::VisitPhantomObject(heap, candidate);
|
||||
}
|
||||
@ -330,8 +316,7 @@ struct WeakListVisitor<Context> {
|
||||
static void DoWeakList(Heap* heap, Context* context,
|
||||
WeakObjectRetainer* retainer, int index) {
|
||||
// Visit the weak list, removing dead intermediate elements.
|
||||
Object* list_head =
|
||||
VisitWeakList<T>(heap, context->get(index), retainer, false);
|
||||
Object* list_head = VisitWeakList<T>(heap, context->get(index), retainer);
|
||||
|
||||
// Update the list head.
|
||||
context->set(index, list_head, UPDATE_WRITE_BARRIER);
|
||||
@ -383,7 +368,7 @@ struct WeakListVisitor<JSArrayBuffer> {
|
||||
static void VisitLiveObject(Heap* heap, JSArrayBuffer* array_buffer,
|
||||
WeakObjectRetainer* retainer) {
|
||||
Object* typed_array_obj = VisitWeakList<JSArrayBufferView>(
|
||||
heap, array_buffer->weak_first_view(), retainer, false);
|
||||
heap, array_buffer->weak_first_view(), retainer);
|
||||
array_buffer->set_weak_first_view(typed_array_obj);
|
||||
if (typed_array_obj != heap->undefined_value() && MustRecordSlots(heap)) {
|
||||
Object** slot = HeapObject::RawField(array_buffer,
|
||||
@ -414,21 +399,23 @@ struct WeakListVisitor<AllocationSite> {
|
||||
};
|
||||
|
||||
|
||||
template Object* VisitWeakList<Code>(Heap* heap, Object* list,
|
||||
WeakObjectRetainer* retainer);
|
||||
|
||||
|
||||
template Object* VisitWeakList<JSFunction>(Heap* heap, Object* list,
|
||||
WeakObjectRetainer* retainer);
|
||||
|
||||
|
||||
template Object* VisitWeakList<Context>(Heap* heap, Object* list,
|
||||
WeakObjectRetainer* retainer,
|
||||
bool stop_after_young);
|
||||
WeakObjectRetainer* retainer);
|
||||
|
||||
|
||||
template Object* VisitWeakList<JSArrayBuffer>(Heap* heap, Object* list,
|
||||
WeakObjectRetainer* retainer,
|
||||
bool stop_after_young);
|
||||
WeakObjectRetainer* retainer);
|
||||
|
||||
template Object* VisitWeakList<JSArrayBufferView>(Heap* heap, Object* list,
|
||||
WeakObjectRetainer* retainer,
|
||||
bool stop_after_young);
|
||||
|
||||
template Object* VisitWeakList<AllocationSite>(Heap* heap, Object* list,
|
||||
WeakObjectRetainer* retainer,
|
||||
bool stop_after_young);
|
||||
WeakObjectRetainer* retainer);
|
||||
}
|
||||
} // namespace v8::internal
|
||||
|
@ -489,8 +489,7 @@ class WeakObjectRetainer;
|
||||
// pointers. The template parameter T is a WeakListVisitor that defines how to
|
||||
// access the next-element pointers.
|
||||
template <class T>
|
||||
Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer,
|
||||
bool stop_after_young);
|
||||
Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer);
|
||||
}
|
||||
} // namespace v8::internal
|
||||
|
||||
|
@ -16927,15 +16927,8 @@ Handle<JSArrayBuffer> JSTypedArray::MaterializeArrayBuffer(
|
||||
fixed_typed_array->length(), typed_array->type(),
|
||||
static_cast<uint8_t*>(buffer->backing_store()));
|
||||
|
||||
Heap* heap = isolate->heap();
|
||||
if (heap->InNewSpace(*typed_array)) {
|
||||
DCHECK(typed_array->weak_next() == isolate->heap()->undefined_value());
|
||||
typed_array->set_weak_next(heap->new_array_buffer_views_list());
|
||||
heap->set_new_array_buffer_views_list(*typed_array);
|
||||
} else {
|
||||
buffer->set_weak_first_view(*typed_array);
|
||||
DCHECK(typed_array->weak_next() == isolate->heap()->undefined_value());
|
||||
}
|
||||
buffer->set_weak_first_view(*typed_array);
|
||||
DCHECK(typed_array->weak_next() == isolate->heap()->undefined_value());
|
||||
typed_array->set_buffer(*buffer);
|
||||
JSObject::SetMapAndElements(typed_array, new_map, new_elements);
|
||||
|
||||
|
@ -88,8 +88,6 @@ bool Runtime::SetupArrayBufferAllocatingData(Isolate* isolate,
|
||||
|
||||
void Runtime::NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer) {
|
||||
Isolate* isolate = array_buffer->GetIsolate();
|
||||
// Firstly, iterate over the views which are referenced directly by the array
|
||||
// buffer.
|
||||
for (Handle<Object> view_obj(array_buffer->weak_first_view(), isolate);
|
||||
!view_obj->IsUndefined();) {
|
||||
Handle<JSArrayBufferView> view(JSArrayBufferView::cast(*view_obj));
|
||||
@ -102,24 +100,6 @@ void Runtime::NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer) {
|
||||
}
|
||||
view_obj = handle(view->weak_next(), isolate);
|
||||
}
|
||||
|
||||
// Secondly, iterate over the global list of new space views to find views
|
||||
// that belong to the neutered array buffer.
|
||||
Heap* heap = isolate->heap();
|
||||
for (Handle<Object> view_obj(heap->new_array_buffer_views_list(), isolate);
|
||||
!view_obj->IsUndefined();) {
|
||||
Handle<JSArrayBufferView> view(JSArrayBufferView::cast(*view_obj));
|
||||
if (view->buffer() == *array_buffer) {
|
||||
if (view->IsJSTypedArray()) {
|
||||
JSTypedArray::cast(*view)->Neuter();
|
||||
} else if (view->IsJSDataView()) {
|
||||
JSDataView::cast(*view)->Neuter();
|
||||
} else {
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
view_obj = handle(view->weak_next(), isolate);
|
||||
}
|
||||
array_buffer->Neuter();
|
||||
}
|
||||
|
||||
@ -285,18 +265,11 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitialize) {
|
||||
holder->set_byte_offset(*byte_offset_object);
|
||||
holder->set_byte_length(*byte_length_object);
|
||||
|
||||
Heap* heap = isolate->heap();
|
||||
if (!maybe_buffer->IsNull()) {
|
||||
Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer);
|
||||
holder->set_buffer(*buffer);
|
||||
|
||||
if (heap->InNewSpace(*holder)) {
|
||||
holder->set_weak_next(heap->new_array_buffer_views_list());
|
||||
heap->set_new_array_buffer_views_list(*holder);
|
||||
} else {
|
||||
holder->set_weak_next(buffer->weak_first_view());
|
||||
buffer->set_weak_first_view(*holder);
|
||||
}
|
||||
holder->set_weak_next(buffer->weak_first_view());
|
||||
buffer->set_weak_first_view(*holder);
|
||||
|
||||
Handle<ExternalArray> elements = isolate->factory()->NewExternalArray(
|
||||
static_cast<int>(length), array_type,
|
||||
@ -394,15 +367,8 @@ RUNTIME_FUNCTION(Runtime_TypedArrayInitializeFromArrayLike) {
|
||||
isolate->factory()->NewNumberFromSize(byte_length));
|
||||
holder->set_byte_length(*byte_length_obj);
|
||||
holder->set_length(*length_obj);
|
||||
|
||||
Heap* heap = isolate->heap();
|
||||
if (heap->InNewSpace(*holder)) {
|
||||
holder->set_weak_next(heap->new_array_buffer_views_list());
|
||||
heap->set_new_array_buffer_views_list(*holder);
|
||||
} else {
|
||||
holder->set_weak_next(buffer->weak_first_view());
|
||||
buffer->set_weak_first_view(*holder);
|
||||
}
|
||||
holder->set_weak_next(buffer->weak_first_view());
|
||||
buffer->set_weak_first_view(*holder);
|
||||
|
||||
Handle<ExternalArray> elements = isolate->factory()->NewExternalArray(
|
||||
static_cast<int>(length), array_type,
|
||||
@ -576,14 +542,8 @@ RUNTIME_FUNCTION(Runtime_DataViewInitialize) {
|
||||
holder->set_byte_offset(*byte_offset);
|
||||
holder->set_byte_length(*byte_length);
|
||||
|
||||
Heap* heap = isolate->heap();
|
||||
if (heap->InNewSpace(*holder)) {
|
||||
holder->set_weak_next(heap->new_array_buffer_views_list());
|
||||
heap->set_new_array_buffer_views_list(*holder);
|
||||
} else {
|
||||
holder->set_weak_next(buffer->weak_first_view());
|
||||
buffer->set_weak_first_view(*holder);
|
||||
}
|
||||
holder->set_weak_next(buffer->weak_first_view());
|
||||
buffer->set_weak_first_view(*holder);
|
||||
|
||||
return isolate->heap()->undefined_value();
|
||||
}
|
||||
|
@ -672,8 +672,6 @@ void Deserializer::Deserialize(Isolate* isolate) {
|
||||
isolate_->heap()->undefined_value());
|
||||
isolate_->heap()->set_array_buffers_list(
|
||||
isolate_->heap()->undefined_value());
|
||||
isolate->heap()->set_new_array_buffer_views_list(
|
||||
isolate_->heap()->undefined_value());
|
||||
|
||||
// The allocation site list is build during root iteration, but if no sites
|
||||
// were encountered then it needs to be initialized to undefined.
|
||||
|
@ -62,20 +62,7 @@ static bool HasArrayBufferInWeakList(Heap* heap, JSArrayBuffer* ab) {
|
||||
}
|
||||
|
||||
|
||||
static int CountViewsInNewSpaceList(Heap* heap, JSArrayBuffer* array_buffer) {
|
||||
int count = 0;
|
||||
for (Object* o = heap->new_array_buffer_views_list(); !o->IsUndefined();) {
|
||||
JSArrayBufferView* view = JSArrayBufferView::cast(o);
|
||||
if (array_buffer == view->buffer()) {
|
||||
count++;
|
||||
}
|
||||
o = view->weak_next();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static int CountViews(Heap* heap, JSArrayBuffer* array_buffer) {
|
||||
static int CountViews(JSArrayBuffer* array_buffer) {
|
||||
int count = 0;
|
||||
for (Object* o = array_buffer->weak_first_view();
|
||||
!o->IsUndefined();
|
||||
@ -83,27 +70,17 @@ static int CountViews(Heap* heap, JSArrayBuffer* array_buffer) {
|
||||
count++;
|
||||
}
|
||||
|
||||
return count + CountViewsInNewSpaceList(heap, array_buffer);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static bool HasViewInNewSpaceList(Heap* heap, JSArrayBufferView* ta) {
|
||||
for (Object* o = heap->new_array_buffer_views_list(); !o->IsUndefined();
|
||||
o = JSArrayBufferView::cast(o)->weak_next()) {
|
||||
if (ta == o) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool HasViewInWeakList(Heap* heap, JSArrayBuffer* array_buffer,
|
||||
static bool HasViewInWeakList(JSArrayBuffer* array_buffer,
|
||||
JSArrayBufferView* ta) {
|
||||
for (Object* o = array_buffer->weak_first_view();
|
||||
!o->IsUndefined();
|
||||
o = JSArrayBufferView::cast(o)->weak_next()) {
|
||||
if (ta == o) return true;
|
||||
}
|
||||
return HasViewInNewSpaceList(heap, ta);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -223,18 +200,18 @@ void TestViewFromApi() {
|
||||
|
||||
Handle<JSArrayBufferView> ita1 = v8::Utils::OpenHandle(*ta1);
|
||||
Handle<JSArrayBufferView> ita2 = v8::Utils::OpenHandle(*ta2);
|
||||
CHECK_EQ(2, CountViews(isolate->heap(), *iab));
|
||||
CHECK(HasViewInWeakList(isolate->heap(), *iab, *ita1));
|
||||
CHECK(HasViewInWeakList(isolate->heap(), *iab, *ita2));
|
||||
CHECK_EQ(2, CountViews(*iab));
|
||||
CHECK(HasViewInWeakList(*iab, *ita1));
|
||||
CHECK(HasViewInWeakList(*iab, *ita2));
|
||||
}
|
||||
isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
|
||||
CHECK_EQ(1, CountViews(isolate->heap(), *iab));
|
||||
CHECK_EQ(1, CountViews(*iab));
|
||||
Handle<JSArrayBufferView> ita1 = v8::Utils::OpenHandle(*ta1);
|
||||
CHECK(HasViewInWeakList(isolate->heap(), *iab, *ita1));
|
||||
CHECK(HasViewInWeakList(*iab, *ita1));
|
||||
}
|
||||
isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
|
||||
|
||||
CHECK_EQ(0, CountViews(isolate->heap(), *iab));
|
||||
CHECK_EQ(0, CountViews(*iab));
|
||||
}
|
||||
|
||||
|
||||
@ -322,13 +299,10 @@ static void TestTypedArrayFromScript(const char* constructor) {
|
||||
v8::Handle<TypedArray>::Cast(CompileRun("ta3"));
|
||||
CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()) - start);
|
||||
Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
|
||||
CHECK_EQ(3, CountViews(isolate->heap(), *iab));
|
||||
CHECK(HasViewInWeakList(isolate->heap(), *iab,
|
||||
*v8::Utils::OpenHandle(*ta1)));
|
||||
CHECK(HasViewInWeakList(isolate->heap(), *iab,
|
||||
*v8::Utils::OpenHandle(*ta2)));
|
||||
CHECK(HasViewInWeakList(isolate->heap(), *iab,
|
||||
*v8::Utils::OpenHandle(*ta3)));
|
||||
CHECK_EQ(3, CountViews(*iab));
|
||||
CHECK(HasViewInWeakList(*iab, *v8::Utils::OpenHandle(*ta1)));
|
||||
CHECK(HasViewInWeakList(*iab, *v8::Utils::OpenHandle(*ta2)));
|
||||
CHECK(HasViewInWeakList(*iab, *v8::Utils::OpenHandle(*ta3)));
|
||||
}
|
||||
|
||||
i::SNPrintF(source, "ta%d = null;", i);
|
||||
@ -342,14 +316,13 @@ static void TestTypedArrayFromScript(const char* constructor) {
|
||||
v8::Handle<v8::ArrayBuffer> ab =
|
||||
v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab"));
|
||||
Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
|
||||
CHECK_EQ(2, CountViews(isolate->heap(), *iab));
|
||||
CHECK_EQ(2, CountViews(*iab));
|
||||
for (int j = 1; j <= 3; j++) {
|
||||
if (j == i) continue;
|
||||
i::SNPrintF(source, "ta%d", j);
|
||||
v8::Handle<TypedArray> ta =
|
||||
v8::Handle<TypedArray>::Cast(CompileRun(source.start()));
|
||||
CHECK(HasViewInWeakList(isolate->heap(), *iab,
|
||||
*v8::Utils::OpenHandle(*ta)));
|
||||
CHECK(HasViewInWeakList(*iab, *v8::Utils::OpenHandle(*ta)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -363,7 +336,7 @@ static void TestTypedArrayFromScript(const char* constructor) {
|
||||
v8::Handle<v8::ArrayBuffer> ab =
|
||||
v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab"));
|
||||
Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
|
||||
CHECK_EQ(0, CountViews(isolate->heap(), *iab));
|
||||
CHECK_EQ(0, CountViews(*iab));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user