Commit 74131bdd authored by Seth Brenith's avatar Seth Brenith Committed by Commit Bot

Move a bunch of bitfield definitions to Torque

This allows Torque code to refer to these bitfields (not currently
relevant for any of these classes), and allows the postmortem debugging
API to provide details about these bitfields.

Change-Id: I79c74a3c5ef1f77e839720a4e8ee1f8482a576ca
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2049870
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66471}
parent 61e117d7
......@@ -5,8 +5,8 @@
#ifndef V8_OBJECTS_API_CALLBACKS_H_
#define V8_OBJECTS_API_CALLBACKS_H_
#include "src/base/bit-field.h"
#include "src/objects/struct.h"
#include "torque-generated/bit-fields-tq.h"
#include "torque-generated/class-definitions-tq.h"
// Has to be the last include (doesn't have include guards):
......@@ -85,20 +85,8 @@ class AccessorInfo : public Struct {
private:
inline bool HasExpectedReceiverType();
// Bit positions in |flags|.
#define ACCESSOR_INFO_FLAGS_BIT_FIELDS(V, _) \
V(AllCanReadBit, bool, 1, _) \
V(AllCanWriteBit, bool, 1, _) \
V(IsSpecialDataPropertyBit, bool, 1, _) \
V(IsSloppyBit, bool, 1, _) \
V(ReplaceOnAccessBit, bool, 1, _) \
V(GetterSideEffectTypeBits, SideEffectType, 2, _) \
/* We could save a bit from setter side-effect type, if necessary */ \
V(SetterSideEffectTypeBits, SideEffectType, 2, _) \
V(InitialAttributesBits, PropertyAttributes, 3, _)
DEFINE_BIT_FIELDS(ACCESSOR_INFO_FLAGS_BIT_FIELDS)
#undef ACCESSOR_INFO_FLAGS_BIT_FIELDS
// Bit positions in |flags|.
DEFINE_TORQUE_GENERATED_ACCESSOR_INFO_FLAGS()
OBJECT_CONSTRUCTORS(AccessorInfo, Struct);
};
......
......@@ -30,9 +30,24 @@ extern class AccessCheckInfo extends Struct {
data: Object;
}
type PropertyAttributes extends int32
constexpr 'v8::internal::PropertyAttributes';
type SideEffectType extends int32 constexpr 'v8::SideEffectType';
bitfield struct AccessorInfoFlags extends uint31 {
all_can_read: bool: 1 bit;
all_can_write: bool: 1 bit;
is_special_data_property: bool: 1 bit;
is_sloppy: bool: 1 bit;
replace_on_access: bool: 1 bit;
getter_side_effect_type: SideEffectType: 2 bit;
setter_side_effect_type: SideEffectType: 2 bit;
initial_attributes: PropertyAttributes: 3 bit;
}
extern class AccessorInfo extends Struct {
name: Object;
flags: Smi;
flags: SmiTagged<AccessorInfoFlags>;
expected_receiver_type: Object;
setter: NonNullForeign|Zero;
getter: NonNullForeign|Zero;
......
......@@ -119,15 +119,8 @@ class DebugInfo : public TorqueGeneratedDebugInfo<DebugInfo, Struct> {
// This could also be implemented as a weak hash table.
DECL_INT_ACCESSORS(debugging_id)
// Bit positions in |debugger_hints|.
#define DEBUGGER_HINTS_BIT_FIELDS(V, _) \
V(SideEffectStateBits, int, 2, _) \
V(DebugIsBlackboxedBit, bool, 1, _) \
V(ComputedDebugIsBlackboxedBit, bool, 1, _) \
V(DebuggingIdBits, int, 20, _)
DEFINE_BIT_FIELDS(DEBUGGER_HINTS_BIT_FIELDS)
#undef DEBUGGER_HINTS_BIT_FIELDS
// Bit positions in |debugger_hints|.
DEFINE_TORQUE_GENERATED_DEBUGGER_HINTS()
static const int kNoDebuggingId = 0;
......
......@@ -27,10 +27,17 @@ bitfield struct DebugInfoFlags extends uint31 {
debug_execution_mode: bool: 1 bit;
}
bitfield struct DebuggerHints extends uint31 {
side_effect_state: int32: 2 bit;
debug_is_blackboxed: bool: 1 bit;
computed_debug_is_blackboxed: bool: 1 bit;
debugging_id: int32: 20 bit;
}
@generateCppClass
extern class DebugInfo extends Struct {
shared: SharedFunctionInfo;
debugger_hints: Smi;
debugger_hints: SmiTagged<DebuggerHints>;
// Script field from shared function info.
script: Undefined|Script;
// The original uninstrumented bytecode array for functions with break
......
......@@ -15,24 +15,52 @@
#include 'src/objects/js-segment-iterator.h'
#include 'src/objects/js-segmenter.h'
type DateTimeStyle extends int32
constexpr 'v8::internal::JSDateTimeFormat::DateTimeStyle';
type HourCycle extends int32
constexpr 'v8::internal::JSDateTimeFormat::HourCycle';
bitfield struct JSDateTimeFormatFlags extends uint31 {
hour_cycle: HourCycle: 3 bit;
date_style: DateTimeStyle: 3 bit;
time_style: DateTimeStyle: 3 bit;
}
extern class JSDateTimeFormat extends JSObject {
locale: String;
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;
flags: SmiTagged<JSDateTimeFormatFlags>;
}
type JSDisplayNamesStyle extends int32
constexpr 'v8::internal::JSDisplayNames::Style';
type JSDisplayNamesFallback extends int32
constexpr 'v8::internal::JSDisplayNames::Fallback';
bitfield struct JSDisplayNamesFlags extends uint31 {
style: JSDisplayNamesStyle: 2 bit;
fallback: JSDisplayNamesFallback: 1 bit;
}
extern class JSDisplayNames extends JSObject {
internal: Foreign; // Managed<DisplayNamesInternal>
flags: Smi;
flags: SmiTagged<JSDisplayNamesFlags>;
}
type JSListFormatStyle extends int32
constexpr 'v8::internal::JSListFormat::Style';
type JSListFormatType extends int32
constexpr 'v8::internal::JSListFormat::Type';
bitfield struct JSListFormatFlags extends uint31 {
style: JSListFormatStyle: 2 bit;
Type: JSListFormatType: 2 bit; // "type" is a reserved word.
}
extern class JSListFormat extends JSObject {
locale: String;
icu_formatter: Foreign; // Managed<icu::ListFormatter>
flags: Smi;
flags: SmiTagged<JSListFormatFlags>;
}
extern class JSNumberFormat extends JSObject {
......@@ -42,35 +70,58 @@ extern class JSNumberFormat extends JSObject {
bound_format: JSFunction|Undefined;
}
type JSPluralRulesType extends int32
constexpr 'v8::internal::JSPluralRules::Type';
bitfield struct JSPluralRulesFlags extends uint31 {
Type: JSPluralRulesType: 1 bit; // "type" is a reserved word.
}
extern class JSPluralRules extends JSObject {
locale: String;
flags: Smi;
flags: SmiTagged<JSPluralRulesFlags>;
icu_plural_rules: Foreign; // Managed<icu::PluralRules>
icu_number_formatter:
Foreign; // Managed<icu::number::LocalizedNumberFormatter>
}
type JSRelativeTimeFormatNumeric extends int32
constexpr 'v8::internal::JSRelativeTimeFormat::Numeric';
bitfield struct JSRelativeTimeFormatFlags extends uint31 {
numeric: JSRelativeTimeFormatNumeric: 1 bit;
}
extern class JSRelativeTimeFormat extends JSObject {
locale: String;
numberingSystem: String;
icu_formatter: Foreign; // Managed<icu::RelativeDateTimeFormatter>
flags: Smi;
flags: SmiTagged<JSRelativeTimeFormatFlags>;
}
extern class JSLocale extends JSObject {
icu_locale: Foreign; // Managed<icu::Locale>
}
type JSSegmenterGranularity extends int32
constexpr 'v8::internal::JSSegmenter::Granularity';
bitfield struct JSSegmenterFlags extends uint31 {
granularity: JSSegmenterGranularity: 2 bit;
}
extern class JSSegmenter extends JSObject {
locale: String;
icu_break_iterator: Foreign; // Managed<icu::BreakIterator>
flags: Smi;
flags: SmiTagged<JSSegmenterFlags>;
}
bitfield struct JSSegmentIteratorFlags extends uint31 {
granularity: JSSegmenterGranularity: 2 bit;
break_type_set: bool: 1 bit;
}
extern class JSSegmentIterator extends JSObject {
icu_break_iterator: Foreign; // Managed<icu::BreakIterator>
unicode_string: Foreign; // Managed<icu::UnicodeString>
flags: Smi;
flags: SmiTagged<JSSegmentIteratorFlags>;
}
extern class JSV8BreakIterator extends JSObject {
......
......@@ -105,14 +105,8 @@ class JSDateTimeFormat : public JSObject {
inline void set_time_style(DateTimeStyle time_style);
inline DateTimeStyle time_style() const;
// Bit positions in |flags|.
#define FLAGS_BIT_FIELDS(V, _) \
V(HourCycleBits, HourCycle, 3, _) \
V(DateStyleBits, DateTimeStyle, 3, _) \
V(TimeStyleBits, DateTimeStyle, 3, _)
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS
// Bit positions in |flags|.
DEFINE_TORQUE_GENERATED_JS_DATE_TIME_FORMAT_FLAGS()
STATIC_ASSERT(HourCycle::kUndefined <= HourCycleBits::kMax);
STATIC_ASSERT(HourCycle::kH11 <= HourCycleBits::kMax);
......
......@@ -37,14 +37,14 @@ inline JSDisplayNames::Style JSDisplayNames::style() const {
}
inline void JSDisplayNames::set_fallback(Fallback fallback) {
DCHECK_GE(FallbackBits::kMax, fallback);
DCHECK_GE(FallbackBit::kMax, fallback);
int hints = flags();
hints = FallbackBits::update(hints, fallback);
hints = FallbackBit::update(hints, fallback);
set_flags(hints);
}
inline JSDisplayNames::Fallback JSDisplayNames::fallback() const {
return FallbackBits::decode(flags());
return FallbackBit::decode(flags());
}
} // namespace internal
......
......@@ -67,18 +67,14 @@ class JSDisplayNames : public JSObject {
DECL_CAST(JSDisplayNames)
// Bit positions in |flags|.
#define FLAGS_BIT_FIELDS(V, _) \
V(StyleBits, Style, 2, _) \
V(FallbackBits, Fallback, 1, _)
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS
// Bit positions in |flags|.
DEFINE_TORQUE_GENERATED_JS_DISPLAY_NAMES_FLAGS()
STATIC_ASSERT(Style::kLong <= StyleBits::kMax);
STATIC_ASSERT(Style::kShort <= StyleBits::kMax);
STATIC_ASSERT(Style::kNarrow <= StyleBits::kMax);
STATIC_ASSERT(Fallback::kCode <= FallbackBits::kMax);
STATIC_ASSERT(Fallback::kNone <= FallbackBits::kMax);
STATIC_ASSERT(Fallback::kCode <= FallbackBit::kMax);
STATIC_ASSERT(Fallback::kNone <= FallbackBit::kMax);
// [flags] Bit field containing various flags about the function.
DECL_INT_ACCESSORS(flags)
......
......@@ -83,12 +83,8 @@ class JSListFormat : public JSObject {
inline void set_type(Type type);
inline Type type() const;
// Bit positions in |flags|.
#define FLAGS_BIT_FIELDS(V, _) \
V(StyleBits, Style, 2, _) \
V(TypeBits, Type, 2, _)
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS
// Bit positions in |flags|.
DEFINE_TORQUE_GENERATED_JS_LIST_FORMAT_FLAGS()
STATIC_ASSERT(Style::LONG <= StyleBits::kMax);
STATIC_ASSERT(Style::SHORT <= StyleBits::kMax);
......
......@@ -30,14 +30,14 @@ ACCESSORS(JSPluralRules, icu_number_formatter,
kIcuNumberFormatterOffset)
inline void JSPluralRules::set_type(Type type) {
DCHECK_LE(type, TypeBits::kMax);
DCHECK_LE(type, TypeBit::kMax);
int hints = flags();
hints = TypeBits::update(hints, type);
hints = TypeBit::update(hints, type);
set_flags(hints);
}
inline JSPluralRules::Type JSPluralRules::type() const {
return TypeBits::decode(flags());
return TypeBit::decode(flags());
}
CAST_ACCESSOR(JSPluralRules)
......
......@@ -58,16 +58,13 @@ class JSPluralRules : public JSObject {
DECL_PRINTER(JSPluralRules)
DECL_VERIFIER(JSPluralRules)
// Bit positions in |flags|.
#define FLAGS_BIT_FIELDS(V, _) V(TypeBits, Type, 1, _)
// Bit positions in |flags|.
DEFINE_TORQUE_GENERATED_JS_PLURAL_RULES_FLAGS()
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS
STATIC_ASSERT(Type::CARDINAL <= TypeBit::kMax);
STATIC_ASSERT(Type::ORDINAL <= TypeBit::kMax);
STATIC_ASSERT(Type::CARDINAL <= TypeBits::kMax);
STATIC_ASSERT(Type::ORDINAL <= TypeBits::kMax);
// Layout description.
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JS_PLURAL_RULES_FIELDS)
......
......@@ -28,14 +28,14 @@ ACCESSORS(JSRelativeTimeFormat, icu_formatter,
SMI_ACCESSORS(JSRelativeTimeFormat, flags, kFlagsOffset)
inline void JSRelativeTimeFormat::set_numeric(Numeric numeric) {
DCHECK_GE(NumericBits::kMax, numeric);
DCHECK_GE(NumericBit::kMax, numeric);
int hints = flags();
hints = NumericBits::update(hints, numeric);
hints = NumericBit::update(hints, numeric);
set_flags(hints);
}
inline JSRelativeTimeFormat::Numeric JSRelativeTimeFormat::numeric() const {
return NumericBits::decode(flags());
return NumericBit::decode(flags());
}
CAST_ACCESSOR(JSRelativeTimeFormat)
......
......@@ -75,14 +75,11 @@ class JSRelativeTimeFormat : public JSObject {
inline void set_numeric(Numeric numeric);
inline Numeric numeric() const;
// Bit positions in |flags|.
#define FLAGS_BIT_FIELDS(V, _) \
V(NumericBits, Numeric, 1, _)
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS
STATIC_ASSERT(Numeric::AUTO <= NumericBits::kMax);
STATIC_ASSERT(Numeric::ALWAYS <= NumericBits::kMax);
// Bit positions in |flags|.
DEFINE_TORQUE_GENERATED_JS_RELATIVE_TIME_FORMAT_FLAGS()
STATIC_ASSERT(Numeric::AUTO <= NumericBit::kMax);
STATIC_ASSERT(Numeric::ALWAYS <= NumericBit::kMax);
// [flags] Bit field containing various flags about the function.
DECL_INT_ACCESSORS(flags)
......
......@@ -27,7 +27,7 @@ ACCESSORS(JSSegmentIterator, unicode_string, Managed<icu::UnicodeString>,
kUnicodeStringOffset)
BIT_FIELD_ACCESSORS(JSSegmentIterator, flags, is_break_type_set,
JSSegmentIterator::BreakTypeSetBits)
JSSegmentIterator::BreakTypeSetBit)
SMI_ACCESSORS(JSSegmentIterator, flags, kFlagsOffset)
......
......@@ -76,12 +76,8 @@ class JSSegmentIterator : public JSObject {
inline void set_granularity(JSSegmenter::Granularity granularity);
inline JSSegmenter::Granularity granularity() const;
// Bit positions in |flags|.
#define FLAGS_BIT_FIELDS(V, _) \
V(GranularityBits, JSSegmenter::Granularity, 2, _) \
V(BreakTypeSetBits, bool, 1, _)
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS
// Bit positions in |flags|.
DEFINE_TORQUE_GENERATED_JS_SEGMENT_ITERATOR_FLAGS()
STATIC_ASSERT(JSSegmenter::Granularity::GRAPHEME <= GranularityBits::kMax);
STATIC_ASSERT(JSSegmenter::Granularity::WORD <= GranularityBits::kMax);
......
......@@ -62,10 +62,8 @@ class JSSegmenter : public JSObject {
inline void set_granularity(Granularity granularity);
inline Granularity granularity() const;
// Bit positions in |flags|.
#define FLAGS_BIT_FIELDS(V, _) V(GranularityBits, Granularity, 2, _)
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS
// Bit positions in |flags|.
DEFINE_TORQUE_GENERATED_JS_SEGMENTER_FLAGS()
STATIC_ASSERT(Granularity::GRAPHEME <= GranularityBits::kMax);
STATIC_ASSERT(Granularity::WORD <= GranularityBits::kMax);
......
......@@ -5,8 +5,8 @@
#ifndef V8_OBJECTS_PROPERTY_DESCRIPTOR_OBJECT_H_
#define V8_OBJECTS_PROPERTY_DESCRIPTOR_OBJECT_H_
#include "src/base/bit-field.h"
#include "src/objects/struct.h"
#include "torque-generated/bit-fields-tq.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
......@@ -18,19 +18,7 @@ class PropertyDescriptorObject
: public TorqueGeneratedPropertyDescriptorObject<PropertyDescriptorObject,
Struct> {
public:
#define FLAGS_BIT_FIELDS(V, _) \
V(IsEnumerableBit, bool, 1, _) \
V(HasEnumerableBit, bool, 1, _) \
V(IsConfigurableBit, bool, 1, _) \
V(HasConfigurableBit, bool, 1, _) \
V(IsWritableBit, bool, 1, _) \
V(HasWritableBit, bool, 1, _) \
V(HasValueBit, bool, 1, _) \
V(HasGetBit, bool, 1, _) \
V(HasSetBit, bool, 1, _)
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS
DEFINE_TORQUE_GENERATED_PROPERTY_DESCRIPTOR_OBJECT_FLAGS()
static const int kRegularAccessorPropertyBits =
HasEnumerableBit::kMask | HasConfigurableBit::kMask | HasGetBit::kMask |
......
......@@ -4,10 +4,22 @@
#include 'src/objects/property-descriptor-object.h'
bitfield struct PropertyDescriptorObjectFlags extends uint31 {
is_enumerable: bool: 1 bit;
has_enumerable: bool: 1 bit;
is_configurable: bool: 1 bit;
has_configurable: bool: 1 bit;
is_writable: bool: 1 bit;
has_writable: bool: 1 bit;
has_value: bool: 1 bit;
has_get: bool: 1 bit;
has_set: bool: 1 bit;
}
@generateCppClass
@generatePrint
extern class PropertyDescriptorObject extends Struct {
flags: Smi;
flags: SmiTagged<PropertyDescriptorObjectFlags>;
value: JSAny|TheHole;
get: JSAny|TheHole;
set: JSAny|TheHole;
......
......@@ -333,13 +333,7 @@ class WasmGlobalObject : public JSObject {
DECL_PRINTER(WasmGlobalObject)
DECL_VERIFIER(WasmGlobalObject)
#define WASM_GLOBAL_OBJECT_FLAGS_BIT_FIELDS(V, _) \
V(TypeBits, wasm::ValueType, 8, _) \
V(IsMutableBit, bool, 1, _)
DEFINE_BIT_FIELDS(WASM_GLOBAL_OBJECT_FLAGS_BIT_FIELDS)
#undef WASM_GLOBAL_OBJECT_FLAGS_BIT_FIELDS
DEFINE_TORQUE_GENERATED_WASM_GLOBAL_OBJECT_FLAGS()
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_WASM_GLOBAL_OBJECT_FIELDS)
......
......@@ -74,11 +74,17 @@ extern class WasmMemoryObject extends JSObject {
instances: WeakArrayList|Undefined;
}
type WasmValueType extends uint8 constexpr 'v8::internal::wasm::ValueType';
bitfield struct WasmGlobalObjectFlags extends uint31 {
Type: WasmValueType: 8 bit; // "type" is a reserved word.
is_mutable: bool: 1 bit;
}
extern class WasmGlobalObject extends JSObject {
untagged_buffer: JSArrayBuffer|Undefined;
tagged_buffer: FixedArray|Undefined;
offset: Smi;
flags: Smi;
flags: SmiTagged<WasmGlobalObjectFlags>;
}
extern class WasmExceptionObject extends JSObject {
......
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