Skip to content

Commit d0760ac

Browse files
committed
Webkit SVN Tag Safari-538.12.1
1 parent aeaca47 commit d0760ac

File tree

785 files changed

+57393
-25320
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

785 files changed

+57393
-25320
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ profile
1717
DerivedData
1818
.idea/
1919
.svn*
20+
*.pyc

JavaScriptCore/API/APIShims.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,39 @@ class APIEntryShim : public APIEntryShimWithoutLock {
8383
class APICallbackShim {
8484
public:
8585
APICallbackShim(ExecState* exec)
86-
: m_dropAllLocks(exec->vm().exclusiveThread ? 0 : exec)
86+
: m_dropAllLocks(shouldDropAllLocks(exec->vm()) ? exec : nullptr)
8787
, m_vm(&exec->vm())
8888
{
8989
wtfThreadData().resetCurrentIdentifierTable();
9090
}
9191

92+
APICallbackShim(VM& vm)
93+
: m_dropAllLocks(shouldDropAllLocks(vm) ? &vm : nullptr)
94+
, m_vm(&vm)
95+
{
96+
wtfThreadData().resetCurrentIdentifierTable();
97+
}
98+
9299
~APICallbackShim()
93100
{
94101
wtfThreadData().setCurrentIdentifierTable(m_vm->identifierTable);
95102
}
96103

97104
private:
105+
static bool shouldDropAllLocks(VM& vm)
106+
{
107+
if (vm.exclusiveThread)
108+
return false;
109+
110+
// If the VM is in the middle of being destroyed then we don't want to resurrect it
111+
// by allowing DropAllLocks to ref it. By this point the APILock has already been
112+
// released anyways, so it doesn't matter that DropAllLocks is a no-op.
113+
if (!vm.refCount())
114+
return false;
115+
116+
return true;
117+
}
118+
98119
JSLock::DropAllLocks m_dropAllLocks;
99120
VM* m_vm;
100121
};

JavaScriptCore/API/JSAPIWrapperObject.mm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "config.h"
2727
#include "JSAPIWrapperObject.h"
2828

29+
#include "DelayedReleaseScope.h"
2930
#include "JSCJSValueInlines.h"
3031
#include "JSCallbackObject.h"
3132
#include "JSCellInlines.h"
@@ -53,7 +54,8 @@
5354
JSC::JSAPIWrapperObject* wrapperObject = JSC::jsCast<JSC::JSAPIWrapperObject*>(handle.get().asCell());
5455
if (!wrapperObject->wrappedObject())
5556
return;
56-
[static_cast<id>(wrapperObject->wrappedObject()) release];
57+
58+
JSC::Heap::heap(wrapperObject)->releaseSoon(adoptNS(static_cast<id>(wrapperObject->wrappedObject())));
5759
JSC::WeakSet::deallocate(JSC::WeakImpl::asWeakImpl(handle.slot()));
5860
}
5961

JavaScriptCore/API/JSBase.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
2+
* Copyright (C) 2006, 2007, 2013 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -54,7 +54,7 @@ JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef th
5454
JSObject* jsThisObject = toJS(thisObject);
5555

