Reviewers: Toon Verwaest,
Message:
PTAL.
Description:
Keep maps when resetting elements.
Please review this at https://codereview.chromium.org/335553004/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+10, -24 lines):
M src/elements.cc
M src/objects.cc
M src/objects-inl.h
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index
a8f43d598bb0bb37075f1802f15e4506775d0458..a64268835d78f899f8b7151f284be527560c94a6
100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -1436,9 +1436,7 @@ class DictionaryElementsAccessor
}
if (new_length == 0) {
- // If the length of a slow array is reset to zero, we clear
- // the array and flush backing storage. This has the added
- // benefit that the array returns to fast mode.
+ // Flush the backing store.
JSObject::ResetElements(array);
} else {
DisallowHeapAllocation no_gc;
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
2bca797d18a8bc5d33c839e842a0474a33530dbc..2764b371473716c69ed75f39711d85d55b32464e
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -2738,6 +2738,9 @@ FixedArrayBase* Map::GetInitialElements() {
GetHeap()->EmptyFixedTypedArrayForMap(this);
ASSERT(!GetHeap()->InNewSpace(empty_array));
return empty_array;
+ } else if (has_dictionary_elements()) {
+
ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_slow_element_dictionary()));
+ return GetHeap()->empty_slow_element_dictionary();
} else {
UNREACHABLE();
}
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
bdfa23cde59d32626192b08ec182f5e2784550e6..94a29febb1cf897fae97a168dc893fa2405c78ee
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -4857,28 +4857,13 @@ void
JSObject::TransformToFastProperties(Handle<JSObject> object,
void JSObject::ResetElements(Handle<JSObject> object) {
- if (object->map()->is_observed()) {
- // Maintain invariant that observed elements are always in dictionary
mode.
- Isolate* isolate = object->GetIsolate();
- Factory* factory = isolate->factory();
- Handle<SeededNumberDictionary> dictionary =
- SeededNumberDictionary::New(isolate, 0);
- if (object->map() == *factory->sloppy_arguments_elements_map()) {
- FixedArray::cast(object->elements())->set(1, *dictionary);
- } else {
- object->set_elements(*dictionary);
- }
- return;
- }
-
- ElementsKind elements_kind = GetInitialFastElementsKind();
- if (!FLAG_smi_only_arrays) {
- elements_kind = FastSmiToObjectElementsKind(elements_kind);
+ Heap* heap = object->GetIsolate()->heap();
+ if (object->map() == heap->sloppy_arguments_elements_map()) {
+ FixedArray::cast(object->elements())->set(
+ 1, heap->empty_slow_element_dictionary());
+ } else {
+ object->set_elements(object->map()->GetInitialElements());
}
- Handle<Map> map = JSObject::GetElementsTransitionMap(object,
elements_kind);
- DisallowHeapAllocation no_gc;
- Handle<FixedArrayBase> elements(map->GetInitialElements());
- JSObject::SetMapAndElements(object, map, elements);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.