Extending the Context API with yet another field (of different type) is not very nice, because it hacks in just one specialized use case. I think that the right way would be providing a more general API in Context for adding any number of
embedder data fields, similar to the proposed API for Object:

class Context {
  ...
  Local<Value> GetInternalField(int index);
  void SetInternalField(int index, Handle<Value> data);

  void* GetAlignedPointerFromInternalField(int index);
  void SetAlignedPointerInInternalField(int index, void* ptr);
}

The number of internal fields would be dynamic (i.e. we would reallocate if
necessary), and the old SetData/GetData will be deprecated, but implemented via
field 0 in the meantime. We can probably totally inline the getters in the
header, so things would be quite efficient.

This would be consistent with the other proposal, we will be able solve the
typing problems with External, and you can even associate any number of embedder
data with a Context.

If this is OK, I think I can implement all this in the new one or two days...

https://codereview.chromium.org/11087020/

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to