5656
// evaluate sets "this" to the global object if it is NULL
57-
JSGlobalObject* globalObject = exec->dynamicGlobalObject();
57+
JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
5858
SourceCode source = makeSource(script->string(), sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
5959

6060
JSValue evaluationException;
@@ -85,7 +85,7 @@ bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourc
8585
SourceCode source = makeSource(script->string(), sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
8686

8787
JSValue syntaxException;
88-
bool isValidSyntax = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source, &syntaxException);
88+
bool isValidSyntax = checkSyntax(exec->vmEntryGlobalObject()->globalExec(), source, &syntaxException);
8989

9090
if (!isValidSyntax) {
9191
if (exception)

JavaScriptCore/API/JSBase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ JS_EXPORT void JSGarbageCollect(JSContextRef ctx);
142142
/* Enable the Objective-C API for platforms with a modern runtime. */
143143
#if !defined(JSC_OBJC_API_ENABLED)
144144
#ifndef JSC_OBJC_API_AVAILABLE_MAC_OS_X_1080
145-
#define JSC_OBJC_API_ENABLED (defined(__clang__) && defined(__APPLE__) && defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 && !defined(__i386__))
145+
#define JSC_OBJC_API_ENABLED (defined(__clang__) && defined(__APPLE__) && ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 && !defined(__i386__)) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)))
146146
#else
147-
#define JSC_OBJC_API_ENABLED (defined(__clang__) && defined(__APPLE__) && defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 && !defined(__i386__))
147+
#define JSC_OBJC_API_ENABLED (defined(__clang__) && defined(__APPLE__) && ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 && !defined(__i386__)) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)))
148148
#endif
149149
#endif
150150

JavaScriptCore/API/JSBasePrivate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ owns a large non-GC memory region. Calling this function will encourage the
4343
garbage collector to collect soon, hoping to reclaim that large non-GC memory
4444
region.
4545
*/
46-
JS_EXPORT void JSReportExtraMemoryCost(JSContextRef ctx, size_t size) AVAILABLE_IN_WEBKIT_VERSION_4_0;
46+
JS_EXPORT void JSReportExtraMemoryCost(JSContextRef ctx, size_t size) CF_AVAILABLE(10_6, 7_0);
4747

4848
JS_EXPORT void JSDisableGCTimer(void);
4949

JavaScriptCore/API/JSCallbackObject.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,14 @@ class JSCallbackObject : public Parent {
205205
void init(ExecState*);
206206

207207
static JSCallbackObject* asCallbackObject(JSValue);
208+
static JSCallbackObject* asCallbackObject(EncodedJSValue);
208209

209210
static EncodedJSValue JSC_HOST_CALL call(ExecState*);
210211
static EncodedJSValue JSC_HOST_CALL construct(ExecState*);
211212

212213
JSValue getStaticValue(ExecState*, PropertyName);
213-
static JSValue staticFunctionGetter(ExecState*, JSValue, PropertyName);
214-
static JSValue callbackGetter(ExecState*, JSValue, PropertyName);
214+
static EncodedJSValue staticFunctionGetter(ExecState*, EncodedJSValue, EncodedJSValue, PropertyName);
215+
static EncodedJSValue callbackGetter(ExecState*, EncodedJSValue, EncodedJSValue, PropertyName);
215216

216217
OwnPtr<JSCallbackObjectData> m_callbackObjectData;
217218
};

JavaScriptCore/API/JSCallbackObjectFunctions.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ inline JSCallbackObject<Parent>* JSCallbackObject<Parent>::asCallbackObject(JSVa
4949
return jsCast<JSCallbackObject*>(asObject(value));
5050
}
5151

52+
template <class Parent>
53+
inline JSCallbackObject<Parent>* JSCallbackObject<Parent>::asCallbackObject(EncodedJSValue value)
54+
{
55+
ASSERT(asObject(JSValue::decode(value))->inherits(info()));
56+
return jsCast<JSCallbackObject*>(asObject(JSValue::decode(value)));
57+
}
58+
5259
template <class Parent>
5360
JSCallbackObject<Parent>::JSCallbackObject(ExecState* exec, Structure* structure, JSClassRef jsClass, void* data)
5461
: Parent(exec->vm(), structure)
@@ -584,14 +591,14 @@ JSValue JSCallbackObject<Parent>::getStaticValue(ExecState* exec, PropertyName p
584591
}
585592

586593
template <class Parent>
587-
JSValue JSCallbackObject<Parent>::staticFunctionGetter(ExecState* exec, JSValue slotParent, PropertyName propertyName)
594+
EncodedJSValue JSCallbackObject<Parent>::staticFunctionGetter(ExecState* exec, EncodedJSValue slotParent, EncodedJSValue, PropertyName propertyName)
588595
{
589596
JSCallbackObject* thisObj = asCallbackObject(slotParent);
590597

591598
// Check for cached or override property.
592599
PropertySlot slot2(thisObj);
593600
if (Parent::getOwnPropertySlot(thisObj, exec, propertyName, slot2))
594-
return slot2.getValue(exec, propertyName);
601+
return JSValue::encode(slot2.getValue(exec, propertyName));
595602

596603
if (StringImpl* name = propertyName.publicName()) {
597604
for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) {
@@ -601,18 +608,18 @@ JSValue JSCallbackObject<Parent>::staticFunctionGetter(ExecState* exec, JSValue
601608
VM& vm = exec->vm();
602609
JSObject* o = JSCallbackFunction::create(vm, thisObj->globalObject(), callAsFunction, name);
603610
thisObj->putDirect(vm, propertyName, o, entry->attributes);
604-
return o;
611+
return JSValue::encode(o);
605612
}
606613
}
607614
}
608615
}
609616
}
610617

611-
return exec->vm().throwException(exec, createReferenceError(exec, ASCIILiteral("Static function property defined with NULL callAsFunction callback.")));
618+
return JSValue::encode(exec->vm().throwException(exec, createReferenceError(exec, ASCIILiteral("Static function property defined with NULL callAsFunction callback."))));
612619
}
613620

614621
template <class Parent>
615-
JSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, JSValue slotParent, PropertyName propertyName)
622+
EncodedJSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, EncodedJSValue slotParent, EncodedJSValue, PropertyName propertyName)
616623
{
617624
JSCallbackObject* thisObj = asCallbackObject(slotParent);
618625

@@ -632,15 +639,15 @@ JSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, JSValue slotPa
632639
}
633640
if (exception) {
634641
exec->vm().throwException(exec, toJS(exec, exception));
635-
return jsUndefined();
642+
return JSValue::encode(jsUndefined());
636643
}
637644
if (value)
638-
return toJS(exec, value);
645+
return JSValue::encode(toJS(exec, value));
639646
}
640647
}
641648
}
642649

643-
return exec->vm().throwException(exec, createReferenceError(exec, ASCIILiteral("hasProperty callback returned true for a property that doesn't exist.")));
650+
return JSValue::encode(exec->vm().throwException(exec, createReferenceError(exec, ASCIILiteral("hasProperty callback returned true for a property that doesn't exist."))));
644651
}
645652

646653
} // namespace JSC

0 commit comments

Comments
 (0)