summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/API
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2009-08-11 17:01:47 +0100
committerBen Murdoch <benm@google.com>2009-08-11 18:21:02 +0100
commit0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 (patch)
tree2943df35f62d885c89d01063cc528dd73b480fea /JavaScriptCore/API
parent7e7a70bfa49a1122b2597a1e6367d89eb4035eca (diff)
downloadexternal_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.zip
external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.gz
external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.bz2
Merge in WebKit r47029.
Diffstat (limited to 'JavaScriptCore/API')
-rw-r--r--JavaScriptCore/API/APICast.h35
-rw-r--r--JavaScriptCore/API/JSBase.cpp2
-rw-r--r--JavaScriptCore/API/JSBase.h8
-rw-r--r--JavaScriptCore/API/JSCallbackObjectFunctions.h21
-rw-r--r--JavaScriptCore/API/JSClassRef.h6
-rw-r--r--JavaScriptCore/API/JSContextRef.cpp4
-rw-r--r--JavaScriptCore/API/JSObjectRef.cpp6
-rw-r--r--JavaScriptCore/API/tests/testapi.c8
8 files changed, 53 insertions, 37 deletions
diff --git a/JavaScriptCore/API/APICast.h b/JavaScriptCore/API/APICast.h
index 762a15e..b6d1532 100644
--- a/JavaScriptCore/API/APICast.h
+++ b/JavaScriptCore/API/APICast.h
@@ -26,7 +26,7 @@
#ifndef APICast_h
#define APICast_h
-#include "JSNumberCell.h"
+#include "JSAPIValueWrapper.h"
#include "JSValue.h"
#include <wtf/Platform.h>
#include <wtf/UnusedParam.h>
@@ -58,18 +58,18 @@ inline JSC::ExecState* toJS(JSGlobalContextRef c)
return reinterpret_cast<JSC::ExecState*>(c);
}
-inline JSC::JSValue toJS(JSC::ExecState* exec, JSValueRef v)
+inline JSC::JSValue toJS(JSC::ExecState*, JSValueRef v)
{
- JSC::JSValue jsValue = JSC::JSValue::decode(reinterpret_cast<JSC::EncodedJSValue>(const_cast<OpaqueJSValue*>(v)));
-#if USE(ALTERNATE_JSIMMEDIATE)
- UNUSED_PARAM(exec);
+#if USE(JSVALUE32_64)
+ JSC::JSCell* jsCell = reinterpret_cast<JSC::JSCell*>(const_cast<OpaqueJSValue*>(v));
+ if (!jsCell)
+ return JSC::JSValue();
+ if (jsCell->isAPIValueWrapper())
+ return static_cast<JSC::JSAPIValueWrapper*>(jsCell)->value();
+ return jsCell;
#else
- if (jsValue && jsValue.isNumber()) {
- ASSERT(jsValue.isAPIMangledNumber());
- return JSC::jsNumber(exec, jsValue.uncheckedGetNumber());
- }
+ return JSC::JSValue::decode(reinterpret_cast<JSC::EncodedJSValue>(const_cast<OpaqueJSValue*>(v)));
#endif
- return jsValue;
}
inline JSC::JSObject* toJS(JSObjectRef o)
@@ -89,15 +89,16 @@ inline JSC::JSGlobalData* toJS(JSContextGroupRef g)
inline JSValueRef toRef(JSC::ExecState* exec, JSC::JSValue v)
{
-#if USE(ALTERNATE_JSIMMEDIATE)
- UNUSED_PARAM(exec);
+#if USE(JSVALUE32_64)
+ if (!v)
+ return 0;
+ if (!v.isCell())
+ return reinterpret_cast<JSValueRef>(asCell(JSC::jsAPIValueWrapper(exec, v)));
+ return reinterpret_cast<JSValueRef>(asCell(v));
#else
- if (v && v.isNumber()) {
- ASSERT(!v.isAPIMangledNumber());
- return reinterpret_cast<JSValueRef>(JSC::JSValue::encode(JSC::jsAPIMangledNumber(exec, v.uncheckedGetNumber())));
- }
-#endif
+ UNUSED_PARAM(exec);
return reinterpret_cast<JSValueRef>(JSC::JSValue::encode(v));
+#endif
}
inline JSObjectRef toRef(JSC::JSObject* o)
diff --git a/JavaScriptCore/API/JSBase.cpp b/JavaScriptCore/API/JSBase.cpp
index fc3d0fe..4a32d35 100644
--- a/JavaScriptCore/API/JSBase.cpp
+++ b/JavaScriptCore/API/JSBase.cpp
@@ -96,7 +96,7 @@ void JSGarbageCollect(JSContextRef ctx)
ExecState* exec = toJS(ctx);
JSGlobalData& globalData = exec->globalData();
- JSLock lock(globalData.isSharedInstance);
+ JSLock lock(globalData.isSharedInstance ? LockForReal : SilenceAssertionsOnly);
if (!globalData.heap.isBusy())
globalData.heap.collect();
diff --git a/JavaScriptCore/API/JSBase.h b/JavaScriptCore/API/JSBase.h
index 6f012ca..9f3d88e 100644
--- a/JavaScriptCore/API/JSBase.h
+++ b/JavaScriptCore/API/JSBase.h
@@ -69,6 +69,14 @@ typedef struct OpaqueJSValue* JSObjectRef;
#define JS_EXPORT
#elif defined(__GNUC__)
#define JS_EXPORT __attribute__((visibility("default")))
+#elif defined(_WIN32_WCE)
+ #if defined(JS_BUILDING_JS)
+ #define JS_EXPORT __declspec(dllexport)
+ #elif defined(JS_IMPORT_JS)
+ #define JS_EXPORT __declspec(dllimport)
+ #else
+ #define JS_EXPORT
+ #endif
#elif defined(WIN32) || defined(_WIN32)
/*
* TODO: Export symbols with JS_EXPORT when using MSVC.
diff --git a/JavaScriptCore/API/JSCallbackObjectFunctions.h b/JavaScriptCore/API/JSCallbackObjectFunctions.h
index 987c59f..1abed3f 100644
--- a/JavaScriptCore/API/JSCallbackObjectFunctions.h
+++ b/JavaScriptCore/API/JSCallbackObjectFunctions.h
@@ -318,11 +318,12 @@ bool JSCallbackObject<Base>::hasInstance(ExecState* exec, JSValue value, JSValue
for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) {
+ JSValueRef valueRef = toRef(exec, value);
JSValueRef exception = 0;
bool result;
{
JSLock::DropAllLocks dropAllLocks(exec);
- result = hasInstance(execRef, thisRef, toRef(exec, value), &exception);
+ result = hasInstance(execRef, thisRef, valueRef, &exception);
}
exec->setException(toJS(exec, exception));
return result;
@@ -428,11 +429,13 @@ double JSCallbackObject<Base>::toNumber(ExecState* exec) const
JSLock::DropAllLocks dropAllLocks(exec);
value = convertToType(ctx, thisRef, kJSTypeNumber, &exception);
}
- exec->setException(toJS(exec, exception));
- if (value) {
- double dValue;
- return toJS(exec, value).getNumber(dValue) ? dValue : NaN;
+ if (exception) {
+ exec->setException(toJS(exec, exception));
+ return 0;
}
+
+ double dValue;
+ return toJS(exec, value).getNumber(dValue) ? dValue : NaN;
}
return Base::toNumber(exec);
@@ -452,11 +455,11 @@ UString JSCallbackObject<Base>::toString(ExecState* exec) const
JSLock::DropAllLocks dropAllLocks(exec);
value = convertToType(ctx, thisRef, kJSTypeString, &exception);
}
- exec->setException(toJS(exec, exception));
- if (value)
- return toJS(exec, value).getString();
- if (exception)
+ if (exception) {
+ exec->setException(toJS(exec, exception));
return "";
+ }
+ return toJS(exec, value).getString();
}
return Base::toString(exec);
diff --git a/JavaScriptCore/API/JSClassRef.h b/JavaScriptCore/API/JSClassRef.h
index 4f67618..c4777dd 100644
--- a/JavaScriptCore/API/JSClassRef.h
+++ b/JavaScriptCore/API/JSClassRef.h
@@ -34,7 +34,7 @@
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
-struct StaticValueEntry {
+struct StaticValueEntry : FastAllocBase {
StaticValueEntry(JSObjectGetPropertyCallback _getProperty, JSObjectSetPropertyCallback _setProperty, JSPropertyAttributes _attributes)
: getProperty(_getProperty), setProperty(_setProperty), attributes(_attributes)
{
@@ -45,7 +45,7 @@ struct StaticValueEntry {
JSPropertyAttributes attributes;
};
-struct StaticFunctionEntry {
+struct StaticFunctionEntry : FastAllocBase {
StaticFunctionEntry(JSObjectCallAsFunctionCallback _callAsFunction, JSPropertyAttributes _attributes)
: callAsFunction(_callAsFunction), attributes(_attributes)
{
@@ -58,7 +58,7 @@ struct StaticFunctionEntry {
typedef HashMap<RefPtr<JSC::UString::Rep>, StaticValueEntry*> OpaqueJSClassStaticValuesTable;
typedef HashMap<RefPtr<JSC::UString::Rep>, StaticFunctionEntry*> OpaqueJSClassStaticFunctionsTable;
-class OpaqueJSClass;
+struct OpaqueJSClass;
// An OpaqueJSClass (JSClass) is created without a context, so it can be used with any context, even across context groups.
// This structure holds data members that vary across context groups.
diff --git a/JavaScriptCore/API/JSContextRef.cpp b/JavaScriptCore/API/JSContextRef.cpp
index a3bdc69..c358a84 100644
--- a/JavaScriptCore/API/JSContextRef.cpp
+++ b/JavaScriptCore/API/JSContextRef.cpp
@@ -70,7 +70,7 @@ JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass)
#else
{
#endif
- JSLock lock(true);
+ JSLock lock(LockForReal);
return JSGlobalContextCreateInGroup(toRef(&JSGlobalData::sharedInstance()), globalObjectClass);
}
#endif // PLATFORM(DARWIN)
@@ -82,7 +82,7 @@ JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClass
{
initializeThreading();
- JSLock lock(true);
+ JSLock lock(LockForReal);
RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::create();
diff --git a/JavaScriptCore/API/JSObjectRef.cpp b/JavaScriptCore/API/JSObjectRef.cpp
index 50ee635..87d36ec 100644
--- a/JavaScriptCore/API/JSObjectRef.cpp
+++ b/JavaScriptCore/API/JSObjectRef.cpp
@@ -449,7 +449,7 @@ JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size
return result;
}
-struct OpaqueJSPropertyNameArray {
+struct OpaqueJSPropertyNameArray : FastAllocBase {
OpaqueJSPropertyNameArray(JSGlobalData* globalData)
: refCount(0)
, globalData(globalData)
@@ -491,7 +491,7 @@ JSPropertyNameArrayRef JSPropertyNameArrayRetain(JSPropertyNameArrayRef array)
void JSPropertyNameArrayRelease(JSPropertyNameArrayRef array)
{
if (--array->refCount == 0) {
- JSLock lock(array->globalData->isSharedInstance);
+ JSLock lock(array->globalData->isSharedInstance ? LockForReal : SilenceAssertionsOnly);
delete array;
}
}
@@ -511,7 +511,7 @@ void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef array, JSStri
PropertyNameArray* propertyNames = toJS(array);
propertyNames->globalData()->heap.registerThread();
- JSLock lock(propertyNames->globalData()->isSharedInstance);
+ JSLock lock(propertyNames->globalData()->isSharedInstance ? LockForReal : SilenceAssertionsOnly);
propertyNames->add(propertyName->identifier(propertyNames->globalData()));
}
diff --git a/JavaScriptCore/API/tests/testapi.c b/JavaScriptCore/API/tests/testapi.c
index 2fa2a84..1f413e1 100644
--- a/JavaScriptCore/API/tests/testapi.c
+++ b/JavaScriptCore/API/tests/testapi.c
@@ -383,8 +383,12 @@ static JSValueRef EvilExceptionObject_convertToType(JSContextRef context, JSObje
if (!function)
return NULL;
JSValueRef value = JSObjectCallAsFunction(context, function, object, 0, NULL, exception);
- if (!value)
- return (JSValueRef)JSStringCreateWithUTF8CString("convertToType failed");
+ if (!value) {
+ JSStringRef errorString = JSStringCreateWithUTF8CString("convertToType failed");
+ JSValueRef errorStringRef = JSValueMakeString(context, errorString);
+ JSStringRelease(errorString);
+ return errorStringRef;
+ }
return value;
}