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

Changeset 194369 in webkit


Ignore:
Timestamp:
Dec 22, 2015, 12:04:56 PM (11 years ago)
Author:
keith_miller@apple.com
Message:

Remove OverridesHasInstance from TypeInfoFlags
https://bugs.webkit.org/show_bug.cgi?id=152005

Reviewed by Saam Barati.

Currently, we have three TypeInfo flags associated with instanceof behavior,
ImplementsHasInstance, ImplementDefaultHasInstance, and OverridesHasInstance. This patch
removes the third and moves the first to the out of line flags. In theory, we should only
need one flag but removing ImplementsHasInstance is more involved and should be done in a
separate patch.

Source/JavaScriptCore:

  • API/JSCallbackConstructor.h:
  • API/JSCallbackObject.h:
  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_overrides_has_instance):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::emit_op_overrides_has_instance):

  • llint/LLIntData.cpp:

(JSC::LLInt::Data::performAssertions):

  • llint/LowLevelInterpreter.asm:
  • runtime/InternalFunction.h:
  • runtime/JSBoundFunction.h:
  • runtime/JSCallee.h:
  • runtime/JSTypeInfo.h:

(JSC::TypeInfo::implementsHasInstance):
(JSC::TypeInfo::TypeInfo): Deleted.
(JSC::TypeInfo::overridesHasInstance): Deleted.

  • runtime/NumberConstructor.h:

Source/WebCore:

  • bindings/js/JSDOMBinding.h:
  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader):

