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 { ...@@ -159,7 +159,7 @@ namespace array_join {
this.AddSeparators(nofSeparators, separatorLength, writeSeparators); this.AddSeparators(nofSeparators, separatorLength, writeSeparators);
this.totalStringLength = this.totalStringLength =
AddStringLength(this.totalStringLength, str.length); AddStringLength(this.totalStringLength, str.length_intptr);
this.fixedArray = this.fixedArray =
StoreAndGrowFixedArray(this.fixedArray, this.index++, str); StoreAndGrowFixedArray(this.fixedArray, this.index++, str);
this.isOneByte = this.isOneByte =
...@@ -265,7 +265,7 @@ namespace array_join { ...@@ -265,7 +265,7 @@ namespace array_join {
initialLoadFn: LoadJoinElementFn): String { initialLoadFn: LoadJoinElementFn): String {
const initialMap: Map = receiver.map; const initialMap: Map = receiver.map;
const len: uintptr = Convert<uintptr>(lengthNumber); const len: uintptr = Convert<uintptr>(lengthNumber);
const separatorLength: intptr = sep.length; const separatorLength: intptr = sep.length_intptr;
let nofSeparators: intptr = 0; let nofSeparators: intptr = 0;
let loadFn: LoadJoinElementFn = initialLoadFn; let loadFn: LoadJoinElementFn = initialLoadFn;
let buffer: Buffer = NewBuffer(len, sep); let buffer: Buffer = NewBuffer(len, sep);
......
...@@ -60,13 +60,49 @@ type Code extends AbstractCode generates 'TNode<Code>'; ...@@ -60,13 +60,49 @@ type Code extends AbstractCode generates 'TNode<Code>';
type BuiltinPtr extends Smi generates 'TNode<BuiltinPtr>'; type BuiltinPtr extends Smi generates 'TNode<BuiltinPtr>';
type Context extends HeapObject generates 'TNode<Context>'; type Context extends HeapObject generates 'TNode<Context>';
type NativeContext extends Context; type NativeContext extends Context;
type String extends HeapObject generates 'TNode<String>';
type Oddball extends HeapObject generates 'TNode<Oddball>'; type Oddball extends HeapObject generates 'TNode<Oddball>';
type HeapNumber extends HeapObject generates 'TNode<HeapNumber>'; type HeapNumber extends HeapObject generates 'TNode<HeapNumber>';
type Number = Smi | HeapNumber; type Number = Smi | HeapNumber;
type BigInt extends HeapObject generates 'TNode<BigInt>'; type BigInt extends HeapObject generates 'TNode<BigInt>';
type Numeric = Number | 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 // The HeapNumber value NaN
type NaN extends HeapNumber; type NaN extends HeapNumber;
...@@ -1049,7 +1085,7 @@ extern operator '!' macro IsFalse(Boolean): bool; ...@@ -1049,7 +1085,7 @@ extern operator '!' macro IsFalse(Boolean): bool;
extern operator '.instanceType' macro LoadInstanceType(HeapObject): extern operator '.instanceType' macro LoadInstanceType(HeapObject):
InstanceType; 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_smi' macro LoadStringLengthAsSmi(String): Smi;
extern operator '.length' macro GetArgumentsLength(constexpr Arguments): intptr; extern operator '.length' macro GetArgumentsLength(constexpr Arguments): intptr;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "src/objects.h" #include "src/objects.h"
#include "src/objects/heap-object.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): // Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h" #include "src/objects/object-macros.h"
...@@ -67,9 +68,10 @@ class Name : public HeapObject { ...@@ -67,9 +68,10 @@ class Name : public HeapObject {
void NameShortPrint(); void NameShortPrint();
int NameShortPrint(Vector<char> str); int NameShortPrint(Vector<char> str);
// Layout description. DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
static const int kHashFieldOffset = HeapObject::kHeaderSize; TORQUE_GENERATED_NAME_FIELDS)
static const int kHeaderSize = kHashFieldOffset + kInt32Size;
static const int kHeaderSize = kSize;
// Mask constant for checking if a name has a computed hash code // 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 // and if it is a string that is an array index. The least significant bit
...@@ -175,15 +177,8 @@ class Symbol : public Name { ...@@ -175,15 +177,8 @@ class Symbol : public Name {
DECL_PRINTER(Symbol) DECL_PRINTER(Symbol)
DECL_VERIFIER(Symbol) DECL_VERIFIER(Symbol)
// Layout description. DEFINE_FIELD_OFFSET_CONSTANTS(Name::kHeaderSize,
#define SYMBOL_FIELDS(V) \ TORQUE_GENERATED_SYMBOL_FIELDS)
V(kFlagsOffset, kInt32Size) \
V(kNameOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Name::kHeaderSize, SYMBOL_FIELDS)
#undef SYMBOL_FIELDS
// Flags layout. // Flags layout.
#define FLAGS_BIT_FIELDS(V, _) \ #define FLAGS_BIT_FIELDS(V, _) \
......
...@@ -325,9 +325,10 @@ class String : public Name { ...@@ -325,9 +325,10 @@ class String : public Name {
inline bool IsFlat(); inline bool IsFlat();
// Layout description. DEFINE_FIELD_OFFSET_CONSTANTS(Name::kHeaderSize,
static const int kLengthOffset = Name::kHeaderSize; TORQUE_GENERATED_STRING_FIELDS)
static const int kHeaderSize = kLengthOffset + kInt32Size;
static const int kHeaderSize = kSize;
// Max char codes. // Max char codes.
static const int32_t kMaxOneByteCharCode = unibrow::Latin1::kMaxChar; static const int32_t kMaxOneByteCharCode = unibrow::Latin1::kMaxChar;
...@@ -602,15 +603,8 @@ class ConsString : public String { ...@@ -602,15 +603,8 @@ class ConsString : public String {
DECL_CAST(ConsString) DECL_CAST(ConsString)
// Layout description. DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize,
#define CONS_STRING_FIELDS(V) \ TORQUE_GENERATED_CONS_STRING_FIELDS)
V(kFirstOffset, kTaggedSize) \
V(kSecondOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize, CONS_STRING_FIELDS)
#undef CONS_STRING_FIELDS
// Minimum length for a cons string. // Minimum length for a cons string.
static const int kMinLength = 13; static const int kMinLength = 13;
...@@ -642,14 +636,8 @@ class ThinString : public String { ...@@ -642,14 +636,8 @@ class ThinString : public String {
DECL_CAST(ThinString) DECL_CAST(ThinString)
DECL_VERIFIER(ThinString) DECL_VERIFIER(ThinString)
// Layout description. DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize,
#define THIN_STRING_FIELDS(V) \ TORQUE_GENERATED_THIN_STRING_FIELDS)
V(kActualOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize, THIN_STRING_FIELDS)
#undef THIN_STRING_FIELDS
typedef FixedBodyDescriptor<kActualOffset, kSize, kSize> BodyDescriptor; typedef FixedBodyDescriptor<kActualOffset, kSize, kSize> BodyDescriptor;
...@@ -681,15 +669,8 @@ class SlicedString : public String { ...@@ -681,15 +669,8 @@ class SlicedString : public String {
DECL_CAST(SlicedString) DECL_CAST(SlicedString)
// Layout description. DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize,
#define SLICED_STRING_FIELDS(V) \ TORQUE_GENERATED_SLICED_STRING_FIELDS)
V(kParentOffset, kTaggedSize) \
V(kOffsetOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize, SLICED_STRING_FIELDS)
#undef SLICED_STRING_FIELDS
// Minimum length for a sliced string. // Minimum length for a sliced string.
static const int kMinLength = 13; static const int kMinLength = 13;
...@@ -714,17 +695,12 @@ class ExternalString : public String { ...@@ -714,17 +695,12 @@ class ExternalString : public String {
public: public:
DECL_CAST(ExternalString) DECL_CAST(ExternalString)
// Layout description. DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize,
#define EXTERNAL_STRING_FIELDS(V) \ TORQUE_GENERATED_EXTERNAL_STRING_FIELDS)
V(kResourceOffset, kSystemPointerSize) \
/* Size of uncached external strings. */ \ // Size of uncached external strings.
V(kUncachedSize, 0) \ static const int kUncachedSize =
V(kResourceDataOffset, kSystemPointerSize) \ kResourceOffset + FIELD_SIZE(kResourceOffset);
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(String::kHeaderSize, EXTERNAL_STRING_FIELDS)
#undef EXTERNAL_STRING_FIELDS
// Return whether the external string data pointer is not cached. // Return whether the external string data pointer is not cached.
inline bool is_uncached() const; 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