Ignore:
Timestamp:
Aug 19, 2013, 2:44:17 PM (12 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=119995
Start removing custom implementations of getOwnPropertyDescriptor

Reviewed by Sam Weinig.

This can now typically implemented in terms of getOwnPropertySlot.
Add a macro to PropertyDescriptor to define an implementation of GOPD in terms of GOPS.
Switch over most classes in JSC & the WebCore bindings generator to use this.

Source/JavaScriptCore:

  • API/JSCallbackObjectFunctions.h:
  • debugger/DebuggerActivation.cpp:
  • runtime/Arguments.cpp:
  • runtime/ArrayConstructor.cpp:
  • runtime/ArrayPrototype.cpp:
  • runtime/BooleanPrototype.cpp:
  • runtime/DateConstructor.cpp:
  • runtime/DatePrototype.cpp:
  • runtime/ErrorPrototype.cpp:
  • runtime/JSActivation.cpp:
  • runtime/JSArray.cpp:
  • runtime/JSArrayBuffer.cpp:
  • runtime/JSArrayBufferView.cpp:
  • runtime/JSCell.cpp:
  • runtime/JSDataView.cpp:
  • runtime/JSDataViewPrototype.cpp:
  • runtime/JSFunction.cpp:
  • runtime/JSGenericTypedArrayViewInlines.h:
  • runtime/JSNotAnObject.cpp:
  • runtime/JSONObject.cpp:
  • runtime/JSObject.cpp:
  • runtime/NamePrototype.cpp:
  • runtime/NumberConstructor.cpp:
  • runtime/NumberPrototype.cpp:
  • runtime/ObjectConstructor.cpp:
    • Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL.
  • runtime/PropertyDescriptor.h:
    • Added GET_OWN_PROPERTY_DESCRIPTOR_IMPL macro.
  • runtime/PropertySlot.h:

(JSC::PropertySlot::isValue):
(JSC::PropertySlot::isGetter):
(JSC::PropertySlot::isCustom):
(JSC::PropertySlot::isCacheableValue):
(JSC::PropertySlot::isCacheableGetter):
(JSC::PropertySlot::isCacheableCustom):
(JSC::PropertySlot::attributes):
(JSC::PropertySlot::getterSetter):

  • Add accessors necessary to convert PropertySlot to descriptor.
  • runtime/RegExpConstructor.cpp:
  • runtime/RegExpMatchesArray.cpp:
  • runtime/RegExpMatchesArray.h:
  • runtime/RegExpObject.cpp:
  • runtime/RegExpPrototype.cpp:
  • runtime/StringConstructor.cpp:
  • runtime/StringObject.cpp:
    • Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL.

Source/WebCore:

  • bindings/js/JSCSSStyleDeclarationCustom.cpp:
  • bindings/js/JSHTMLAppletElementCustom.cpp:
  • bindings/js/JSHTMLEmbedElementCustom.cpp:
  • bindings/js/JSHTMLObjectElementCustom.cpp:
  • bindings/js/JSHistoryCustom.cpp:

(WebCore::JSHistory::getOwnPropertySlotDelegate):

  • bindings/js/JSLocationCustom.cpp:

(WebCore::JSLocation::getOwnPropertySlotDelegate):

  • bindings/js/JSWorkerGlobalScopeCustom.cpp:
    • Remove getOwnPropertyDescriptorDelegate methods, Change attributes of cross-frame access properties in JSHistory/JSLocation to prevent properties from being redefined.
  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader):
(GenerateImplementation):
(GenerateConstructorHelperMethods):

  • Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL.
  • bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
  • bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
  • bindings/scripts/test/JS/JSTestEventConstructor.cpp:
  • bindings/scripts/test/JS/JSTestEventTarget.cpp:
  • bindings/scripts/test/JS/JSTestException.cpp:
  • bindings/scripts/test/JS/JSTestInterface.cpp:
  • bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
  • bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
  • bindings/scripts/test/JS/JSTestNode.cpp:
  • bindings/scripts/test/JS/JSTestObj.cpp:
  • bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
  • bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
  • bindings/scripts/test/JS/JSTestTypedefs.cpp:
    • Update test expectations.

LayoutTests:

  • http/tests/security/xss-DENIED-defineProperty-expected.txt:
    • Remove erroneous error messages - cross frame access to reload is allowed - it's just read-only, non-configurable.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r154253 r154300  
    23822382}
    23832383
    2384 bool JSObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
    2385 {
    2386     unsigned attributes = 0;
    2387     JSCell* cell = 0;
    2388     PropertyOffset offset = object->structure()->get(exec->vm(), propertyName, attributes, cell);
    2389     if (isValidOffset(offset)) {
    2390         descriptor.setDescriptor(object->getDirect(offset), attributes);
    2391         return true;
    2392     }
    2393    
    2394     unsigned i = propertyName.asIndex();
    2395     if (i == PropertyName::NotAnIndex)
    2396         return false;
    2397    
    2398     switch (object->structure()->indexingType()) {
    2399     case ALL_BLANK_INDEXING_TYPES:
    2400     case ALL_UNDECIDED_INDEXING_TYPES:
    2401         return false;
    2402        
    2403     case ALL_INT32_INDEXING_TYPES:
    2404     case ALL_CONTIGUOUS_INDEXING_TYPES: {
    2405         Butterfly* butterfly = object->m_butterfly;
    2406         if (i >= butterfly->vectorLength())
    2407             return false;
    2408         JSValue value = butterfly->contiguous()[i].get();
    2409         if (!value)
    2410             return false;
    2411         descriptor.setDescriptor(value, 0);
    2412         return true;
    2413     }
    2414        
    2415     case ALL_DOUBLE_INDEXING_TYPES: {
    2416         Butterfly* butterfly = object->m_butterfly;
    2417         if (i >= butterfly->vectorLength())
    2418             return false;
    2419         double value = butterfly->contiguousDouble()[i];
    2420         if (value != value)
    2421             return false;
    2422         descriptor.setDescriptor(JSValue(JSValue::EncodeAsDouble, value), 0);
    2423         return true;
    2424     }
    2425        
    2426     case ALL_ARRAY_STORAGE_INDEXING_TYPES: {
    2427         ArrayStorage* storage = object->m_butterfly->arrayStorage();
    2428         if (i >= storage->length())
    2429             return false;
    2430         if (i < storage->vectorLength()) {
    2431             WriteBarrier<Unknown>& value = storage->m_vector[i];
    2432             if (!value)
    2433                 return false;
    2434             descriptor.setDescriptor(value.get(), 0);
    2435             return true;
    2436         }
    2437         if (SparseArrayValueMap* map = storage->m_sparseMap.get()) {
    2438             SparseArrayValueMap::iterator it = map->find(i);
    2439             if (it == map->notFound())
    2440                 return false;
    2441             it->value.get(descriptor);
    2442             return true;
    2443         }
    2444         return false;
    2445     }
    2446        
    2447     default:
    2448         RELEASE_ASSERT_NOT_REACHED();
    2449         return false;
    2450     }
    2451 }
     2384GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSObject)
    24522385
    24532386bool JSObject::getPropertyDescriptor(ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
Note: See TracChangeset for help on using the changeset viewer.