Changeset 34659 in webkit for trunk/JavaScriptCore/API
- Timestamp:
- Jun 19, 2008, 10:29:29 AM (17 years ago)
- Location:
- trunk/JavaScriptCore/API
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSBase.cpp
r34581 r34659 29 29 30 30 #include "APICast.h" 31 #include "completion.h" 31 32 #include <kjs/ExecState.h> 32 33 #include <kjs/InitializeThreading.h> … … 86 87 initializeThreading(); 87 88 89 // 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, 90 // and it may actually be garbage for some clients (most likely, because of JSGarbageCollect being called after releasing the context). 91 88 92 JSLock lock; 89 if (!Collector::isBusy()) 90 Collector::collect(); 93 94 // FIXME: It would be good to avoid creating a JSGlobalData instance if it didn't exist for this thread yet. 95 Heap* heap = JSGlobalData::threadInstance().heap; 96 if (!heap->isBusy()) 97 heap->collect(); 98 99 // FIXME: Similarly, we shouldn't create a shared instance here. 100 heap = JSGlobalData::sharedInstance().heap; 101 if (!heap->isBusy()) 102 heap->collect(); 103 91 104 // FIXME: Perhaps we should trigger a second mark and sweep 92 105 // once the garbage collector is done if this is called when -
trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h
r34607 r34659 471 471 if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) { 472 472 if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) { 473 JSObject* o = new JSCallbackFunction(exec, callAsFunction, propertyName);473 JSObject* o = new (exec) JSCallbackFunction(exec, callAsFunction, propertyName); 474 474 thisObj->putDirect(propertyName, o, entry->attributes); 475 475 return o; -
trunk/JavaScriptCore/API/JSClassRef.cpp
r34361 r34659 163 163 if (!parentPrototype) 164 164 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 destruction165 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 166 166 } 167 167 return cachedPrototype; -
trunk/JavaScriptCore/API/JSContextRef.cpp
r34581 r34659 45 45 46 46 if (!globalObjectClass) { 47 JSGlobalObject* globalObject = new JSGlobalObject;47 JSGlobalObject* globalObject = new (JSGlobalObject::Shared) JSGlobalObject; 48 48 return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec())); 49 49 } 50 50 51 JSGlobalObject* globalObject = new JSCallbackObject<JSGlobalObject>(globalObjectClass);51 JSGlobalObject* globalObject = new (JSGlobalObject::Shared) JSCallbackObject<JSGlobalObject>(globalObjectClass); 52 52 JSGlobalContextRef ctx = toGlobalRef(globalObject->globalExec()); 53 53 JSValue* prototype = globalObjectClass->prototype(ctx); -
trunk/JavaScriptCore/API/JSObjectRef.cpp
r34607 r34659 75 75 76 76 if (!jsClass) 77 return toRef(new JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient77 return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient 78 78 79 79 JSValue* jsPrototype = jsClass->prototype(ctx); … … 81 81 jsPrototype = exec->lexicalGlobalObject()->objectPrototype(); 82 82 83 return toRef(new JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data));83 return toRef(new (exec) JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data)); 84 84 } 85 85 … … 90 90 Identifier nameID = name ? Identifier(exec, toJS(name)) : Identifier(exec, "anonymous"); 91 91 92 return toRef(new JSCallbackFunction(exec, callAsFunction, nameID));92 return toRef(new (exec) JSCallbackFunction(exec, callAsFunction, nameID)); 93 93 } 94 94 … … 102 102 : exec->dynamicGlobalObject()->objectPrototype(); 103 103 104 JSCallbackConstructor* constructor = new JSCallbackConstructor(exec, jsClass, callAsConstructor);104 JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec, jsClass, callAsConstructor); 105 105 constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly); 106 106 return toRef(constructor); … … 119 119 ArgList args; 120 120 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))); 123 123 124 124 JSObject* result = exec->dynamicGlobalObject()->functionConstructor()->construct(exec, args, nameID, UString(sourceURLRep), startingLineNumber); -
trunk/JavaScriptCore/API/JSValueRef.cpp
r34581 r34659 177 177 } 178 178 179 JSValueRef JSValueMakeNumber(JSContextRef , double value)180 { 181 JSLock lock; 182 return toRef(jsNumber( value));183 } 184 185 JSValueRef JSValueMakeString(JSContextRef , JSStringRef string)179 JSValueRef JSValueMakeNumber(JSContextRef ctx, double value) 180 { 181 JSLock lock; 182 return toRef(jsNumber(toJS(ctx), value)); 183 } 184 185 JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string) 186 186 { 187 187 JSLock lock; 188 188 UString::Rep* rep = toJS(string); 189 return toRef(jsString( UString(rep)));189 return toRef(jsString(toJS(ctx), UString(rep))); 190 190 } 191 191
Note:
See TracChangeset
for help on using the changeset viewer.