[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: Id912197054727815b481b2c683b93473bfcbd0c6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1574491
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Suraj Sharma <surshar@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#61099}
This commit is contained in:
Suraj Sharma 2019-04-25 18:16:36 -07:00 committed by Commit Bot
parent 561b9b07fd
commit 57b30632d8
21 changed files with 127 additions and 121 deletions

View File

@ -964,10 +964,15 @@ torque_files = [
"src/builtins/typed-array-slice.tq",
"src/builtins/typed-array-some.tq",
"src/builtins/typed-array-subarray.tq",
"src/objects/intl-objects.tq",
"test/torque/test-torque.tq",
"third_party/v8/builtins/array-sort.tq",
]
if (!v8_enable_i18n_support) {
torque_files -= [ "src/objects/intl-objects.tq" ]
}
torque_namespaces = [
"arguments",
"array",

View File

@ -524,6 +524,16 @@ 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 JSAsyncFromSyncIterator extends JSObject {
sync_iterator: JSReceiver;
next: Object;

View File

@ -2237,62 +2237,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

View File

@ -0,0 +1,63 @@
// 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.
#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-date-time-format.h'
#include 'src/objects/js-list-format.h'
#include 'src/objects/js-locale.h'
#include 'src/objects/js-segment-iterator.h'
#include 'src/objects/js-segmenter.h'
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 JSLocale extends JSObject {
icu_locale: Foreign; // Managed<icu::Locale>
}
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;
}

View File

@ -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)

View File

@ -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;

View File

@ -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) {

View File

@ -105,15 +105,8 @@ class JSListFormat : public JSObject {
DECL_VERIFIER(JSListFormat)
// Layout description.
#define JS_LIST_FORMAT_FIELDS(V) \
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);
};

View File

@ -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)

View File

@ -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);
};

View File

@ -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)

View File

@ -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, _) \

View File

@ -879,15 +879,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;
@ -1209,15 +1202,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);
};

View File

@ -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);

View File

@ -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)

View File

@ -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) {

View File

@ -109,16 +109,8 @@ class JSRelativeTimeFormat : public JSObject {
DECL_VERIFIER(JSRelativeTimeFormat)
// Layout description.
#define JS_RELATIVE_TIME_FORMAT_FIELDS(V) \
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);

View File

@ -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)

View File

@ -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);
};

View File

@ -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) {

View File

@ -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);