Title: [134351] trunk/Source/WebCore
- Revision
- 134351
- Author
- [email protected]
- Date
- 2012-11-12 20:46:20 -0800 (Mon, 12 Nov 2012)
Log Message
[V8] We should be able to get V8PerContextData from a v8::Context more quickly
https://bugs.webkit.org/show_bug.cgi?id=102008
Reviewed by Ojan Vafai.
This patch uses the new v8::Context::GetAlignedPointerFromEmbedderData
API to get the V8PerContextData associated with a v8::Context much more
quickly. We no longer need to use a hidden property on the inner global
object. This patch will enable future optimizations.
* bindings/v8/V8HiddenPropertyName.h:
(WebCore):
* bindings/v8/V8PerContextData.cpp:
(WebCore::V8PerContextData::dispose):
(WebCore::V8PerContextData::init):
* bindings/v8/V8PerContextData.h:
(WebCore::V8PerContextData::from):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (134350 => 134351)
--- trunk/Source/WebCore/ChangeLog 2012-11-13 04:44:20 UTC (rev 134350)
+++ trunk/Source/WebCore/ChangeLog 2012-11-13 04:46:20 UTC (rev 134351)
@@ -1,3 +1,23 @@
+2012-11-12 Adam Barth <[email protected]>
+
+ [V8] We should be able to get V8PerContextData from a v8::Context more quickly
+ https://bugs.webkit.org/show_bug.cgi?id=102008
+
+ Reviewed by Ojan Vafai.
+
+ This patch uses the new v8::Context::GetAlignedPointerFromEmbedderData
+ API to get the V8PerContextData associated with a v8::Context much more
+ quickly. We no longer need to use a hidden property on the inner global
+ object. This patch will enable future optimizations.
+
+ * bindings/v8/V8HiddenPropertyName.h:
+ (WebCore):
+ * bindings/v8/V8PerContextData.cpp:
+ (WebCore::V8PerContextData::dispose):
+ (WebCore::V8PerContextData::init):
+ * bindings/v8/V8PerContextData.h:
+ (WebCore::V8PerContextData::from):
+
2012-11-12 Elliott Sprehn <[email protected]>
Make Frames and HTMLFrameOwnerElement less friendly
Modified: trunk/Source/WebCore/bindings/v8/V8HiddenPropertyName.h (134350 => 134351)
--- trunk/Source/WebCore/bindings/v8/V8HiddenPropertyName.h 2012-11-13 04:44:20 UTC (rev 134350)
+++ trunk/Source/WebCore/bindings/v8/V8HiddenPropertyName.h 2012-11-13 04:46:20 UTC (rev 134351)
@@ -44,7 +44,6 @@
V(event) \
V(listener) \
V(ownerNode) \
- V(perContextData) \
V(scriptState) \
V(sleepFunction) \
V(state) \
Modified: trunk/Source/WebCore/bindings/v8/V8PerContextData.cpp (134350 => 134351)
--- trunk/Source/WebCore/bindings/v8/V8PerContextData.cpp 2012-11-13 04:44:20 UTC (rev 134350)
+++ trunk/Source/WebCore/bindings/v8/V8PerContextData.cpp 2012-11-13 04:46:20 UTC (rev 134351)
@@ -32,23 +32,14 @@
#include "V8PerContextData.h"
#include "V8Binding.h"
-#include "V8HiddenPropertyName.h"
#include "V8ObjectConstructor.h"
namespace WebCore {
-V8PerContextData* V8PerContextData::from(v8::Handle<v8::Context> context)
-{
- v8::Handle<v8::Value> wrappedPerContextData = toInnerGlobalObject(context)->GetHiddenValue(V8HiddenPropertyName::perContextData());
- if (wrappedPerContextData.IsEmpty())
- return 0;
- return static_cast<V8PerContextData*>(v8::External::Unwrap(wrappedPerContextData));
-}
-
void V8PerContextData::dispose()
{
v8::HandleScope handleScope;
- toInnerGlobalObject(m_context)->DeleteHiddenValue(V8HiddenPropertyName::perContextData());
+ m_context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, 0);
{
WrapperBoilerplateMap::iterator it = m_wrapperBoilerplates.begin();
@@ -88,7 +79,7 @@
bool V8PerContextData::init()
{
- toInnerGlobalObject(m_context)->SetHiddenValue(V8HiddenPropertyName::perContextData(), v8::External::Wrap(this));
+ m_context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, this);
v8::Handle<v8::String> prototypeString = v8::String::NewSymbol("prototype");
if (prototypeString.IsEmpty())
Modified: trunk/Source/WebCore/bindings/v8/V8PerContextData.h (134350 => 134351)
--- trunk/Source/WebCore/bindings/v8/V8PerContextData.h 2012-11-13 04:44:20 UTC (rev 134350)
+++ trunk/Source/WebCore/bindings/v8/V8PerContextData.h 2012-11-13 04:46:20 UTC (rev 134351)
@@ -44,6 +44,13 @@
typedef WTF::Vector<V8NPObject*> V8NPObjectVector;
typedef WTF::HashMap<int, V8NPObjectVector> V8NPObjectMap;
+enum V8ContextEmbedderDataField {
+ v8ContextDebugIdIndex,
+ v8ContextPerContextDataIndex
+ // Rather than adding more embedder data fields to v8::Context,
+ // consider adding the data to V8PerContextData instead.
+};
+
class V8PerContextData {
public:
static PassOwnPtr<V8PerContextData> create(v8::Persistent<v8::Context> context)
@@ -58,7 +65,10 @@
bool init();
- static V8PerContextData* from(v8::Handle<v8::Context>);
+ static V8PerContextData* from(v8::Handle<v8::Context> context)
+ {
+ return static_cast<V8PerContextData*>(context->GetAlignedPointerFromEmbedderData(v8ContextPerContextDataIndex));
+ }
// To create JS Wrapper objects, we create a cache of a 'boiler plate'
// object, and then simply Clone that object each time we need a new one.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes