summaryrefslogtreecommitdiff
path: root/deps/v8/src/objects/string.tq
blob: 1bc51ce5da406b365034b962286a5eb0fe3e6f4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@abstract
@generateCppClass
@reserveBitsInInstanceType(6)
extern class String extends Name {
  const length: int32;
}

@generateCppClass
@generateBodyDescriptor
@doNotGenerateCast
extern class ConsString extends String {
  first: String;
  second: String;
}

@abstract
@generateBodyDescriptor
@doNotGenerateCast
extern class ExternalString extends String {
  resource: ExternalPointer;
  resource_data: ExternalPointer;
}

@doNotGenerateCast
extern class ExternalOneByteString extends ExternalString {
}

@doNotGenerateCast
extern class ExternalTwoByteString extends ExternalString {
}

@generateCppClass
@doNotGenerateCast
extern class InternalizedString extends String {
}

@abstract
@generateCppClass
@doNotGenerateCast
extern class SeqString extends String {
}
@generateCppClass
@generateBodyDescriptor
@doNotGenerateCast
extern class SeqOneByteString extends SeqString {
  chars[length]: char8;
}
@generateCppClass
@generateBodyDescriptor
@doNotGenerateCast
extern class SeqTwoByteString extends SeqString {
  chars[length]: char16;
}

@generateCppClass
@generateBodyDescriptor
@doNotGenerateCast
extern class SlicedString extends String {
  parent: String;
  offset: Smi;
}

@generateCppClass
@generateBodyDescriptor
@doNotGenerateCast
extern class ThinString extends String {
  actual: String;
}

// A direct string can be accessed directly through CSA without going into the
// C++ runtime. See also: ToDirectStringAssembler.
type DirectString extends String;

@export
macro AllocateSeqOneByteString(length: uint32): SeqOneByteString {
  assert(length <= kStringMaxLength);
  if (length == 0) return UnsafeCast<SeqOneByteString>(kEmptyString);
  return new SeqOneByteString{
    map: kOneByteStringMap,
    hash_field: kNameEmptyHashField,
    length: Signed(length),
    chars: ...UninitializedIterator {}
  };
}

@export
macro AllocateSeqTwoByteString(length: uint32): String {
  assert(length <= kStringMaxLength);
  if (length == 0) return kEmptyString;
  return new SeqTwoByteString{
    map: kStringMap,
    hash_field: kNameEmptyHashField,
    length: Signed(length),
    chars: ...UninitializedIterator {}
  };
}