Bug 196022 - [JSC] Reorganize JSScope mechanism
Summary: [JSC] Reorganize JSScope mechanism
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-20 12:03 PDT by Yusuke Suzuki
Modified: 2019-03-20 12:03 PDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2019-03-20 12:03:36 PDT
Currently, all the scopes inherit JSScope, and JSScope inherits JSNonFinalObject!
This is because,

1. One of the JSScope class, JSGlobalObject needs to be an object.
2. We would like to have a convenient way to get `globalObject` from JSScope `scope->globalObject(vm)`

But this convenient inheritance hierarchy results in memory bloat now. All the scopes have Butterfly pointer, and it is nullptr except for JSGlobalObject.
If we cut this butterfly pointer, we can make JSLexicalEnvironment small. And we can find so many small JSLexicalEnvironments (scopeSize = 1) are allocated in RAMification's Air test.
This is largely because of closures I think. And I think such a small JSLexicalEnvironment can be seen in the wild due to closures. Reducing size of JSLexicalEnvironment tighten our memory footprint.

My current plan is,

Break the current inheritance hierarchy and make JSScope something like an interface.
Put m_next field in all the scope objects in the same offset (we can ensure it by RELEASE_ASSERT in LLIntData etc.)