Changeset 264679 in webkit


Ignore:
Timestamp:
Jul 21, 2020 2:10:29 PM (4 years ago)
Author:
mark.lam@apple.com
Message:

llint_slow_path_get_private_name() should not be using PropertySlot::InternalMethodType::VMInquiry.
https://bugs.webkit.org/show_bug.cgi?id=214603

Reviewed by Yusuke Suzuki.

VMInquiry means (1) the get operation should not call back into JS, (2) it should
not throw any exceptions (except for OutOfMemoryError or StackOverflowError which
can be thrown at any time), or have any side effects that is observable from JS
code. In this case, llint_slow_path_get_private_name() is just implementating
PrivateFieldGet (https://tc39.es/proposal-class-fields/#sec-privatefieldget) and
should actually be using PropertySlot::InternalMethodType::GetOwnProperty
(according to https://tc39.es/proposal-class-fields/#sec-privatefieldfind).

This patch makes the above change, and also adds an assert in JSObject::getPrivateField
to ensure that no one calls it for a VMInquiry since it is not supported.

Also added a PropertySlot::isVMInquiry() convenience query method.

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • runtime/JSObjectInlines.h:

(JSC::JSObject::getPrivateField):

  • runtime/PropertySlot.h:

(JSC::PropertySlot::isVMInquiry const):

Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r264673 r264679  
     12020-07-21  Mark Lam  <mark.lam@apple.com>
     2
     3        llint_slow_path_get_private_name() should not be using PropertySlot::InternalMethodType::VMInquiry.
     4        https://bugs.webkit.org/show_bug.cgi?id=214603
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        VMInquiry means (1) the get operation should not call back into JS, (2) it should
     9        not throw any exceptions (except for OutOfMemoryError or StackOverflowError which
     10        can be thrown at any time), or have any side effects that is observable from JS
     11        code.  In this case, llint_slow_path_get_private_name() is just implementating
     12        PrivateFieldGet (https://tc39.es/proposal-class-fields/#sec-privatefieldget) and
     13        should actually be using PropertySlot::InternalMethodType::GetOwnProperty
     14        (according to https://tc39.es/proposal-class-fields/#sec-privatefieldfind).
     15
     16        This patch makes the above change, and also adds an assert in JSObject::getPrivateField
     17        to ensure that no one calls it for a VMInquiry since it is not supported.
     18
     19        Also added a PropertySlot::isVMInquiry() convenience query method.
     20
     21        * llint/LLIntSlowPaths.cpp:
     22        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
     23        * runtime/JSObjectInlines.h:
     24        (JSC::JSObject::getPrivateField):
     25        * runtime/PropertySlot.h:
     26        (JSC::PropertySlot::isVMInquiry const):
     27
    1282020-07-21  Keith Miller  <keith_miller@apple.com>
    229
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r264105 r264679  
    10941094    ASSERT(property.isPrivateName());
    10951095
    1096     PropertySlot slot(baseValue, PropertySlot::InternalMethodType::VMInquiry);
     1096    PropertySlot slot(baseValue, PropertySlot::InternalMethodType::GetOwnProperty);
    10971097    asObject(baseValue)->getPrivateField(globalObject, property, slot);
    10981098    LLINT_CHECK_EXCEPTION();
  • trunk/Source/JavaScriptCore/runtime/JSObjectInlines.h

    r264574 r264679  
    22 *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
    33 *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
    4  *  Copyright (C) 2003-2019 Apple Inc. All rights reserved.
     4 *  Copyright (C) 2003-2020 Apple Inc. All rights reserved.
    55 *  Copyright (C) 2007 Eric Seidel (eric@webkit.org)
    66 *
     
    604604    VM& vm = getVM(globalObject);
    605605    auto scope = DECLARE_THROW_SCOPE(vm);
     606    ASSERT(!slot.isVMInquiry());
    606607    if (!JSObject::getPrivateFieldSlot(this, globalObject, propertyName, slot)) {
    607608        throwException(globalObject, scope, createInvalidPrivateNameError(globalObject));
  • trunk/Source/JavaScriptCore/runtime/PropertySlot.h

    r261464 r264679  
    11/*
    2  *  Copyright (C) 2005-2019 Apple Inc. All rights reserved.
     2 *  Copyright (C) 2005-2020 Apple Inc. All rights reserved.
    33 *
    44 *  This library is free software; you can redistribute it and/or
     
    140140
    141141    InternalMethodType internalMethodType() const { return m_internalMethodType; }
     142    bool isVMInquiry() const { return m_internalMethodType == InternalMethodType::VMInquiry; }
    142143
    143144    void disableCaching()
Note: See TracChangeset for help on using the changeset viewer.