Commit b26d28d9 authored by adamk@chromium.org's avatar adamk@chromium.org

This patch implements optimized objectInfo structure which manages the set of...

This patch implements optimized objectInfo structure which manages the set of observers associated with an object and the changeRecord types which they accept.

Observation in the normal case (Object.observe, default accept types, one observer) now allocates fewer objects and unobservation no longer needs to scan and splice an InternalArray -- making the combined speed of observe/unobserve about 200% faster.

This patch implements the following optimizations:

-objectInfo is initially created without any connected objects or arrays. The first observer is referenced directly by objectInfo, and when a second observer is added, changeObservers converts to a mapping of callbackPriority->observer, which allows for constant time registration/de-registration.

-observer.accept and objectInfo.performing are conceptually the same data-structure. This is now directly represented as an abstract "TypeMap" which can later be optimized to be a smi in common cases, (e.g:   https://codereview.chromium.org/19269007/).

-objectInfo observers are only represented by an object with an accept typeMap if the set of accept types is non-default

R=rossberg@chromium.org

Committed: https://code.google.com/p/v8/source/detail?r=16343

Review URL: https://codereview.chromium.org/19541010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16539 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 50ae7dbe
This diff is collapsed.
......@@ -435,14 +435,14 @@ TEST(ObservationWeakMap) {
i::Handle<i::JSWeakMap> objectInfoMap =
i::Handle<i::JSWeakMap>::cast(
i::GetProperty(observation_state, "objectInfoMap"));
i::Handle<i::JSWeakMap> notifierTargetMap =
i::Handle<i::JSWeakMap> notifierObjectInfoMap =
i::Handle<i::JSWeakMap>::cast(
i::GetProperty(observation_state, "notifierTargetMap"));
i::GetProperty(observation_state, "notifierObjectInfoMap"));
CHECK_EQ(1, NumberOfElements(callbackInfoMap));
CHECK_EQ(1, NumberOfElements(objectInfoMap));
CHECK_EQ(1, NumberOfElements(notifierTargetMap));
CHECK_EQ(1, NumberOfElements(notifierObjectInfoMap));
HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
CHECK_EQ(0, NumberOfElements(callbackInfoMap));
CHECK_EQ(0, NumberOfElements(objectInfoMap));
CHECK_EQ(0, NumberOfElements(notifierTargetMap));
CHECK_EQ(0, NumberOfElements(notifierObjectInfoMap));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment