Ignore:
Timestamp:
Jun 30, 2021, 7:12:20 PM (4 years ago)
Author:
[email protected]
Message:

[JSC] Stop generating default parameter code if class constructor is called without 'new'
https://bugs.webkit.org/show_bug.cgi?id=227547
rdar://78821453

Reviewed by Mark Lam.

JSTests:

  • stress/calling-non-callable-constructors.js: Added.

(shouldThrow):

Source/JavaScriptCore:

We already do not generate body bytecode when class constructor is called without 'new' because many features including "super()" assume
that they generate bytecode only when it is called as a constructor. But we are not doing that for default parameters' bytecode generation.
This patch stops generating bytecode for default parameters if class constructor is called without 'new'.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::generate):
(JSC::BytecodeGenerator::BytecodeGenerator):

  • runtime/ConstructorKind.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r279447 r279448  
    623623
    624624    bool hasDirectSuper() const { return m_hasDirectSuper; }
    625     bool setHasDirectSuper() { return std::exchange(m_hasDirectSuper, true); }
     625    void setHasDirectSuper() { m_hasDirectSuper = true; }
    626626
    627627    bool needsSuperBinding() const { return m_needsSuperBinding; }
    628     bool setNeedsSuperBinding() { return std::exchange(m_needsSuperBinding, true); }
     628    void setNeedsSuperBinding() { m_needsSuperBinding = true; }
    629629   
    630630    void setEvalContextType(EvalContextType evalContextType) { m_evalContextType = evalContextType; }
Note: See TracChangeset for help on using the changeset viewer.