Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (164395 => 164396)
--- trunk/Source/_javascript_Core/ChangeLog 2014-02-19 23:22:47 UTC (rev 164395)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-02-19 23:31:26 UTC (rev 164396)
@@ -1,3 +1,18 @@
+2014-02-19 Sam Weinig <[email protected]>
+
+ [JS] Convert Promise.prototype.catch to be a built-in
+ https://bugs.webkit.org/show_bug.cgi?id=129052
+
+ Reviewed by Geoffrey Garen.
+
+ * GNUmakefile.list.am:
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * builtins/Promise.prototype.js: Added.
+ (catch): Add JS based implementation of Promise.prototype.catch.
+
+ * runtime/JSPromisePrototype.cpp:
+ Remove the C++ implementation of Promise.prototype.catch.
+
2014-02-19 Filip Pizlo <[email protected]>
FTL should allow LLVM to allocate data sections with alignment > 8
Modified: trunk/Source/_javascript_Core/GNUmakefile.list.am (164395 => 164396)
--- trunk/Source/_javascript_Core/GNUmakefile.list.am 2014-02-19 23:22:47 UTC (rev 164395)
+++ trunk/Source/_javascript_Core/GNUmakefile.list.am 2014-02-19 23:31:26 UTC (rev 164396)
@@ -39,6 +39,7 @@
_javascript_core_builtins_js_nosources += \
Source/_javascript_Core/builtins/Array.prototype.js
+ Source/_javascript_Core/builtins/Promise.prototype.js
_javascript_core_sources += \
Source/_javascript_Core/API/APICallbackFunction.h \
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (164395 => 164396)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2014-02-19 23:22:47 UTC (rev 164395)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2014-02-19 23:31:26 UTC (rev 164396)
@@ -2273,6 +2273,7 @@
7C184E2117BEE240007CB63A /* JSPromiseConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPromiseConstructor.h; sourceTree = "<group>"; };
7C184E2417BFFA36007CB63A /* JSPromiseConstructor.lut.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSPromiseConstructor.lut.h; sourceTree = "<group>"; };
7C184E2517BFFA36007CB63A /* JSPromisePrototype.lut.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSPromisePrototype.lut.h; sourceTree = "<group>"; };
+ 7CFBAC1C18B535E500D00750 /* Promise.prototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = Promise.prototype.js; sourceTree = "<group>"; };
7E4EE7080EBB7963005934AA /* StructureChain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructureChain.h; sourceTree = "<group>"; };
7E4EE70E0EBB7A5B005934AA /* StructureChain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StructureChain.cpp; sourceTree = "<group>"; };
7EFF00630EC05A9A00AA7C93 /* NodeInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeInfo.h; sourceTree = "<group>"; };
@@ -4768,6 +4769,7 @@
A7D801A11880D66E0026C39B /* BuiltinExecutables.cpp */,
A7D801A21880D66E0026C39B /* BuiltinExecutables.h */,
A75EE9B018AAB7E200AAD043 /* BuiltinNames.h */,
+ 7CFBAC1C18B535E500D00750 /* Promise.prototype.js */,
);
path = builtins;
sourceTree = "<group>";
Added: trunk/Source/_javascript_Core/builtins/Promise.prototype.js (0 => 164396)
--- trunk/Source/_javascript_Core/builtins/Promise.prototype.js (rev 0)
+++ trunk/Source/_javascript_Core/builtins/Promise.prototype.js 2014-02-19 23:31:26 UTC (rev 164396)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+function catch(onRejected) {
+ "use strict";
+
+ return this.then(undefined, onRejected);
+}
Modified: trunk/Source/_javascript_Core/runtime/JSPromisePrototype.cpp (164395 => 164396)
--- trunk/Source/_javascript_Core/runtime/JSPromisePrototype.cpp 2014-02-19 23:22:47 UTC (rev 164395)
+++ trunk/Source/_javascript_Core/runtime/JSPromisePrototype.cpp 2014-02-19 23:31:26 UTC (rev 164396)
@@ -44,7 +44,6 @@
STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSPromisePrototype);
static EncodedJSValue JSC_HOST_CALL JSPromisePrototypeFuncThen(ExecState*);
-static EncodedJSValue JSC_HOST_CALL JSPromisePrototypeFuncCatch(ExecState*);
}
@@ -187,31 +186,6 @@
return JSValue::encode(jsCast<JSPromiseDeferred*>(deferred)->promise());
}
-EncodedJSValue JSC_HOST_CALL JSPromisePrototypeFuncCatch(ExecState* exec)
-{
- // -- Promise.prototype.catch(onRejected) --
-
- // 1. Let 'promise' be the this value.
- JSValue promise = exec->thisValue();
-
- // 2. Return the result of calling Invoke(promise, "then", (undefined, onRejected)).
- // NOTE: Invoke does not seem to be defined anywhere, so I am guessing here.
- JSValue thenValue = promise.get(exec, exec->vm().propertyNames->then);
- if (exec->hadException())
- return JSValue::encode(jsUndefined());
-
- CallData thenCallData;
- CallType thenCallType = getCallData(thenValue, thenCallData);
- if (thenCallType == CallTypeNone)
- return JSValue::encode(throwTypeError(exec));
-
- MarkedArgumentBuffer arguments;
- arguments.append(jsUndefined());
- arguments.append(exec->argument(0));
-
- return JSValue::encode(call(exec, thenValue, thenCallType, thenCallData, promise, arguments));
-}
-
} // namespace JSC
#endif // ENABLE(PROMISES)