зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1081435 - Implement CallNonGenericMethod for typed array selfhosted methods. r=jandem
This commit is contained in:
Родитель
9f432a3c84
Коммит
d7366c79f1
|
@ -8,13 +8,13 @@ function StarGeneratorNext(val) {
|
|||
// common case with a single call. It's also inlined in Baseline.
|
||||
|
||||
if (!IsSuspendedStarGenerator(this)) {
|
||||
if (!IsObject(this) || !IsStarGeneratorObject(this))
|
||||
if (!IsObject(this) || !IsStarGeneratorObject(this))
|
||||
return callFunction(CallStarGeneratorMethodIfWrapped, this, val, "StarGeneratorNext");
|
||||
|
||||
if (StarGeneratorObjectIsClosed(this))
|
||||
if (StarGeneratorObjectIsClosed(this))
|
||||
return { value: undefined, done: true };
|
||||
|
||||
if (GeneratorIsRunning(this))
|
||||
if (GeneratorIsRunning(this))
|
||||
ThrowError(JSMSG_NESTING_GENERATOR);
|
||||
}
|
||||
|
||||
|
@ -29,13 +29,13 @@ function StarGeneratorNext(val) {
|
|||
|
||||
function StarGeneratorThrow(val) {
|
||||
if (!IsSuspendedStarGenerator(this)) {
|
||||
if (!IsObject(this) || !IsStarGeneratorObject(this))
|
||||
if (!IsObject(this) || !IsStarGeneratorObject(this))
|
||||
return callFunction(CallStarGeneratorMethodIfWrapped, this, val, "StarGeneratorThrow");
|
||||
|
||||
if (StarGeneratorObjectIsClosed(this))
|
||||
if (StarGeneratorObjectIsClosed(this))
|
||||
throw val;
|
||||
|
||||
if (GeneratorIsRunning(this))
|
||||
if (GeneratorIsRunning(this))
|
||||
ThrowError(JSMSG_NESTING_GENERATOR);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
// ES6 draft rev28 (2014/10/14) 22.2.3.10 %TypedArray%.prototype.find(predicate [,thisArg]).
|
||||
function TypedArrayFind(predicate, thisArg = undefined) {
|
||||
// This function is not generic.
|
||||
if (!IsObject(this) || !IsTypedArray(this))
|
||||
ThrowError(JSMSG_INCOMPATIBLE_PROTO, "%TypedArray%", "find", typeof this);
|
||||
if (!IsObject(this) || !IsTypedArray(this)) {
|
||||
return callFunction(CallTypedArrayMethodIfWrapped, this, predicate, thisArg,
|
||||
"TypedArrayFind");
|
||||
}
|
||||
|
||||
// Steps 1-2.
|
||||
var O = this;
|
||||
|
@ -40,8 +42,10 @@ function TypedArrayFind(predicate, thisArg = undefined) {
|
|||
// ES6 draft rev28 (2014/10/14) 22.2.3.11 %TypedArray%.prototype.findIndex(predicate [,thisArg]).
|
||||
function TypedArrayFindIndex(predicate, thisArg = undefined) {
|
||||
// This function is not generic.
|
||||
if (!IsObject(this) || !IsTypedArray(this))
|
||||
ThrowError(JSMSG_INCOMPATIBLE_PROTO, "%TypedArray%", "findIndex", typeof this);
|
||||
if (!IsObject(this) || !IsTypedArray(this)) {
|
||||
return callFunction(CallTypedArrayMethodIfWrapped, this, predicate, thisArg,
|
||||
"TypedArrayFindIndex");
|
||||
}
|
||||
|
||||
// Steps 1-2.
|
||||
var O = this;
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
var global = newGlobal();
|
||||
var array = global.Int8Array(10);
|
||||
|
||||
assertEq(array.find(v => v == 1), undefined)
|
||||
assertEq(array.findIndex(v => v == 0), 0)
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
|
@ -845,18 +845,18 @@ CallSelfHostedNonGenericMethod(JSContext *cx, CallArgs args)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
IsObjectOfType(HandleValue v)
|
||||
bool
|
||||
Is(HandleValue v)
|
||||
{
|
||||
return v.isObject() && v.toObject().is<T>();
|
||||
}
|
||||
|
||||
template<typename T, NativeImpl Impl>
|
||||
template<IsAcceptableThis Test>
|
||||
static bool
|
||||
NativeMethod(JSContext *cx, unsigned argc, Value *vp)
|
||||
CallNonGenericSelfhostedMethod(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
return CallNonGenericMethod<IsObjectOfType<T>, Impl>(cx, args);
|
||||
return CallNonGenericMethod<Test, CallSelfHostedNonGenericMethod>(cx, args);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -1109,10 +1109,13 @@ static const JSFunctionSpec intrinsic_functions[] = {
|
|||
JS_FN("TypedArrayLength", intrinsic_TypedArrayLength, 1,0),
|
||||
JS_FN("IsTypedArray", intrinsic_IsTypedArray, 1,0),
|
||||
|
||||
JS_FN("CallTypedArrayMethodIfWrapped",
|
||||
CallNonGenericSelfhostedMethod<Is<TypedArrayObject>>, 2, 0),
|
||||
|
||||
JS_FN("CallLegacyGeneratorMethodIfWrapped",
|
||||
(NativeMethod<LegacyGeneratorObject, CallSelfHostedNonGenericMethod>), 2, 0),
|
||||
CallNonGenericSelfhostedMethod<Is<LegacyGeneratorObject>>, 2, 0),
|
||||
JS_FN("CallStarGeneratorMethodIfWrapped",
|
||||
(NativeMethod<StarGeneratorObject, CallSelfHostedNonGenericMethod>), 2, 0),
|
||||
CallNonGenericSelfhostedMethod<Is<StarGeneratorObject>>, 2, 0),
|
||||
|
||||
JS_FN("IsWeakSet", intrinsic_IsWeakSet, 1,0),
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче