Ignore:
Timestamp:
Feb 17, 2016, 2:11:39 PM (9 years ago)
Author:
[email protected]
Message:

Implement Proxy Get
https://bugs.webkit.org/show_bug.cgi?id=154081

Reviewed by Michael Saboff.

Source/JavaScriptCore:

This patch implements ProxyObject and ProxyConstructor. Their
implementations are straight forward and follow the spec.
The largest change in this patch is adding a second parameter
to PropertySlot's constructor that specifies the internal method type of
the getOwnPropertySlot inquiry. We use getOwnPropertySlot to
implement more than one Internal Method in the spec. Because
of this, we need InternalMethodType to give us context about
which Internal Method we're executing. Specifically, Proxy will
call into different handlers based on this information.

InternalMethodType is an enum with the following values:

  • Get This corresponds to Get internal method in the spec.
  • GetOwnProperty This corresponds to GetOwnProperty internal method in the spec.
  • HasProperty This corresponds to HasProperty internal method in the spec.
  • VMInquiry This is basically everything else that isn't one of the above types. This value also mandates that getOwnPropertySlot does not perform any user observable effects. I.e, it can't call a JS function.

The other non-VMInquiry InternalMethodTypes are allowed to perform user
observable effects. I.e, in future patches, ProxyObject will implement
InternalMethodType::HasProperty and InternalMethodType::GetOwnProperty, which will both be defined
to call user defined JS functions, which clearly have the right to perform
user observable effects.

This patch implements getOwnPropertySlot of ProxyObject under
InternalMethodType::Get.

  • API/JSCallbackObjectFunctions.h:

(JSC::JSCallbackObject<Parent>::put):
(JSC::JSCallbackObject<Parent>::staticFunctionGetter):

  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • debugger/DebuggerScope.cpp:

(JSC::DebuggerScope::caughtValue):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::execute):

  • jit/JITOperations.cpp:
  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • runtime/ArrayPrototype.cpp:

(JSC::getProperty):

  • runtime/CommonIdentifiers.h:
  • runtime/JSCJSValueInlines.h:

(JSC::JSValue::get):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::getOwnNonIndexPropertyNames):
(JSC::JSFunction::put):
(JSC::JSFunction::defineOwnProperty):

  • runtime/JSGenericTypedArrayViewConstructorInlines.h:

(JSC::constructGenericTypedArrayViewWithArguments):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::defineOwnProperty):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::regExpMatchesArrayStructure):
(JSC::JSGlobalObject::moduleRecordStructure):
(JSC::JSGlobalObject::moduleNamespaceObjectStructure):
(JSC::JSGlobalObject::proxyObjectStructure):
(JSC::JSGlobalObject::wasmModuleStructure):

  • runtime/JSModuleEnvironment.cpp:

(JSC::JSModuleEnvironment::getOwnPropertySlot):

  • runtime/JSModuleNamespaceObject.cpp:

(JSC::callbackGetter):

  • runtime/JSONObject.cpp:

(JSC::Stringifier::Holder::appendNextProperty):
(JSC::Walker::walk):

  • runtime/JSObject.cpp:

(JSC::JSObject::calculatedClassName):
(JSC::JSObject::putDirectNonIndexAccessor):
(JSC::JSObject::hasProperty):
(JSC::JSObject::deleteProperty):
(JSC::JSObject::hasOwnProperty):
(JSC::JSObject::getOwnPropertyDescriptor):

  • runtime/JSObject.h:

(JSC::JSObject::getDirectIndex):
(JSC::JSObject::get):

  • runtime/JSScope.cpp:

(JSC::abstractAccess):

  • runtime/ObjectConstructor.cpp:

(JSC::toPropertyDescriptor):

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncLookupGetter):
(JSC::objectProtoFuncLookupSetter):
(JSC::objectProtoFuncToString):

  • runtime/PropertySlot.h:

(JSC::attributesForStructure):
(JSC::PropertySlot::PropertySlot):
(JSC::PropertySlot::isCacheableGetter):
(JSC::PropertySlot::isCacheableCustom):
(JSC::PropertySlot::internalMethodType):
(JSC::PropertySlot::disableCaching):
(JSC::PropertySlot::getValue):

  • runtime/ProxyConstructor.cpp: Added.

(JSC::ProxyConstructor::create):
(JSC::ProxyConstructor::ProxyConstructor):
(JSC::ProxyConstructor::finishCreation):
(JSC::constructProxyObject):
(JSC::ProxyConstructor::getConstructData):
(JSC::ProxyConstructor::getCallData):

  • runtime/ProxyConstructor.h: Added.

(JSC::ProxyConstructor::createStructure):

  • runtime/ProxyObject.cpp: Added.

(JSC::ProxyObject::ProxyObject):
(JSC::ProxyObject::finishCreation):
(JSC::performProxyGet):
(JSC::ProxyObject::getOwnPropertySlotCommon):
(JSC::ProxyObject::getOwnPropertySlot):
(JSC::ProxyObject::getOwnPropertySlotByIndex):
(JSC::ProxyObject::visitChildren):

  • runtime/ProxyObject.h: Added.

(JSC::ProxyObject::create):
(JSC::ProxyObject::createStructure):
(JSC::ProxyObject::target):
(JSC::ProxyObject::handler):

  • runtime/ReflectObject.cpp:

(JSC::reflectObjectGet):

  • runtime/SamplingProfiler.cpp:

(JSC::SamplingProfiler::StackFrame::nameFromCallee):

  • tests/es6.yaml:
  • tests/stress/proxy-basic.js: Added.

(assert):
(let.handler.get null):
(get let):
(let.handler.get switch):
(let.handler):
(let.theTarget.get x):

  • tests/stress/proxy-in-proto-chain.js: Added.

(assert):

  • tests/stress/proxy-of-a-proxy.js: Added.

(assert):
(throw.new.Error.):

  • tests/stress/proxy-property-descriptor.js: Added.

(assert):
(set Object):

  • wasm/WASMModuleParser.cpp:

(JSC::WASMModuleParser::getImportedValue):

Source/WebCore:

Tests are in JavaScriptCore.

  • bindings/js/JSCryptoAlgorithmDictionary.cpp:

(WebCore::getProperty):
(WebCore::getHashAlgorithm):

  • bindings/js/JSCryptoKeySerializationJWK.cpp:

(WebCore::getJSArrayFromJSON):
(WebCore::getStringFromJSON):
(WebCore::getBooleanFromJSON):

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::DialogHandler::returnValue):

  • bindings/js/JSDictionary.cpp:

(WebCore::JSDictionary::tryGetProperty):

  • bindings/js/JSStorageCustom.cpp:

(WebCore::JSStorage::deleteProperty):
(WebCore::JSStorage::deletePropertyByIndex):
(WebCore::JSStorage::putDelegate):

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneSerializer::getProperty):

  • testing/Internals.cpp:

(WebCore::Internals::isReadableStreamDisturbed):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r196702 r196722  
    278278    WriteBarrier<Structure> m_moduleRecordStructure;
    279279    WriteBarrier<Structure> m_moduleNamespaceObjectStructure;
     280    WriteBarrier<Structure> m_proxyObjectStructure;
    280281#if ENABLE(WEBASSEMBLY)
    281282    WriteBarrier<Structure> m_wasmModuleStructure;
     
    529530    Structure* moduleRecordStructure() const { return m_moduleRecordStructure.get(); }
    530531    Structure* moduleNamespaceObjectStructure() const { return m_moduleNamespaceObjectStructure.get(); }
     532    Structure* proxyObjectStructure() const { return m_proxyObjectStructure.get(); }
    531533#if ENABLE(WEBASSEMBLY)
    532534    Structure* wasmModuleStructure() const { return m_wasmModuleStructure.get(); }
Note: See TracChangeset for help on using the changeset viewer.