summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/API
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/API')
-rw-r--r--JavaScriptCore/API/APICast.h23
-rw-r--r--JavaScriptCore/API/JSBase.cpp12
-rw-r--r--JavaScriptCore/API/JSCallbackConstructor.cpp2
-rw-r--r--JavaScriptCore/API/JSCallbackConstructor.h6
-rw-r--r--JavaScriptCore/API/JSCallbackFunction.cpp4
-rw-r--r--JavaScriptCore/API/JSCallbackFunction.h6
-rw-r--r--JavaScriptCore/API/JSCallbackObject.cpp2
-rw-r--r--JavaScriptCore/API/JSCallbackObject.h21
-rw-r--r--JavaScriptCore/API/JSCallbackObjectFunctions.h39
-rw-r--r--JavaScriptCore/API/JSClassRef.cpp4
-rw-r--r--JavaScriptCore/API/JSClassRef.h4
-rw-r--r--JavaScriptCore/API/JSContextRef.cpp30
-rw-r--r--JavaScriptCore/API/JSContextRef.h7
-rw-r--r--JavaScriptCore/API/JSObjectRef.cpp18
-rw-r--r--JavaScriptCore/API/JSStringRef.cpp3
-rw-r--r--JavaScriptCore/API/JSStringRefCF.cpp6
-rw-r--r--JavaScriptCore/API/JSValueRef.cpp84
-rw-r--r--JavaScriptCore/API/OpaqueJSString.cpp4
-rw-r--r--JavaScriptCore/API/OpaqueJSString.h2
-rw-r--r--JavaScriptCore/API/WebKitAvailability.h4
20 files changed, 156 insertions, 125 deletions
diff --git a/JavaScriptCore/API/APICast.h b/JavaScriptCore/API/APICast.h
index ecd524c..1344a16 100644
--- a/JavaScriptCore/API/APICast.h
+++ b/JavaScriptCore/API/APICast.h
@@ -26,8 +26,15 @@
#ifndef APICast_h
#define APICast_h
-#include "ustring.h"
-#include "ExecState.h"
+#include "JSValue.h"
+
+namespace JSC {
+ class ExecState;
+ class PropertyNameArray;
+ class JSGlobalData;
+ class JSObject;
+ class JSValuePtr;
+}
typedef const struct OpaqueJSContextGroup* JSContextGroupRef;
typedef const struct OpaqueJSContext* JSContextRef;
@@ -48,9 +55,9 @@ inline JSC::ExecState* toJS(JSGlobalContextRef c)
return reinterpret_cast<JSC::ExecState*>(c);
}
-inline JSC::JSValue* toJS(JSValueRef v)
+inline JSC::JSValuePtr toJS(JSValueRef v)
{
- return reinterpret_cast<JSC::JSValue*>(const_cast<OpaqueJSValue*>(v));
+ return JSC::JSValuePtr::decode(reinterpret_cast<JSC::JSValueEncodedAsPointer*>(const_cast<OpaqueJSValue*>(v)));
}
inline JSC::JSObject* toJS(JSObjectRef o)
@@ -68,14 +75,14 @@ inline JSC::JSGlobalData* toJS(JSContextGroupRef g)
return reinterpret_cast<JSC::JSGlobalData*>(const_cast<OpaqueJSContextGroup*>(g));
}
-inline JSValueRef toRef(JSC::JSValue* v)
+inline JSValueRef toRef(JSC::JSValuePtr v)
{
- return reinterpret_cast<JSValueRef>(v);
+ return reinterpret_cast<JSValueRef>(JSC::JSValuePtr::encode(v));
}
-inline JSValueRef* toRef(JSC::JSValue** v)
+inline JSValueRef* toRef(JSC::JSValuePtr* v)
{
- return reinterpret_cast<JSValueRef*>(const_cast<const JSC::JSValue**>(v));
+ return reinterpret_cast<JSValueRef*>(v);
}
inline JSObjectRef toRef(JSC::JSObject* o)
diff --git a/JavaScriptCore/API/JSBase.cpp b/JavaScriptCore/API/JSBase.cpp
index bd2935c..2ffe345 100644
--- a/JavaScriptCore/API/JSBase.cpp
+++ b/JavaScriptCore/API/JSBase.cpp
@@ -28,12 +28,12 @@
#include "JSBasePrivate.h"
#include "APICast.h"
-#include "completion.h"
+#include "Completion.h"
#include "OpaqueJSString.h"
#include "SourceCode.h"
-#include <runtime/ExecState.h>
+#include <interpreter/CallFrame.h>
#include <runtime/InitializeThreading.h>
-#include <kjs/interpreter.h>
+#include <runtime/Completion.h>
#include <runtime/JSGlobalObject.h>
#include <runtime/JSLock.h>
#include <runtime/JSObject.h>
@@ -48,10 +48,10 @@ JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef th
JSObject* jsThisObject = toJS(thisObject);
- // Interpreter::evaluate sets "this" to the global object if it is NULL
+ // evaluate sets "this" to the global object if it is NULL
JSGlobalObject* globalObject = exec->dynamicGlobalObject();
SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber);
- Completion completion = Interpreter::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject);
+ Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject);
if (completion.complType() == Throw) {
if (exception)
@@ -73,7 +73,7 @@ bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourc
JSLock lock(exec);
SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber);
- Completion completion = Interpreter::checkSyntax(exec->dynamicGlobalObject()->globalExec(), source);
+ Completion completion = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source);
if (completion.complType() == Throw) {
if (exception)
*exception = toRef(completion.value());
diff --git a/JavaScriptCore/API/JSCallbackConstructor.cpp b/JavaScriptCore/API/JSCallbackConstructor.cpp
index 29c26ea..e10733e 100644
--- a/JavaScriptCore/API/JSCallbackConstructor.cpp
+++ b/JavaScriptCore/API/JSCallbackConstructor.cpp
@@ -36,7 +36,7 @@ namespace JSC {
const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0, 0 };
-JSCallbackConstructor::JSCallbackConstructor(PassRefPtr<StructureID> structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
+JSCallbackConstructor::JSCallbackConstructor(PassRefPtr<Structure> structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
: JSObject(structure)
, m_class(jsClass)
, m_callback(callback)
diff --git a/JavaScriptCore/API/JSCallbackConstructor.h b/JavaScriptCore/API/JSCallbackConstructor.h
index 01f15a8..cb8307f 100644
--- a/JavaScriptCore/API/JSCallbackConstructor.h
+++ b/JavaScriptCore/API/JSCallbackConstructor.h
@@ -33,15 +33,15 @@ namespace JSC {
class JSCallbackConstructor : public JSObject {
public:
- JSCallbackConstructor(PassRefPtr<StructureID>, JSClassRef, JSObjectCallAsConstructorCallback);
+ JSCallbackConstructor(PassRefPtr<Structure>, JSClassRef, JSObjectCallAsConstructorCallback);
virtual ~JSCallbackConstructor();
JSClassRef classRef() const { return m_class; }
JSObjectCallAsConstructorCallback callback() const { return m_callback; }
static const ClassInfo info;
- static PassRefPtr<StructureID> createStructureID(JSValue* proto)
+ static PassRefPtr<Structure> createStructure(JSValuePtr proto)
{
- return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | HasStandardGetOwnPropertySlot));
+ return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | HasStandardGetOwnPropertySlot));
}
private:
diff --git a/JavaScriptCore/API/JSCallbackFunction.cpp b/JavaScriptCore/API/JSCallbackFunction.cpp
index 45d726a..86a2ebc 100644
--- a/JavaScriptCore/API/JSCallbackFunction.cpp
+++ b/JavaScriptCore/API/JSCallbackFunction.cpp
@@ -46,11 +46,11 @@ JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCa
{
}
-JSValue* JSCallbackFunction::call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args)
+JSValuePtr JSCallbackFunction::call(ExecState* exec, JSObject* functionObject, JSValuePtr thisValue, const ArgList& args)
{
JSContextRef execRef = toRef(exec);
JSObjectRef functionRef = toRef(functionObject);
- JSObjectRef thisObjRef = toRef(thisValue->toThisObject(exec));
+ JSObjectRef thisObjRef = toRef(thisValue.toThisObject(exec));
int argumentCount = static_cast<int>(args.size());
Vector<JSValueRef, 16> arguments(argumentCount);
diff --git a/JavaScriptCore/API/JSCallbackFunction.h b/JavaScriptCore/API/JSCallbackFunction.h
index 806a992..46f6fcc 100644
--- a/JavaScriptCore/API/JSCallbackFunction.h
+++ b/JavaScriptCore/API/JSCallbackFunction.h
@@ -39,16 +39,16 @@ public:
// InternalFunction mish-mashes constructor and function behavior -- we should
// refactor the code so this override isn't necessary
- static PassRefPtr<StructureID> createStructureID(JSValue* proto)
+ static PassRefPtr<Structure> createStructure(JSValuePtr proto)
{
- return StructureID::create(proto, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot));
+ return Structure::create(proto, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot));
}
private:
virtual CallType getCallData(CallData&);
virtual const ClassInfo* classInfo() const { return &info; }
- static JSValue* call(ExecState*, JSObject*, JSValue*, const ArgList&);
+ static JSValuePtr call(ExecState*, JSObject*, JSValuePtr, const ArgList&);
JSObjectCallAsFunctionCallback m_callback;
};
diff --git a/JavaScriptCore/API/JSCallbackObject.cpp b/JavaScriptCore/API/JSCallbackObject.cpp
index 4be35bd..2fde0f8 100644
--- a/JavaScriptCore/API/JSCallbackObject.cpp
+++ b/JavaScriptCore/API/JSCallbackObject.cpp
@@ -27,7 +27,7 @@
#include "config.h"
#include "JSCallbackObject.h"
-#include "collector.h"
+#include "Collector.h"
namespace JSC {
diff --git a/JavaScriptCore/API/JSCallbackObject.h b/JavaScriptCore/API/JSCallbackObject.h
index 7543e17..9001c43 100644
--- a/JavaScriptCore/API/JSCallbackObject.h
+++ b/JavaScriptCore/API/JSCallbackObject.h
@@ -36,7 +36,7 @@ namespace JSC {
template <class Base>
class JSCallbackObject : public Base {
public:
- JSCallbackObject(ExecState*, PassRefPtr<StructureID>, JSClassRef, void* data);
+ JSCallbackObject(ExecState*, PassRefPtr<Structure>, JSClassRef, void* data);
JSCallbackObject(JSClassRef);
virtual ~JSCallbackObject();
@@ -48,9 +48,9 @@ public:
JSClassRef classRef() const { return m_callbackObjectData->jsClass; }
bool inherits(JSClassRef) const;
- static PassRefPtr<StructureID> createStructureID(JSValue* proto)
+ static PassRefPtr<Structure> createStructure(JSValuePtr proto)
{
- return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | OverridesHasInstance));
+ return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | OverridesHasInstance));
}
private:
@@ -59,12 +59,12 @@ private:
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, unsigned, PropertySlot&);
- virtual void put(ExecState*, const Identifier&, JSValue*, PutPropertySlot&);
+ virtual void put(ExecState*, const Identifier&, JSValuePtr, PutPropertySlot&);
virtual bool deleteProperty(ExecState*, const Identifier&);
virtual bool deleteProperty(ExecState*, unsigned);
- virtual bool hasInstance(ExecState* exec, JSValue* value, JSValue* proto);
+ virtual bool hasInstance(ExecState* exec, JSValuePtr value, JSValuePtr proto);
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
@@ -77,15 +77,14 @@ private:
void init(ExecState*);
- static JSCallbackObject* asCallbackObject(JSValue*);
+ static JSCallbackObject* asCallbackObject(JSValuePtr);
- static JSValue* call(ExecState*, JSObject* functionObject, JSValue* thisValue, const ArgList&);
+ static JSValuePtr call(ExecState*, JSObject* functionObject, JSValuePtr thisValue, const ArgList&);
static JSObject* construct(ExecState*, JSObject* constructor, const ArgList&);
- static JSValue* cachedValueGetter(ExecState*, const Identifier&, const PropertySlot&);
- static JSValue* staticValueGetter(ExecState*, const Identifier&, const PropertySlot&);
- static JSValue* staticFunctionGetter(ExecState*, const Identifier&, const PropertySlot&);
- static JSValue* callbackGetter(ExecState*, const Identifier&, const PropertySlot&);
+ static JSValuePtr staticValueGetter(ExecState*, const Identifier&, const PropertySlot&);
+ static JSValuePtr staticFunctionGetter(ExecState*, const Identifier&, const PropertySlot&);
+ static JSValuePtr callbackGetter(ExecState*, const Identifier&, const PropertySlot&);
struct JSCallbackObjectData {
JSCallbackObjectData(void* privateData, JSClassRef jsClass)
diff --git a/JavaScriptCore/API/JSCallbackObjectFunctions.h b/JavaScriptCore/API/JSCallbackObjectFunctions.h
index f008987..23f941d 100644
--- a/JavaScriptCore/API/JSCallbackObjectFunctions.h
+++ b/JavaScriptCore/API/JSCallbackObjectFunctions.h
@@ -40,14 +40,14 @@
namespace JSC {
template <class Base>
-inline JSCallbackObject<Base>* JSCallbackObject<Base>::asCallbackObject(JSValue* value)
+inline JSCallbackObject<Base>* JSCallbackObject<Base>::asCallbackObject(JSValuePtr value)
{
ASSERT(asObject(value)->inherits(&info));
return static_cast<JSCallbackObject*>(asObject(value));
}
template <class Base>
-JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, PassRefPtr<StructureID> structure, JSClassRef jsClass, void* data)
+JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, PassRefPtr<Structure> structure, JSClassRef jsClass, void* data)
: Base(structure)
, m_callbackObjectData(new JSCallbackObjectData(data, jsClass))
{
@@ -127,10 +127,7 @@ bool JSCallbackObject<Base>::getOwnPropertySlot(ExecState* exec, const Identifie
propertyNameRef = OpaqueJSString::create(propertyName.ustring());
JSLock::DropAllLocks dropAllLocks(exec);
if (JSValueRef value = getProperty(ctx, thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) {
- // cache the value so we don't have to compute it again
- // FIXME: This violates the PropertySlot design a little bit.
- // We should either use this optimization everywhere, or nowhere.
- slot.setCustom(asObject(toJS(value)), cachedValueGetter);
+ slot.setValue(toJS(value));
return true;
}
}
@@ -160,7 +157,7 @@ bool JSCallbackObject<Base>::getOwnPropertySlot(ExecState* exec, unsigned proper
}
template <class Base>
-void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot& slot)
+void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot)
{
JSContextRef ctx = toRef(exec);
JSObjectRef thisRef = toRef(this);
@@ -280,7 +277,7 @@ JSObject* JSCallbackObject<Base>::construct(ExecState* exec, JSObject* construct
}
template <class Base>
-bool JSCallbackObject<Base>::hasInstance(ExecState* exec, JSValue* value, JSValue*)
+bool JSCallbackObject<Base>::hasInstance(ExecState* exec, JSValuePtr value, JSValuePtr)
{
JSContextRef execRef = toRef(exec);
JSObjectRef thisRef = toRef(this);
@@ -307,11 +304,11 @@ CallType JSCallbackObject<Base>::getCallData(CallData& callData)
}
template <class Base>
-JSValue* JSCallbackObject<Base>::call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args)
+JSValuePtr JSCallbackObject<Base>::call(ExecState* exec, JSObject* functionObject, JSValuePtr thisValue, const ArgList& args)
{
JSContextRef execRef = toRef(exec);
JSObjectRef functionRef = toRef(functionObject);
- JSObjectRef thisObjRef = toRef(thisValue->toThisObject(exec));
+ JSObjectRef thisObjRef = toRef(thisValue.toThisObject(exec));
for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(functionObject)->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) {
@@ -380,8 +377,10 @@ double JSCallbackObject<Base>::toNumber(ExecState* exec) const
for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
JSLock::DropAllLocks dropAllLocks(exec);
- if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot())))
- return toJS(value)->getNumber();
+ if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot()))) {
+ double dValue;
+ return toJS(value).getNumber(dValue) ? dValue : NaN;
+ }
}
return Base::toNumber(exec);
@@ -401,7 +400,7 @@ UString JSCallbackObject<Base>::toString(ExecState* exec) const
value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot()));
}
if (value)
- return toJS(value)->getString();
+ return toJS(value).getString();
}
return Base::toString(exec);
@@ -430,15 +429,7 @@ bool JSCallbackObject<Base>::inherits(JSClassRef c) const
}
template <class Base>
-JSValue* JSCallbackObject<Base>::cachedValueGetter(ExecState*, const Identifier&, const PropertySlot& slot)
-{
- JSValue* v = slot.slotBase();
- ASSERT(v);
- return v;
-}
-
-template <class Base>
-JSValue* JSCallbackObject<Base>::staticValueGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValuePtr JSCallbackObject<Base>::staticValueGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
JSCallbackObject* thisObj = asCallbackObject(slot.slotBase());
@@ -460,7 +451,7 @@ JSValue* JSCallbackObject<Base>::staticValueGetter(ExecState* exec, const Identi
}
template <class Base>
-JSValue* JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValuePtr JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
JSCallbackObject* thisObj = asCallbackObject(slot.slotBase());
@@ -485,7 +476,7 @@ JSValue* JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, const Ide
}
template <class Base>
-JSValue* JSCallbackObject<Base>::callbackGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValuePtr JSCallbackObject<Base>::callbackGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
JSCallbackObject* thisObj = asCallbackObject(slot.slotBase());
diff --git a/JavaScriptCore/API/JSClassRef.cpp b/JavaScriptCore/API/JSClassRef.cpp
index 88fd70d..afde7ce 100644
--- a/JavaScriptCore/API/JSClassRef.cpp
+++ b/JavaScriptCore/API/JSClassRef.cpp
@@ -32,7 +32,7 @@
#include <runtime/InitializeThreading.h>
#include <runtime/JSGlobalObject.h>
#include <runtime/ObjectPrototype.h>
-#include <kjs/identifier.h>
+#include <runtime/Identifier.h>
using namespace JSC;
@@ -111,7 +111,7 @@ PassRefPtr<OpaqueJSClass> OpaqueJSClass::createNoAutomaticPrototype(const JSClas
return adoptRef(new OpaqueJSClass(definition, 0));
}
-void clearReferenceToPrototype(JSObjectRef prototype)
+static void clearReferenceToPrototype(JSObjectRef prototype)
{
OpaqueJSClassContextData* jsClassData = static_cast<OpaqueJSClassContextData*>(JSObjectGetPrivate(prototype));
ASSERT(jsClassData);
diff --git a/JavaScriptCore/API/JSClassRef.h b/JavaScriptCore/API/JSClassRef.h
index 71fae18..4f67618 100644
--- a/JavaScriptCore/API/JSClassRef.h
+++ b/JavaScriptCore/API/JSClassRef.h
@@ -29,8 +29,8 @@
#include "JSObjectRef.h"
#include <runtime/JSObject.h>
-#include <kjs/protect.h>
-#include <kjs/ustring.h>
+#include <runtime/Protect.h>
+#include <runtime/UString.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
diff --git a/JavaScriptCore/API/JSContextRef.cpp b/JavaScriptCore/API/JSContextRef.cpp
index ee7286d..c331179 100644
--- a/JavaScriptCore/API/JSContextRef.cpp
+++ b/JavaScriptCore/API/JSContextRef.cpp
@@ -34,10 +34,17 @@
#include "JSObject.h"
#include <wtf/Platform.h>
+#if PLATFORM(DARWIN)
+#include <mach-o/dyld.h>
+
+static const int32_t webkitFirstVersionWithConcurrentGlobalContexts = 0x2100500; // 528.5.0
+#endif
+
using namespace JSC;
JSContextGroupRef JSContextGroupCreate()
{
+ initializeThreading();
return toRef(JSGlobalData::create().releaseRef());
}
@@ -54,8 +61,21 @@ void JSContextGroupRelease(JSContextGroupRef group)
JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass)
{
- JSLock lock(true);
- return JSGlobalContextCreateInGroup(toRef(&JSGlobalData::sharedInstance()), globalObjectClass);
+ initializeThreading();
+#if PLATFORM(DARWIN)
+ // When running on Tiger or Leopard, or if the application was linked before JSGlobalContextCreate was changed
+ // to use a unique JSGlobalData, we use a shared one for compatibility.
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+ if (NSVersionOfLinkTimeLibrary("JavaScriptCore") <= webkitFirstVersionWithConcurrentGlobalContexts) {
+#else
+ {
+#endif
+ JSLock lock(true);
+ return JSGlobalContextCreateInGroup(toRef(&JSGlobalData::sharedInstance()), globalObjectClass);
+ }
+#endif // PLATFORM(DARWIN)
+
+ return JSGlobalContextCreateInGroup(0, globalObjectClass);
}
JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass)
@@ -66,6 +86,10 @@ JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClass
RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::create();
+#if ENABLE(JSC_MULTIPLE_THREADS)
+ globalData->makeUsableFromMultipleThreads();
+#endif
+
if (!globalObjectClass) {
JSGlobalObject* globalObject = new (globalData.get()) JSGlobalObject;
return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec()));
@@ -73,7 +97,7 @@ JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClass
JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(globalObjectClass);
ExecState* exec = globalObject->globalExec();
- JSValue* prototype = globalObjectClass->prototype(exec);
+ JSValuePtr prototype = globalObjectClass->prototype(exec);
if (!prototype)
prototype = jsNull();
globalObject->resetPrototype(prototype);
diff --git a/JavaScriptCore/API/JSContextRef.h b/JavaScriptCore/API/JSContextRef.h
index bb6ea6e..bc89511 100644
--- a/JavaScriptCore/API/JSContextRef.h
+++ b/JavaScriptCore/API/JSContextRef.h
@@ -71,13 +71,14 @@ JS_EXPORT void JSContextGroupRelease(JSContextGroupRef group) AVAILABLE_AFTER_WE
@discussion JSGlobalContextCreate allocates a global object and populates it with all the
built-in JavaScript objects, such as Object, Function, String, and Array.
- The created context can only be used on the main thread. JavaScript values cannot be
- shared or exchanged between contexts.
+ In WebKit version 4.0 and later, the context is created in a unique context group.
+ Therefore, scripts may execute in it concurrently with scripts executing in other contexts.
+ However, you may not use values created in the context in other contexts.
@param globalObjectClass The class to use when creating the global object. Pass
NULL to use the default object class.
@result A JSGlobalContext with a global object of class globalObjectClass.
*/
-JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_AFTER_WEBKIT_VERSION_3_1;
+JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER;
/*!
@function
diff --git a/JavaScriptCore/API/JSObjectRef.cpp b/JavaScriptCore/API/JSObjectRef.cpp
index a4f32ba..67bb2a5 100644
--- a/JavaScriptCore/API/JSObjectRef.cpp
+++ b/JavaScriptCore/API/JSObjectRef.cpp
@@ -31,6 +31,8 @@
#include "DateConstructor.h"
#include "ErrorConstructor.h"
#include "FunctionConstructor.h"
+#include "Identifier.h"
+#include "InitializeThreading.h"
#include "JSArray.h"
#include "JSCallbackConstructor.h"
#include "JSCallbackFunction.h"
@@ -45,13 +47,13 @@
#include "ObjectPrototype.h"
#include "PropertyNameArray.h"
#include "RegExpConstructor.h"
-#include "identifier.h"
#include <wtf/Platform.h>
using namespace JSC;
JSClassRef JSClassCreate(const JSClassDefinition* definition)
{
+ initializeThreading();
RefPtr<OpaqueJSClass> jsClass = (definition->attributes & kJSClassAttributeNoAutomaticPrototype)
? OpaqueJSClass::createNoAutomaticPrototype(definition)
: OpaqueJSClass::create(definition);
@@ -103,7 +105,7 @@ JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObje
exec->globalData().heap.registerThread();
JSLock lock(exec);
- JSValue* jsPrototype = jsClass
+ JSValuePtr jsPrototype = jsClass
? jsClass->prototype(exec)
: exec->lexicalGlobalObject()->objectPrototype();
@@ -233,9 +235,9 @@ JSValueRef JSObjectGetPrototype(JSContextRef, JSObjectRef object)
void JSObjectSetPrototype(JSContextRef, JSObjectRef object, JSValueRef value)
{
JSObject* jsObject = toJS(object);
- JSValue* jsValue = toJS(value);
+ JSValuePtr jsValue = toJS(value);
- jsObject->setPrototype(jsValue->isObject() ? jsValue : jsNull());
+ jsObject->setPrototype(jsValue.isObject() ? jsValue : jsNull());
}
bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName)
@@ -257,7 +259,7 @@ JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef
JSObject* jsObject = toJS(object);
- JSValue* jsValue = jsObject->get(exec, propertyName->identifier(&exec->globalData()));
+ JSValuePtr jsValue = jsObject->get(exec, propertyName->identifier(&exec->globalData()));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
@@ -274,7 +276,7 @@ void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef prope
JSObject* jsObject = toJS(object);
Identifier name(propertyName->identifier(&exec->globalData()));
- JSValue* jsValue = toJS(value);
+ JSValuePtr jsValue = toJS(value);
if (attributes && !jsObject->hasProperty(exec, name))
jsObject->putWithAttributes(exec, name, jsValue, attributes);
@@ -298,7 +300,7 @@ JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsi
JSObject* jsObject = toJS(object);
- JSValue* jsValue = jsObject->get(exec, propertyIndex);
+ JSValuePtr jsValue = jsObject->get(exec, propertyIndex);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
@@ -315,7 +317,7 @@ void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned p
JSLock lock(exec);
JSObject* jsObject = toJS(object);
- JSValue* jsValue = toJS(value);
+ JSValuePtr jsValue = toJS(value);
jsObject->put(exec, propertyIndex, jsValue);
if (exec->hadException()) {
diff --git a/JavaScriptCore/API/JSStringRef.cpp b/JavaScriptCore/API/JSStringRef.cpp
index 6452ffc..8e236e4 100644
--- a/JavaScriptCore/API/JSStringRef.cpp
+++ b/JavaScriptCore/API/JSStringRef.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "JSStringRef.h"
+#include "InitializeThreading.h"
#include "OpaqueJSString.h"
#include <wtf/unicode/UTF8.h>
@@ -34,11 +35,13 @@ using namespace WTF::Unicode;
JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars)
{
+ initializeThreading();
return OpaqueJSString::create(chars, numChars).releaseRef();
}
JSStringRef JSStringCreateWithUTF8CString(const char* string)
{
+ initializeThreading();
if (string) {
size_t length = strlen(string);
Vector<UChar, 1024> buffer(length);
diff --git a/JavaScriptCore/API/JSStringRefCF.cpp b/JavaScriptCore/API/JSStringRefCF.cpp
index 3a37866..2b8fd9e 100644
--- a/JavaScriptCore/API/JSStringRefCF.cpp
+++ b/JavaScriptCore/API/JSStringRefCF.cpp
@@ -27,14 +27,16 @@
#include "JSStringRefCF.h"
#include "APICast.h"
+#include "InitializeThreading.h"
#include "JSStringRef.h"
#include "OpaqueJSString.h"
-#include <kjs/ustring.h>
+#include <runtime/UString.h>
#include <runtime/JSValue.h>
#include <wtf/OwnArrayPtr.h>
JSStringRef JSStringCreateWithCFString(CFStringRef string)
{
+ JSC::initializeThreading();
CFIndex length = CFStringGetLength(string);
if (length) {
OwnArrayPtr<UniChar> buffer(new UniChar[length]);
@@ -44,7 +46,7 @@ JSStringRef JSStringCreateWithCFString(CFStringRef string)
} else {
return OpaqueJSString::create(0, 0).releaseRef();
}
- }
+}
CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string)
{
diff --git a/JavaScriptCore/API/JSValueRef.cpp b/JavaScriptCore/API/JSValueRef.cpp
index 15dd633..7080952 100644
--- a/JavaScriptCore/API/JSValueRef.cpp
+++ b/JavaScriptCore/API/JSValueRef.cpp
@@ -32,9 +32,9 @@
#include <runtime/JSGlobalObject.h>
#include <runtime/JSString.h>
-#include <kjs/operations.h>
-#include <kjs/protect.h>
-#include <kjs/ustring.h>
+#include <runtime/Operations.h>
+#include <runtime/Protect.h>
+#include <runtime/UString.h>
#include <runtime/JSValue.h>
#include <wtf/Assertions.h>
@@ -43,18 +43,18 @@
JSType JSValueGetType(JSContextRef, JSValueRef value)
{
- JSC::JSValue* jsValue = toJS(value);
- if (jsValue->isUndefined())
+ JSC::JSValuePtr jsValue = toJS(value);
+ if (jsValue.isUndefined())
return kJSTypeUndefined;
- if (jsValue->isNull())
+ if (jsValue.isNull())
return kJSTypeNull;
- if (jsValue->isBoolean())
+ if (jsValue.isBoolean())
return kJSTypeBoolean;
- if (jsValue->isNumber())
+ if (jsValue.isNumber())
return kJSTypeNumber;
- if (jsValue->isString())
+ if (jsValue.isString())
return kJSTypeString;
- ASSERT(jsValue->isObject());
+ ASSERT(jsValue.isObject());
return kJSTypeObject;
}
@@ -62,45 +62,45 @@ using namespace JSC; // placed here to avoid conflict between JSC::JSType and JS
bool JSValueIsUndefined(JSContextRef, JSValueRef value)
{
- JSValue* jsValue = toJS(value);
- return jsValue->isUndefined();
+ JSValuePtr jsValue = toJS(value);
+ return jsValue.isUndefined();
}
bool JSValueIsNull(JSContextRef, JSValueRef value)
{
- JSValue* jsValue = toJS(value);
- return jsValue->isNull();
+ JSValuePtr jsValue = toJS(value);
+ return jsValue.isNull();
}
bool JSValueIsBoolean(JSContextRef, JSValueRef value)
{
- JSValue* jsValue = toJS(value);
- return jsValue->isBoolean();
+ JSValuePtr jsValue = toJS(value);
+ return jsValue.isBoolean();
}
bool JSValueIsNumber(JSContextRef, JSValueRef value)
{
- JSValue* jsValue = toJS(value);
- return jsValue->isNumber();
+ JSValuePtr jsValue = toJS(value);
+ return jsValue.isNumber();
}
bool JSValueIsString(JSContextRef, JSValueRef value)
{
- JSValue* jsValue = toJS(value);
- return jsValue->isString();
+ JSValuePtr jsValue = toJS(value);
+ return jsValue.isString();
}
bool JSValueIsObject(JSContextRef, JSValueRef value)
{
- JSValue* jsValue = toJS(value);
- return jsValue->isObject();
+ JSValuePtr jsValue = toJS(value);
+ return jsValue.isObject();
}
bool JSValueIsObjectOfClass(JSContextRef, JSValueRef value, JSClassRef jsClass)
{
- JSValue* jsValue = toJS(value);
+ JSValuePtr jsValue = toJS(value);
- if (JSObject* o = jsValue->getObject()) {
+ if (JSObject* o = jsValue.getObject()) {
if (o->inherits(&JSCallbackObject<JSGlobalObject>::info))
return static_cast<JSCallbackObject<JSGlobalObject>*>(o)->inherits(jsClass);
else if (o->inherits(&JSCallbackObject<JSObject>::info))
@@ -115,10 +115,10 @@ bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* ex
exec->globalData().heap.registerThread();
JSLock lock(exec);
- JSValue* jsA = toJS(a);
- JSValue* jsB = toJS(b);
+ JSValuePtr jsA = toJS(a);
+ JSValuePtr jsB = toJS(b);
- bool result = equal(exec, jsA, jsB); // false if an exception is thrown
+ bool result = JSValuePtr::equal(exec, jsA, jsB); // false if an exception is thrown
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
@@ -129,10 +129,10 @@ bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* ex
bool JSValueIsStrictEqual(JSContextRef, JSValueRef a, JSValueRef b)
{
- JSValue* jsA = toJS(a);
- JSValue* jsB = toJS(b);
+ JSValuePtr jsA = toJS(a);
+ JSValuePtr jsB = toJS(b);
- bool result = strictEqual(jsA, jsB);
+ bool result = JSValuePtr::strictEqual(jsA, jsB);
return result;
}
@@ -142,9 +142,9 @@ bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObject
exec->globalData().heap.registerThread();
JSLock lock(exec);
- JSValue* jsValue = toJS(value);
+ JSValuePtr jsValue = toJS(value);
JSObject* jsConstructor = toJS(constructor);
- if (!jsConstructor->structureID()->typeInfo().implementsHasInstance())
+ if (!jsConstructor->structure()->typeInfo().implementsHasInstance())
return false;
bool result = jsConstructor->hasInstance(exec, jsValue, jsConstructor->get(exec, exec->propertyNames().prototype)); // false if an exception is thrown
if (exec->hadException()) {
@@ -191,8 +191,8 @@ JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string)
bool JSValueToBoolean(JSContextRef ctx, JSValueRef value)
{
ExecState* exec = toJS(ctx);
- JSValue* jsValue = toJS(value);
- return jsValue->toBoolean(exec);
+ JSValuePtr jsValue = toJS(value);
+ return jsValue.toBoolean(exec);
}
double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
@@ -201,9 +201,9 @@ double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception
exec->globalData().heap.registerThread();
JSLock lock(exec);
- JSValue* jsValue = toJS(value);
+ JSValuePtr jsValue = toJS(value);
- double number = jsValue->toNumber(exec);
+ double number = jsValue.toNumber(exec);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
@@ -219,9 +219,9 @@ JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef*
exec->globalData().heap.registerThread();
JSLock lock(exec);
- JSValue* jsValue = toJS(value);
+ JSValuePtr jsValue = toJS(value);
- RefPtr<OpaqueJSString> stringRef(OpaqueJSString::create(jsValue->toString(exec)));
+ RefPtr<OpaqueJSString> stringRef(OpaqueJSString::create(jsValue.toString(exec)));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
@@ -237,9 +237,9 @@ JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exce
exec->globalData().heap.registerThread();
JSLock lock(exec);
- JSValue* jsValue = toJS(value);
+ JSValuePtr jsValue = toJS(value);
- JSObjectRef objectRef = toRef(jsValue->toObject(exec));
+ JSObjectRef objectRef = toRef(jsValue.toObject(exec));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
@@ -255,7 +255,7 @@ void JSValueProtect(JSContextRef ctx, JSValueRef value)
exec->globalData().heap.registerThread();
JSLock lock(exec);
- JSValue* jsValue = toJS(value);
+ JSValuePtr jsValue = toJS(value);
gcProtect(jsValue);
}
@@ -265,6 +265,6 @@ void JSValueUnprotect(JSContextRef ctx, JSValueRef value)
exec->globalData().heap.registerThread();
JSLock lock(exec);
- JSValue* jsValue = toJS(value);
+ JSValuePtr jsValue = toJS(value);
gcUnprotect(jsValue);
}
diff --git a/JavaScriptCore/API/OpaqueJSString.cpp b/JavaScriptCore/API/OpaqueJSString.cpp
index 0819141..7c7b1af 100644
--- a/JavaScriptCore/API/OpaqueJSString.cpp
+++ b/JavaScriptCore/API/OpaqueJSString.cpp
@@ -26,9 +26,9 @@
#include "config.h"
#include "OpaqueJSString.h"
-#include <runtime/ExecState.h>
+#include <interpreter/CallFrame.h>
#include <runtime/JSGlobalObject.h>
-#include <kjs/identifier.h>
+#include <runtime/Identifier.h>
using namespace JSC;
diff --git a/JavaScriptCore/API/OpaqueJSString.h b/JavaScriptCore/API/OpaqueJSString.h
index da05b06..473c815 100644
--- a/JavaScriptCore/API/OpaqueJSString.h
+++ b/JavaScriptCore/API/OpaqueJSString.h
@@ -26,7 +26,7 @@
#ifndef OpaqueJSString_h
#define OpaqueJSString_h
-#include <kjs/ustring.h>
+#include <runtime/UString.h>
namespace JSC {
class Identifier;
diff --git a/JavaScriptCore/API/WebKitAvailability.h b/JavaScriptCore/API/WebKitAvailability.h
index fae3904..1273360 100644
--- a/JavaScriptCore/API/WebKitAvailability.h
+++ b/JavaScriptCore/API/WebKitAvailability.h
@@ -43,7 +43,9 @@
#ifdef __APPLE__
#import <AvailabilityMacros.h>
#else
-// For non-Mac platforms, require the newest version.
+/*
+ * For non-Mac platforms, require the newest version.
+ */
#define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_LATEST
/*
* only certain compilers support __attribute__((deprecated))