summaryrefslogtreecommitdiff
path: root/js/src/vm/SelfHosting.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/vm/SelfHosting.cpp')
-rw-r--r--js/src/vm/SelfHosting.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp
index de497d02e1..2a60a1885c 100644
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -22,6 +22,7 @@
#include "jswrapper.h"
#include "selfhosted.out.h"
+#include "builtin/BigInt.h"
#include "builtin/intl/Collator.h"
#include "builtin/intl/DateTimeFormat.h"
#include "builtin/intl/IntlObject.h"
@@ -44,6 +45,7 @@
#include "jit/InlinableNatives.h"
#include "js/CharacterEncoding.h"
#include "js/Date.h"
+#include "vm/BigIntType.h"
#include "vm/Compression.h"
#include "vm/GeneratorObject.h"
#include "vm/Interpreter.h"
@@ -1182,6 +1184,18 @@ intrinsic_IsFloat32TypedArray(JSContext* cx, unsigned argc, Value* vp)
}
static bool
+intrinsic_IsBigInt64TypedArray(JSContext* cx, unsigned argc, Value* vp)
+{
+ return intrinsic_IsSpecificTypedArray(cx, argc, vp, Scalar::BigInt64);
+}
+
+static bool
+intrinsic_IsBigUint64TypedArray(JSContext* cx, unsigned argc, Value* vp)
+{
+ return intrinsic_IsSpecificTypedArray(cx, argc, vp, Scalar::BigUint64);
+}
+
+static bool
intrinsic_TypedArrayBuffer(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
@@ -1521,6 +1535,14 @@ struct DisjointElements
CopyValues(dest, src.cast<double*>(), count);
return;
+ case Scalar::BigInt64:
+ CopyValues(dest, src.cast<int64_t*>(), count);
+ return;
+
+ case Scalar::BigUint64:
+ CopyValues(dest, src.cast<uint64_t*>(), count);
+ return;
+
case Scalar::Uint8Clamped:
CopyValues(dest, src.cast<uint8_clamped*>(), count);
return;
@@ -1579,6 +1601,16 @@ CopyToDisjointArray(TypedArrayObject* target, uint32_t targetOffset, SharedMem<v
break;
}
+ case Scalar::BigInt64: {
+ DisjointElements::copy(dest.cast<int64_t*>(), src, srcType, count);
+ break;
+ }
+
+ case Scalar::BigUint64: {
+ DisjointElements::copy(dest.cast<uint64_t*>(), src, srcType, count);
+ break;
+ }
+
case Scalar::Uint8Clamped: {
DisjointElements::copy(dest.cast<uint8_clamped*>(), src, srcType, count);
break;
@@ -2164,6 +2196,29 @@ intrinsic_PromiseResolve(JSContext* cx, unsigned argc, Value* vp)
return true;
}
+static bool intrinsic_ToBigInt(JSContext* cx, unsigned argc, Value* vp)
+{
+ CallArgs args = CallArgsFromVp(argc, vp);
+ MOZ_ASSERT(args.length() == 1);
+ BigInt* res = ToBigInt(cx, args[0]);
+ if (!res) {
+ return false;
+ }
+ args.rval().setBigInt(res);
+ return true;
+}
+
+static bool intrinsic_ToNumeric(JSContext* cx, unsigned argc, Value* vp)
+{
+ CallArgs args = CallArgsFromVp(argc, vp);
+ MOZ_ASSERT(args.length() == 1);
+ if (!ToNumeric(cx, args[0])) {
+ return false;
+ }
+ args.rval().set(args[0]);
+ return true;
+}
+
// The self-hosting global isn't initialized with the normal set of builtins.
// Instead, individual C++-implemented functions that're required by
// self-hosted code are defined as global functions. Accessing these
@@ -2187,6 +2242,8 @@ static const JSFunctionSpec intrinsic_functions[] = {
JS_FN("std_Array_reverse", array_reverse, 0,0),
JS_FNINFO("std_Array_splice", array_splice, &array_splice_info, 2,0),
+ JS_FN("std_BigInt_valueOf", BigIntObject::valueOf, 0,0),
+
JS_FN("std_Date_now", date_now, 0,0),
JS_FN("std_Date_valueOf", date_valueOf, 0,0),
@@ -2399,6 +2456,8 @@ static const JSFunctionSpec intrinsic_functions[] = {
JS_FN("IsUint32TypedArray", intrinsic_IsUint32TypedArray, 1,0),
JS_FN("IsInt32TypedArray", intrinsic_IsInt32TypedArray, 1,0),
JS_FN("IsFloat32TypedArray", intrinsic_IsFloat32TypedArray, 1,0),
+ JS_FN("IsBigInt64TypedArray", intrinsic_IsBigInt64TypedArray, 1,0),
+ JS_FN("IsBigUint64TypedArray", intrinsic_IsBigUint64TypedArray, 1,0),
JS_INLINABLE_FN("IsTypedArray",
intrinsic_IsInstanceOfBuiltin<TypedArrayObject>, 1,0,
IntrinsicIsTypedArray),
@@ -2591,6 +2650,9 @@ static const JSFunctionSpec intrinsic_functions[] = {
JS_FN("CallPromiseMethodIfWrapped", CallNonGenericSelfhostedMethod<Is<PromiseObject>>, 2, 0),
JS_FN("PromiseResolve", intrinsic_PromiseResolve, 2, 0),
+ JS_FN("ToBigInt", intrinsic_ToBigInt, 1, 0),
+ JS_FN("ToNumeric", intrinsic_ToNumeric, 1, 0),
+
JS_FS_END
};