Add internal API for accessing V8 handles of QJS types
authorKent Hansen <kent.hansen@nokia.com>
Thu, 22 Mar 2012 21:30:14 +0000 (22:30 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 29 May 2012 07:00:57 +0000 (09:00 +0200)
commit6318f91dc0bf1ac428037c963b80b7a5d4e1ad30
tree4b307f601d25d9f6c6aee65fbf754893c1fc6a79
parent18eba786347c42e0c1c9a2a5f8331624f1779920
Add internal API for accessing V8 handles of QJS types

Make it possible to use the V8 API directly. This might be necessary
in cases where the QJS API is missing some functionality (e.g.,
controlling the V8 profiler), or for performance reasons (e.g.,
avoiding overhead of QJSValue indirection).

The V8 API is clearly more extensive than the QJS API, and QJS will
likely never reach feature parity with it (since that's outside the
scope of QJS). By providing access to the underlying V8 types, users
can still choose to use V8 directly in the (hopefully rare) cases
where the public QJS API isn't sufficient.

Two new functions are introduced:
- qt_QJSEngineV8Context(QJSEngine *) returns a local handle to the
  engine's internal V8 context.
- qt_QJSValueV8Value(const QJSValue &) returns a local handle to the
  QJSValue's internal V8 value.

The caller is responsible for
- ensuring that a V8 handle scope is in place;
- entering/exiting the QJSEngine's V8 context.

The documentation and tests show how that can be done.

Also added a benchmark for QJSValue that can be used to measure the
effect of using raw V8 API for some common operations.

Change-Id: I680aeb2f67ffe5eeadd432a05c8084e43921a118
Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
src/qml/qml/v8/qjsengine.cpp
src/qml/qml/v8/qjsvalue.cpp
src/qml/qml/v8/qjsvalue_impl_p.h
src/qml/qml/v8/qjsvalue_p.h
tests/auto/qml/qjsengine/qjsengine.pro
tests/auto/qml/qjsengine/tst_qjsengine.cpp
tests/benchmarks/script/qjsvalue/qjsvalue.pro [new file with mode: 0644]
tests/benchmarks/script/qjsvalue/tst_qjsvalue.cpp [new file with mode: 0644]
tests/benchmarks/script/script.pro [new file with mode: 0644]