Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(830)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp

Issue 2335203006: Add [CachedAccessor] attribute to cache (almost) constant accessors (window.document). (Closed)
Patch Set: Polishing + naming revisited Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp b/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
index 77d1a1ab3dc07c8734a8aef35a79b05615d20f55..95b0c0f1783ab32978c64b483c5ea6ae9fe7f0ba 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
@@ -31,6 +31,7 @@
#include "bindings/core/v8/GeneratedCodeHelper.h" // just for DCHECK
#include "bindings/core/v8/V8ObjectConstructor.h"
#include "bindings/core/v8/V8PerContextData.h"
+#include "bindings/core/v8/WindowProxy.h"
#include "platform/TraceEvent.h"
namespace blink {
@@ -91,10 +92,10 @@ void installAttributeInternal(v8::Isolate* isolate, v8::Local<v8::Object> instan
}
template <class FunctionOrTemplate>
-v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate(v8::Isolate*, v8::FunctionCallback, V8DOMConfiguration::FastAccessorBuilderCallback, v8::Local<v8::Value> data, v8::Local<v8::Signature>, int length);
+v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate(v8::Isolate*, v8::FunctionCallback, V8DOMConfiguration::FastAccessorBuilderCallback, V8DOMConfiguration::PrivatePropertyCallback, v8::Local<v8::Value> data, v8::Local<v8::Signature>, int length);
template <>
-v8::Local<v8::FunctionTemplate> createAccessorFunctionOrTemplate<v8::FunctionTemplate>(v8::Isolate* isolate, v8::FunctionCallback callback, V8DOMConfiguration::FastAccessorBuilderCallback fastCallback, v8::Local<v8::Value> data, v8::Local<v8::Signature> signature, int length)
+v8::Local<v8::FunctionTemplate> createAccessorFunctionOrTemplate<v8::FunctionTemplate>(v8::Isolate* isolate, v8::FunctionCallback callback, V8DOMConfiguration::FastAccessorBuilderCallback fastCallback, V8DOMConfiguration::PrivatePropertyCallback cacheProperty, v8::Local<v8::Value> data, v8::Local<v8::Signature> signature, int length)
haraken 2016/09/20 14:15:03 cachedAccessorCallback ?
{
v8::Local<v8::FunctionTemplate> functionTemplate;
if (callback) {
@@ -104,7 +105,12 @@ v8::Local<v8::FunctionTemplate> createAccessorFunctionOrTemplate<v8::FunctionTem
DCHECK(fab);
functionTemplate = v8::FunctionTemplate::NewWithFastHandler(isolate, callback, fab, data, signature, length);
} else {
- functionTemplate = v8::FunctionTemplate::New(isolate, callback, data, signature, length);
+ if (cacheProperty) {
+ functionTemplate = v8::FunctionTemplate::NewWithCache(isolate, callback,
+ cacheProperty(isolate), data, signature, length);
+ } else {
+ functionTemplate = v8::FunctionTemplate::New(isolate, callback, data, signature, length);
+ }
}
if (!functionTemplate.IsEmpty()) {
@@ -116,12 +122,12 @@ v8::Local<v8::FunctionTemplate> createAccessorFunctionOrTemplate<v8::FunctionTem
}
template <>
-v8::Local<v8::Function> createAccessorFunctionOrTemplate<v8::Function>(v8::Isolate* isolate, v8::FunctionCallback callback, V8DOMConfiguration::FastAccessorBuilderCallback, v8::Local<v8::Value> data, v8::Local<v8::Signature> signature, int length)
+v8::Local<v8::Function> createAccessorFunctionOrTemplate<v8::Function>(v8::Isolate* isolate, v8::FunctionCallback callback, V8DOMConfiguration::FastAccessorBuilderCallback, V8DOMConfiguration::PrivatePropertyCallback, v8::Local<v8::Value> data, v8::Local<v8::Signature> signature, int length)
{
if (!callback)
return v8::Local<v8::Function>();
- v8::Local<v8::FunctionTemplate> functionTemplate = createAccessorFunctionOrTemplate<v8::FunctionTemplate>(isolate, callback, nullptr, data, signature, length);
+ v8::Local<v8::FunctionTemplate> functionTemplate = createAccessorFunctionOrTemplate<v8::FunctionTemplate>(isolate, callback, nullptr, nullptr, data, signature, length);
if (functionTemplate.IsEmpty())
return v8::Local<v8::Function>();
@@ -162,8 +168,8 @@ void installAccessorInternal(v8::Isolate* isolate, v8::Local<ObjectOrTemplate> i
if (accessor.propertyLocationConfiguration &
(V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) {
- v8::Local<FunctionOrTemplate> getter = createAccessorFunctionOrTemplate<FunctionOrTemplate>(isolate, getterCallback, fastGetterCallback, data, signature, 0);
- v8::Local<FunctionOrTemplate> setter = createAccessorFunctionOrTemplate<FunctionOrTemplate>(isolate, setterCallback, nullptr, data, signature, 1);
+ v8::Local<FunctionOrTemplate> getter = createAccessorFunctionOrTemplate<FunctionOrTemplate>(isolate, getterCallback, fastGetterCallback, accessor.cachePropertyCallback, data, signature, 0);
+ v8::Local<FunctionOrTemplate> setter = createAccessorFunctionOrTemplate<FunctionOrTemplate>(isolate, setterCallback, nullptr, 0, data, signature, 1);
if (accessor.propertyLocationConfiguration & V8DOMConfiguration::OnInstance)
instanceOrTemplate->SetAccessorProperty(name, getter, setter, static_cast<v8::PropertyAttribute>(accessor.attribute), static_cast<v8::AccessControl>(accessor.settings));
if (accessor.propertyLocationConfiguration & V8DOMConfiguration::OnPrototype)
@@ -173,8 +179,8 @@ void installAccessorInternal(v8::Isolate* isolate, v8::Local<ObjectOrTemplate> i
// Attributes installed on the interface object must be static
// attributes, so no need to specify a signature, i.e. no need to do
// type check against a holder.
- v8::Local<FunctionOrTemplate> getter = createAccessorFunctionOrTemplate<FunctionOrTemplate>(isolate, getterCallback, fastGetterCallback, data, v8::Local<v8::Signature>(), 0);
- v8::Local<FunctionOrTemplate> setter = createAccessorFunctionOrTemplate<FunctionOrTemplate>(isolate, setterCallback, nullptr, data, v8::Local<v8::Signature>(), 1);
+ v8::Local<FunctionOrTemplate> getter = createAccessorFunctionOrTemplate<FunctionOrTemplate>(isolate, getterCallback, fastGetterCallback, 0, data, v8::Local<v8::Signature>(), 0);
+ v8::Local<FunctionOrTemplate> setter = createAccessorFunctionOrTemplate<FunctionOrTemplate>(isolate, setterCallback, nullptr, 0, data, v8::Local<v8::Signature>(), 1);
interfaceOrTemplate->SetAccessorProperty(name, getter, setter, static_cast<v8::PropertyAttribute>(accessor.attribute), static_cast<v8::AccessControl>(accessor.settings));
}
}

Powered by Google App Engine
This is Rietveld 408576698