Changeset 245213 in webkit
- Timestamp:
- May 12, 2019 12:43:16 PM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/CMakeLists.txt
r244950 r245213 964 964 runtime/SymbolPrototype.h 965 965 runtime/SymbolTable.h 966 runtime/SymbolTableOrScopeDepth.h 966 967 runtime/TemplateObjectDescriptor.h 967 968 runtime/TestRunnerUtils.h -
trunk/Source/JavaScriptCore/ChangeLog
r245203 r245213 1 2019-05-12 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Compact generator code's bytecode size 4 https://bugs.webkit.org/show_bug.cgi?id=197822 5 6 Reviewed by Michael Saboff. 7 8 op_put_to_scope's symbolTableOrScopeDepth is represented as int. This was OK for the old bytecode format since 9 VirtualRegister / scope depth can be represented by int anyway. But it is problematic now since only int8_t range 10 will be represented in narrow bytecode. When this field is used for symbol table constant index, it is always 11 larger than FirstConstantRegisterIndex. So it always exceeds the range of int8_t, and results in wide bytecode. 12 It makes all generator's op_put_to_scope wide bytecode. 13 14 In this patch, we introduce a new (logically) union type SymbolTableOrScopeDepth. It holds unsigned value, and we store the 15 SymbolTableConstantIndex - FirstConstantRegisterIndex in this unsigned value to make op_put_to_scope narrow bytecode. 16 17 * CMakeLists.txt: 18 * JavaScriptCore.xcodeproj/project.pbxproj: 19 * bytecode/BytecodeGeneratorification.cpp: 20 (JSC::BytecodeGeneratorification::run): 21 * bytecode/BytecodeList.rb: 22 * bytecode/CodeBlock.cpp: 23 (JSC::CodeBlock::finishCreation): 24 * bytecode/Fits.h: 25 * bytecompiler/BytecodeGenerator.cpp: 26 (JSC::BytecodeGenerator::BytecodeGenerator): 27 (JSC::BytecodeGenerator::emitProfileType): 28 (JSC::BytecodeGenerator::emitPutToScope): 29 (JSC::BytecodeGenerator::localScopeDepth const): 30 * bytecompiler/BytecodeGenerator.h: 31 * runtime/SymbolTableOrScopeDepth.h: Added. 32 (JSC::SymbolTableOrScopeDepth::symbolTable): 33 (JSC::SymbolTableOrScopeDepth::scopeDepth): 34 (JSC::SymbolTableOrScopeDepth::raw): 35 (JSC::SymbolTableOrScopeDepth::symbolTable const): 36 (JSC::SymbolTableOrScopeDepth::scopeDepth const): 37 (JSC::SymbolTableOrScopeDepth::raw const): 38 (JSC::SymbolTableOrScopeDepth::dump const): 39 (JSC::SymbolTableOrScopeDepth::SymbolTableOrScopeDepth): 40 1 41 2019-05-10 Saam barati <sbarati@apple.com> 2 42 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r244950 r245213 1743 1743 DEA7E2451BBC677F00D78440 /* JSTypedArrayViewPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 53917E7C1B791106000EBD33 /* JSTypedArrayViewPrototype.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1744 1744 E124A8F70E555775003091F1 /* OpaqueJSString.h in Headers */ = {isa = PBXBuildFile; fileRef = E124A8F50E555775003091F1 /* OpaqueJSString.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1745 E31179AA2288386100514B2C /* SymbolTableOrScopeDepth.h in Headers */ = {isa = PBXBuildFile; fileRef = E31179A92288385D00514B2C /* SymbolTableOrScopeDepth.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1745 1746 E31618131EC5FE170006A218 /* DOMAnnotation.h in Headers */ = {isa = PBXBuildFile; fileRef = E31618101EC5FE080006A218 /* DOMAnnotation.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1746 1747 E31618151EC5FE270006A218 /* DOMAttributeGetterSetter.h in Headers */ = {isa = PBXBuildFile; fileRef = E31618121EC5FE080006A218 /* DOMAttributeGetterSetter.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4722 4723 E18E3A570DF9278C00D90B34 /* VM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = VM.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 4723 4724 E30677971B8BC6F5003F87F0 /* ModuleLoader.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = ModuleLoader.js; sourceTree = "<group>"; }; 4725 E31179A92288385D00514B2C /* SymbolTableOrScopeDepth.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SymbolTableOrScopeDepth.h; sourceTree = "<group>"; }; 4724 4726 E31618101EC5FE080006A218 /* DOMAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMAnnotation.h; sourceTree = "<group>"; }; 4725 4727 E31618111EC5FE080006A218 /* DOMAttributeGetterSetter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMAttributeGetterSetter.cpp; sourceTree = "<group>"; }; … … 7300 7302 0F919D2715856770004A4E7D /* SymbolTable.cpp */, 7301 7303 14A396A60CD2933100B5B4FF /* SymbolTable.h */, 7304 E31179A92288385D00514B2C /* SymbolTableOrScopeDepth.h */, 7302 7305 BDB4B5E099CD4C1BB3C1CF05 /* TemplateObjectDescriptor.cpp */, 7303 7306 70ECA6041AFDBEA200449739 /* TemplateObjectDescriptor.h */, … … 9858 9861 996B73281BDA08EF00331B84 /* SymbolPrototype.lut.h in Headers */, 9859 9862 BC18C46B0E16F5CD00B34460 /* SymbolTable.h in Headers */, 9863 E31179AA2288386100514B2C /* SymbolTableOrScopeDepth.h in Headers */, 9860 9864 0FD79A2D1EBBBDBB00DA88D3 /* Synchronousness.h in Headers */, 9861 9865 0F1FB38F1E173A6700A9BE50 /* SynchronousStopTheWorldMutatorScheduler.h in Headers */, -
trunk/Source/JavaScriptCore/bytecode/BytecodeGeneratorification.cpp
r244915 r245213 253 253 operand, // value 254 254 GetPutInfo(DoNotThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization), // info 255 m_generatorFrameSymbolTableIndex, // symbol table constant index255 SymbolTableOrScopeDepth::symbolTable(VirtualRegister { m_generatorFrameSymbolTableIndex }), // symbol table constant index 256 256 storage.scopeOffset.offset() // scope offset 257 257 ); -
trunk/Source/JavaScriptCore/bytecode/BytecodeList.rb
r243127 r245213 51 51 :StructureChain, 52 52 :SymbolTable, 53 :SymbolTableOrScopeDepth, 53 54 :ToThisStatus, 54 55 :TypeLocation, … … 882 883 # $begin: :private, 883 884 getPutInfo: GetPutInfo, 884 symbolTableOrScopeDepth: int,885 symbolTableOrScopeDepth: SymbolTableOrScopeDepth, 885 886 offset: unsigned, 886 887 }, … … 978 979 args: { 979 980 targetVirtualRegister: VirtualRegister, 980 symbolTableOrScopeDepth: int,981 symbolTableOrScopeDepth: SymbolTableOrScopeDepth, 981 982 flag: ProfileTypeBytecodeFlag, 982 983 identifier?: unsigned, -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r245050 r245213 644 644 // Only do watching if the property we're putting to is not anonymous. 645 645 if (bytecode.m_var != UINT_MAX) { 646 SymbolTable* symbolTable = jsCast<SymbolTable*>(getConstant(bytecode.m_symbolTableOrScopeDepth ));646 SymbolTable* symbolTable = jsCast<SymbolTable*>(getConstant(bytecode.m_symbolTableOrScopeDepth.symbolTable().offset())); 647 647 const Identifier& ident = identifier(bytecode.m_var); 648 648 ConcurrentJSLocker locker(symbolTable->m_lock); … … 658 658 const Identifier& ident = identifier(bytecode.m_var); 659 659 metadata.m_watchpointSet = nullptr; 660 ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), bytecode.m_symbolTableOrScopeDepth , scope, ident, Put, bytecode.m_getPutInfo.resolveType(), bytecode.m_getPutInfo.initializationMode());660 ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), bytecode.m_symbolTableOrScopeDepth.scopeDepth(), scope, ident, Put, bytecode.m_getPutInfo.resolveType(), bytecode.m_getPutInfo.initializationMode()); 661 661 RETURN_IF_EXCEPTION(throwScope, false); 662 662 … … 688 688 case ProfileTypeBytecodeClosureVar: { 689 689 const Identifier& ident = identifier(bytecode.m_identifier); 690 unsigned localScopeDepth = bytecode.m_symbolTableOrScopeDepth ;690 unsigned localScopeDepth = bytecode.m_symbolTableOrScopeDepth.scopeDepth(); 691 691 // Even though type profiling may be profiling either a Get or a Put, we can always claim a Get because 692 692 // we're abstractly "read"ing from a JSScope. … … 712 712 } 713 713 case ProfileTypeBytecodeLocallyResolved: { 714 int symbolTableIndex = bytecode.m_symbolTableOrScopeDepth ;714 int symbolTableIndex = bytecode.m_symbolTableOrScopeDepth.symbolTable().offset(); 715 715 SymbolTable* symbolTable = jsCast<SymbolTable*>(getConstant(symbolTableIndex)); 716 716 const Identifier& ident = identifier(bytecode.m_identifier); -
trunk/Source/JavaScriptCore/bytecode/Fits.h
r240138 r245213 34 34 #include "ResultType.h" 35 35 #include "SpecialPointer.h" 36 #include "SymbolTableOrScopeDepth.h" 36 37 #include "VirtualRegister.h" 37 38 #include <type_traits> … … 130 131 return VirtualRegister { (i - s_firstConstantIndex) + FirstConstantRegisterIndex }; 131 132 return VirtualRegister { i }; 133 } 134 }; 135 136 template<> 137 struct Fits<SymbolTableOrScopeDepth, OpcodeSize::Narrow> { 138 static bool check(SymbolTableOrScopeDepth u) 139 { 140 return u.raw() <= UINT8_MAX; 141 } 142 143 static uint8_t convert(SymbolTableOrScopeDepth u) 144 { 145 ASSERT(check(u)); 146 return static_cast<uint8_t>(u.raw()); 147 } 148 149 static SymbolTableOrScopeDepth convert(uint8_t u) 150 { 151 return SymbolTableOrScopeDepth::raw(u); 132 152 } 133 153 }; -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r245047 r245213 552 552 functionSymbolTable->set(NoLockingNecessary, name, entry); 553 553 } 554 OpPutToScope::emit(this, m_lexicalEnvironmentRegister, UINT_MAX, virtualRegisterForArgument(1 + i), GetPutInfo(ThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization), symbolTableConstantIndex, offset.offset());554 OpPutToScope::emit(this, m_lexicalEnvironmentRegister, UINT_MAX, virtualRegisterForArgument(1 + i), GetPutInfo(ThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization), SymbolTableOrScopeDepth::symbolTable(VirtualRegister { symbolTableConstantIndex }), offset.offset()); 555 555 } 556 556 … … 590 590 functionSymbolTable->set(NoLockingNecessary, name, SymbolTableEntry(VarOffset(offset))); 591 591 592 OpPutToScope::emit(this, m_lexicalEnvironmentRegister, addConstant(ident), virtualRegisterForArgument(1 + i), GetPutInfo(ThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization), symbolTableConstantIndex, offset.offset());592 OpPutToScope::emit(this, m_lexicalEnvironmentRegister, addConstant(ident), virtualRegisterForArgument(1 + i), GetPutInfo(ThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization), SymbolTableOrScopeDepth::symbolTable(VirtualRegister { symbolTableConstantIndex }), offset.offset()); 593 593 } 594 594 } … … 1804 1804 return; 1805 1805 1806 OpProfileType::emit(this, registerToProfile, 0, flag, { }, resolveType());1806 OpProfileType::emit(this, registerToProfile, { }, flag, { }, resolveType()); 1807 1807 1808 1808 // Don't emit expression info for this version of profile type. This generally means … … 1824 1824 return; 1825 1825 1826 OpProfileType::emit(this, registerToProfile, 0, flag, { }, resolveType());1826 OpProfileType::emit(this, registerToProfile, { }, flag, { }, resolveType()); 1827 1827 emitTypeProfilerExpressionInfo(startDivot, endDivot); 1828 1828 } … … 1837 1837 1838 1838 ProfileTypeBytecodeFlag flag; 1839 intsymbolTableOrScopeDepth;1839 SymbolTableOrScopeDepth symbolTableOrScopeDepth; 1840 1840 if (var.local() || var.offset().isScope()) { 1841 1841 flag = ProfileTypeBytecodeLocallyResolved; 1842 1842 ASSERT(var.symbolTableConstantIndex()); 1843 symbolTableOrScopeDepth = var.symbolTableConstantIndex();1843 symbolTableOrScopeDepth = SymbolTableOrScopeDepth::symbolTable(VirtualRegister { var.symbolTableConstantIndex() }); 1844 1844 } else { 1845 1845 flag = ProfileTypeBytecodeClosureVar; 1846 symbolTableOrScopeDepth = localScopeDepth();1846 symbolTableOrScopeDepth = SymbolTableOrScopeDepth::scopeDepth(localScopeDepth()); 1847 1847 } 1848 1848 … … 2513 2513 case VarKind::Invalid: { 2514 2514 GetPutInfo getPutInfo(0); 2515 int scopeDepth;2515 SymbolTableOrScopeDepth symbolTableOrScopeDepth; 2516 2516 ScopeOffset offset; 2517 2517 if (variable.offset().isScope()) { 2518 2518 offset = variable.offset().scopeOffset(); 2519 2519 getPutInfo = GetPutInfo(resolveMode, LocalClosureVar, initializationMode); 2520 s copeDepth = variable.symbolTableConstantIndex();2520 symbolTableOrScopeDepth = SymbolTableOrScopeDepth::symbolTable(VirtualRegister { variable.symbolTableConstantIndex() }); 2521 2521 } else { 2522 2522 ASSERT(resolveType() != LocalClosureVar); 2523 2523 getPutInfo = GetPutInfo(resolveMode, resolveType(), initializationMode); 2524 s copeDepth = localScopeDepth();2525 } 2526 OpPutToScope::emit(this, scope, addConstant(variable.ident()), value, getPutInfo, s copeDepth, !!offset ? offset.offset() : 0);2524 symbolTableOrScopeDepth = SymbolTableOrScopeDepth::scopeDepth(localScopeDepth()); 2525 } 2526 OpPutToScope::emit(this, scope, addConstant(variable.ident()), value, getPutInfo, symbolTableOrScopeDepth, !!offset ? offset.offset() : 0); 2527 2527 m_codeBlock->addPropertyAccessInstruction(m_lastInstruction.offset()); 2528 2528 return value; … … 3744 3744 } 3745 3745 3746 intBytecodeGenerator::localScopeDepth() const3746 unsigned BytecodeGenerator::localScopeDepth() const 3747 3747 { 3748 3748 return m_localScopeDepth; -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r245047 r245213 1236 1236 SegmentedVector<LabelScope, 32> m_labelScopes; 1237 1237 unsigned m_finallyDepth { 0 }; 1238 intm_localScopeDepth { 0 };1238 unsigned m_localScopeDepth { 0 }; 1239 1239 const CodeType m_codeType; 1240 1240 1241 intlocalScopeDepth() const;1241 unsigned localScopeDepth() const; 1242 1242 void pushLocalControlFlowScope(); 1243 1243 void popLocalControlFlowScope();
Note: See TracChangeset
for help on using the changeset viewer.