Ignore:
Timestamp:
May 16, 2018, 10:21:41 PM (7 years ago)
Author:
[email protected]
Message:

UnlinkedFunctionExecutable doesn't need a parent source override field since it's only used for default class constructors
https://bugs.webkit.org/show_bug.cgi?id=185637

Reviewed by Keith Miller.

We had this general mechanism for overriding an UnlinkedFunctionExecutable's parent
source code. However, we were only using this for default class constructors. There
are only two types of default class constructors. This patch makes it so that
we just store this information inside of a single bit, and ask for the source
code as needed instead of holding it in a nullable field that is 24 bytes in size.

This brings UnlinkedFunctionExecutable's size down from 184 bytes to 160 bytes.
This has the consequence of making it allocated out of a 160 byte size class
instead of a 224 byte size class. This should bring down its memory footprint
by ~40%.

  • builtins/BuiltinExecutables.cpp:

(JSC::BuiltinExecutables::defaultConstructorSourceCode):
(JSC::BuiltinExecutables::createDefaultConstructor):
(JSC::BuiltinExecutables::createExecutable):

  • builtins/BuiltinExecutables.h:
  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
(JSC::UnlinkedFunctionExecutable::link):

  • bytecode/UnlinkedFunctionExecutable.h:
  • runtime/CodeCache.cpp:

(JSC::CodeCache::getUnlinkedGlobalFunctionExecutable):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h

    r231477 r231889  
    11/*
    2  * Copyright (C) 2012-2016 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2012-2018 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5959    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    6060
    61     static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, JSParserScriptMode scriptMode, VariableEnvironment& parentScopeTDZVariables, DerivedContextType derivedContextType, SourceCode&& parentSourceOverride = SourceCode())
     61    static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, JSParserScriptMode scriptMode, VariableEnvironment& parentScopeTDZVariables, DerivedContextType derivedContextType, bool isBuiltinDefaultClassConstructor = false)
    6262    {
    6363        UnlinkedFunctionExecutable* instance = new (NotNull, allocateCell<UnlinkedFunctionExecutable>(vm->heap))
    64             UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, WTFMove(parentSourceOverride), node, unlinkedFunctionKind, constructAbility, scriptMode, parentScopeTDZVariables, derivedContextType);
     64            UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, node, unlinkedFunctionKind, constructAbility, scriptMode, parentScopeTDZVariables, derivedContextType, isBuiltinDefaultClassConstructor);
    6565        instance->finishCreation(*vm);
    6666        return instance;
     
    140140
    141141private:
    142     UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, SourceCode&& parentSourceOverride, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, JSParserScriptMode, VariableEnvironment&,  JSC::DerivedContextType);
     142    UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, JSParserScriptMode, VariableEnvironment&,  JSC::DerivedContextType, bool isBuiltinDefaultClassConstructor);
    143143
    144144    unsigned m_firstLineOffset;
     
    158158    unsigned m_hasCapturedVariables : 1;
    159159    unsigned m_isBuiltinFunction : 1;
     160    unsigned m_isBuiltinDefaultClassConstructor : 1;
    160161    unsigned m_constructAbility: 1;
    161162    unsigned m_constructorKind : 2;
     
    171172    Identifier m_ecmaName;
    172173    Identifier m_inferredName;
    173     SourceCode m_parentSourceOverride;
    174174    SourceCode m_classSource;
    175175
Note: See TracChangeset for help on using the changeset viewer.