Skip to content
This repository was archived by the owner on May 6, 2019. It is now read-only.

Commit 559e4cb

Browse files
committed
Updated JavaScriptCore and WebKit libs and headers
1 parent 048c22d commit 559e4cb

21 files changed

Lines changed: 1259 additions & 636 deletions

‎include/JavaScriptCore/APICast.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ inline JSValueRef toRef(JSC::ExecState* exec, JSC::JSValue v)
111111
if (!v)
112112
return 0;
113113
if (!v.isCell())
114-
return reinterpret_cast<JSValueRef>(asCell(JSC::jsAPIValueWrapper(exec, v)));
115-
return reinterpret_cast<JSValueRef>(asCell(v));
114+
return reinterpret_cast<JSValueRef>(JSC::jsAPIValueWrapper(exec, v).asCell());
115+
return reinterpret_cast<JSValueRef>(v.asCell());
116116
#else
117117
UNUSED_PARAM(exec);
118118
return reinterpret_cast<JSValueRef>(JSC::JSValue::encode(v));

‎include/JavaScriptCore/APIShims.h‎

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* Copyright (C) 2009 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#ifndef APIShims_h
27+
#define APIShims_h
28+
29+
#include "CallFrame.h"
30+
#include "GCActivityCallback.h"
31+
#include "JSLock.h"
32+
#include <wtf/WTFThreadData.h>
33+
34+
namespace JSC {
35+
36+
class APIEntryShimWithoutLock {
37+
protected:
38+
APIEntryShimWithoutLock(JSGlobalData* globalData, bool registerThread)
39+
: m_globalData(globalData)
40+
, m_entryIdentifierTable(wtfThreadData().setCurrentIdentifierTable(globalData->identifierTable))
41+
{
42+
UNUSED_PARAM(registerThread);
43+
if (registerThread)
44+
globalData->heap.machineThreads().addCurrentThread();
45+
m_globalData->heap.activityCallback()->synchronize();
46+
m_globalData->timeoutChecker.start();
47+
}
48+
49+
~APIEntryShimWithoutLock()
50+
{
51+
m_globalData->timeoutChecker.stop();
52+
wtfThreadData().setCurrentIdentifierTable(m_entryIdentifierTable);
53+
}
54+
55+
private:
56+
JSGlobalData* m_globalData;
57+
IdentifierTable* m_entryIdentifierTable;
58+
};
59+
60+
class APIEntryShim : public APIEntryShimWithoutLock {
61+
public:
62+
// Normal API entry
63+
APIEntryShim(ExecState* exec, bool registerThread = true)
64+
: APIEntryShimWithoutLock(&exec->globalData(), registerThread)
65+
, m_lock(exec)
66+
{
67+
}
68+
69+
// JSPropertyNameAccumulator only has a globalData.
70+
APIEntryShim(JSGlobalData* globalData, bool registerThread = true)
71+
: APIEntryShimWithoutLock(globalData, registerThread)
72+
, m_lock(globalData->isSharedInstance() ? LockForReal : SilenceAssertionsOnly)
73+
{
74+
}
75+
76+
private:
77+
JSLock m_lock;
78+
};
79+
80+
class APICallbackShim {
81+
public:
82+
APICallbackShim(ExecState* exec)
83+
: m_dropAllLocks(exec)
84+
, m_globalData(&exec->globalData())
85+
{
86+
wtfThreadData().resetCurrentIdentifierTable();
87+
}
88+
89+
~APICallbackShim()
90+
{
91+
m_globalData->heap.activityCallback()->synchronize();
92+
wtfThreadData().setCurrentIdentifierTable(m_globalData->identifierTable);
93+
}
94+
95+
private:
96+
JSLock::DropAllLocks m_dropAllLocks;
97+
JSGlobalData* m_globalData;
98+
};
99+
100+
}
101+
102+
#endif

‎include/JavaScriptCore/JSBase.h‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,26 @@ typedef const struct OpaqueJSValue* JSValueRef;
6363
typedef struct OpaqueJSValue* JSObjectRef;
6464

6565
/* JavaScript symbol exports */
66+
/* These rules should stay the same as in WebKit2/Shared/API/c/WKBase.h */
6667

