Ignore:
Timestamp:
Dec 1, 2007, 3:56:56 PM (18 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/bindings/runtime_root.cpp

    r23538 r28309  
    2626#include "runtime_root.h"
    2727
     28#include "JSGlobalObject.h"
    2829#include "object.h"
    2930#include "runtime.h"
    3031#include "runtime_object.h"
    31 
    3232#include <wtf/HashCountedSet.h>
    3333#include <wtf/HashSet.h>
     
    196196#endif
    197197
    198 PassRefPtr<RootObject> RootObject::create(const void* nativeHandle, PassRefPtr<Interpreter> interpreter)
    199 {
    200     return new RootObject(nativeHandle, interpreter);
    201 }
    202 
    203 RootObject::RootObject(const void* nativeHandle, PassRefPtr<Interpreter> interpreter)
    204     : m_refCount(0)
    205     , m_isValid(true)
     198PassRefPtr<RootObject> RootObject::create(const void* nativeHandle, JSGlobalObject* globalObject)
     199{
     200    return new RootObject(nativeHandle, globalObject);
     201}
     202
     203RootObject::RootObject(const void* nativeHandle, JSGlobalObject* globalObject)
     204    : m_isValid(true)
    206205    , m_nativeHandle(nativeHandle)
    207     , m_interpreter(interpreter)
    208 {
    209     ASSERT(m_interpreter);
     206    , m_globalObject(globalObject)
     207{
     208    ASSERT(globalObject);
    210209    rootObjectSet()->add(this);
    211210}
     
    233232
    234233    m_nativeHandle = 0;
    235     m_interpreter = 0;
     234    m_globalObject = 0;
    236235
    237236    ProtectCountSet::iterator end = m_protectCountSet.end();
     
    285284{
    286285    ASSERT(m_isValid);
    287     return m_interpreter.get();
     286    return m_globalObject->interpreter();
    288287}
    289288
Note: See TracChangeset for help on using the changeset viewer.