13 | | After moving the DOM pointers into the JavaScript VM, we'll still need to provide a fast path for C++ code to access the pointers. Today, C++ simply reads a pointer from a fixed offset in the Node object. In this proposal, C++ code will need to take a slightly more indirect route: |
| 13 | After moving the DOM pointers into the JavaScript VM, we'll still need to provide a fast path for C++ code to access the pointers. Today, C++ simply reads a pointer from a fixed offset in the Node object. In this proposal, C++ code will need to take a slightly more indirect route: |
| 14 | |
| 15 | {{{ |
| 16 | Node* Node::nextSibling() |
| 17 | { |
| 18 | m_wrapper->fastGetProperty(kNextSiblingIndex)->impl(); |
| 19 | } |
| 20 | |
| 21 | void Note::setNextSibling(Node* node) |
| 22 | { |
| 23 | m_wrapper->fastSetProperty(kNextSiblingIndex, node->m_wrapper); |
| 24 | } |
| 25 | }}} |
| 26 | |
| 27 | In order to get or set the nextSibling property, the C++ code needs to consult its JavaScript wrapper. (Note: This implies that we'll need to eagerly creata JavaScript wrappers for DOM nodes.) In this approach, the JavaScript wrapper stores the four DOM pointers at fixed offsets in memory, letting the C++ code read or write the property directly rather than having to do a hash table lookup. |