Ignore:
Timestamp:
Jul 14, 2006, 3:39:58 PM (19 years ago)
Author:
ggaren
Message:

JavaScriptCore:

Reviewed by Maciej.


  • Implemented ref-counting of JSContexts by splitting into two datatypes: JSGlobalContext, which you can create/retain/release, and JSContext, which you can't.


Internally, you retain a JSGlobalContext/ExecState by retaining its
interpreter, which, in the case of a global ExecState, owns it.


  • Also made ~Interpreter() protected to catch places where Interpreter is manually deleted. (Can't make it private because some crazy fool decided it would be a good idea to subclass Interpreter in other frameworks. I pity da fool.)
  • API/APICast.h: (toJS): Added cast for new JSGlobalContext
  • API/JSStringRef.h: Changed vague "you must" language to more specific (but, ultimately, equally vague) "behavior is undefined if you don't" language. (KJS::Interpreter::Interpreter): Factored more common initialization into init()
  • kjs/interpreter.h: (KJS::Interpreter::ref): new (KJS::Interpreter::deref): new (KJS::Interpreter::refCount): new
  • kjs/testkjs.cpp: (doIt): Ref-count the interpreter.

JavaScriptGlue:

Reviewed by Maciej.


  • Updated JSInterpreter to work with Interpreter ref-counting in JavaScriptCore.

(JSInterpreter::JSInterpreter::~JSInterpreter): Now protected to catch
manual delete.

WebCore:

Reviewed by Maciej.

  • Updated ScriptInterpreter to work with Interpreter ref-counting in JavaScriptCore.

(KJS::ScriptInterpreter::~ScriptInterpreter): Now protected to catch
manual delete.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSContextRef.cpp

    r15428 r15437  
    3535using namespace KJS;
    3636
    37 JSContextRef JSContextCreate(JSClassRef globalObjectClass)
     37JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass)
    3838{
    3939    JSLock lock;
     
    4747
    4848    Interpreter* interpreter = new Interpreter(globalObject); // adds the built-in object prototype to the global object
    49     return toRef(interpreter->globalExec());
     49    JSGlobalContextRef context = reinterpret_cast<JSGlobalContextRef>(interpreter->globalExec());
     50    return JSGlobalContextRetain(context);
    5051}
    5152
    52 void JSContextDestroy(JSContextRef context)
     53JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef context)
    5354{
    5455    JSLock lock;
    5556    ExecState* exec = toJS(context);
    56     delete exec->dynamicInterpreter();
     57    exec->dynamicInterpreter()->ref();
     58    return context;
     59}
     60
     61void JSGlobalContextRelease(JSGlobalContextRef context)
     62{
     63    JSLock lock;
     64    ExecState* exec = toJS(context);
     65    exec->dynamicInterpreter()->deref();
    5766}
    5867
Note: See TracChangeset for help on using the changeset viewer.