Line data Source code
1 : // Copyright 2018 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 :
5 : #ifndef V8_BUILTINS_BUILTINS_DATA_VIEW_GEN_H_
6 : #define V8_BUILTINS_BUILTINS_DATA_VIEW_GEN_H_
7 :
8 : #include "src/code-stub-assembler.h"
9 : #include "src/elements-kind.h"
10 : #include "src/objects/bigint.h"
11 :
12 : namespace v8 {
13 : namespace internal {
14 :
15 8736 : class DataViewBuiltinsAssembler : public CodeStubAssembler {
16 : public:
17 : explicit DataViewBuiltinsAssembler(compiler::CodeAssemblerState* state)
18 8736 : : CodeStubAssembler(state) {}
19 :
20 : TNode<Int32T> LoadUint8(TNode<RawPtrT> data_pointer, TNode<UintPtrT> offset) {
21 : return UncheckedCast<Int32T>(
22 2296 : Load(MachineType::Uint8(), data_pointer, offset));
23 : }
24 :
25 : TNode<Int32T> LoadInt8(TNode<RawPtrT> data_pointer, TNode<UintPtrT> offset) {
26 : return UncheckedCast<Int32T>(
27 280 : Load(MachineType::Int8(), data_pointer, offset));
28 : }
29 :
30 : void StoreWord8(TNode<RawPtrT> data_pointer, TNode<UintPtrT> offset,
31 : TNode<Word32T> value) {
32 : StoreNoWriteBarrier(MachineRepresentation::kWord8, data_pointer, offset,
33 4592 : value);
34 : }
35 :
36 : int32_t DataViewElementSize(ElementsKind elements_kind) {
37 1120 : return ElementsKindToByteSize(elements_kind);
38 : }
39 :
40 : TNode<Uint32T> DataViewEncodeBigIntBits(bool sign, int32_t digits) {
41 672 : return Unsigned(Int32Constant(BigInt::SignBits::encode(sign) |
42 224 : BigInt::LengthBits::encode(digits)));
43 : }
44 :
45 112 : TNode<Uint32T> DataViewDecodeBigIntLength(TNode<BigInt> value) {
46 112 : TNode<Word32T> bitfield = LoadBigIntBitfield(value);
47 112 : return DecodeWord32<BigIntBase::LengthBits>(bitfield);
48 : }
49 :
50 112 : TNode<Uint32T> DataViewDecodeBigIntSign(TNode<BigInt> value) {
51 112 : TNode<Word32T> bitfield = LoadBigIntBitfield(value);
52 112 : return DecodeWord32<BigIntBase::SignBits>(bitfield);
53 : }
54 : };
55 :
56 : } // namespace internal
57 : } // namespace v8
58 :
59 : #endif // V8_BUILTINS_BUILTINS_DATA_VIEW_GEN_H_
|