• barraclough@apple.com's avatar
    Some cleanup in JSValue::get · ab7b6096
    barraclough@apple.com authored
    Reviewed by Geoff Garen.
    JSValue::get is implemented to:
        1) Check if the value is a cell – if not, synthesize a prototype to search,
        2) call getOwnPropertySlot on the cell,
        3) if this returns false, cast to JSObject to get the prototype, and walk the prototype chain.
    By all rights this should crash when passed a string and accessing a property that does not exist, because
    the string is a cell, getOwnPropertySlot should return false, and the cast to JSObject should be unsafe.
    To work around this, JSString::getOwnPropertySlot actually implements 'get' functionality - searching the
    prototype chain, and faking out a return value of undefined if no property is found.
    This is a huge hazard, since fixing JSString::getOwnPropertySlot or calling getOwnPropertySlot on cells
    from elsewhere would introduce bugs. Fortunately it is only ever called in this one place.
    The fix here is to move getOwnPropertySlot onto JSObjecte and end this madness - cells don't have property
    slots anyway.
    Interesting changes are in JSCJSValueInlines.h, JSString.cpp - the rest is pretty much all JSCell -> JSObject.
    * WebCore.exp.in:
    * bindings/js/JSDOMWindowCustom.cpp:
    * bindings/scripts/CodeGeneratorJS.pm:
    * bridge/objc/objc_runtime.h:
    * bridge/objc/objc_runtime.mm:
    * bridge/runtime_array.cpp:
    * bridge/runtime_array.h:
    * bridge/runtime_method.cpp:
    * bridge/runtime_method.h:
    * bridge/runtime_object.cpp:
    * bridge/runtime_object.h:
        - getOwnPropertySlot, JSCell -> JSObject
    * WebProcess/Plugins/Netscape/JSNPObject.cpp:
    * WebProcess/Plugins/Netscape/JSNPObject.h:
        - getOwnPropertySlot, JSCell -> JSObject
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153532 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JSGlobalObject.h 21.6 KB