Changeset 208028 in webkit
- Timestamp:
- Oct 27, 2016 8:56:50 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r208026 r208028 1 2016-10-27 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [DOM] Add JSEventType 4 https://bugs.webkit.org/show_bug.cgi?id=164096 5 6 Reviewed by Darin Adler. 7 8 Event is inherited by many Event classes. But, Event's accessors and interfaces are 9 frequently called. For example, event.{type, target, srcElement} for accessors. And 10 event.stopPropagation() and event.preventDefault() functions. 11 12 However, since the user-visible event instance is typically the instance of the subclass, 13 jsDynamicCast<JSEvent*>() walks several classes before it succeeds. It is costly. 14 15 In this patch, we add a new WebCore JSType JSEventType for JSEvent and add a new 16 function jsEventCast. That supports a super fast cast operation. And it paves the way 17 for implementing DOM accessors of Event in DOMJIT. 18 19 No behavior change. 20 21 * WebCore.xcodeproj/project.pbxproj: 22 * bindings/js/JSDOMWrapper.h: 23 * bindings/js/JSEventCustom.h: Added. 24 (WebCore::jsEventCast): 25 * bindings/scripts/CodeGeneratorJS.pm: 26 (GetJSTypeForNode): 27 (GenerateHeader): 28 (GetCastingHelperForThisObject): 29 * bindings/scripts/test/JS/JSTestEventConstructor.h: 30 (WebCore::JSTestEventConstructor::createStructure): 31 * dom/Event.idl: 32 * domjit/DOMJITHelpers.h: 33 (WebCore::DOMJIT::branchIfEvent): 34 (WebCore::DOMJIT::branchIfNotEvent): 35 1 36 2016-10-27 Simon Fraser <simon.fraser@apple.com> 2 37 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r208010 r208028 6202 6202 E3150EA61DA7219000194012 /* JSNodeDOMJIT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3AFA9641DA6E908002861BD /* JSNodeDOMJIT.cpp */; }; 6203 6203 E3150EA71DA7219300194012 /* DOMJITHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = E3150EA51DA7218D00194012 /* DOMJITHelpers.h */; }; 6204 E3565B7B1DC2D6C900217DBD /* JSEventCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = E34EE49F1DC2D57500EAA9D3 /* JSEventCustom.h */; settings = {ATTRIBUTES = (Private, ); }; }; 6204 6205 E35CA14D1DBC3A3F00F83516 /* DOMJITAbstractHeapRepository.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E35CA14B1DBC3A3C00F83516 /* DOMJITAbstractHeapRepository.cpp */; }; 6205 6206 E35CA14E1DBC3A4200F83516 /* DOMJITAbstractHeapRepository.h in Headers */ = {isa = PBXBuildFile; fileRef = E35CA14C1DBC3A3C00F83516 /* DOMJITAbstractHeapRepository.h */; }; … … 14032 14033 E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRegistry.h; sourceTree = "<group>"; }; 14033 14034 E3150EA51DA7218D00194012 /* DOMJITHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITHelpers.h; sourceTree = "<group>"; }; 14035 E34EE49F1DC2D57500EAA9D3 /* JSEventCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEventCustom.h; sourceTree = "<group>"; }; 14034 14036 E35CA14B1DBC3A3C00F83516 /* DOMJITAbstractHeapRepository.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMJITAbstractHeapRepository.cpp; sourceTree = "<group>"; }; 14035 14037 E35CA14C1DBC3A3C00F83516 /* DOMJITAbstractHeapRepository.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITAbstractHeapRepository.h; sourceTree = "<group>"; }; … … 21610 21612 F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */, 21611 21613 F3D461471161D53200CA0D09 /* JSErrorHandler.h */, 21614 E34EE49F1DC2D57500EAA9D3 /* JSEventCustom.h */, 21612 21615 BC60901E0E91B8EC000C68B5 /* JSEventTargetCustom.cpp */, 21613 21616 46B63F6B1C6E8CDF002E914B /* JSEventTargetCustom.h */, … … 25507 25510 1C81B95C0E97330800266E07 /* InspectorClient.h in Headers */, 25508 25511 1C81B95A0E97330800266E07 /* InspectorController.h in Headers */, 25512 E3565B7B1DC2D6C900217DBD /* JSEventCustom.h in Headers */, 25509 25513 82AB1744124B99EC00C5069D /* InspectorCSSAgent.h in Headers */, 25510 25514 4A9CC82116BF9BB400EC645A /* InspectorCSSOMWrappers.h in Headers */, -
trunk/Source/WebCore/bindings/js/JSDOMWrapper.h
r207381 r208028 31 31 class ScriptExecutionContext; 32 32 33 // We encode Node type into JSType. The format is the following. 34 // offset | 7 | 6 5 4 | 3 2 1 0 | 35 // value | 1 | Kind | NodeType | 33 // JSC allows us to extend JSType. If the highest bit is set, we can add any Object types and they are 34 // recognized as OtherObj in JSC. And we encode Node type into JSType if the given JSType is subclass of Node. 35 // offset | 7 | 6 | 5 4 | 3 2 1 0 | 36 // value | 1 | 0 | Non-node DOM types | 37 // If the given JSType is a subclass of Node, the format is the following. 38 // offset | 7 | 6 | 5 4 | 3 2 1 0 | 39 // value | 1 | 1 | Kind | NodeType | 36 40 static const uint8_t JSNodeTypeMask = 0b00001111; 37 41 38 42 static const uint8_t JSDOMWrapperType = 0b10000000; 39 static const uint8_t JSNodeType = 0b10010000; 43 static const uint8_t JSEventType = 0b10000001; 44 static const uint8_t JSNodeType = 0b11000000; 40 45 static const uint8_t JSTextNodeType = JSNodeType | NodeConstants::TEXT_NODE; 41 46 static const uint8_t JSProcessingInstructionNodeType = JSNodeType | NodeConstants::PROCESSING_INSTRUCTION_NODE; … … 46 51 static const uint8_t JSCDATASectionNodeType = JSNodeType | NodeConstants::CDATA_SECTION_NODE; 47 52 static const uint8_t JSAttrNodeType = JSNodeType | NodeConstants::ATTRIBUTE_NODE; 48 static const uint8_t JSElementType = 0b1 0100000 | NodeConstants::ELEMENT_NODE;53 static const uint8_t JSElementType = 0b11010000 | NodeConstants::ELEMENT_NODE; 49 54 50 55 static_assert(JSDOMWrapperType > JSC::LastJSCObjectType, "JSC::JSType offers the highest bit."); -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r208023 r208028 1217 1217 sub GetJSTypeForNode 1218 1218 { 1219 my ($ codeGenerator, $interface) = @_;1219 my ($interface) = @_; 1220 1220 1221 1221 if ($codeGenerator->InheritsInterface($interface, "Document")) { … … 1447 1447 push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags), info());\n"); 1448 1448 } elsif ($codeGenerator->InheritsInterface($interface, "Node")) { 1449 my $type = GetJSTypeForNode($ codeGenerator, $interface);1449 my $type = GetJSTypeForNode($interface); 1450 1450 push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::JSType($type), StructureFlags), info());\n"); 1451 } elsif ($codeGenerator->InheritsInterface($interface, "Event")) { 1452 push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::JSType(JSEventType), StructureFlags), info());\n"); 1451 1453 } else { 1452 1454 push(@headerContent, " return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());\n"); … … 2489 2491 return "jsDocumentCast" if $interfaceName eq "Document"; 2490 2492 return "jsEventTargetCast" if $interfaceName eq "EventTarget"; 2493 return "jsEventCast" if $interfaceName eq "Event"; 2491 2494 return "jsDynamicCast<JS$interfaceName*>"; 2492 2495 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.h
r207715 r208028 45 45 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) 46 46 { 47 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC:: ObjectType, StructureFlags), info());47 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::JSType(JSEventType), StructureFlags), info()); 48 48 } 49 49 -
trunk/Source/WebCore/dom/Event.idl
r207908 r208028 28 28 ExportToWrappedFunction, 29 29 Exposed=(Window,Worker), 30 JSCustomHeader, 30 31 ] interface Event { 31 32 // PhaseType -
trunk/Source/WebCore/domjit/DOMJITHelpers.h
r207999 r208028 99 99 } 100 100 101 inline CCallHelpers::Jump branchIfEvent(CCallHelpers& jit, GPRReg target) 102 { 103 return jit.branchIfType(target, JSC::JSType(JSEventType)); 104 } 105 106 inline CCallHelpers::Jump branchIfNotEvent(CCallHelpers& jit, GPRReg target) 107 { 108 return jit.branchIfNotType(target, JSC::JSType(JSEventType)); 109 } 110 101 111 inline CCallHelpers::Jump branchIfNode(CCallHelpers& jit, GPRReg target) 102 112 {
Note: See TracChangeset
for help on using the changeset viewer.