Changeset 207652 in webkit


Ignore:
Timestamp:
Oct 20, 2016 6:33:14 PM (7 years ago)
Author:
Yusuke Suzuki
Message:

[JSC] Drop isEnvironmentRecord type info flag and use JSType information instead
https://bugs.webkit.org/show_bug.cgi?id=163761

Reviewed by Keith Miller.

JSTests:

  • modules/string-prototype-module-scope.js: Added.

(shouldBe):
(catch):
(refer):

  • stress/string-prototype-scopes-global-lexical-environment-strict.js: Added.

(shouldBe):
(catch):

  • stress/string-prototype-scopes-global-lexical-environment.js: Added.

(shouldBe):
(catch):

  • stress/string-prototype-scopes-strict.js: Added.

(shouldBe):
(catch):
(try.refer):
(refer):

  • stress/string-prototype-scopes.js: Added.

(shouldBe):
(catch):
(try.refer):
(refer):
(object.toString):
(with):

Source/JavaScriptCore:

When we call a function in the following form,

var charAt = String.prototype.charAt;
charAt(); |this| becomes the global object.

we should see |this| as undefined/null. In StringPrototype.cpp,
we use IsEnvironmentRecord type info flag to check whther the
given |this| is an environment record.
However, type info flag is precious thing and only StringPrototype.cpp
uses IsEnvironmentRecord. In addition to that, JSType should
already knows whether the given object is an environment record.
So IsEnvironmentRecord type info flag should be dropped.

This patch adds a new JSType, StrictEvalActivation. And we add a new
method JSObject::isEnvironmentRecord(). This method uses JSType to
return the result. And we drop IsEnvironmentRecord type info flag.
This patch makes a room for putting one bit flag to the out of line
type info flag. Previously, it is already exhausted.

  • llint/LLIntData.cpp:

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

  • llint/LowLevelInterpreter.asm:
  • runtime/JSObject.h:

(JSC::JSObject::isStrictEvalActivation):
(JSC::JSObject::isEnvironmentRecord):

  • runtime/JSSymbolTableObject.h:
  • runtime/JSType.h:
  • runtime/JSTypeInfo.h:

(JSC::TypeInfo::newImpurePropertyFiresWatchpoints):
(JSC::TypeInfo::isEnvironmentRecord): Deleted.

  • runtime/StrictEvalActivation.h:

(JSC::StrictEvalActivation::createStructure):

  • runtime/StringPrototype.cpp:

(JSC::checkObjectCoercible):

LayoutTests:

  • js/dom/script-tests/string-prototype-scopes-in-workers.js: Added.

(catch):

  • js/dom/script-tests/string-prototype-scopes.js: Added.

(catch):

  • js/dom/string-prototype-scopes-expected.txt: Added.
  • js/dom/string-prototype-scopes-in-workers-expected.txt: Added.
  • js/dom/string-prototype-scopes-in-workers.html: Added.
  • js/dom/string-prototype-scopes.html: Added.
