Title: [254593] branches/safari-609-branch/Source/_javascript_Core
- Revision
- 254593
- Author
- alanc...@apple.com
- Date
- 2020-01-15 11:14:55 -0800 (Wed, 15 Jan 2020)
Log 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 _javascript_Core 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
Modified Paths
Diff
Modified: branches/safari-609-branch/Source/_javascript_Core/API/JSScript.mm (254592 => 254593)
--- branches/safari-609-branch/Source/_javascript_Core/API/JSScript.mm 2020-01-15 19:14:53 UTC (rev 254592)
+++ branches/safari-609-branch/Source/_javascript_Core/API/JSScript.mm 2020-01-15 19:14:55 UTC (rev 254593)
@@ -167,7 +167,7 @@
Ref<JSC::CachedBytecode> cachedBytecode = JSC::CachedBytecode::create(WTFMove(mappedFile));
- JSC::VM& vm = [m_virtualMachine vm];
+ JSC::VM& vm = *toJS([m_virtualMachine JSContextGroupRef]);
JSC::SourceCode sourceCode = [self sourceCode];
JSC::SourceCodeKey key = m_type == kJSScriptTypeProgram ? sourceCodeKeyForSerializedProgram(vm, sourceCode) : sourceCodeKeyForSerializedModule(vm, sourceCode);
if (isCachedBytecodeStillValid(vm, cachedBytecode.copyRef(), key, m_type == kJSScriptTypeProgram ? JSC::SourceCodeType::ProgramType : JSC::SourceCodeType::ModuleType))
@@ -235,7 +235,7 @@
- (JSC::SourceCode)sourceCode
{
- JSC::VM& vm = [m_virtualMachine vm];
+ JSC::VM& vm = *toJS([m_virtualMachine JSContextGroupRef]);
JSC::JSLockHolder locker(vm);
TextPosition startPosition { };
@@ -248,7 +248,7 @@
- (JSC::JSSourceCode*)jsSourceCode
{
- JSC::VM& vm = [m_virtualMachine vm];
+ JSC::VM& vm = *toJS([m_virtualMachine JSContextGroupRef]);
JSC::JSLockHolder locker(vm);
JSC::JSSourceCode* jsSourceCode = JSC::JSSourceCode::create(vm, [self sourceCode]);
return jsSourceCode;
@@ -277,12 +277,13 @@
JSC::BytecodeCacheError cacheError;
JSC::SourceCode sourceCode = [self sourceCode];
+ JSC::VM& vm = *toJS([m_virtualMachine JSContextGroupRef]);
switch (m_type) {
case kJSScriptTypeModule:
- m_cachedBytecode = JSC::generateModuleBytecode([m_virtualMachine vm], sourceCode, fd, cacheError);
+ m_cachedBytecode = JSC::generateModuleBytecode(vm, sourceCode, fd, cacheError);
break;
case kJSScriptTypeProgram:
- m_cachedBytecode = JSC::generateProgramBytecode([m_virtualMachine vm], sourceCode, fd, cacheError);
+ m_cachedBytecode = JSC::generateProgramBytecode(vm, sourceCode, fd, cacheError);
break;
}
Modified: branches/safari-609-branch/Source/_javascript_Core/API/JSVirtualMachine.mm (254592 => 254593)
--- branches/safari-609-branch/Source/_javascript_Core/API/JSVirtualMachine.mm 2020-01-15 19:14:53 UTC (rev 254592)
+++ branches/safari-609-branch/Source/_javascript_Core/API/JSVirtualMachine.mm 2020-01-15 19:14:55 UTC (rev 254593)
@@ -298,14 +298,15 @@
#endif // ENABLE(DFG_JIT)
-- (JSC::VM&)vm
+- (JSContextGroupRef)JSContextGroupRef
{
- return *toJS(m_group);
+ return m_group;
}
- (BOOL)isWebThreadAware
{
- return [self vm].apiLock().isWebThreadAware();
+ JSC::VM* vm = toJS(m_group);
+ return vm->apiLock().isWebThreadAware();
}
+ (void)setCrashOnVMCreation:(BOOL)shouldCrash
Modified: branches/safari-609-branch/Source/_javascript_Core/API/JSVirtualMachineInternal.h (254592 => 254593)
--- branches/safari-609-branch/Source/_javascript_Core/API/JSVirtualMachineInternal.h 2020-01-15 19:14:53 UTC (rev 254592)
+++ branches/safari-609-branch/Source/_javascript_Core/API/JSVirtualMachineInternal.h 2020-01-15 19:14:55 UTC (rev 254593)
@@ -46,10 +46,10 @@
- (JSContext *)contextForGlobalContextRef:(JSGlobalContextRef)globalContext;
- (void)addContext:(JSContext *)wrapper forGlobalContextRef:(JSGlobalContextRef)globalContext;
-- (JSC::VM&)vm;
-
- (BOOL)isWebThreadAware;
+@property (readonly) JSContextGroupRef JSContextGroupRef;
+
@end
#endif // defined(__OBJC__)
Modified: branches/safari-609-branch/Source/_javascript_Core/ChangeLog (254592 => 254593)
--- branches/safari-609-branch/Source/_javascript_Core/ChangeLog 2020-01-15 19:14:53 UTC (rev 254592)
+++ branches/safari-609-branch/Source/_javascript_Core/ChangeLog 2020-01-15 19:14:55 UTC (rev 254593)
@@ -1,3 +1,67 @@
+2020-01-14 Alan Coon <alanc...@apple.com>
+
+ 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 _javascript_Core 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
+
+ 2020-01-07 Yusuke Suzuki <ysuz...@apple.com>
+
+ [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 _javascript_Core 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:
+
2020-01-13 Alan Coon <alanc...@apple.com>
Cherry-pick r254349. rdar://problem/58529720
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes