Changeset 148062 in webkit


Ignore:
Timestamp:
Apr 9, 2013 4:28:59 PM (11 years ago)
Author:
oliver@apple.com
Message:

Add liveness tests to JSC API entry points
https://bugs.webkit.org/show_bug.cgi?id=114318

Reviewed by Filip Pizlo.

Add simple checks for the existence of a method table on any
JSCells passed across the API. This in turn forces a structure
validity test.

  • API/APICast.h:

(toJS):
(toJSForGC):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/APICast.h

    r142557 r148062  
    6868    if (!jsCell)
    6969        return JSC::jsNull();
     70    JSC::JSValue result;
    7071    if (jsCell->isAPIValueWrapper())
    71         return JSC::jsCast<JSC::JSAPIValueWrapper*>(jsCell)->value();
    72     return jsCell;
     72        result = JSC::jsCast<JSC::JSAPIValueWrapper*>(jsCell)->value();
     73    else
     74        result = jsCell;
    7375#else
    7476    JSC::JSValue result = JSC::JSValue::decode(reinterpret_cast<JSC::EncodedJSValue>(const_cast<OpaqueJSValue*>(v)));
     77#endif
    7578    if (!result)
    7679        return JSC::jsNull();
     80    if (result.isCell())
     81        RELEASE_ASSERT(result.asCell()->methodTable());
    7782    return result;
    78 #endif
    7983}
    8084
     
    8690    if (!jsCell)
    8791        return JSC::JSValue();
    88     return jsCell;
     92    JSC::JSValue result = jsCell;
    8993#else
    90     return JSC::JSValue::decode(reinterpret_cast<JSC::EncodedJSValue>(const_cast<OpaqueJSValue*>(v)));
     94    JSC::JSValue result = JSC::JSValue::decode(reinterpret_cast<JSC::EncodedJSValue>(const_cast<OpaqueJSValue*>(v)));
    9195#endif
     96    if (result && result.isCell())
     97        RELEASE_ASSERT(result.asCell()->methodTable());
     98    return result;
    9299}
    93100
    94101inline JSC::JSObject* toJS(JSObjectRef o)
    95102{
    96     return reinterpret_cast<JSC::JSObject*>(o);
     103    JSC::JSObject* object = reinterpret_cast<JSC::JSObject*>(o);
     104    if (object)
     105        RELEASE_ASSERT(object->methodTable());
     106    return object;
    97107}
    98108
  • trunk/Source/JavaScriptCore/ChangeLog

    r148045 r148062  
     12013-04-09  Oliver Hunt  <oliver@apple.com>
     2
     3        Add liveness tests to JSC API entry points
     4        https://bugs.webkit.org/show_bug.cgi?id=114318
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Add simple checks for the existence of a method table on any
     9        JSCells passed across the API.  This in turn forces a structure
     10        validity test.
     11
     12        * API/APICast.h:
     13        (toJS):
     14        (toJSForGC):
     15
    1162013-04-09  Balazs Kilvady  <kilvadyb@homejinni.com>
    217
Note: See TracChangeset for help on using the changeset viewer.