⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 254593 in webkit


Ignore:
Timestamp:
Jan 15, 2020, 11:14:55 AM (7 years ago)
Author:
Alan Coon
Message:

Cherry-pick r254152. rdar://problem/58552854

[JSC] Remove vm accessor in JSVirtualMachine to reduce binary size
​https://bugs.webkit.org/show_bug.cgi?id=205880

Reviewed by Mark Lam.

Objective-C has reflection mechanism. This means that fields, methods, and their types
need to hold its string representations in binary even if we are using release build.
While typical Objective-C class does not have large size of type names, C++ struct / class
has very large one, and putting them in Objective-C method names, parameter types, or fields
makes binary size very large.

By analyzing JavaScriptCore binary, I found that Objective-C method type symbols are taking 200~KB
binary size. (Section objc_methtype: 235081 (addr 0x105e9a3 offset 17164707)). And it is due to
JSC::VM type included in [JSVirtualMachine vm] accessor.

This patch removes this accessor and gets 200KB binary size reduction.

  • API/JSScript.mm: (-[JSScript readCache]): (-[JSScript sourceCode]): (-[JSScript jsSourceCode]): (-[JSScript writeCache:]):
  • API/JSVirtualMachine.mm: (-[JSVirtualMachine JSContextGroupRef]): (-[JSVirtualMachine isWebThreadAware]): (-[JSVirtualMachine vm]): Deleted.
  • API/JSVirtualMachineInternal.h:

