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

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

Issue 2751263002: [Bindings] Cache handles for dictionary keys on V8PerIsolateData. (Closed)
Patch Set: const Created 3 years, 9 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/V8PerIsolateData.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp b/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp
index b01fec9de8d90057ffd32f26320064480c86195b..b8df86693089ad7e3dc067cd285907d9eac1f44e 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp
@@ -29,6 +29,7 @@
#include "bindings/core/v8/DOMDataStore.h"
#include "bindings/core/v8/ScriptSourceCode.h"
+#include "bindings/core/v8/V8Binding.h"
#include "bindings/core/v8/V8HiddenValue.h"
#include "bindings/core/v8/V8ObjectConstructor.h"
#include "bindings/core/v8/V8PrivateProperty.h"
@@ -189,6 +190,27 @@ void V8PerIsolateData::setInterfaceTemplate(
map.insert(key, v8::Eternal<v8::FunctionTemplate>(isolate(), value));
}
+const v8::Eternal<v8::Name>* V8PerIsolateData::findOrCreateKeys(
+ const void* lookupKey,
+ const char* const keys[],
+ size_t keyCount) {
+ auto it = m_keyMap.find(lookupKey);
+ Vector<v8::Eternal<v8::Name>>* vector = nullptr;
+ if (UNLIKELY(it == m_keyMap.end())) {
+ v8::Isolate* isolate = this->isolate();
+ Vector<v8::Eternal<v8::Name>> newVector(keyCount);
+ std::transform(
+ keys, keys + keyCount, newVector.begin(), [isolate](const char* key) {
+ return v8::Eternal<v8::Name>(isolate, v8AtomicString(isolate, key));
+ });
+ vector = &m_keyMap.set(lookupKey, std::move(newVector)).storedValue->value;
+ } else {
+ vector = &it->value;
+ }
+ DCHECK_EQ(vector->size(), keyCount);
+ return vector->data();
+}
+
v8::Local<v8::Context> V8PerIsolateData::ensureScriptRegexpContext() {
if (!m_scriptRegexpScriptState) {
LEAK_SANITIZER_DISABLED_SCOPE;

Powered by Google App Engine
This is Rietveld 408576698