Skip to content

Commit

Permalink
Webkit SVN Tag Safari-538.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnthe committed Jan 17, 2014
1 parent aeaca47 commit d0760ac
Show file tree
Hide file tree
Showing 785 changed files with 57,393 additions and 25,320 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ profile
DerivedData
.idea/
.svn*
*.pyc
23 changes: 22 additions & 1 deletion JavaScriptCore/API/APIShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,39 @@ class APIEntryShim : public APIEntryShimWithoutLock {
class APICallbackShim {
public:
APICallbackShim(ExecState* exec)
: m_dropAllLocks(exec->vm().exclusiveThread ? 0 : exec)
: m_dropAllLocks(shouldDropAllLocks(exec->vm()) ? exec : nullptr)
, m_vm(&exec->vm())
{
wtfThreadData().resetCurrentIdentifierTable();
}

APICallbackShim(VM& vm)
: m_dropAllLocks(shouldDropAllLocks(vm) ? &vm : nullptr)
, m_vm(&vm)
{
wtfThreadData().resetCurrentIdentifierTable();
}

~APICallbackShim()
{
wtfThreadData().setCurrentIdentifierTable(m_vm->identifierTable);
}

private:
static bool shouldDropAllLocks(VM& vm)
{
if (vm.exclusiveThread)
return false;

// If the VM is in the middle of being destroyed then we don't want to resurrect it
// by allowing DropAllLocks to ref it. By this point the APILock has already been
// released anyways, so it doesn't matter that DropAllLocks is a no-op.
if (!vm.refCount())
return false;

return true;
}

JSLock::DropAllLocks m_dropAllLocks;
VM* m_vm;
};
Expand Down
4 changes: 3 additions & 1 deletion JavaScriptCore/API/JSAPIWrapperObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "config.h"
#include "JSAPIWrapperObject.h"

#include "DelayedReleaseScope.h"
#include "JSCJSValueInlines.h"
#include "JSCallbackObject.h"
#include "JSCellInlines.h"
Expand Down Expand Up @@ -53,7 +54,8 @@
JSC::JSAPIWrapperObject* wrapperObject = JSC::jsCast<JSC::JSAPIWrapperObject*>(handle.get().asCell());
if (!wrapperObject->wrappedObject())
return;
[static_cast<id>(wrapperObject->wrappedObject()) release];

JSC::Heap::heap(wrapperObject)->releaseSoon(adoptNS(static_cast<id>(wrapperObject->wrappedObject())));
JSC::WeakSet::deallocate(JSC::WeakImpl::asWeakImpl(handle.slot()));
}

Expand Down
6 changes: 3 additions & 3 deletions JavaScriptCore/API/JSBase.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -54,7 +54,7 @@ JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef th
JSObject* jsThisObject = toJS(thisObject);

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

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

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

if (!isValidSyntax) {
if (exception)
Expand Down
4 changes: 2 additions & 2 deletions JavaScriptCore/API/JSBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ JS_EXPORT void JSGarbageCollect(JSContextRef ctx);
/* Enable the Objective-C API for platforms with a modern runtime. */
#if !defined(JSC_OBJC_API_ENABLED)
#ifndef JSC_OBJC_API_AVAILABLE_MAC_OS_X_1080
#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__))
#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)))
#else
#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__))
#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)))
#endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion JavaScriptCore/API/JSBasePrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ owns a large non-GC memory region. Calling this function will encourage the
garbage collector to collect soon, hoping to reclaim that large non-GC memory
region.
*/
JS_EXPORT void JSReportExtraMemoryCost(JSContextRef ctx, size_t size) AVAILABLE_IN_WEBKIT_VERSION_4_0;
JS_EXPORT void JSReportExtraMemoryCost(JSContextRef ctx, size_t size) CF_AVAILABLE(10_6, 7_0);

JS_EXPORT void JSDisableGCTimer(void);

Expand Down
5 changes: 3 additions & 2 deletions JavaScriptCore/API/JSCallbackObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,14 @@ class JSCallbackObject : public Parent {
void init(ExecState*);

static JSCallbackObject* asCallbackObject(JSValue);
static JSCallbackObject* asCallbackObject(EncodedJSValue);

static EncodedJSValue JSC_HOST_CALL call(ExecState*);
static EncodedJSValue JSC_HOST_CALL construct(ExecState*);

JSValue getStaticValue(ExecState*, PropertyName);
static JSValue staticFunctionGetter(ExecState*, JSValue, PropertyName);
static JSValue callbackGetter(ExecState*, JSValue, PropertyName);
static EncodedJSValue staticFunctionGetter(ExecState*, EncodedJSValue, EncodedJSValue, PropertyName);
static EncodedJSValue callbackGetter(ExecState*, EncodedJSValue, EncodedJSValue, PropertyName);

OwnPtr<JSCallbackObjectData> m_callbackObjectData;
};
Expand Down
23 changes: 15 additions & 8 deletions JavaScriptCore/API/JSCallbackObjectFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ inline JSCallbackObject<Parent>* JSCallbackObject<Parent>::asCallbackObject(JSVa
return jsCast<JSCallbackObject*>(asObject(value));
}

template <class Parent>
inline JSCallbackObject<Parent>* JSCallbackObject<Parent>::asCallbackObject(EncodedJSValue value)
{
ASSERT(asObject(JSValue::decode(value))->inherits(info()));
return jsCast<JSCallbackObject*>(asObject(JSValue::decode(value)));
}

template <class Parent>
JSCallbackObject<Parent>::JSCallbackObject(ExecState* exec, Structure* structure, JSClassRef jsClass, void* data)
: Parent(exec->vm(), structure)
Expand Down Expand Up @@ -584,14 +591,14 @@ JSValue JSCallbackObject<Parent>::getStaticValue(ExecState* exec, PropertyName p
}

template <class Parent>
JSValue JSCallbackObject<Parent>::staticFunctionGetter(ExecState* exec, JSValue slotParent, PropertyName propertyName)
EncodedJSValue JSCallbackObject<Parent>::staticFunctionGetter(ExecState* exec, EncodedJSValue slotParent, EncodedJSValue, PropertyName propertyName)
{
JSCallbackObject* thisObj = asCallbackObject(slotParent);

// Check for cached or override property.
PropertySlot slot2(thisObj);
if (Parent::getOwnPropertySlot(thisObj, exec, propertyName, slot2))
return slot2.getValue(exec, propertyName);
return JSValue::encode(slot2.getValue(exec, propertyName));

if (StringImpl* name = propertyName.publicName()) {
for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) {
Expand All @@ -601,18 +608,18 @@ JSValue JSCallbackObject<Parent>::staticFunctionGetter(ExecState* exec, JSValue
VM& vm = exec->vm();
JSObject* o = JSCallbackFunction::create(vm, thisObj->globalObject(), callAsFunction, name);
thisObj->putDirect(vm, propertyName, o, entry->attributes);
return o;
return JSValue::encode(o);
}
}
}
}
}

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

template <class Parent>
JSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, JSValue slotParent, PropertyName propertyName)
EncodedJSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, EncodedJSValue slotParent, EncodedJSValue, PropertyName propertyName)
{
JSCallbackObject* thisObj = asCallbackObject(slotParent);

Expand All @@ -632,15 +639,15 @@ JSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, JSValue slotPa
}
if (exception) {
exec->vm().throwException(exec, toJS(exec, exception));
return jsUndefined();
return JSValue::encode(jsUndefined());
}
if (value)
return toJS(exec, value);
return JSValue::encode(toJS(exec, value));
}
}
}

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

} // namespace JSC
Loading

0 comments on commit d0760ac

Please sign in to comment.