Commit 8b917cd9 authored by Suraj Sharma's avatar Suraj Sharma Committed by Commit Bot

[torque] Convert few class layout definitions to torque.

Converted JSGlobalObject, JSIteratorResult, JSLocale, JSDateTimeFormat,
JSListFormat, JSNumberFormat, JSPluralRules, JSRelativeTimeFormat,
JSSegmenter, JSAsyncFromSyncIterator to torque.

Bug: v8:8952
Change-Id: I760a658c5bef7e12bc8f07b741245e9d1933164e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1529262
Commit-Queue: Suraj Sharma <surshar@microsoft.com>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60727}
parent 10fa91af
......@@ -16,6 +16,15 @@
#include 'src/objects/js-regexp-string-iterator.h'
#include 'src/objects/module.h'
#include 'src/objects/stack-frame-info.h'
#include 'src/objects/js-date-time-format.h'
#include 'src/objects/js-list-format.h'
#include 'src/objects/js-locale.h'
#include 'src/objects/js-number-format.h'
#include 'src/objects/js-objects.h'
#include 'src/objects/js-plural-rules.h'
#include 'src/objects/js-relative-time-format.h'
#include 'src/objects/js-segment-iterator.h'
#include 'src/objects/js-segmenter.h'
type void;
type never;
......@@ -484,6 +493,66 @@ extern class JSDate extends JSObject {
cache_stamp: Undefined | Smi | NaN;
}
extern class JSGlobalObject extends JSObject {
native_context: NativeContext;
global_proxy: JSGlobalProxy;
}
extern class JSIteratorResult extends JSObject {
value: Object;
done: Boolean;
}
extern class JSLocale extends JSObject {
icu_locale: Foreign; // Managed<icu::Locale>
}
extern class JSDateTimeFormat extends JSObject {
icu_locale: Foreign; // Managed<icu::Locale>
icu_simple_date_format: Foreign; // Managed<icu::SimpleDateFormat>
icu_date_interval_format: Foreign; // Managed<icu::DateIntervalFormat>
bound_format: JSFunction | Undefined;
flags: Smi;
}
extern class JSListFormat extends JSObject {
locale: String;
icu_formatter: Foreign; // Managed<icu::ListFormatter>
flags: Smi;
}
extern class JSNumberFormat extends JSObject {
locale: String;
icu_number_format: Foreign; // Managed<icu::NumberFormat>
bound_format: JSFunction | Undefined;
flags: Smi;
}
extern class JSPluralRules extends JSObject {
locale: String;
flags: Smi;
icu_plural_rules: Foreign; // Managed<icu::PluralRules>
icu_decimal_format: Foreign; // Managed<icu::DecimalFormat>
}
extern class JSRelativeTimeFormat extends JSObject {
locale: String;
icu_formatter: Foreign; // Managed<icu::RelativeDateTimeFormatter>
flags: Smi;
}
extern class JSSegmenter extends JSObject {
locale: String;
icu_break_iterator: Foreign; // Managed<icu::BreakIterator>
flags: Smi;
}
extern class JSSegmentIterator extends JSObject {
icu_break_iterator: Foreign; // Managed<icu::BreakIterator>
unicode_string: Foreign; // Managed<icu::UnicodeString>
flags: Smi;
}
extern class JSAsyncFromSyncIterator extends JSObject {
sync_iterator: JSReceiver;
next: Object;
......
......@@ -2161,62 +2161,64 @@ void JSCollator::JSCollatorVerify(Isolate* isolate) {
void JSDateTimeFormat::JSDateTimeFormatVerify(Isolate* isolate) {
JSObjectVerify(isolate);
VerifyObjectField(isolate, kICULocaleOffset);
VerifyObjectField(isolate, kICUSimpleDateFormatOffset);
VerifyObjectField(isolate, kICUDateIntervalFormatOffset);
VerifyObjectField(isolate, kIcuLocaleOffset);
VerifyObjectField(isolate, kIcuSimpleDateFormatOffset);
VerifyObjectField(isolate, kIcuDateIntervalFormatOffset);
VerifySmiField(kFlagsOffset);
VerifyObjectField(isolate, kBoundFormatOffset);
VerifyObjectField(isolate, kFlagsOffset);
CHECK(bound_format()->IsUndefined(isolate) || bound_format()->IsJSFunction());
}
void JSListFormat::JSListFormatVerify(Isolate* isolate) {
JSObjectVerify(isolate);
VerifyObjectField(isolate, kLocaleOffset);
VerifyObjectField(isolate, kICUFormatterOffset);
VerifyObjectField(isolate, kFlagsOffset);
VerifyObjectField(isolate, kIcuFormatterOffset);
VerifySmiField(kFlagsOffset);
}
void JSLocale::JSLocaleVerify(Isolate* isolate) {
JSObjectVerify(isolate);
VerifyObjectField(isolate, kICULocaleOffset);
VerifyObjectField(isolate, kIcuLocaleOffset);
}
void JSNumberFormat::JSNumberFormatVerify(Isolate* isolate) {
CHECK(IsJSNumberFormat());
JSObjectVerify(isolate);
VerifyObjectField(isolate, kLocaleOffset);
VerifyObjectField(isolate, kICUNumberFormatOffset);
VerifyObjectField(isolate, kIcuNumberFormatOffset);
VerifyObjectField(isolate, kBoundFormatOffset);
VerifyObjectField(isolate, kFlagsOffset);
CHECK(bound_format()->IsUndefined(isolate) || bound_format()->IsJSFunction());
VerifySmiField(kFlagsOffset);
}
void JSPluralRules::JSPluralRulesVerify(Isolate* isolate) {
CHECK(IsJSPluralRules());
JSObjectVerify(isolate);
VerifyObjectField(isolate, kLocaleOffset);
VerifyObjectField(isolate, kFlagsOffset);
VerifyObjectField(isolate, kICUPluralRulesOffset);
VerifyObjectField(isolate, kICUDecimalFormatOffset);
VerifySmiField(kFlagsOffset);
VerifyObjectField(isolate, kIcuPluralRulesOffset);
VerifyObjectField(isolate, kIcuDecimalFormatOffset);
}
void JSRelativeTimeFormat::JSRelativeTimeFormatVerify(Isolate* isolate) {
JSObjectVerify(isolate);
VerifyObjectField(isolate, kLocaleOffset);
VerifyObjectField(isolate, kICUFormatterOffset);
VerifyObjectField(isolate, kFlagsOffset);
VerifyObjectField(isolate, kIcuFormatterOffset);
VerifySmiField(kFlagsOffset);
}
void JSSegmentIterator::JSSegmentIteratorVerify(Isolate* isolate) {
JSObjectVerify(isolate);
VerifyObjectField(isolate, kICUBreakIteratorOffset);
VerifyObjectField(isolate, kIcuBreakIteratorOffset);
VerifyObjectField(isolate, kUnicodeStringOffset);
VerifyObjectField(isolate, kFlagsOffset);
VerifySmiField(kFlagsOffset);
}
void JSSegmenter::JSSegmenterVerify(Isolate* isolate) {
JSObjectVerify(isolate);
VerifyObjectField(isolate, kLocaleOffset);
VerifyObjectField(isolate, kICUBreakIteratorOffset);
VerifyObjectField(isolate, kFlagsOffset);
VerifyObjectField(isolate, kIcuBreakIteratorOffset);
VerifySmiField(kFlagsOffset);
}
#endif // V8_INTL_SUPPORT
......
......@@ -20,11 +20,11 @@ namespace internal {
OBJECT_CONSTRUCTORS_IMPL(JSDateTimeFormat, JSObject)
ACCESSORS(JSDateTimeFormat, icu_locale, Managed<icu::Locale>, kICULocaleOffset)
ACCESSORS(JSDateTimeFormat, icu_locale, Managed<icu::Locale>, kIcuLocaleOffset)
ACCESSORS(JSDateTimeFormat, icu_simple_date_format,
Managed<icu::SimpleDateFormat>, kICUSimpleDateFormatOffset)
Managed<icu::SimpleDateFormat>, kIcuSimpleDateFormatOffset)
ACCESSORS(JSDateTimeFormat, icu_date_interval_format,
Managed<icu::DateIntervalFormat>, kICUDateIntervalFormatOffset)
Managed<icu::DateIntervalFormat>, kIcuDateIntervalFormatOffset)
ACCESSORS(JSDateTimeFormat, bound_format, Object, kBoundFormatOffset)
SMI_ACCESSORS(JSDateTimeFormat, flags, kFlagsOffset)
......
......@@ -15,6 +15,7 @@
#include "src/isolate.h"
#include "src/objects/intl-objects.h"
#include "src/objects/managed.h"
#include "torque-generated/class-definitions-from-dsl.h"
#include "unicode/uversion.h"
// Has to be the last include (doesn't have include guards):
......@@ -92,18 +93,8 @@ class JSDateTimeFormat : public JSObject {
enum class DateTimeStyle { kUndefined, kFull, kLong, kMedium, kShort };
// Layout description.
#define JS_DATE_TIME_FORMAT_FIELDS(V) \
V(kICULocaleOffset, kTaggedSize) \
V(kICUSimpleDateFormatOffset, kTaggedSize) \
V(kICUDateIntervalFormatOffset, kTaggedSize) \
V(kBoundFormatOffset, kTaggedSize) \
V(kFlagsOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
JS_DATE_TIME_FORMAT_FIELDS)
#undef JS_DATE_TIME_FORMAT_FIELDS
TORQUE_GENERATED_JSDATE_TIME_FORMAT_FIELDS)
inline void set_hour_cycle(Intl::HourCycle hour_cycle);
inline Intl::HourCycle hour_cycle() const;
......
......@@ -23,7 +23,7 @@ OBJECT_CONSTRUCTORS_IMPL(JSListFormat, JSObject)
// Base list format accessors.
ACCESSORS(JSListFormat, locale, String, kLocaleOffset)
ACCESSORS(JSListFormat, icu_formatter, Managed<icu::ListFormatter>,
kICUFormatterOffset)
kIcuFormatterOffset)
SMI_ACCESSORS(JSListFormat, flags, kFlagsOffset)
inline void JSListFormat::set_style(Style style) {
......
......@@ -105,16 +105,8 @@ class JSListFormat : public JSObject {
DECL_VERIFIER(JSListFormat)
// Layout description.
#define JS_LIST_FORMAT_FIELDS(V) \
V(kJSListFormatOffset, kTaggedSize) \
V(kLocaleOffset, kTaggedSize) \
V(kICUFormatterOffset, kTaggedSize) \
V(kFlagsOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_LIST_FORMAT_FIELDS)
#undef JS_LIST_FORMAT_FIELDS
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSLIST_FORMAT_FIELDS)
OBJECT_CONSTRUCTORS(JSListFormat, JSObject);
};
......
......@@ -21,7 +21,7 @@ namespace internal {
OBJECT_CONSTRUCTORS_IMPL(JSLocale, JSObject)
ACCESSORS(JSLocale, icu_locale, Managed<icu::Locale>, kICULocaleOffset)
ACCESSORS(JSLocale, icu_locale, Managed<icu::Locale>, kIcuLocaleOffset)
CAST_ACCESSOR(JSLocale)
......
......@@ -58,12 +58,8 @@ class JSLocale : public JSObject {
DECL_VERIFIER(JSLocale)
// Layout description.
#define JS_LOCALE_FIELDS(V) \
V(kICULocaleOffset, kTaggedSize) \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_LOCALE_FIELDS)
#undef JS_LOCALE_FIELDS
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSLOCALE_FIELDS)
OBJECT_CONSTRUCTORS(JSLocale, JSObject);
};
......
......@@ -22,7 +22,7 @@ OBJECT_CONSTRUCTORS_IMPL(JSNumberFormat, JSObject)
ACCESSORS(JSNumberFormat, locale, String, kLocaleOffset)
ACCESSORS(JSNumberFormat, icu_number_format, Managed<icu::NumberFormat>,
kICUNumberFormatOffset)
kIcuNumberFormatOffset)
ACCESSORS(JSNumberFormat, bound_format, Object, kBoundFormatOffset)
SMI_ACCESSORS(JSNumberFormat, flags, kFlagsOffset)
......
......@@ -98,16 +98,8 @@ class JSNumberFormat : public JSObject {
inline CurrencyDisplay currency_display() const;
// Layout description.
#define JS_NUMBER_FORMAT_FIELDS(V) \
V(kLocaleOffset, kTaggedSize) \
V(kICUNumberFormatOffset, kTaggedSize) \
V(kBoundFormatOffset, kTaggedSize) \
V(kFlagsOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_NUMBER_FORMAT_FIELDS)
#undef JS_NUMBER_FORMAT_FIELDS
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSNUMBER_FORMAT_FIELDS)
// Bit positions in |flags|.
#define FLAGS_BIT_FIELDS(V, _) \
......
......@@ -874,15 +874,8 @@ class JSIteratorResult : public JSObject {
DECL_ACCESSORS(done, Object)
// Layout description.
#define JS_ITERATOR_RESULT_FIELDS(V) \
V(kValueOffset, kTaggedSize) \
V(kDoneOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
JS_ITERATOR_RESULT_FIELDS)
#undef JS_ITERATOR_RESULT_FIELDS
TORQUE_GENERATED_JSITERATOR_RESULT_FIELDS)
// Indices of in-object properties.
static const int kValueIndex = 0;
......@@ -1204,15 +1197,8 @@ class JSGlobalObject : public JSObject {
DECL_VERIFIER(JSGlobalObject)
// Layout description.
#define JS_GLOBAL_OBJECT_FIELDS(V) \
V(kNativeContextOffset, kTaggedSize) \
V(kGlobalProxyOffset, kTaggedSize) \
/* Header size. */ \
V(kHeaderSize, 0) \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_GLOBAL_OBJECT_FIELDS)
#undef JS_GLOBAL_OBJECT_FIELDS
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSGLOBAL_OBJECT_FIELDS)
OBJECT_CONSTRUCTORS(JSGlobalObject, JSObject);
};
......
......@@ -24,9 +24,9 @@ OBJECT_CONSTRUCTORS_IMPL(JSPluralRules, JSObject)
ACCESSORS(JSPluralRules, locale, String, kLocaleOffset)
SMI_ACCESSORS(JSPluralRules, flags, kFlagsOffset)
ACCESSORS(JSPluralRules, icu_plural_rules, Managed<icu::PluralRules>,
kICUPluralRulesOffset)
kIcuPluralRulesOffset)
ACCESSORS(JSPluralRules, icu_decimal_format, Managed<icu::DecimalFormat>,
kICUDecimalFormatOffset)
kIcuDecimalFormatOffset)
inline void JSPluralRules::set_type(Type type) {
DCHECK_LT(type, Type::COUNT);
......
......@@ -69,16 +69,8 @@ class JSPluralRules : public JSObject {
STATIC_ASSERT(Type::ORDINAL <= TypeBits::kMax);
// Layout description.
#define JS_PLURAL_RULES_FIELDS(V) \
V(kLocaleOffset, kTaggedSize) \
V(kFlagsOffset, kTaggedSize) \
V(kICUPluralRulesOffset, kTaggedSize) \
V(kICUDecimalFormatOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_PLURAL_RULES_FIELDS)
#undef JS_PLURAL_RULES_FIELDS
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSPLURAL_RULES_FIELDS)
DECL_ACCESSORS(locale, String)
DECL_INT_ACCESSORS(flags)
......
......@@ -23,7 +23,7 @@ OBJECT_CONSTRUCTORS_IMPL(JSRelativeTimeFormat, JSObject)
// Base relative time format accessors.
ACCESSORS(JSRelativeTimeFormat, locale, String, kLocaleOffset)
ACCESSORS(JSRelativeTimeFormat, icu_formatter,
Managed<icu::RelativeDateTimeFormatter>, kICUFormatterOffset)
Managed<icu::RelativeDateTimeFormatter>, kIcuFormatterOffset)
SMI_ACCESSORS(JSRelativeTimeFormat, flags, kFlagsOffset)
inline void JSRelativeTimeFormat::set_style(Style style) {
......
......@@ -106,17 +106,8 @@ class JSRelativeTimeFormat : public JSObject {
DECL_VERIFIER(JSRelativeTimeFormat)
// Layout description.
#define JS_RELATIVE_TIME_FORMAT_FIELDS(V) \
V(kJSRelativeTimeFormatOffset, kTaggedSize) \
V(kLocaleOffset, kTaggedSize) \
V(kICUFormatterOffset, kTaggedSize) \
V(kFlagsOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
JS_RELATIVE_TIME_FORMAT_FIELDS)
#undef JS_RELATIVE_TIME_FORMAT_FIELDS
TORQUE_GENERATED_JSRELATIVE_TIME_FORMAT_FIELDS)
private:
static Style getStyle(const char* str);
......
......@@ -22,7 +22,7 @@ OBJECT_CONSTRUCTORS_IMPL(JSSegmentIterator, JSObject)
// Base segment iterator accessors.
ACCESSORS(JSSegmentIterator, icu_break_iterator, Managed<icu::BreakIterator>,
kICUBreakIteratorOffset)
kIcuBreakIteratorOffset)
ACCESSORS(JSSegmentIterator, unicode_string, Managed<icu::UnicodeString>,
kUnicodeStringOffset)
......
......@@ -90,16 +90,8 @@ class JSSegmentIterator : public JSObject {
DECL_INT_ACCESSORS(flags)
// Layout description.
#define SEGMENTER_FIELDS(V) \
/* Pointer fields. */ \
V(kICUBreakIteratorOffset, kTaggedSize) \
V(kUnicodeStringOffset, kTaggedSize) \
V(kFlagsOffset, kTaggedSize) \
/* Total Size */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, SEGMENTER_FIELDS)
#undef SEGMENTER_FIELDS
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSSEGMENT_ITERATOR_FIELDS)
OBJECT_CONSTRUCTORS(JSSegmentIterator, JSObject);
};
......
......@@ -23,7 +23,7 @@ OBJECT_CONSTRUCTORS_IMPL(JSSegmenter, JSObject)
// Base segmenter accessors.
ACCESSORS(JSSegmenter, locale, String, kLocaleOffset)
ACCESSORS(JSSegmenter, icu_break_iterator, Managed<icu::BreakIterator>,
kICUBreakIteratorOffset)
kIcuBreakIteratorOffset)
SMI_ACCESSORS(JSSegmenter, flags, kFlagsOffset)
inline void JSSegmenter::set_granularity(Granularity granularity) {
......
......@@ -78,16 +78,8 @@ class JSSegmenter : public JSObject {
DECL_VERIFIER(JSSegmenter)
// Layout description.
#define JS_SEGMENTER_FIELDS(V) \
V(kJSSegmenterOffset, kTaggedSize) \
V(kLocaleOffset, kTaggedSize) \
V(kICUBreakIteratorOffset, kTaggedSize) \
V(kFlagsOffset, kTaggedSize) \
/* Header size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_SEGMENTER_FIELDS)
#undef JS_SEGMENTER_FIELDS
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSSEGMENTER_FIELDS)
private:
static Granularity GetGranularity(const char* str);
......
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