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

Changeset 232143 in webkit


Ignore:
Timestamp:
May 23, 2018, 8:01:43 PM (8 years ago)
Author:
keith_miller@apple.com
Message:

Expose $vm if window.internals is exposed
​https://bugs.webkit.org/show_bug.cgi?id=185900

Reviewed by Mark Lam.

This is useful for testing vm internals when running LayoutTests.

Source/JavaScriptCore:

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
(JSC::JSGlobalObject::exposeDollarVM):

  • runtime/JSGlobalObject.h:

Source/WebCore:

  • testing/js/WebCoreTestSupport.cpp:

(WebCoreTestSupport::injectInternalsObject):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r232138 r232143  
     12018-05-23  Keith Miller  <keith_miller@apple.com>
     2
     3        Expose $vm if window.internals is exposed
     4        https://bugs.webkit.org/show_bug.cgi?id=185900
     5
     6        Reviewed by Mark Lam.
     7
     8        This is useful for testing vm internals when running LayoutTests.
     9
     10        * runtime/JSGlobalObject.cpp:
     11        (JSC::JSGlobalObject::init):
     12        (JSC::JSGlobalObject::visitChildren):
     13        (JSC::JSGlobalObject::exposeDollarVM):
     14        * runtime/JSGlobalObject.h:
     15
    1162018-05-23  Keith Miller  <keith_miller@apple.com>
    217
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r232070 r232143  
    965965    m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::ThrowTypeErrorFunction)] = m_throwTypeErrorFunction.get();
    966966
    967     if (UNLIKELY(Options::useDollarVM())) {
    968         m_dollarVMStructure.set(vm, this, JSDollarVM::createStructure(vm, this, m_objectPrototype.get()));
    969         JSDollarVM* dollarVM = JSDollarVM::create(vm, m_dollarVMStructure.get());
    970 
    971         GlobalPropertyInfo extraStaticGlobals[] = {
    972             GlobalPropertyInfo(vm.propertyNames->builtinNames().dollarVMPrivateName(), dollarVM, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
    973         };
    974         addStaticGlobals(extraStaticGlobals, WTF_ARRAY_LENGTH(extraStaticGlobals));
    975 
    976         putDirectWithoutTransition(vm, Identifier::fromString(exec, "$vm"), dollarVM, static_cast<unsigned>(PropertyAttribute::DontEnum));
    977     }
     967    if (UNLIKELY(Options::useDollarVM()))
     968        exposeDollarVM();
    978969
    979970#if ENABLE(WEBASSEMBLY)
    … …  
    14301421    visitor.append(thisObject->m_moduleRecordStructure);
    14311422    visitor.append(thisObject->m_moduleNamespaceObjectStructure);
    1432     visitor.append(thisObject->m_dollarVMStructure);
    14331423    visitor.append(thisObject->m_proxyObjectStructure);
    14341424    visitor.append(thisObject->m_callableProxyObjectStructure);
    … …  
    14811471{
    14821472    return CallFrame::create(m_globalCallFrame);
     1473}
     1474
     1475void JSGlobalObject::exposeDollarVM()
     1476{
     1477    VM& vm = this->vm();
     1478
     1479    if (hasOwnProperty(globalExec(), vm.propertyNames->builtinNames().dollarVMPrivateName()))
     1480        return;
     1481
     1482    JSDollarVM* dollarVM = JSDollarVM::create(vm, JSDollarVM::createStructure(vm, this, m_objectPrototype.get()));
     1483
     1484    GlobalPropertyInfo extraStaticGlobals[] = {
     1485        GlobalPropertyInfo(vm.propertyNames->builtinNames().dollarVMPrivateName(), dollarVM, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
     1486    };
     1487    addStaticGlobals(extraStaticGlobals, WTF_ARRAY_LENGTH(extraStaticGlobals));
     1488
     1489    putDirect(vm, Identifier::fromString(globalExec(), "$vm"), dollarVM, static_cast<unsigned>(PropertyAttribute::DontEnum));
    14831490}
    14841491
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r232070 r232143  
    356356    WriteBarrier<Structure> m_asyncGeneratorFunctionStructure;
    357357    WriteBarrier<Structure> m_generatorFunctionStructure;
    358     WriteBarrier<Structure> m_dollarVMStructure;
    359358    WriteBarrier<Structure> m_iteratorResultObjectStructure;
    360359    WriteBarrier<Structure> m_regExpMatchesArrayStructure;
    … …  
    903902
    904903    bool needsSiteSpecificQuirks() const { return m_needsSiteSpecificQuirks; }
     904    JS_EXPORT_PRIVATE void exposeDollarVM();
    905905
    906906#if JSC_OBJC_API_ENABLED
  • trunk/Source/WebCore/ChangeLog

    r232139 r232143  
     12018-05-23  Keith Miller  <keith_miller@apple.com>
     2
     3        Expose $vm if window.internals is exposed
     4        https://bugs.webkit.org/show_bug.cgi?id=185900
     5
     6        Reviewed by Mark Lam.
     7
     8        This is useful for testing vm internals when running LayoutTests.
     9
     10        * testing/js/WebCoreTestSupport.cpp:
     11        (WebCoreTestSupport::injectInternalsObject):
     12
    1132018-05-23  David Kilzer  <ddkilzer@apple.com>
    214
  • trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp

    r228218 r232143  
    5858    JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
    5959    ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext();
    60     if (is<Document>(*scriptContext))
     60    if (is<Document>(*scriptContext)) {
    6161        globalObject->putDirect(exec->vm(), Identifier::fromString(exec, Internals::internalsId), toJS(exec, globalObject, Internals::create(downcast<Document>(*scriptContext))));
     62        globalObject->exposeDollarVM();
     63    }
    6264}
    6365
Note: See TracChangeset for help on using the changeset viewer.