6768
#undef JS_EXPORT
6869
#if defined(JS_NO_EXPORT)
69-
#define JS_EXPORT
70+
#define JS_EXPORT
7071
#elif defined(__GNUC__) && !defined(__CC_ARM) && !defined(__ARMCC__)
71-
#define JS_EXPORT __attribute__((visibility("default")))
72-
#elif defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE)
73-
#if defined(BUILDING_JavaScriptCore) || defined(BUILDING_WTF)
74-
#define JS_EXPORT __declspec(dllexport)
75-
#else
76-
#define JS_EXPORT __declspec(dllimport)
77-
#endif
72+
#define JS_EXPORT __attribute__((visibility("default")))
73+
#elif defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE) || defined(__CC_ARM) || defined(__ARMCC__)
74+
#if defined(BUILDING_JavaScriptCore) || defined(BUILDING_WTF)
75+
#define JS_EXPORT __declspec(dllexport)
7876
#else
79-
#define JS_EXPORT
77+
#define JS_EXPORT __declspec(dllimport)
78+
#endif
79+
#else /* !defined(JS_NO_EXPORT) */
80+
#define JS_EXPORT
81+
#endif /* defined(JS_NO_EXPORT) */
82+
83+
/* JS tests uses WTF but has no config.h, so we need to set the export defines here. */
84+
#ifndef WTF_EXPORT_PRIVATE
85+
#define WTF_EXPORT_PRIVATE JS_EXPORT
8086
#endif
8187

8288
#ifdef __cplusplus

‎include/JavaScriptCore/JSContextRefPrivate.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ extern "C" {
4646
*/
4747
JS_EXPORT JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx);
4848

49+
50+
/*!
51+
@function
52+
@abstract Gets a Backtrace for the existing context
53+
@param ctx The JSContext whose backtrace you want to get
54+
@result A string containing the backtrace
55+
*/
56+
JS_EXPORT JSStringRef JSContextCreateBacktrace(JSContextRef ctx, unsigned maxStackSize) AVAILABLE_IN_WEBKIT_VERSION_4_0;
57+
4958
#ifdef __cplusplus
5059
}
5160
#endif

