• Seth Brenith's avatar
    Require the first three fields of ScopeInfo to be present · 2bbf3333
    Seth Brenith authored
    ScopeInfo objects generally start with three fields: flags, parameter
    count, and local variable count. But a single read-only ScopeInfo
    instance has none of those fields. This is the empty ScopeInfo, which is
    used for contexts that don't correspond to any scope (the native context
    and contexts for builtin functions). Since there is only ever a single
    instance of the empty ScopeInfo, the memory savings of omitting these
    fields is trivial, and we can simplify logic somewhat by including them.
    Rather than checking for length to be zero, this change introduces a new
    flag indicating that a ScopeInfo instance is the empty one.
    
    On its own, this change doesn't provide a whole lot of value. However,
    it sets us up for two further improvements, which are consistent with
    the goals outlined in [1]:
    
    1. We should fully describe ScopeInfo fields in Torque. Getting rid of
    the requirement to check for emptiness would substantially simplify the
    indexed field expressions.
    
    2. ScopeInfo shouldn't inherit from FixedArray, and shouldn't begin with
    a `length` field when the length can be computed from the other fields.
    This would save a small amount of heap memory and avoid any possibility
    of a mismatch between the two ways of computing the length.
    
    [1] https://docs.google.com/document/d/1tiGK7_lubxPHnInI2vscUwMHfadn8gIEa1apmI8HxR4/edit#heading=h.n63k76b3zfwa
    
    Bug: v8:8952
    Change-Id: I018127698a5d91fb2a91684bc3aec2e27ee27c41
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2561598Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
    Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
    Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
    Cr-Commit-Position: refs/heads/master@{#71500}
    2bbf3333
scope-info.tq 1.71 KB