Commit d68cdcae authored by Matt Gardner's avatar Matt Gardner Committed by Commit Bot

[torque] Convert name and string types layouts to torque

Bug: v8:8952
Change-Id: I099de2052941684d4ca714062a52c82ef0bb3850
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1516473
Commit-Queue: Matt Gardner <magardn@microsoft.com>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60247}
parent 6487ad7a
......@@ -159,7 +159,7 @@ namespace array_join {
this.AddSeparators(nofSeparators, separatorLength, writeSeparators);
this.totalStringLength =
AddStringLength(this.totalStringLength, str.length);
AddStringLength(this.totalStringLength, str.length_intptr);
this.fixedArray =
StoreAndGrowFixedArray(this.fixedArray, this.index++, str);
this.isOneByte =
......@@ -265,7 +265,7 @@ namespace array_join {
initialLoadFn: LoadJoinElementFn): String {
const initialMap: Map = receiver.map;
const len: uintptr = Convert<uintptr>(lengthNumber);
const separatorLength: intptr = sep.length;
const separatorLength: intptr = sep.length_intptr;
let nofSeparators: intptr = 0;
let loadFn: LoadJoinElementFn = initialLoadFn;
let buffer: Buffer = NewBuffer(len, sep);
......
......@@ -60,13 +60,49 @@ type Code extends AbstractCode generates 'TNode<Code>';
type BuiltinPtr extends Smi generates 'TNode<BuiltinPtr>';
type Context extends HeapObject generates 'TNode<Context>';
type NativeContext extends Context;
type String extends HeapObject generates 'TNode<String>';
type Oddball extends HeapObject generates 'TNode<Oddball>';
type HeapNumber extends HeapObject generates 'TNode<HeapNumber>';
type Number = Smi | HeapNumber;
type BigInt extends HeapObject generates 'TNode<BigInt>';
type Numeric = Number | BigInt;
extern class Name extends HeapObject { hash_field: int32; }
extern class Symbol extends Name {
flags: int32;
name: Object;
}
// abstract
extern class String extends Name { length: uint32; }
extern class ConsString extends String {
first: String;
second: String;
}
extern class ExternalString extends String {
resource: RawPtr;
resource_data: RawPtr;
}
extern class ExternalOneByteString extends ExternalString {}
extern class ExternalTwoByteString extends ExternalString {}
extern class InternalizedString extends String {}
// TODO(v8:8983): Add declaration for variable-sized region.
extern class SeqString extends String {}
extern class SeqOneByteString extends SeqString {}
extern class SeqTwoByteString extends SeqString {}
extern class SlicedString extends String {
parent: String;
offset: Smi;
}
extern class ThinString extends String { actual: String; }
// The HeapNumber value NaN
type NaN extends HeapNumber;
......@@ -1049,7 +1085,7 @@ extern operator '!' macro IsFalse(Boolean): bool;
extern operator '.instanceType' macro LoadInstanceType(HeapObject):
InstanceType;
extern operator '.length' macro LoadStringLengthAsWord(String): intptr;
extern operator '.length_intptr' macro LoadStringLengthAsWord(String): intptr;
extern operator '.length_smi' macro LoadStringLengthAsSmi(String): Smi;
extern operator '.length' macro GetArgumentsLength(constexpr Arguments): intptr;
......
......@@ -7,6 +7,7 @@
#include "src/objects.h"
#include "src/objects/heap-object.h"
#include "torque-generated/class-definitions-from-dsl.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
......@@ -67,9 +68,10 @@ class Name : public HeapObject {
void NameShortPrint();
int NameShortPrint(Vector<char> str);
// Layout description.
static const int kHashFieldOffset = HeapObject::kHeaderSize;
static const int kHeaderSize = kHashFieldOffset + kInt32Size;
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
TORQUE_GENERATED_NAME_FIELDS)
static const int kHeaderSize = kSize;
// Mask constant for checking if a name has a computed hash code
// and if it is a string that is an array index. The least significant bit
......@@ -175,15 +177,8 @@ class Symbol : public Name {
DECL_PRINTER(Symbol)
DECL_VERIFIER(Symbol)
// Layout description.
#define SYMBOL_FIELDS(V) \
V(kFlagsOffset, kInt32Size) \
V(kNameOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Name::kHeaderSize, SYMBOL_FIELDS)
#undef SYMBOL_FIELDS
DEFINE_FIELD_OFFSET_CONSTANTS(Name::kHeaderSize,
TORQUE_GENERATED_SYMBOL_FIELDS)
// Flags layout.
#define FLAGS_BIT_FIELDS(V, _) \
......
......@@ -325,9 +325,10 @@ class String : public Name {
inline bool IsFlat();
// Layout description.
static const int kLengthOffset = Name::kHeaderSize;
static const int kHeaderSize = kLengthOffset + kInt32Size;
DEFINE_FIELD_OFFSET_CONSTANTS(Name::kHeaderSize,
TORQUE_GENERATED_STRING_FIELDS)
static const int kHeaderSize = kSize;
// Max char codes.
static const int32_t kMaxOneByteCharCode = unibrow::Latin1::kMaxChar;
......@@ -602,15 +603,8 @@ class ConsString : public String {
DECL_CAST(ConsString)
// Layout description.
#define CONS_STRING_FIELDS(V) \
V(kFirstOffset, kTaggedSize) \
V(kSecondOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize, CONS_STRING_FIELDS)
#undef CONS_STRING_FIELDS
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize,
TORQUE_GENERATED_CONS_STRING_FIELDS)
// Minimum length for a cons string.
static const int kMinLength = 13;
......@@ -642,14 +636,8 @@ class ThinString : public String {
DECL_CAST(ThinString)
DECL_VERIFIER(ThinString)
// Layout description.
#define THIN_STRING_FIELDS(V) \
V(kActualOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize, THIN_STRING_FIELDS)
#undef THIN_STRING_FIELDS
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize,
TORQUE_GENERATED_THIN_STRING_FIELDS)
typedef FixedBodyDescriptor<kActualOffset, kSize, kSize> BodyDescriptor;
......@@ -681,15 +669,8 @@ class SlicedString : public String {
DECL_CAST(SlicedString)
// Layout description.
#define SLICED_STRING_FIELDS(V) \
V(kParentOffset, kTaggedSize) \
V(kOffsetOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize, SLICED_STRING_FIELDS)
#undef SLICED_STRING_FIELDS
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize,
TORQUE_GENERATED_SLICED_STRING_FIELDS)
// Minimum length for a sliced string.
static const int kMinLength = 13;
......@@ -714,17 +695,12 @@ class ExternalString : public String {
public:
DECL_CAST(ExternalString)
// Layout description.
#define EXTERNAL_STRING_FIELDS(V) \
V(kResourceOffset, kSystemPointerSize) \
/* Size of uncached external strings. */ \
V(kUncachedSize, 0) \
V(kResourceDataOffset, kSystemPointerSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize, EXTERNAL_STRING_FIELDS)
#undef EXTERNAL_STRING_FIELDS
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize,
TORQUE_GENERATED_EXTERNAL_STRING_FIELDS)
// Size of uncached external strings.
static const int kUncachedSize =
kResourceOffset + FIELD_SIZE(kResourceOffset);
// Return whether the external string data pointer is not cached.
inline bool is_uncached() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment