Ignore:
Timestamp:
Dec 1, 2007, 3:56:56 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

Reviewed by Beth Dakin.


Reversed the ownership relationship between Interpreter and JSGlobalObject.
Now, the JSGlobalObject owns the Interpreter, and top-level objects
that need the two to persist just protect the JSGlobalObject from GC.


Global object bootstrapping looks a little odd right now, but it will
make much more sense soon, after further rounds of refactoring.

  • bindings/runtime_root.h: Made this class inherit from RefCounted, to avoid code duplication.
  • kjs/collector.cpp: (KJS::Collector::collect): No need to give special GC treatment to Interpreters, since we mark their global objects, which mark them.
  • kjs/interpreter.cpp: (KJS::Interpreter::mark): No need to mark our global object, since it marks us.
  • kjs/interpreter.h: Don't inherit from RefCounted -- JSGlobalObject owns us directly.
  • kjs/testkjs.cpp: Modified to follow the new rules. (createGlobalObject): (runWithScripts):

JavaScriptGlue:

Reviewed by Beth Dakin.


Modified to follow new JSGlobalObject/Interpreter ownership rules
in JavaScriptCore.

  • JSRun.cpp: (JSRun::JSRun): (JSRun::GetInterpreter): (JSRun::Evaluate): (JSRun::CheckSyntax):
  • JSRun.h:
  • JSValueWrapper.cpp: (unprotectGlobalObject): (initializeGlobalObjectKey): (getThreadGlobalExecState):

WebCore:

Reviewed by Beth Dakin.


Modified WebCore to follow the new JSGlobalObject/Interpreter ownership
rules in JavaScriptCore.

  • bindings/js/kjs_binding.cpp:
  • bindings/js/kjs_binding.h: Removed stale, unused interpreterForGlobalObject().
  • bindings/js/kjs_proxy.cpp: Changed to store a global object, rather than an interpreter. (WebCore::KJSProxy::finishedWithEvent): Need to NULL check m_globalObject here because we no longer unnecessarily instantiate it.
  • bindings/js/kjs_window.cpp: (KJS::ScheduledAction::execute):
  • bindings/js/kjs_window.h: Removed redundant and less efficient interpreter() function -- global objects have direct access to their interpreters now.

Changed these functions to pass around JSGlobalObjects instead of
Interpreters:

  • page/Frame.cpp: (WebCore::Frame::bindingRootObject): (WebCore::Frame::createRootObject):
  • page/Frame.h:
  • page/mac/WebCoreFrameBridge.mm: (createRootObject):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSGlobalObject.h

    r27022 r28309  
    22/*
    33 *  Copyright (C) 2007 Eric Seidel <[email protected]>
     4 *  Copyright (C) 2007 Apple Ince. All rights reserved.
    45 *
    56 *  This library is free software; you can redistribute it and/or
     
    2627
    2728namespace KJS {
     29
    2830    class Interpreter;
     31
    2932    class JSGlobalObject : public JSObject {
    3033    public:
    3134        JSGlobalObject() { }
    3235        JSGlobalObject(JSValue* proto) : JSObject(proto) { }
    33        
     36
    3437        virtual bool isGlobalObject() const { return true; }
    35        
    36         Interpreter* interpreter() const { return m_interpreter; }
    37         void setInterpreter(Interpreter* i) { m_interpreter = i; }
     38
     39        virtual void mark()
     40        {
     41            JSObject::mark();
     42            m_interpreter->mark();
     43        }
     44
     45        Interpreter* interpreter() const { return m_interpreter.get(); }
     46        void setInterpreter(std::auto_ptr<Interpreter> i) { m_interpreter = i; }
     47
    3848    private:
    39         Interpreter* m_interpreter;
     49        std::auto_ptr<Interpreter> m_interpreter;
    4050    };
     51
    4152} // namespace KJS
    4253
Note: See TracChangeset for help on using the changeset viewer.