Changeset 126004 in webkit
- Timestamp:
- Aug 20, 2012 12:47:27 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r126002 r126004 1 2012-08-20 Kentaro Hara <haraken@chromium.org> 2 3 [V8] Move V8Proxy::newInstance() to V8ObjectConstructor 4 https://bugs.webkit.org/show_bug.cgi?id=94443 5 6 Reviewed by Adam Barth. 7 8 To kill V8Proxy, this patch moves V8Proxy::newInstance() to 9 V8ObjectConstructor::newInstanceInFrame(). 10 In addition, this patch does the following things: 11 12 - For consistency with V8ObjectConstructor::newInstanceInFrame(), 13 this patch inserts an if(v8::V8::IsDead()) check to just after 14 Function::NewInstance(). The check is done by V8Binding::assertIfV8IsDead(). 15 16 - To avoid #include circular dependency, this patch de-inline 17 V8ObjectConstructor::newInstance()s. I didn't observe any perf regression. 18 I don't think these methods are worth being inlined, because 19 these methods call Function::NewInstance(), which is not inlined 20 and calls a bunch of heavy mehtods in V8. 21 22 No tests. No change in behavior. 23 24 * bindings/v8/NPV8Object.cpp: 25 (_NPN_Construct): 26 * bindings/v8/V8Binding.cpp: 27 (WebCore::assertIfV8IsDead): 28 (WebCore): 29 * bindings/v8/V8Binding.h: 30 (WebCore): 31 * bindings/v8/V8ObjectConstructor.cpp: 32 (WebCore::V8ObjectConstructor::newInstance): 33 (WebCore): 34 (WebCore::V8ObjectConstructor::newInstanceInFrame): 35 * bindings/v8/V8ObjectConstructor.h: 36 (WebCore): 37 (V8ObjectConstructor): 38 * bindings/v8/V8Proxy.cpp: 39 (WebCore::V8Proxy::runScript): 40 (WebCore::V8Proxy::instrumentedCallFunction): 41 1 42 2012-08-20 Kentaro Hara <haraken@chromium.org> 2 43 -
trunk/Source/WebCore/bindings/v8/NPV8Object.cpp
r125998 r126004 592 592 v8::Handle<v8::Function> ctor(v8::Function::Cast(*ctorObj)); 593 593 if (!ctor->IsNull()) { 594 V8Proxy* proxy = toV8Proxy(npObject); 595 ASSERT(proxy); 596 594 Frame* frame = object->rootObject->frame(); 595 ASSERT(frame); 597 596 OwnArrayPtr<v8::Handle<v8::Value> > argv = createValueListFromVariantArgs(arguments, argumentCount, npObject); 598 resultObject = proxy->newInstance(ctor, argumentCount, argv.get());597 resultObject = V8ObjectConstructor::newInstanceInDocument(ctor, argumentCount, argv.get(), frame ? frame->document() : 0); 599 598 } 600 599 -
trunk/Source/WebCore/bindings/v8/V8Binding.cpp
r125995 r126004 382 382 } 383 383 384 void crashIfV8IsDead() 385 { 386 if (v8::V8::IsDead()) { 387 // FIXME: We temporarily deal with V8 internal error situations 388 // such as out-of-memory by crashing the renderer. 389 CRASH(); 390 } 391 } 392 384 393 } // namespace WebCore -
trunk/Source/WebCore/bindings/v8/V8Binding.h
r125995 r126004 369 369 PassRefPtr<DOMStringList> toDOMStringList(v8::Handle<v8::Value>); 370 370 371 void crashIfV8IsDead(); 372 371 373 class V8ParameterBase { 372 374 public: -
trunk/Source/WebCore/bindings/v8/V8ObjectConstructor.cpp
r125995 r126004 26 26 #include "V8ObjectConstructor.h" 27 27 28 #include "Frame.h" 28 29 #include "V8Binding.h" 30 #include "V8RecursionScope.h" 31 32 #if PLATFORM(CHROMIUM) 33 #include "TraceEvent.h" 34 #endif 29 35 30 36 namespace WebCore { 37 38 v8::Local<v8::Object> V8ObjectConstructor::newInstance(v8::Handle<v8::Function> function) 39 { 40 if (function.IsEmpty()) 41 return v8::Local<v8::Object>(); 42 ConstructorMode constructorMode; 43 V8RecursionScope::MicrotaskSuppression scope; 44 v8::Local<v8::Object> result = function->NewInstance(); 45 crashIfV8IsDead(); 46 return result; 47 } 48 49 v8::Local<v8::Object> V8ObjectConstructor::newInstance(v8::Handle<v8::ObjectTemplate> objectTemplate) 50 { 51 if (objectTemplate.IsEmpty()) 52 return v8::Local<v8::Object>(); 53 ConstructorMode constructorMode; 54 V8RecursionScope::MicrotaskSuppression scope; 55 v8::Local<v8::Object> result = objectTemplate->NewInstance(); 56 crashIfV8IsDead(); 57 return result; 58 } 59 60 v8::Local<v8::Object> V8ObjectConstructor::newInstance(v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[]) 61 { 62 if (function.IsEmpty()) 63 return v8::Local<v8::Object>(); 64 ConstructorMode constructorMode; 65 V8RecursionScope::MicrotaskSuppression scope; 66 v8::Local<v8::Object> result = function->NewInstance(argc, argv); 67 crashIfV8IsDead(); 68 return result; 69 } 70 71 v8::Local<v8::Object> V8ObjectConstructor::newInstanceInDocument(v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[], Document* document) 72 { 73 #if PLATFORM(CHROMIUM) 74 TRACE_EVENT0("v8", "v8.newInstance"); 75 #endif 76 77 // No artificial limitations on the depth of recursion, see comment in 78 // V8Proxy::callFunction. 79 V8RecursionScope recursionScope(document); 80 v8::Local<v8::Object> result = function->NewInstance(argc, argv); 81 crashIfV8IsDead(); 82 return result; 83 } 31 84 32 85 v8::Handle<v8::Value> V8ObjectConstructor::isValidConstructorMode(const v8::Arguments& args) -
trunk/Source/WebCore/bindings/v8/V8ObjectConstructor.h
r125995 r126004 33 33 34 34 #include "V8PerIsolateData.h" 35 #include "V8RecursionScope.h"36 35 37 36 #include <v8.h> 38 37 39 38 namespace WebCore { 39 40 class Document; 40 41 41 42 class ConstructorMode { … … 67 68 class V8ObjectConstructor { 68 69 public: 69 static inline v8::Local<v8::Object> newInstance(v8::Handle<v8::Function>); 70 static inline v8::Local<v8::Object> newInstance(v8::Handle<v8::ObjectTemplate>); 71 static inline v8::Local<v8::Object> newInstance(v8::Handle<v8::Function>, int argc, v8::Handle<v8::Value> argv[]); 70 static v8::Local<v8::Object> newInstance(v8::Handle<v8::Function>); 71 static v8::Local<v8::Object> newInstance(v8::Handle<v8::ObjectTemplate>); 72 static v8::Local<v8::Object> newInstance(v8::Handle<v8::Function>, int, v8::Handle<v8::Value> argv[]); 73 static v8::Local<v8::Object> newInstanceInDocument(v8::Handle<v8::Function>, int, v8::Handle<v8::Value> argv[], Document*); 72 74 73 75 static v8::Handle<v8::Value> isValidConstructorMode(const v8::Arguments&); 74 76 }; 75 77 76 v8::Local<v8::Object> V8ObjectConstructor::newInstance(v8::Handle<v8::Function> function)77 {78 if (function.IsEmpty())79 return v8::Local<v8::Object>();80 ConstructorMode constructorMode;81 V8RecursionScope::MicrotaskSuppression scope;82 return function->NewInstance();83 }84 85 v8::Local<v8::Object> V8ObjectConstructor::newInstance(v8::Handle<v8::ObjectTemplate> objectTemplate)86 {87 if (objectTemplate.IsEmpty())88 return v8::Local<v8::Object>();89 ConstructorMode constructorMode;90 V8RecursionScope::MicrotaskSuppression scope;91 return objectTemplate->NewInstance();92 }93 94 v8::Local<v8::Object> V8ObjectConstructor::newInstance(v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[])95 {96 if (function.IsEmpty())97 return v8::Local<v8::Object>();98 ConstructorMode constructorMode;99 V8RecursionScope::MicrotaskSuppression scope;100 return function->NewInstance(argc, argv);101 }102 103 78 } // namespace WebCore 104 79 -
trunk/Source/WebCore/bindings/v8/V8Proxy.cpp
r126002 r126004 106 106 } 107 107 108 static void handleFatalErrorInV8()109 {110 // FIXME: We temporarily deal with V8 internal error situations111 // such as out-of-memory by crashing the renderer.112 CRASH();113 }114 115 108 static v8::Local<v8::Value> handleMaxRecursionDepthExceeded() 116 109 { … … 263 256 return v8::Local<v8::Value>(); 264 257 265 if (v8::V8::IsDead()) 266 handleFatalErrorInV8(); 267 258 crashIfV8IsDead(); 268 259 return result; 269 260 } … … 321 312 322 313 InspectorInstrumentation::didCallFunction(cookie); 323 324 if (v8::V8::IsDead()) 325 handleFatalErrorInV8(); 326 327 return result; 328 } 329 330 v8::Local<v8::Value> V8Proxy::newInstance(v8::Handle<v8::Function> constructor, int argc, v8::Handle<v8::Value> args[]) 331 { 332 #if PLATFORM(CHROMIUM) 333 TRACE_EVENT0("v8", "v8.newInstance"); 334 #endif 335 336 // No artificial limitations on the depth of recursion, see comment in 337 // V8Proxy::callFunction. 338 v8::Local<v8::Value> result; 339 { 340 V8RecursionScope recursionScope(frame() ? frame()->document() : 0); 341 result = constructor->NewInstance(argc, args); 342 } 343 344 if (v8::V8::IsDead()) 345 handleFatalErrorInV8(); 346 314 crashIfV8IsDead(); 347 315 return result; 348 316 }
Note: See TracChangeset
for help on using the changeset viewer.