‎include/JavaScriptCore/JSObjectRef.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ typedef JSValueRef
288288
@field attributes A logically ORed set of JSPropertyAttributes to give to the property.
289289
*/
290290
typedef struct {
291-
const char* const name;
291+
const char* name;
292292
JSObjectGetPropertyCallback getProperty;
293293
JSObjectSetPropertyCallback setProperty;
294294
JSPropertyAttributes attributes;
@@ -302,7 +302,7 @@ typedef struct {
302302
@field attributes A logically ORed set of JSPropertyAttributes to give to the property.
303303
*/
304304
typedef struct {
305-
const char* const name;
305+
const char* name;
306306
JSObjectCallAsFunctionCallback callAsFunction;
307307
JSPropertyAttributes attributes;
308308
} JSStaticFunction;

‎include/JavaScriptCore/JSRetainPtr.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@
2929
#ifndef JSRetainPtr_h
3030
#define JSRetainPtr_h
3131

32+
#include <JavaScriptCore/JSContextRef.h>
3233
#include <JavaScriptCore/JSStringRef.h>
3334
#include <algorithm>
3435

3536
inline void JSRetain(JSStringRef string) { JSStringRetain(string); }
3637
inline void JSRelease(JSStringRef string) { JSStringRelease(string); }
38+
inline void JSRetain(JSGlobalContextRef context) { JSGlobalContextRetain(context); }
39+
inline void JSRelease(JSGlobalContextRef context) { JSGlobalContextRelease(context); }
3740

3841
enum AdoptTag { Adopt };
3942

@@ -68,9 +71,6 @@ template<typename T> class JSRetainPtr {
6871

6972
void swap(JSRetainPtr&);
7073

71-
// FIXME: Remove releaseRef once we change all callers to call leakRef instead.
72-
T releaseRef() { return leakRef(); }
73-
7474
private:
7575
T m_ptr;
7676
};

‎include/JavaScriptCore/JSStringRef.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
extern "C" {
3838
#endif
3939

40-
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WINSCW__) \
41-
&& !((defined(__CC_ARM) || defined(__ARMCC__)) && defined(__SYMBIAN32__)) /* RVCT */
40+
#if !defined(WIN32) && !defined(_WIN32) \
41+
&& !((defined(__CC_ARM) || defined(__ARMCC__)) && !defined(__linux__)) /* RVCT */
4242
/*!
4343
@typedef JSChar
4444
@abstract A Unicode character.

‎include/JavaScriptCore/JSWeakObjectMapRefInternal.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class JSObject;
3737

3838
typedef void (*JSWeakMapDestroyedCallback)(struct OpaqueJSWeakObjectMap*, void*);
3939

40-
typedef JSC::WeakGCMap<void*, JSC::JSObject*> WeakMapType;
40+
typedef JSC::WeakGCMap<void*, JSC::JSObject> WeakMapType;
4141

4242
struct OpaqueJSWeakObjectMap : public RefCounted<OpaqueJSWeakObjectMap> {
4343
public:

‎include/JavaScriptCore/JSWeakObjectMapRefPrivate.h‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ typedef void (*JSWeakMapDestroyedCallback)(JSWeakObjectMapRef map, void* data);
5252
@param destructor A function to call when the weak map is destroyed.
5353
@result A JSWeakObjectMapRef bound to the given context, data and destructor.
5454
@discussion The JSWeakObjectMapRef can be used as a storage mechanism to hold custom JS objects without forcing those objects to
55-
remain live as JSValueProtect would. Any objects that are intended to be stored in a weak map must be user defined objects that
56-
remove themselves from the map in their finalizer.
55+
remain live as JSValueProtect would.
5756
*/
5857
JS_EXPORT JSWeakObjectMapRef JSWeakObjectMapCreate(JSContextRef ctx, void* data, JSWeakMapDestroyedCallback destructor);
5958

@@ -79,14 +78,12 @@ JS_EXPORT JSObjectRef JSWeakObjectMapGet(JSContextRef ctx, JSWeakObjectMapRef ma
7978

8079
/*!
8180
@function
82-
@abstract Clears the association between a key and an object in a JSWeakObjectMapRef
81+
@abstract Removes the entry for the given key if the key is present, otherwise it has no effect.
8382
@param ctx The execution context to use.
84-
@param map The map to clear the key association from.
85-
@param key The key to use.
86-
@param object The old object value.
87-
@result Returns true if the key/object association was present in map, and has been removed.
83+
@param map The map to use.
84+
@param key The key to remove.
8885
*/
89-
JS_EXPORT bool JSWeakObjectMapClear(JSContextRef ctx, JSWeakObjectMapRef map, void* key, JSObjectRef object);
86+
JS_EXPORT void JSWeakObjectMapRemove(JSContextRef ctx, JSWeakObjectMapRef map, void* key);
9087

9188
#ifdef __cplusplus
9289
}

‎include/JavaScriptCore/OpaqueJSString.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626
#ifndef OpaqueJSString_h
2727
#define OpaqueJSString_h
2828

29+
#include <wtf/ThreadSafeRefCounted.h>
2930
#include <runtime/UString.h>
3031

3132
namespace JSC {
3233
class Identifier;
3334
class JSGlobalData;
3435
}
3536

36-
struct OpaqueJSString : public ThreadSafeShared<OpaqueJSString> {
37+
struct OpaqueJSString : public ThreadSafeRefCounted<OpaqueJSString> {
3738

3839
static PassRefPtr<OpaqueJSString> create() // null
3940
{
@@ -45,7 +46,7 @@ struct OpaqueJSString : public ThreadSafeShared<OpaqueJSString> {
4546
return adoptRef(new OpaqueJSString(characters, length));
4647
}
4748

48-
static PassRefPtr<OpaqueJSString> create(const JSC::UString&);
49+
JS_EXPORT_PRIVATE static PassRefPtr<OpaqueJSString> create(const JSC::UString&);
4950

5051
UChar* characters() { return this ? m_characters : 0; }
5152
unsigned length() { return this ? m_length : 0; }
@@ -54,7 +55,7 @@ struct OpaqueJSString : public ThreadSafeShared<OpaqueJSString> {
5455
JSC::Identifier identifier(JSC::JSGlobalData*) const;
5556

5657
private:
57-
friend class WTF::ThreadSafeShared<OpaqueJSString>;
58+
friend class WTF::ThreadSafeRefCounted<OpaqueJSString>;
5859

5960
OpaqueJSString()
6061
: m_characters(0)

0 commit comments

Comments
 (0)