Location:
trunk
Files:
11 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r207650 r207652  
     12016-10-20  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [JSC] Drop isEnvironmentRecord type info flag and use JSType information instead
     4        https://bugs.webkit.org/show_bug.cgi?id=163761
     5
     6        Reviewed by Keith Miller.
     7
     8        * modules/string-prototype-module-scope.js: Added.
     9        (shouldBe):
     10        (catch):
     11        (refer):
     12        * stress/string-prototype-scopes-global-lexical-environment-strict.js: Added.
     13        (shouldBe):
     14        (catch):
     15        * stress/string-prototype-scopes-global-lexical-environment.js: Added.
     16        (shouldBe):
     17        (catch):
     18        * stress/string-prototype-scopes-strict.js: Added.
     19        (shouldBe):
     20        (catch):
     21        (try.refer):
     22        (refer):
     23        * stress/string-prototype-scopes.js: Added.
     24        (shouldBe):
     25        (catch):
     26        (try.refer):
     27        (refer):
     28        (object.toString):
     29        (with):
     30
    1312016-10-20  JF Bastien  <jfbastien@apple.com>
    232
  • trunk/LayoutTests/ChangeLog

    r207649 r207652  
     12016-10-20  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [JSC] Drop isEnvironmentRecord type info flag and use JSType information instead
     4        https://bugs.webkit.org/show_bug.cgi?id=163761
     5
     6        Reviewed by Keith Miller.
     7
     8        * js/dom/script-tests/string-prototype-scopes-in-workers.js: Added.
     9        (catch):
     10        * js/dom/script-tests/string-prototype-scopes.js: Added.
     11        (catch):
     12        * js/dom/string-prototype-scopes-expected.txt: Added.
     13        * js/dom/string-prototype-scopes-in-workers-expected.txt: Added.
     14        * js/dom/string-prototype-scopes-in-workers.html: Added.
     15        * js/dom/string-prototype-scopes.html: Added.
     16
    1172016-10-20  Myles C. Maxfield  <mmaxfield@apple.com>
    218
  • trunk/Source/JavaScriptCore/ChangeLog

    r207650 r207652  
     12016-10-20  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [JSC] Drop isEnvironmentRecord type info flag and use JSType information instead
     4        https://bugs.webkit.org/show_bug.cgi?id=163761
     5
     6        Reviewed by Keith Miller.
     7
     8        When we call a function in the following form,
     9
     10            var charAt = String.prototype.charAt;
     11            charAt();  // |this| becomes the global object.
     12
     13        we should see |this| as undefined/null. In StringPrototype.cpp,
     14        we use IsEnvironmentRecord type info flag to check whther the
     15        given |this| is an environment record.
     16        However, type info flag is precious thing and only StringPrototype.cpp
     17        uses IsEnvironmentRecord. In addition to that, JSType should
     18        already knows whether the given object is an environment record.
     19        So IsEnvironmentRecord type info flag should be dropped.
     20
     21        This patch adds a new JSType, StrictEvalActivation. And we add a new
     22        method JSObject::isEnvironmentRecord(). This method uses JSType to
     23        return the result. And we drop IsEnvironmentRecord type info flag.
     24        This patch makes a room for putting one bit flag to the out of line
     25        type info flag. Previously, it is already exhausted.
     26
     27        * llint/LLIntData.cpp:
     28        (JSC::LLInt::Data::performAssertions):
     29        * llint/LowLevelInterpreter.asm:
     30        * runtime/JSObject.h:
     31        (JSC::JSObject::isStrictEvalActivation):
     32        (JSC::JSObject::isEnvironmentRecord):
     33        * runtime/JSSymbolTableObject.h:
     34        * runtime/JSType.h:
     35        * runtime/JSTypeInfo.h:
     36        (JSC::TypeInfo::newImpurePropertyFiresWatchpoints):
     37        (JSC::TypeInfo::isEnvironmentRecord): Deleted.
     38        * runtime/StrictEvalActivation.h:
     39        (JSC::StrictEvalActivation::createStructure):
     40        * runtime/StringPrototype.cpp:
     41        (JSC::checkObjectCoercible):
     42
    1432016-10-20  JF Bastien  <jfbastien@apple.com>
    244
  • trunk/Source/JavaScriptCore/llint/LLIntData.cpp

    r207263 r207652  
    162162    STATIC_ASSERT(ArrayType == 31);
    163163    STATIC_ASSERT(DerivedArrayType == 32);
    164     STATIC_ASSERT(ProxyObjectType == 49);
     164    STATIC_ASSERT(ProxyObjectType == 50);
    165165    STATIC_ASSERT(Int8ArrayType == 33);
    166166    STATIC_ASSERT(Int16ArrayType == 34);
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r207263 r207652  
    351351const ArrayType = 31
    352352const DerivedArrayType = 32
    353 const ProxyObjectType = 49
     353const ProxyObjectType = 50
    354354
    355355# The typed array types need to be numbered in a particular order because of the manually written
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r207411 r207652  
    707707    JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&, bool shouldThrow);
    708708
     709    bool isEnvironmentRecord() const;
    709710    bool isGlobalObject() const;
    710711    bool isJSLexicalEnvironment() const;
    711712    bool isGlobalLexicalEnvironment() const;
     713    bool isStrictEvalActivation() const;
     714    bool isWithScope() const;
     715
    712716    bool isErrorInstance() const;
    713     bool isWithScope() const;
    714717
    715718    JS_EXPORT_PRIVATE void seal(VM&);
     
    11741177{
    11751178    return type() == GlobalLexicalEnvironmentType;
     1179}
     1180
     1181inline bool JSObject::isStrictEvalActivation() const
     1182{
     1183    return type() == StrictEvalActivationType;
     1184}
     1185
     1186inline bool JSObject::isEnvironmentRecord() const
     1187{
     1188    bool result = GlobalObjectType <= type() && type() <= StrictEvalActivationType;
     1189    ASSERT((isGlobalObject() || isJSLexicalEnvironment() || isGlobalLexicalEnvironment() || isStrictEvalActivation()) == result);
     1190    return result;
    11761191}
    11771192
  • trunk/Source/JavaScriptCore/runtime/JSSymbolTableObject.h

    r207411 r207652  
    4040public:
    4141    typedef JSScope Base;
    42     static const unsigned StructureFlags = Base::StructureFlags | IsEnvironmentRecord | OverridesGetPropertyNames;
     42    static const unsigned StructureFlags = Base::StructureFlags | OverridesGetPropertyNames;
    4343   
    4444    SymbolTable* symbolTable() const { return m_symbolTable.get(); }
  • trunk/Source/JavaScriptCore/runtime/JSType.h

    r207239 r207652  
    7878
    7979    GetterSetterType,
     80
     81    // Start environment record types.
    8082    GlobalObjectType,
    8183    LexicalEnvironmentType,
    8284    GlobalLexicalEnvironmentType,
    8385    ModuleEnvironmentType,
     86    StrictEvalActivationType,
     87    // End environment record types.
     88
    8489    RegExpObjectType,
    8590    ProxyObjectType,
  • trunk/Source/JavaScriptCore/runtime/JSTypeInfo.h

    r207625 r207652  
    4949static const unsigned GetOwnPropertySlotIsImpure = 1 << 11;
    5050static const unsigned NewImpurePropertyFiresWatchpoints = 1 << 12;
    51 static const unsigned IsEnvironmentRecord = 1 << 13;
    5251static const unsigned GetOwnPropertySlotIsImpureForPropertyAbsence = 1 << 14;
    5352static const unsigned InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero = 1 << 15;
     
    9190    bool getOwnPropertySlotIsImpureForPropertyAbsence() const { return isSetOnFlags2(GetOwnPropertySlotIsImpureForPropertyAbsence); }
    9291    bool newImpurePropertyFiresWatchpoints() const { return isSetOnFlags2(NewImpurePropertyFiresWatchpoints); }
    93     bool isEnvironmentRecord() const { return isSetOnFlags2(IsEnvironmentRecord); }
    9492    bool interceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero() const { return isSetOnFlags2(InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero); }
    9593
  • trunk/Source/JavaScriptCore/runtime/StrictEvalActivation.h

    r206525 r207652  
    3333public:
    3434    typedef JSScope Base;
    35     static const unsigned StructureFlags = Base::StructureFlags | IsEnvironmentRecord | OverridesToThis;
     35    static const unsigned StructureFlags = Base::StructureFlags | OverridesToThis;
    3636
    3737    static StrictEvalActivation* create(ExecState* exec, JSScope* currentScope)
     
    4747    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
    4848    {
    49         return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
     49        return Structure::create(vm, globalObject, prototype, TypeInfo(StrictEvalActivationType, StructureFlags), info());
    5050    }
    5151   
  • trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp

    r206804 r207652  
    747747        return false;
    748748
    749     if (thisValue.isCell() && thisValue.asCell()->structure()->typeInfo().isEnvironmentRecord())
     749    if (thisValue.isObject() && asObject(thisValue)->isEnvironmentRecord())
    750750        return false;
    751751
Note: See TracChangeset for help on using the changeset viewer.