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

Side by Side Diff: Source/bindings/core/v8/V8Binding.h

Issue 684763004: bindings: Fixes perf regression by crrev.com/646523004. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added a comment. Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Ericsson AB. All rights reserved. 3 * Copyright (C) 2012 Ericsson AB. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 if (UNLIKELY(!impl)) { 220 if (UNLIKELY(!impl)) {
221 v8SetReturnValueNull(callbackInfo); 221 v8SetReturnValueNull(callbackInfo);
222 return; 222 return;
223 } 223 }
224 if (DOMDataStore::setReturnValueForMainWorldNonTemplate(callbackInfo.GetRetu rnValue(), impl)) 224 if (DOMDataStore::setReturnValueForMainWorldNonTemplate(callbackInfo.GetRetu rnValue(), impl))
225 return; 225 return;
226 v8::Handle<v8::Object> wrapper = impl->wrap(callbackInfo.Holder(), callbackI nfo.GetIsolate()); 226 v8::Handle<v8::Object> wrapper = impl->wrap(callbackInfo.Holder(), callbackI nfo.GetIsolate());
227 v8SetReturnValue(callbackInfo, wrapper); 227 v8SetReturnValue(callbackInfo, wrapper);
228 } 228 }
229 229
230 template<typename CallbackInfo>
231 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, Node* impl)
232 {
233 // Since EventTarget has [Custom=ToV8] and V8EventTarget.h defines its own
234 // v8SetReturnValue family, which are slow, we need to override them with
235 // optimized versions for Node and its subclasses. Without this overload,
236 // v8SetReturnValueForMainWorld for Node would be very slow.
237 //
238 // class hierarchy:
239 // ScriptWrappable <-- EventTarget <--+-- Node <-- ...
240 // +-- Window
241 // overloads:
242 // v8SetReturnValueForMainWorld(ScriptWrappable*)
243 // Optimized and very fast.
244 // v8SetReturnValueForMainWorld(EventTarget*)
245 // Uses custom toV8 function and slow.
246 // v8SetReturnValueForMainWorld(Node*)
247 // Optimized and very fast.
248 // v8SetReturnValueForMainWorld(Window*)
249 // Uses custom toV8 function and slow.
250 v8SetReturnValueForMainWorld(callbackInfo, ScriptWrappable::fromNode(impl));
251 }
252
230 template<typename CallbackInfo, typename T> 253 template<typename CallbackInfo, typename T>
231 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, PassR efPtr<T> impl) 254 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, PassR efPtr<T> impl)
232 { 255 {
233 v8SetReturnValueForMainWorld(callbackInfo, impl.get()); 256 v8SetReturnValueForMainWorld(callbackInfo, impl.get());
234 } 257 }
235 258
236 template<typename CallbackInfo, typename T> 259 template<typename CallbackInfo, typename T>
237 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, RawPt r<T> impl) 260 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, RawPt r<T> impl)
238 { 261 {
239 v8SetReturnValueForMainWorld(callbackInfo, impl.get()); 262 v8SetReturnValueForMainWorld(callbackInfo, impl.get());
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 v8::Local<v8::Value> v8IteratorResult(ScriptState* scriptState, const T& value) 1233 v8::Local<v8::Value> v8IteratorResult(ScriptState* scriptState, const T& value)
1211 { 1234 {
1212 return v8IteratorResult(scriptState->isolate(), V8ValueTraits<T>::toV8Value( value, scriptState->context()->Global(), scriptState->isolate())); 1235 return v8IteratorResult(scriptState->isolate(), V8ValueTraits<T>::toV8Value( value, scriptState->context()->Global(), scriptState->isolate()));
1213 } 1236 }
1214 1237
1215 typedef void (*InstallTemplateFunction)(v8::Handle<v8::FunctionTemplate>, v8::Is olate*); 1238 typedef void (*InstallTemplateFunction)(v8::Handle<v8::FunctionTemplate>, v8::Is olate*);
1216 1239
1217 } // namespace blink 1240 } // namespace blink
1218 1241
1219 #endif // V8Binding_h 1242 #endif // V8Binding_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698