Ignore:
Timestamp:
Jul 29, 2008, 11:05:11 PM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Geoff Garen.

Implement JSContextGroup APIs to make concurrent execution possible for
JavaScriptCore clients.

This changes the behavior of JSGlobalContextCreate(), so that it now uses a private context
group for each context, making JSlock implicit locking unnecessary.

  • API/JSContextRef.h:
  • API/JSContextRef.cpp: (JSContextGroupCreate): (JSContextGroupRetain): (JSContextGroupRelease): (JSGlobalContextCreate): (JSGlobalContextCreateInGroup): (JSGlobalContextRelease): (JSContextGetGroup): Added new methods. JSGlobalContextCreate() calls JSGlobalContextCreateInGroup() now.
  • API/APICast.h: (toJS): (toRef): Added converters for JSContextGroupRef.
  • API/JSBase.cpp: (JSGarbageCollect): JSGarbageCollect(0) is now a no-op, and the passed in context is actually used.
  • API/JSBase.h: Aded a typedef for JSContextGroupRef. Updated documentation for JSGarbageCollect().
  • kjs/JSGlobalData.cpp:
  • kjs/JSGlobalData.h: Removed support for JSGlobalData shared instance. JSGlobalData::isSharedInstance member variable still remains, to be deleted in a followup patch.
  • kjs/JSLock.cpp: (KJS::JSLock::JSLock): Disabled JSLock, to be deleted in a follow-up patch.


  • kjs/collector.cpp: (KJS::Heap::markOtherThreadConservatively): Removed an assertion that referenced JSGlobalData::sharedInstance.
  • kjs/collector.h: Made Heap destructor public, so that JSContextRelease can use it.

JavaScriptGlue:

  • JSRun.cpp: (JSRun::JSRun):
  • JSUtils.cpp: (getThreadGlobalExecState): Changed JavaScriptGlue to use a JSGlobalData of its own, now that there is no shared instance.
File:
1 edited

Legend:

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

    r34606 r35442  
    2929#include <JavaScriptCore/JSObjectRef.h>
    3030#include <JavaScriptCore/JSValueRef.h>
     31#include <JavaScriptCore/WebKitAvailability.h>
    3132
    3233#ifndef __cplusplus
     
    4041/*!
    4142@function
     43@abstract Creates a JavaScript context group.
     44@discussion A JSContextGroup associates JavaScript contexts with one another.
     45 Contexts in the same group may share and exchange JavaScript objects. Sharing and/or exchanging
     46 JavaScript objects between contexts in different groups will produce undefined behavior.
     47 When objects from the same context group are used in multiple threads, explicit
     48 synchronization is required.
     49@result The created JSContextGroup.
     50*/
     51JS_EXPORT JSContextGroupRef JSContextGroupCreate() AVAILABLE_AFTER_WEBKIT_VERSION_3_1;
     52
     53/*!
     54@function
     55@abstract Retains a JavaScript context group.
     56@param group The JSContextGroup to retain.
     57@result A JSContextGroup that is the same as group.
     58*/
     59JS_EXPORT JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group) AVAILABLE_AFTER_WEBKIT_VERSION_3_1;
     60
     61/*!
     62@function
     63@abstract Releases a JavaScript context group.
     64@param group The JSContextGroup to release.
     65*/
     66JS_EXPORT void JSContextGroupRelease(JSContextGroupRef group) AVAILABLE_AFTER_WEBKIT_VERSION_3_1;
     67
     68/*!
     69@function
    4270@abstract Creates a global JavaScript execution context.
    4371@discussion JSGlobalContextCreate allocates a global object and populates it with all the
    4472 built-in JavaScript objects, such as Object, Function, String, and Array.
     73 The global context is created in a unique context group.
    4574@param globalObjectClass The class to use when creating the global object. Pass
    4675 NULL to use the default object class.
     
    4877*/
    4978JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass);
     79
     80/*!
     81@function
     82@abstract Creates a global JavaScript execution context in the context group provided.
     83@discussion JSGlobalContextCreateInGroup allocates a global object and populates it with
     84 all the built-in JavaScript objects, such as Object, Function, String, and Array.
     85@param globalObjectClass The class to use when creating the global object. Pass
     86 NULL to use the default object class.
     87@param group The context group to use. The created global context retains the group.
     88@result A JSGlobalContext with a global object of class globalObjectClass and a context
     89 group equal to group.
     90*/
     91JS_EXPORT JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) AVAILABLE_AFTER_WEBKIT_VERSION_3_1;
    5092
    5193/*!
     
    72114JS_EXPORT JSObjectRef JSContextGetGlobalObject(JSContextRef ctx);
    73115
     116/*!
     117@function
     118@abstract Gets the context group to which a JavaScript execution context belongs.
     119@param ctx The JSContext whose group you want to get.
     120@result ctx's group.
     121*/
     122JS_EXPORT JSContextGroupRef JSContextGetGroup(JSContextRef ctx) AVAILABLE_AFTER_WEBKIT_VERSION_3_1;
     123
    74124#ifdef __cplusplus
    75125}
Note: See TracChangeset for help on using the changeset viewer.