Location:
trunk/Source
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSCallbackConstructor.h

    r182747 r194369  
    3535public:
    3636    typedef JSDestructibleObject Base;
    37     static const unsigned StructureFlags = Base::StructureFlags | ImplementsHasInstance;
     37    static const unsigned StructureFlags = Base::StructureFlags | ImplementsHasInstance | ImplementsDefaultHasInstance;
    3838
    3939    static JSCallbackConstructor* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, JSClassRef classRef, JSObjectCallAsConstructorCallback callback)
  • trunk/Source/JavaScriptCore/API/JSCallbackObject.h

    r194248 r194369  
    128128public:
    129129    typedef Parent Base;
    130     static const unsigned StructureFlags = Base::StructureFlags | ProhibitsPropertyCaching | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | ImplementsHasInstance | OverridesHasInstanceFlag | OverridesGetPropertyNames | TypeOfShouldCallGetCallData;
     130    static const unsigned StructureFlags = Base::StructureFlags | ProhibitsPropertyCaching | OverridesGetOwnPropertySlot | InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero | ImplementsHasInstance | OverridesGetPropertyNames | TypeOfShouldCallGetCallData;
    131131
    132132    ~JSCallbackObject();
  • trunk/Source/JavaScriptCore/ChangeLog

    r194368 r194369  
     12015-12-22  Keith Miller  <keith_miller@apple.com>
     2
     3        Remove OverridesHasInstance from TypeInfoFlags
     4        https://bugs.webkit.org/show_bug.cgi?id=152005
     5
     6        Reviewed by Saam Barati.
     7
     8        Currently, we have three TypeInfo flags associated with instanceof behavior,
     9        ImplementsHasInstance, ImplementDefaultHasInstance, and OverridesHasInstance. This patch
     10        removes the third and moves the first to the out of line flags. In theory, we should only
     11        need one flag but removing ImplementsHasInstance is more involved and should be done in a
     12        separate patch.
     13
     14        * API/JSCallbackConstructor.h:
     15        * API/JSCallbackObject.h:
     16        * jit/JITOpcodes.cpp:
     17        (JSC::JIT::emit_op_overrides_has_instance):
     18        * jit/JITOpcodes32_64.cpp:
     19        (JSC::JIT::emit_op_overrides_has_instance):
     20        * llint/LLIntData.cpp:
     21        (JSC::LLInt::Data::performAssertions):
     22        * llint/LowLevelInterpreter.asm:
     23        * runtime/InternalFunction.h:
     24        * runtime/JSBoundFunction.h:
     25        * runtime/JSCallee.h:
     26        * runtime/JSTypeInfo.h:
     27        (JSC::TypeInfo::implementsHasInstance):
     28        (JSC::TypeInfo::TypeInfo): Deleted.
     29        (JSC::TypeInfo::overridesHasInstance): Deleted.
     30        * runtime/NumberConstructor.h:
     31
    1322015-12-22  Filip Pizlo  <fpizlo@apple.com>
    233
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r194248 r194369  
    119119    emitGetVirtualRegister(constructor, regT0);
    120120
    121     // Check that constructor 'ImplementsHasInstance' i.e. the object is a C-API user or a bound function.
     121    // Check that constructor 'ImplementsDefaultHasInstance' i.e. the object is not a C-API user nor a bound function.
    122122    test8(Zero, Address(regT0, JSCell::typeInfoFlagsOffset()), TrustedImm32(ImplementsDefaultHasInstance), regT0);
    123123    emitTagBool(regT0);
  • trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp

    r194248 r194369  
    198198    emitLoadPayload(constructor, regT0);
    199199
    200     // Check that constructor 'ImplementsHasInstance' i.e. the object is a C-API user or a bound function.
     200    // Check that constructor 'ImplementsDefaultHasInstance' i.e. the object is not a C-API user nor a bound function.
    201201    test8(Zero, Address(regT0, JSCell::typeInfoFlagsOffset()), TrustedImm32(ImplementsDefaultHasInstance), regT0);
    202202    Jump done = jump();
  • trunk/Source/JavaScriptCore/llint/LLIntData.cpp

    r194248 r194369  
    3737#include "WriteBarrier.h"
    3838
     39#define STATIC_ASSERT(cond) static_assert(cond, "LLInt assumes " #cond)
     40
    3941namespace JSC { namespace LLInt {
    4042
     
    7375    // prepared to change LowLevelInterpreter.asm as well!!
    7476
    75 #ifndef NDEBUG
    7677#if USE(JSVALUE64)
    7778    const ptrdiff_t PtrSize = 8;
     
    8283#endif
    8384    const ptrdiff_t SlotSize = 8;
    84 #endif
    85 
    86     ASSERT(sizeof(void*) == PtrSize);
    87     ASSERT(sizeof(Register) == SlotSize);
    88     ASSERT(JSStack::CallFrameHeaderSize == CallFrameHeaderSlots);
     85
     86    STATIC_ASSERT(sizeof(void*) == PtrSize);
     87    STATIC_ASSERT(sizeof(Register) == SlotSize);
     88    STATIC_ASSERT(JSStack::CallFrameHeaderSize == CallFrameHeaderSlots);
    8989
    9090    ASSERT(!CallFrame::callerFrameOffset());
    91     ASSERT(JSStack::CallerFrameAndPCSize == (PtrSize * 2) / SlotSize);
     91    STATIC_ASSERT(JSStack::CallerFrameAndPCSize == (PtrSize * 2) / SlotSize);
    9292    ASSERT(CallFrame::returnPCOffset() == CallFrame::callerFrameOffset() + PtrSize);
    9393    ASSERT(JSStack::CodeBlock * sizeof(Register) == CallFrame::returnPCOffset() + PtrSize);
    94     ASSERT(JSStack::Callee * sizeof(Register) == JSStack::CodeBlock * sizeof(Register) + SlotSize);
    95     ASSERT(JSStack::ArgumentCount * sizeof(Register) == JSStack::Callee * sizeof(Register) + SlotSize);
    96     ASSERT(JSStack::ThisArgument * sizeof(Register) == JSStack::ArgumentCount * sizeof(Register) + SlotSize);
    97     ASSERT(JSStack::CallFrameHeaderSize == JSStack::ThisArgument);
     94    STATIC_ASSERT(JSStack::Callee * sizeof(Register) == JSStack::CodeBlock * sizeof(Register) + SlotSize);
     95    STATIC_ASSERT(JSStack::ArgumentCount * sizeof(Register) == JSStack::Callee * sizeof(Register) + SlotSize);
     96    STATIC_ASSERT(JSStack::ThisArgument * sizeof(Register) == JSStack::ArgumentCount * sizeof(Register) + SlotSize);
     97    STATIC_ASSERT(JSStack::CallFrameHeaderSize == JSStack::ThisArgument);
    9898
    9999    ASSERT(CallFrame::argumentOffsetIncludingThis(0) == JSStack::ThisArgument);
     
    107107#endif
    108108#if USE(JSVALUE32_64)
    109     ASSERT(JSValue::Int32Tag == static_cast<unsigned>(-1));
    110     ASSERT(JSValue::BooleanTag == static_cast<unsigned>(-2));
    111     ASSERT(JSValue::NullTag == static_cast<unsigned>(-3));
    112     ASSERT(JSValue::UndefinedTag == static_cast<unsigned>(-4));
    113     ASSERT(JSValue::CellTag == static_cast<unsigned>(-5));
    114     ASSERT(JSValue::EmptyValueTag == static_cast<unsigned>(-6));
    115     ASSERT(JSValue::DeletedValueTag == static_cast<unsigned>(-7));
    116     ASSERT(JSValue::LowestTag == static_cast<unsigned>(-7));
     109    STATIC_ASSERT(JSValue::Int32Tag == static_cast<unsigned>(-1));
     110    STATIC_ASSERT(JSValue::BooleanTag == static_cast<unsigned>(-2));
     111    STATIC_ASSERT(JSValue::NullTag == static_cast<unsigned>(-3));
     112    STATIC_ASSERT(JSValue::UndefinedTag == static_cast<unsigned>(-4));
     113    STATIC_ASSERT(JSValue::CellTag == static_cast<unsigned>(-5));
     114    STATIC_ASSERT(JSValue::EmptyValueTag == static_cast<unsigned>(-6));
     115    STATIC_ASSERT(JSValue::DeletedValueTag == static_cast<unsigned>(-7));
     116    STATIC_ASSERT(JSValue::LowestTag == static_cast<unsigned>(-7));
    117117#else
    118     ASSERT(TagBitTypeOther == 0x2);
    119     ASSERT(TagBitBool == 0x4);
    120     ASSERT(TagBitUndefined == 0x8);
    121     ASSERT(ValueEmpty == 0x0);
    122     ASSERT(ValueFalse == (TagBitTypeOther | TagBitBool));
    123     ASSERT(ValueTrue == (TagBitTypeOther | TagBitBool | 1));
    124     ASSERT(ValueUndefined == (TagBitTypeOther | TagBitUndefined));
    125     ASSERT(ValueNull == TagBitTypeOther);
     118    STATIC_ASSERT(TagBitTypeOther == 0x2);
     119    STATIC_ASSERT(TagBitBool == 0x4);
     120    STATIC_ASSERT(TagBitUndefined == 0x8);
     121    STATIC_ASSERT(ValueEmpty == 0x0);
     122    STATIC_ASSERT(ValueFalse == (TagBitTypeOther | TagBitBool));
     123    STATIC_ASSERT(ValueTrue == (TagBitTypeOther | TagBitBool | 1));
     124    STATIC_ASSERT(ValueUndefined == (TagBitTypeOther | TagBitUndefined));
     125    STATIC_ASSERT(ValueNull == TagBitTypeOther);
    126126#endif
    127127#if (CPU(X86_64) && !OS(WINDOWS)) || CPU(ARM64) || !ENABLE(JIT)
    128     ASSERT(!maxFrameExtentForSlowPathCall);
     128    STATIC_ASSERT(!maxFrameExtentForSlowPathCall);
    129129#elif CPU(ARM) || CPU(SH4)
    130     ASSERT(maxFrameExtentForSlowPathCall == 24);
     130    STATIC_ASSERT(maxFrameExtentForSlowPathCall == 24);
    131131#elif CPU(X86) || CPU(MIPS)
    132     ASSERT(maxFrameExtentForSlowPathCall == 40);
     132    STATIC_ASSERT(maxFrameExtentForSlowPathCall == 40);
    133133#elif CPU(X86_64) && OS(WINDOWS)
    134     ASSERT(maxFrameExtentForSlowPathCall == 64);
     134    STATIC_ASSERT(maxFrameExtentForSlowPathCall == 64);
    135135#endif
    136136
     
    143143#endif
    144144   
    145     ASSERT(StringType == 6);
    146     ASSERT(SymbolType == 7);
    147     ASSERT(ObjectType == 21);
    148     ASSERT(FinalObjectType == 22);
    149     ASSERT(MasqueradesAsUndefined == 1);
    150     ASSERT(ImplementsHasInstance == 2);
    151     ASSERT(ImplementsDefaultHasInstance == 8);
    152     ASSERT(FirstConstantRegisterIndex == 0x40000000);
    153     ASSERT(GlobalCode == 0);
    154     ASSERT(EvalCode == 1);
    155     ASSERT(FunctionCode == 2);
    156     ASSERT(ModuleCode == 3);
     145    STATIC_ASSERT(StringType == 6);
     146    STATIC_ASSERT(SymbolType == 7);
     147    STATIC_ASSERT(ObjectType == 21);
     148    STATIC_ASSERT(FinalObjectType == 22);
     149    STATIC_ASSERT(MasqueradesAsUndefined == 1);
     150    STATIC_ASSERT(ImplementsDefaultHasInstance == 2);
     151    STATIC_ASSERT(FirstConstantRegisterIndex == 0x40000000);
     152    STATIC_ASSERT(GlobalCode == 0);
     153    STATIC_ASSERT(EvalCode == 1);
     154    STATIC_ASSERT(FunctionCode == 2);
     155    STATIC_ASSERT(ModuleCode == 3);
    157156
    158157    ASSERT(!(reinterpret_cast<ptrdiff_t>((reinterpret_cast<WriteBarrier<JSCell>*>(0x4000)->slot())) - 0x4000));
     
    186185    static_assert(InitializationMode::Initialization == 0, "LLInt assumes that InitializationMode::Initialization is 0");
    187186   
    188     ASSERT(GetPutInfo::typeBits == 0x3ff);
    189     ASSERT(GetPutInfo::initializationShift == 10);
    190     ASSERT(GetPutInfo::initializationBits == 0xffc00);
    191 
    192     ASSERT(MarkedBlock::blockMask == ~static_cast<decltype(MarkedBlock::blockMask)>(0x3fff));
     187    STATIC_ASSERT(GetPutInfo::typeBits == 0x3ff);
     188    STATIC_ASSERT(GetPutInfo::initializationShift == 10);
     189    STATIC_ASSERT(GetPutInfo::initializationBits == 0xffc00);
     190
     191    STATIC_ASSERT(MarkedBlock::blockMask == ~static_cast<decltype(MarkedBlock::blockMask)>(0x3fff));
    193192
    194193    // FIXME: make these assertions less horrible.
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r193766 r194369  
    334334# Type flags constants.
    335335const MasqueradesAsUndefined = 1
    336 const ImplementsHasInstance = 2
    337 const ImplementsDefaultHasInstance = 8
     336const ImplementsDefaultHasInstance = 2
    338337
    339338# Bytecode operand constants.
  • trunk/Source/JavaScriptCore/runtime/InternalFunction.h

    r183575 r194369  
    3535public:
    3636    typedef JSDestructibleObject Base;
    37     static const unsigned StructureFlags = Base::StructureFlags | ImplementsHasInstance | TypeOfShouldCallGetCallData;
     37    static const unsigned StructureFlags = Base::StructureFlags | ImplementsHasInstance | ImplementsDefaultHasInstance | TypeOfShouldCallGetCallData;
    3838
    3939    DECLARE_EXPORT_INFO;
  • trunk/Source/JavaScriptCore/runtime/JSBoundFunction.h

    r194248 r194369  
    3939public:
    4040    typedef JSFunction Base;
    41     const static unsigned StructureFlags = OverridesHasInstanceFlag | Base::StructureFlags;
     41    const static unsigned StructureFlags = ~ImplementsDefaultHasInstance & Base::StructureFlags;
    4242
    4343    static JSBoundFunction* create(VM&, JSGlobalObject*, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs, int, const String&);
  • trunk/Source/JavaScriptCore/runtime/JSCallee.h

    r182899 r194369  
    4747public:
    4848    typedef JSNonFinalObject Base;
    49     const static unsigned StructureFlags = Base::StructureFlags | ImplementsHasInstance;
     49    const static unsigned StructureFlags = Base::StructureFlags | ImplementsHasInstance | ImplementsDefaultHasInstance;
    5050
    5151    static JSCallee* create(VM& vm, JSGlobalObject* globalObject, JSScope* scope)
  • trunk/Source/JavaScriptCore/runtime/JSTypeInfo.h

    r194248 r194369  
    3838
    3939static const unsigned MasqueradesAsUndefined = 1; // WebCore uses MasqueradesAsUndefined to make document.all undetectable.
    40 static const unsigned ImplementsHasInstance = 1 << 1;
    41 static const unsigned OverridesHasInstanceFlag = 1 << 2; // FIXME: This is only trivially used by the runtime and should be removed: https://bugs.webkit.org/show_bug.cgi?id=152005
    42 static const unsigned ImplementsDefaultHasInstance = 1 << 3;
    43 static const unsigned TypeOfShouldCallGetCallData = 1 << 4; // Need this flag if you override getCallData() and you want typeof to use this to determine if it should say "function". Currently we always set this flag when we override getCallData().
    44 static const unsigned OverridesGetOwnPropertySlot = 1 << 5;
    45 static const unsigned InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero = 1 << 6;
    46 static const unsigned StructureIsImmortal = 1 << 7;
     40static const unsigned ImplementsDefaultHasInstance = 1 << 1;
     41static const unsigned TypeOfShouldCallGetCallData = 1 << 2; // Need this flag if you override getCallData() and you want typeof to use this to determine if it should say "function". Currently we always set this flag when we override getCallData().
     42static const unsigned OverridesGetOwnPropertySlot = 1 << 3;
     43static const unsigned InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero = 1 << 4;
     44static const unsigned StructureIsImmortal = 1 << 5;
     45// There are two free bits at the end of the InlineTypeFlags.
    4746
    48 static const unsigned OverridesGetPropertyNames = 1 << 8;
    49 static const unsigned ProhibitsPropertyCaching = 1 << 9;
    50 static const unsigned GetOwnPropertySlotIsImpure = 1 << 10;
    51 static const unsigned NewImpurePropertyFiresWatchpoints = 1 << 11;
    52 static const unsigned IsEnvironmentRecord = 1 << 12;
    53 static const unsigned GetOwnPropertySlotIsImpureForPropertyAbsence = 1 << 13;
     47static const unsigned ImplementsHasInstance = 1 << 8;
     48static const unsigned OverridesGetPropertyNames = 1 << 9;
     49static const unsigned ProhibitsPropertyCaching = 1 << 10;
     50static const unsigned GetOwnPropertySlotIsImpure = 1 << 11;
     51static const unsigned NewImpurePropertyFiresWatchpoints = 1 << 12;
     52static const unsigned IsEnvironmentRecord = 1 << 13;
     53static const unsigned GetOwnPropertySlotIsImpureForPropertyAbsence = 1 << 14;
    5454
    5555class TypeInfo {
     
    6868        , m_flags2(outOfLineTypeFlags)
    6969    {
    70         // No object that doesn't ImplementsHasInstance should override it!
    71         ASSERT((m_flags & (ImplementsHasInstance | OverridesHasInstanceFlag)) != OverridesHasInstanceFlag);
    72         // ImplementsDefaultHasInstance means (ImplementsHasInstance & !OverridesHasInstance)
    73         if ((m_flags & (ImplementsHasInstance | OverridesHasInstanceFlag)) == ImplementsHasInstance)
    74             m_flags |= ImplementsDefaultHasInstance;
    7570    }
    7671
     
    8378    unsigned flags() const { return (static_cast<unsigned>(m_flags2) << 8) | static_cast<unsigned>(m_flags); }
    8479    bool masqueradesAsUndefined() const { return isSetOnFlags1(MasqueradesAsUndefined); }
    85     bool implementsHasInstance() const { return isSetOnFlags1(ImplementsHasInstance); }
    86     bool overridesHasInstance() const { return isSetOnFlags1(OverridesHasInstanceFlag); }
     80    bool implementsHasInstance() const { return isSetOnFlags2(ImplementsHasInstance); }
    8781    bool implementsDefaultHasInstance() const { return isSetOnFlags1(ImplementsDefaultHasInstance); }
    8882    bool typeOfShouldCallGetCallData() const { return isSetOnFlags1(TypeOfShouldCallGetCallData); }
  • trunk/Source/JavaScriptCore/runtime/NumberConstructor.h

    r182747 r194369  
    3131public:
    3232    typedef InternalFunction Base;
    33     static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | ImplementsHasInstance;
     33    static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | ImplementsHasInstance | ImplementsDefaultHasInstance;
    3434
    3535    static NumberConstructor* create(VM& vm, Structure* structure, NumberPrototype* numberPrototype)
  • trunk/Source/WebCore/ChangeLog

    r194367 r194369  
     12015-12-22  Keith Miller  <keith_miller@apple.com>
     2
     3        Remove OverridesHasInstance from TypeInfoFlags
     4        https://bugs.webkit.org/show_bug.cgi?id=152005
     5
     6        Reviewed by Saam Barati.
     7
     8        Currently, we have three TypeInfo flags associated with instanceof behavior,
     9        ImplementsHasInstance, ImplementDefaultHasInstance, and OverridesHasInstance. This patch
     10        removes the third and moves the first to the out of line flags. In theory, we should only
     11        need one flag but removing ImplementsHasInstance is more involved and should be done in a
     12        separate patch.
     13
     14        * bindings/js/JSDOMBinding.h:
     15        * bindings/scripts/CodeGeneratorJS.pm:
     16        (GenerateHeader):
     17
    1182015-12-22  Brent Fulgham  <bfulgham@apple.com>
    219
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r193364 r194369  
    101101public:
    102102    typedef JSDOMObject Base;
    103     static const unsigned StructureFlags = Base::StructureFlags | JSC::ImplementsHasInstance;
     103    static const unsigned StructureFlags = Base::StructureFlags | JSC::ImplementsHasInstance | JSC::ImplementsDefaultHasInstance;
    104104
    105105    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r194100 r194369  
    10461046    # Structure ID
    10471047    if ($interfaceName eq "DOMWindow") {
    1048         $structureFlags{"JSC::ImplementsHasInstance"} = 1;
     1048        $structureFlags{"JSC::ImplementsHasInstance | JSC::ImplementsDefaultHasInstance"} = 1;
    10491049    }
    10501050    push(@headerContent, "    static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)\n");
Note: See TracChangeset for help on using the changeset viewer.