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

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

Issue 2335203006: Add [CachedAccessor] attribute to cache (almost) constant accessors (window.document). (Closed)
Patch Set: Pre-review nits 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/WindowProxy.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp
index 6e8dbc7ca9c56d4b19ff438aa396fe8e1ff3c2c9..3c85f87abf4d887072ab97e29316642efc181fa9 100644
--- a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp
@@ -65,6 +65,7 @@
#include "wtf/StringExtras.h"
#include "wtf/text/CString.h"
#include <algorithm>
+#include <map>
#include <utility>
#include <v8-debug.h>
#include <v8.h>
@@ -410,9 +411,13 @@ void WindowProxy::updateDocumentProperty()
checkDocumentWrapper(m_document.newLocal(m_isolate), frame->document());
ASSERT(documentWrapper->IsObject());
- // TODO(jochen): Don't replace the accessor with a data value. We need a way to tell v8 that the accessor's return value won't change after this point.
- if (!v8CallBoolean(context->Global()->ForceSet(context, v8AtomicString(m_isolate, "document"), documentWrapper, static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete))))
- return;
+
+ // Update cache.
+ v8::Local<v8::Private> priv = cachedAccessors().at("Window#document").Get(m_isolate);
Yuki 2016/09/15 08:17:34 Can you use V8PrivateProperty? I think std::map a
Alfonso 2016/09/16 14:21:48 Done.
+
+ // TODO(peterssen): This should be probably constant.
+ // static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)
+ CHECK(context->Global()->ForceSet(context, v8::Private::AsSymbol(priv), documentWrapper).FromJust());
jochen (gone - plz use gerrit) 2016/09/15 08:20:51 why forceset?
Alfonso 2016/09/16 14:21:47 Done.
}
void WindowProxy::updateActivityLogger()

Powered by Google App Engine
This is Rietveld 408576698