Changeset 32807 in webkit for trunk/JavaScriptCore/API


Ignore:
Timestamp:
May 2, 2008, 3:07:53 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Geoffrey Garen.

https://bugs.webkit.org/show_bug.cgi?id=18826
Make JavaScript heap per-thread

Location:
trunk/JavaScriptCore/API
Files:
5 edited

Legend:

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

    r29663 r32807  
    8080{
    8181    JSLock lock;
    82     if (!Collector::isBusy())
    83         Collector::collect();
     82
     83    // It might seem that we have a context passed to this function, and can use toJS(ctx)->heap(), but the parameter is likely to be NULL.
     84    // The performance difference should be negligible anyway.
     85    Heap* heap = Heap::threadHeap();
     86    if (!heap->isBusy())
     87        heap->collect();
    8488    // FIXME: Perhaps we should trigger a second mark and sweep
    8589    // once the garbage collector is done if this is called when
  • trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r32609 r32807  
    467467            if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
    468468                if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
    469                     JSObject* o = new JSCallbackFunction(exec, callAsFunction, propertyName);
     469                    JSObject* o = new (exec) JSCallbackFunction(exec, callAsFunction, propertyName);
    470470                    thisObj->putDirect(propertyName, o, entry->attributes);
    471471                    return o;
  • trunk/JavaScriptCore/API/JSClassRef.cpp

    r31872 r32807  
    163163        if (!parentPrototype)
    164164            parentPrototype = exec->dynamicGlobalObject()->objectPrototype();
    165         cachedPrototype = new JSCallbackObject<JSObject>(exec, prototypeClass, parentPrototype, this); // set ourself as the object's private data, so it can clear our reference on destruction
     165        cachedPrototype = new (exec) JSCallbackObject<JSObject>(exec, prototypeClass, parentPrototype, this); // set ourself as the object's private data, so it can clear our reference on destruction
    166166    }
    167167    return cachedPrototype;
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r32609 r32807  
    7575
    7676    if (!jsClass)
    77         return toRef(new JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient
     77        return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient
    7878
    7979    JSValue* jsPrototype = jsClass->prototype(ctx);
     
    8181        jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
    8282
    83     return toRef(new JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data));
     83    return toRef(new (exec) JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data));
    8484}
    8585
     
    9090    Identifier nameID = name ? Identifier(toJS(name)) : Identifier("anonymous");
    9191   
    92     return toRef(new JSCallbackFunction(exec, callAsFunction, nameID));
     92    return toRef(new (exec) JSCallbackFunction(exec, callAsFunction, nameID));
    9393}
    9494
     
    102102        : exec->dynamicGlobalObject()->objectPrototype();
    103103   
    104     JSCallbackConstructor* constructor = new JSCallbackConstructor(exec, jsClass, callAsConstructor);
     104    JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec, jsClass, callAsConstructor);
    105105    constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
    106106    return toRef(constructor);
     
    119119    List args;
    120120    for (unsigned i = 0; i < parameterCount; i++)
    121         args.append(jsString(UString(toJS(parameterNames[i]))));
    122     args.append(jsString(UString(bodyRep)));
     121        args.append(jsString(exec, UString(toJS(parameterNames[i]))));
     122    args.append(jsString(exec, UString(bodyRep)));
    123123
    124124    JSObject* result = exec->dynamicGlobalObject()->functionConstructor()->construct(exec, args, nameID, UString(sourceURLRep), startingLineNumber);
  • trunk/JavaScriptCore/API/JSValueRef.cpp

    r29663 r32807  
    177177}
    178178
    179 JSValueRef JSValueMakeNumber(JSContextRef, double value)
    180 {
    181     JSLock lock;
    182     return toRef(jsNumber(value));
    183 }
    184 
    185 JSValueRef JSValueMakeString(JSContextRef, JSStringRef string)
     179JSValueRef JSValueMakeNumber(JSContextRef ctx, double value)
     180{
     181    JSLock lock;
     182    return toRef(jsNumber(toJS(ctx), value));
     183}
     184
     185JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string)
    186186{
    187187    JSLock lock;
    188188    UString::Rep* rep = toJS(string);
    189     return toRef(jsString(UString(rep)));
     189    return toRef(jsString(toJS(ctx), UString(rep)));
    190190}
    191191
Note: See TracChangeset for help on using the changeset viewer.