Changeset 166765 in webkit
- Timestamp:
- Apr 3, 2014 9:42:21 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r166761 r166765 1 2014-04-03 Andreas Kling <akling@apple.com> 2 3 Fast-path for casting JS wrappers to JSElement. 4 <https://webkit.org/b/131210> 5 6 Add an extended JSType for Element wrappers so we can avoid walking 7 the ClassInfo chain in those bindings as well. 8 9 Generalized the code to select a casting helper in the bindings 10 generator into a function (GetCastingHelperForThisObject.) 11 Updated all the jsDynamicCast call sites to go through this, in case 12 there's an optimized cast available for the desired type. 13 14 Reviewed by Benjamin Poulain. 15 16 * WebCore.xcodeproj/project.pbxproj: 17 * bindings/js/JSDOMWrapper.h: 18 * bindings/js/JSElementCustom.h: Added. 19 (WebCore::jsElementCast): 20 * bindings/js/JSNodeCustom.h: 21 (WebCore::jsNodeCast): 22 * bindings/scripts/CodeGeneratorJS.pm: 23 (GenerateHeader): 24 (GetCastingHelperForThisObject): 25 (GenerateImplementation): 26 * dom/Element.idl: 27 1 28 2014-04-03 Andreas Kling <akling@apple.com> 2 29 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r166752 r166765 4237 4237 AD726FEF16DA11F5003A4E6D /* JSCSSRuleCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = AD726FE916D9F40A003A4E6D /* JSCSSRuleCustom.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4238 4238 ADDF1AD71257CD9A0003A759 /* RenderSVGPath.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDF1AD51257CD9A0003A759 /* RenderSVGPath.h */; }; 4239 ADEC78F818EE5308001315C2 /* JSElementCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = ADEC78F718EE5308001315C2 /* JSElementCustom.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4239 4240 B10B6980140C174000BC1C26 /* WebVTTToken.h in Headers */ = {isa = PBXBuildFile; fileRef = B10B697D140C174000BC1C26 /* WebVTTToken.h */; }; 4240 4241 B10B6981140C174000BC1C26 /* WebVTTTokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B10B697E140C174000BC1C26 /* WebVTTTokenizer.cpp */; }; … … 11347 11348 ADE11F4A18D8311B0078983B /* ElementDescendantIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementDescendantIterator.h; sourceTree = "<group>"; }; 11348 11349 ADE16736181050C300463A2E /* RenderPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderPtr.h; sourceTree = "<group>"; }; 11350 ADEC78F718EE5308001315C2 /* JSElementCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSElementCustom.h; sourceTree = "<group>"; }; 11349 11351 B10B697D140C174000BC1C26 /* WebVTTToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVTTToken.h; sourceTree = "<group>"; }; 11350 11352 B10B697E140C174000BC1C26 /* WebVTTTokenizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebVTTTokenizer.cpp; sourceTree = "<group>"; }; … … 20533 20535 652FBBBB0DE27CB60001D386 /* JSDOMWindowCustom.h */, 20534 20536 BC2ED5540C6B9BD300920BFF /* JSElementCustom.cpp */, 20537 ADEC78F718EE5308001315C2 /* JSElementCustom.h */, 20535 20538 BCEFAF4D0C317E6900FA81F6 /* JSEventCustom.cpp */, 20536 20539 2E7582ED12764F260062628B /* JSFileReaderCustom.cpp */, … … 26216 26219 2E4346500F546A8200B0F1BA /* WorkerMessagingProxy.h in Headers */, 26217 26220 CD52481B18E200ED0008A07D /* DisplaySleepDisabler.h in Headers */, 26221 ADEC78F818EE5308001315C2 /* JSElementCustom.h in Headers */, 26218 26222 E1271A0B0EEEC77A00F61213 /* WorkerNavigator.h in Headers */, 26219 26223 1ABC7109170E5E1B00F9A9D6 /* WorkerNavigatorStorageQuota.h in Headers */, -
trunk/Source/WebCore/bindings/js/JSDOMWrapper.h
r166760 r166765 31 31 32 32 static const uint8_t JSNodeType = JSC::LastJSCObjectType + 1; 33 static const uint8_t JSElementType = JSC::LastJSCObjectType + 2; 33 34 34 35 class JSDOMWrapper : public JSC::JSDestructibleObject { -
trunk/Source/WebCore/bindings/js/JSNodeCustom.h
r166760 r166765 83 83 if (UNLIKELY(!value.isCell())) 84 84 return nullptr; 85 return value.asCell()->type() == JSNodeType ? JSC::jsCast<JSNode*>(value) : nullptr;85 return value.asCell()->type() >= JSNodeType ? JSC::jsCast<JSNode*>(value) : nullptr; 86 86 } 87 87 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r166760 r166765 960 960 if (IsDOMGlobalObject($interface)) { 961 961 push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags), info());\n"); 962 } elsif ($codeGenerator->InheritsInterface($interface, "Element")) { 963 push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::JSType(JSElementType), StructureFlags), info());\n"); 962 964 } elsif ($codeGenerator->InheritsInterface($interface, "Node")) { 963 965 push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::JSType(JSNodeType), StructureFlags), info());\n"); … … 1694 1696 } 1695 1697 1698 sub GetCastingHelperForThisObject 1699 { 1700 my $interface = shift; 1701 1702 if ($interface->name eq "Node") { 1703 return "jsNodeCast"; 1704 } 1705 if ($interface->name eq "Element") { 1706 return "jsElementCast"; 1707 } 1708 return "jsDynamicCast<JS" . $interface->name . "*>"; 1709 } 1710 1696 1711 sub GenerateImplementation 1697 1712 { … … 2133 2148 push(@implContent, " UNUSED_PARAM(slotBase);\n"); 2134 2149 } else { 2135 if ($interfaceName eq "Node") { 2136 push(@implContent, " JSNode* castedThis = jsNodeCast(JSValue::decode(thisValue));\n"); 2137 } else { 2138 push(@implContent, " ${className}* castedThis = jsDynamicCast<$className*>(JSValue::decode(thisValue));\n"); 2139 } 2150 push(@implContent, " ${className}* castedThis = " . GetCastingHelperForThisObject($interface) . "(JSValue::decode(thisValue));\n"); 2140 2151 push(@implContent, " UNUSED_PARAM(slotBase);\n"); 2141 2152 } … … 2355 2366 push(@implContent, " ${className}* domObject = to${className}(JSValue::decode(thisValue));\n"); 2356 2367 } else { 2357 push(@implContent, " ${className}* domObject = jsDynamicCast<${className}*>(JSValue::decode(thisValue));\n") if ConstructorShouldBeOnInstance($interface);2368 push(@implContent, " ${className}* domObject = " . GetCastingHelperForThisObject($interface) . "(JSValue::decode(thisValue));\n") if ConstructorShouldBeOnInstance($interface); 2358 2369 push(@implContent, " ${className}Prototype* domObject = jsDynamicCast<${className}Prototype*>(baseValue);\n") if !ConstructorShouldBeOnInstance($interface); 2359 2370 } … … 2380 2391 push(@implContent, " ${className}* castedThis = to${className}(JSValue::decode(thisValue));\n"); 2381 2392 } else { 2382 push(@implContent, " ${className}* castedThis = jsDynamicCast<${className}*>(JSValue::decode(thisValue));\n");2393 push(@implContent, " ${className}* castedThis = " . GetCastingHelperForThisObject($interface) . "(JSValue::decode(thisValue));\n"); 2383 2394 } 2384 2395 push(@implContent, " if (UNLIKELY(!castedThis)) {\n"); … … 2487 2498 push(@implContent, " ${className}* castedThis = to${className}(JSValue::decode(thisValue));\n"); 2488 2499 } else { 2489 push(@implContent, " ${className}* castedThis = jsDynamicCast<${className}*>(JSValue::decode(thisValue));\n");2500 push(@implContent, " ${className}* castedThis = " . GetCastingHelperForThisObject($interface) . "(JSValue::decode(thisValue));\n"); 2490 2501 } 2491 2502 push(@implContent, " if (UNLIKELY(!castedThis)) {\n"); … … 2722 2733 } else { 2723 2734 push(@implContent, " JSValue thisValue = exec->thisValue();\n"); 2724 push(@implContent, " $className* castedThis = jsDynamicCast<$className*>(thisValue);\n");2735 push(@implContent, " $className* castedThis = " . GetCastingHelperForThisObject($interface) . "(thisValue);\n"); 2725 2736 my $domFunctionName = $function->signature->name; 2726 2737 push(@implContent, " if (UNLIKELY(!castedThis))\n"); -
trunk/Source/WebCore/dom/Element.idl
r164131 r166765 20 20 21 21 [ 22 JSCustomHeader, 22 23 JSGenerateToNativeObject, 23 24 ] interface Element : Node {
Note: See TracChangeset
for help on using the changeset viewer.