This patch implements optimized objectInfo structure which manages the set of observe...
authoradamk@chromium.org <adamk@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 10 Sep 2013 18:13:54 +0000 (18:13 +0000)
committeradamk@chromium.org <adamk@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 10 Sep 2013 18:13:54 +0000 (18:13 +0000)
commit9139e1a864b1b4ceefa37b7046bc24a4a4bb7f9a
tree5340132f5b9da8e84f8e0e90f32020a816db5ab0
parentf0f3ddc5c7dfaf61c39caf417b92b6f5185b2983
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

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

Patch from Rafael Weinstein <rafaelw@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16629 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
src/object-observe.js
test/cctest/test-object-observe.cc