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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 11 matching lines...) Expand all
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE. 23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "bindings/core/v8/V8PerIsolateData.h" 26 #include "bindings/core/v8/V8PerIsolateData.h"
27 27
28 #include <memory> 28 #include <memory>
29 29
30 #include "bindings/core/v8/DOMDataStore.h" 30 #include "bindings/core/v8/DOMDataStore.h"
31 #include "bindings/core/v8/ScriptSourceCode.h" 31 #include "bindings/core/v8/ScriptSourceCode.h"
32 #include "bindings/core/v8/V8Binding.h"
32 #include "bindings/core/v8/V8HiddenValue.h" 33 #include "bindings/core/v8/V8HiddenValue.h"
33 #include "bindings/core/v8/V8ObjectConstructor.h" 34 #include "bindings/core/v8/V8ObjectConstructor.h"
34 #include "bindings/core/v8/V8PrivateProperty.h" 35 #include "bindings/core/v8/V8PrivateProperty.h"
35 #include "bindings/core/v8/V8ScriptRunner.h" 36 #include "bindings/core/v8/V8ScriptRunner.h"
36 #include "bindings/core/v8/V8ValueCache.h" 37 #include "bindings/core/v8/V8ValueCache.h"
37 #include "platform/ScriptForbiddenScope.h" 38 #include "platform/ScriptForbiddenScope.h"
38 #include "public/platform/Platform.h" 39 #include "public/platform/Platform.h"
39 #include "v8/include/v8-debug.h" 40 #include "v8/include/v8-debug.h"
40 #include "wtf/LeakAnnotations.h" 41 #include "wtf/LeakAnnotations.h"
41 #include "wtf/PtrUtil.h" 42 #include "wtf/PtrUtil.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 183 }
183 184
184 void V8PerIsolateData::setInterfaceTemplate( 185 void V8PerIsolateData::setInterfaceTemplate(
185 const DOMWrapperWorld& world, 186 const DOMWrapperWorld& world,
186 const void* key, 187 const void* key,
187 v8::Local<v8::FunctionTemplate> value) { 188 v8::Local<v8::FunctionTemplate> value) {
188 auto& map = selectInterfaceTemplateMap(world); 189 auto& map = selectInterfaceTemplateMap(world);
189 map.insert(key, v8::Eternal<v8::FunctionTemplate>(isolate(), value)); 190 map.insert(key, v8::Eternal<v8::FunctionTemplate>(isolate(), value));
190 } 191 }
191 192
193 const v8::Eternal<v8::Name>* V8PerIsolateData::findOrCreateKeys(
194 const void* lookupKey,
195 const char* const keys[],
196 size_t keyCount) {
197 auto it = m_keyMap.find(lookupKey);
198 Vector<v8::Eternal<v8::Name>>* vector = nullptr;
199 if (UNLIKELY(it == m_keyMap.end())) {
200 v8::Isolate* isolate = this->isolate();
201 Vector<v8::Eternal<v8::Name>> newVector(keyCount);
202 std::transform(
203 keys, keys + keyCount, newVector.begin(), [isolate](const char* key) {
204 return v8::Eternal<v8::Name>(isolate, v8AtomicString(isolate, key));
205 });
206 vector = &m_keyMap.set(lookupKey, std::move(newVector)).storedValue->value;
207 } else {
208 vector = &it->value;
209 }
210 DCHECK_EQ(vector->size(), keyCount);
211 return vector->data();
212 }
213
192 v8::Local<v8::Context> V8PerIsolateData::ensureScriptRegexpContext() { 214 v8::Local<v8::Context> V8PerIsolateData::ensureScriptRegexpContext() {
193 if (!m_scriptRegexpScriptState) { 215 if (!m_scriptRegexpScriptState) {
194 LEAK_SANITIZER_DISABLED_SCOPE; 216 LEAK_SANITIZER_DISABLED_SCOPE;
195 v8::Local<v8::Context> context(v8::Context::New(isolate())); 217 v8::Local<v8::Context> context(v8::Context::New(isolate()));
196 m_scriptRegexpScriptState = ScriptState::create( 218 m_scriptRegexpScriptState = ScriptState::create(
197 context, 219 context,
198 DOMWrapperWorld::create(isolate(), DOMWrapperWorld::WorldType::RegExp)); 220 DOMWrapperWorld::create(isolate(), DOMWrapperWorld::WorldType::RegExp));
199 } 221 }
200 return m_scriptRegexpScriptState->context(); 222 return m_scriptRegexpScriptState->context();
201 } 223 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 ScriptWrappableVisitor* current = currentVisitor(); 313 ScriptWrappableVisitor* current = currentVisitor();
292 if (current) 314 if (current)
293 current->performCleanup(); 315 current->performCleanup();
294 316
295 V8PerIsolateData::from(m_isolate)->m_scriptWrappableVisitor.swap( 317 V8PerIsolateData::from(m_isolate)->m_scriptWrappableVisitor.swap(
296 m_savedVisitor); 318 m_savedVisitor);
297 m_isolate->SetEmbedderHeapTracer(currentVisitor()); 319 m_isolate->SetEmbedderHeapTracer(currentVisitor());
298 } 320 }
299 321
300 } // namespace blink 322 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698