git-svn-id: ​https://svn.webkit.org/repository/webkit/trunk@254152 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-609-branch/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-609-branch/Source/JavaScriptCore/API/JSScript.mm

    r247542 r254593  
    168168    Ref<JSC::CachedBytecode> cachedBytecode = JSC::CachedBytecode::create(WTFMove(mappedFile));
    169169
    170     JSC::VM& vm = [m_virtualMachine vm];
     170    JSC::VM& vm = *toJS([m_virtualMachine JSContextGroupRef]);
    171171    JSC::SourceCode sourceCode = [self sourceCode];
    172172    JSC::SourceCodeKey key = m_type == kJSScriptTypeProgram ? sourceCodeKeyForSerializedProgram(vm, sourceCode) : sourceCodeKeyForSerializedModule(vm, sourceCode);
    … …  
    236236- (JSC::SourceCode)sourceCode
    237237{
    238     JSC::VM& vm = [m_virtualMachine vm];
     238    JSC::VM& vm = *toJS([m_virtualMachine JSContextGroupRef]);
    239239    JSC::JSLockHolder locker(vm);
    240240
    … …  
    249249- (JSC::JSSourceCode*)jsSourceCode
    250250{
    251     JSC::VM& vm = [m_virtualMachine vm];
     251    JSC::VM& vm = *toJS([m_virtualMachine JSContextGroupRef]);
    252252    JSC::JSLockHolder locker(vm);
    253253    JSC::JSSourceCode* jsSourceCode = JSC::JSSourceCode::create(vm, [self sourceCode]);
    … …  
    278278    JSC::BytecodeCacheError cacheError;
    279279    JSC::SourceCode sourceCode = [self sourceCode];
     280    JSC::VM& vm = *toJS([m_virtualMachine JSContextGroupRef]);
    280281    switch (m_type) {
    281282    case kJSScriptTypeModule:
    282         m_cachedBytecode = JSC::generateModuleBytecode([m_virtualMachine vm], sourceCode, fd, cacheError);
     283        m_cachedBytecode = JSC::generateModuleBytecode(vm, sourceCode, fd, cacheError);
    283284        break;
    284285    case kJSScriptTypeProgram:
    285         m_cachedBytecode = JSC::generateProgramBytecode([m_virtualMachine vm], sourceCode, fd, cacheError);
     286        m_cachedBytecode = JSC::generateProgramBytecode(vm, sourceCode, fd, cacheError);
    286287        break;
    287288    }
  • branches/safari-609-branch/Source/JavaScriptCore/API/JSVirtualMachine.mm

    r249885 r254593  
    299299#endif // ENABLE(DFG_JIT)
    300300
    301 - (JSC::VM&)vm
    302 {
    303     return *toJS(m_group);
     301- (JSContextGroupRef)JSContextGroupRef
     302{
     303    return m_group;
    304304}
    305305
    306306- (BOOL)isWebThreadAware
    307307{
    308     return [self vm].apiLock().isWebThreadAware();
     308    JSC::VM* vm = toJS(m_group);
     309    return vm->apiLock().isWebThreadAware();
    309310}
    310311
  • branches/safari-609-branch/Source/JavaScriptCore/API/JSVirtualMachineInternal.h

    r247346 r254593  
    4747- (JSContext *)contextForGlobalContextRef:(JSGlobalContextRef)globalContext;
    4848- (void)addContext:(JSContext *)wrapper forGlobalContextRef:(JSGlobalContextRef)globalContext;
    49 - (JSC::VM&)vm;
     49- (BOOL)isWebThreadAware;
    5050
    51 - (BOOL)isWebThreadAware;
     51@property (readonly) JSContextGroupRef JSContextGroupRef;
    5252
    5353@end
  • branches/safari-609-branch/Source/JavaScriptCore/ChangeLog

    r254477 r254593  
     12020-01-14  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r254152. rdar://problem/58552854
     4
     5    [JSC] Remove vm accessor in JSVirtualMachine to reduce binary size
     6    https://bugs.webkit.org/show_bug.cgi?id=205880
     7   
     8    Reviewed by Mark Lam.
     9   
     10    Objective-C has reflection mechanism. This means that fields, methods, and their types
     11    need to hold its string representations in binary even if we are using release build.
     12    While typical Objective-C class does not have large size of type names, C++ struct / class
     13    has very large one, and putting them in Objective-C method names, parameter types, or fields
     14    makes binary size very large.
     15   
     16    By analyzing JavaScriptCore binary, I found that Objective-C method type symbols are taking 200~KB
     17    binary size. (Section __objc_methtype: 235081 (addr 0x105e9a3 offset 17164707)). And it is due to
     18    JSC::VM type included in `[JSVirtualMachine vm]` accessor.
     19   
     20    This patch removes this accessor and gets 200KB binary size reduction.
     21   
     22    * API/JSScript.mm:
     23    (-[JSScript readCache]):
     24    (-[JSScript sourceCode]):
     25    (-[JSScript jsSourceCode]):
     26    (-[JSScript writeCache:]):
     27    * API/JSVirtualMachine.mm:
     28    (-[JSVirtualMachine JSContextGroupRef]):
     29    (-[JSVirtualMachine isWebThreadAware]):
     30    (-[JSVirtualMachine vm]): Deleted.
     31    * API/JSVirtualMachineInternal.h:
     32   
     33    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254152 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     34
     35    2020-01-07  Yusuke Suzuki  <ysuzuki@apple.com>
     36
     37            [JSC] Remove vm accessor in JSVirtualMachine to reduce binary size
     38            https://bugs.webkit.org/show_bug.cgi?id=205880
     39
     40            Reviewed by Mark Lam.
     41
     42            Objective-C has reflection mechanism. This means that fields, methods, and their types
     43            need to hold its string representations in binary even if we are using release build.
     44            While typical Objective-C class does not have large size of type names, C++ struct / class
     45            has very large one, and putting them in Objective-C method names, parameter types, or fields
     46            makes binary size very large.
     47
     48            By analyzing JavaScriptCore binary, I found that Objective-C method type symbols are taking 200~KB
     49            binary size. (Section __objc_methtype: 235081 (addr 0x105e9a3 offset 17164707)). And it is due to
     50            JSC::VM type included in `[JSVirtualMachine vm]` accessor.
     51
     52            This patch removes this accessor and gets 200KB binary size reduction.
     53
     54            * API/JSScript.mm:
     55            (-[JSScript readCache]):
     56            (-[JSScript sourceCode]):
     57            (-[JSScript jsSourceCode]):
     58            (-[JSScript writeCache:]):
     59            * API/JSVirtualMachine.mm:
     60            (-[JSVirtualMachine JSContextGroupRef]):
     61            (-[JSVirtualMachine isWebThreadAware]):
     62            (-[JSVirtualMachine vm]): Deleted.
     63            * API/JSVirtualMachineInternal.h:
     64
    1652020-01-13  Alan Coon  <alancoon@apple.com>
    266
Note: See TracChangeset for help on using the changeset viewer.