v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
builtins-bigint-gen.cc
Go to the documentation of this file.
1// Copyright 2017 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
11
12namespace v8 {
13namespace internal {
14
16
17// https://tc39.github.io/proposal-bigint/#sec-to-big-int64
19 if (!Is64()) {
20 Unreachable();
21 return;
22 }
23
24 auto value = Parameter<Object>(Descriptor::kArgument);
25 auto context = Parameter<Context>(Descriptor::kContext);
26 TNode<BigInt> n = ToBigInt(context, value);
27
28 TVARIABLE(UintPtrT, var_low);
29 TVARIABLE(UintPtrT, var_high);
30
31 BigIntToRawBytes(n, &var_low, &var_high);
32 Return(var_low.value());
33}
34
35// https://tc39.github.io/proposal-bigint/#sec-to-big-int64
36TF_BUILTIN(BigIntToI32Pair, CodeStubAssembler) {
37 if (!Is32()) {
38 Unreachable();
39 return;
40 }
41
42 auto value = Parameter<Object>(Descriptor::kArgument);
43 auto context = Parameter<Context>(Descriptor::kContext);
44 TNode<BigInt> bigint = ToBigInt(context, value);
45
46 TVARIABLE(UintPtrT, var_low);
47 TVARIABLE(UintPtrT, var_high);
48
49 BigIntToRawBytes(bigint, &var_low, &var_high);
50 Return(var_low.value(), var_high.value());
51}
52
53// https://tc39.github.io/proposal-bigint/#sec-bigint-constructor-number-value
55 if (!Is64()) {
56 Unreachable();
57 return;
58 }
59
60 auto argument = UncheckedParameter<IntPtrT>(Descriptor::kArgument);
61
62 Return(BigIntFromInt64(argument));
63}
64
65// https://tc39.github.io/proposal-bigint/#sec-bigint-constructor-number-value
66TF_BUILTIN(I32PairToBigInt, CodeStubAssembler) {
67 if (!Is32()) {
68 Unreachable();
69 return;
70 }
71
72 auto low = UncheckedParameter<IntPtrT>(Descriptor::kLow);
73 auto high = UncheckedParameter<IntPtrT>(Descriptor::kHigh);
74
75 Return(BigIntFromInt32Pair(low, high));
76}
77
79
80} // namespace internal
81} // namespace v8
#define TVARIABLE(...)
#define TF_BUILTIN(Name, AssemblerBase)
constexpr bool Is64()