Commit 42fee61a authored by Suraj Sharma's avatar Suraj Sharma Committed by Commit Bot

Reland "[torque] Convert few class layout to torque."

This is a reland of b9bfd006

Original change's description:
> [torque] Convert few class layout to torque and updated torque code formatter.
>
> 1. Converted Module, JSModuleNameSpace, JSCollator, JSV8BreakIterator,
>       TemplateList,
>       JSStrictArgumentsObject to torque.
> 2. Updated torque code formatter to now handle multi-line
>             declarations correctly.
>
> Bug: v8:8952
> Change-Id: I97846b1bc0d2cba5d7a68468fc263423b1b55d19
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1536988
> Reviewed-by: Simon Zünd <szuend@chromium.org>
> Commit-Queue: Suraj Sharma <surshar@microsoft.com>
> Cr-Commit-Position: refs/heads/master@{#61624}

Removed the Torque code Formatter update from this CL

Bug: v8:8952
Change-Id: I01e88ac36acd7ba18791bec609e5ae737672c731
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1619146
Commit-Queue: Suraj Sharma <surshar@microsoft.com>
Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61671}
parent 8cbb60f3
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include 'src/objects/js-regexp-string-iterator.h' #include 'src/objects/js-regexp-string-iterator.h'
#include 'src/objects/module.h' #include 'src/objects/module.h'
#include 'src/objects/stack-frame-info.h' #include 'src/objects/stack-frame-info.h'
#include 'src/objects/template-objects.h'
#include 'src/builtins/builtins-regexp-gen.h' #include 'src/builtins/builtins-regexp-gen.h'
type void; type void;
...@@ -365,6 +366,11 @@ extern class JSSloppyArgumentsObject extends JSArgumentsObjectWithLength { ...@@ -365,6 +366,11 @@ extern class JSSloppyArgumentsObject extends JSArgumentsObjectWithLength {
callee: Object; callee: Object;
} }
@hasSameInstanceTypeAsParent
@noVerifier
extern class JSStrictArgumentsObject extends JSArgumentsObjectWithLength {
}
extern class JSArrayIterator extends JSObject { extern class JSArrayIterator extends JSObject {
iterated_object: JSReceiver; iterated_object: JSReceiver;
next_index: Number; next_index: Number;
...@@ -428,7 +434,36 @@ transient type FastJSArrayWithNoCustomIteration extends FastJSArray; ...@@ -428,7 +434,36 @@ transient type FastJSArrayWithNoCustomIteration extends FastJSArray;
type NoSharedNameSentinel extends Smi; type NoSharedNameSentinel extends Smi;
type JSModuleNamespace extends JSObject; type ModuleInfo extends FixedArray;
type ObjectHashTable extends FixedArray;
extern class Module extends Struct {
code: SharedFunctionInfo | JSFunction |
JSGeneratorObject | ModuleInfo;
exports: ObjectHashTable;
regular_exports: FixedArray;
regular_imports: FixedArray;
hash: Smi;
status: Smi;
module_namespace: JSModuleNamespace | Undefined;
requested_modules: FixedArray;
dfs_index: Smi;
dfs_ancestor_index: Smi;
exception: Object;
script: Script;
@noVerifier import_meta: Hole | JSObject;
}
extern class JSModuleNamespace extends JSObject {
module: Module;
to_string_tag_field: Object;
}
@hasSameInstanceTypeAsParent
@noVerifier
extern class TemplateList extends FixedArray {
}
type WeakArrayList extends HeapObject; type WeakArrayList extends HeapObject;
@abstract @abstract
......
...@@ -1571,10 +1571,7 @@ void BigInt::BigIntVerify(Isolate* isolate) { ...@@ -1571,10 +1571,7 @@ void BigInt::BigIntVerify(Isolate* isolate) {
CHECK_IMPLIES(is_zero(), !sign()); // There is no -0n. CHECK_IMPLIES(is_zero(), !sign()); // There is no -0n.
} }
void JSModuleNamespace::JSModuleNamespaceVerify(Isolate* isolate) { USE_TORQUE_VERIFIER(JSModuleNamespace)
CHECK(IsJSModuleNamespace());
VerifyPointer(isolate, module());
}
void ModuleInfoEntry::ModuleInfoEntryVerify(Isolate* isolate) { void ModuleInfoEntry::ModuleInfoEntryVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::ModuleInfoEntryVerify(*this, isolate); TorqueGeneratedClassVerifiers::ModuleInfoEntryVerify(*this, isolate);
...@@ -1584,17 +1581,7 @@ void ModuleInfoEntry::ModuleInfoEntryVerify(Isolate* isolate) { ...@@ -1584,17 +1581,7 @@ void ModuleInfoEntry::ModuleInfoEntryVerify(Isolate* isolate) {
} }
void Module::ModuleVerify(Isolate* isolate) { void Module::ModuleVerify(Isolate* isolate) {
CHECK(IsModule()); TorqueGeneratedClassVerifiers::ModuleVerify(*this, isolate);
VerifyPointer(isolate, code());
VerifyPointer(isolate, exports());
VerifyPointer(isolate, module_namespace());
VerifyPointer(isolate, requested_modules());
VerifyPointer(isolate, script());
VerifyPointer(isolate, import_meta());
VerifyPointer(isolate, exception());
VerifySmiField(kHashOffset);
VerifySmiField(kStatusOffset);
CHECK((status() >= kEvaluating && code()->IsModuleInfo()) || CHECK((status() >= kEvaluating && code()->IsModuleInfo()) ||
(status() == kInstantiated && code()->IsJSGeneratorObject()) || (status() == kInstantiated && code()->IsJSGeneratorObject()) ||
...@@ -1878,25 +1865,10 @@ void UncompiledDataWithoutPreparseData::UncompiledDataWithoutPreparseDataVerify( ...@@ -1878,25 +1865,10 @@ void UncompiledDataWithoutPreparseData::UncompiledDataWithoutPreparseDataVerify(
USE_TORQUE_VERIFIER(InterpreterData) USE_TORQUE_VERIFIER(InterpreterData)
#ifdef V8_INTL_SUPPORT #ifdef V8_INTL_SUPPORT
void JSV8BreakIterator::JSV8BreakIteratorVerify(Isolate* isolate) {
JSObjectVerify(isolate); USE_TORQUE_VERIFIER(JSV8BreakIterator)
VerifyObjectField(isolate, kLocaleOffset);
VerifyObjectField(isolate, kTypeOffset); USE_TORQUE_VERIFIER(JSCollator)
VerifyObjectField(isolate, kBreakIteratorOffset);
VerifyObjectField(isolate, kUnicodeStringOffset);
VerifyObjectField(isolate, kBoundAdoptTextOffset);
VerifyObjectField(isolate, kBoundFirstOffset);
VerifyObjectField(isolate, kBoundNextOffset);
VerifyObjectField(isolate, kBoundCurrentOffset);
VerifyObjectField(isolate, kBoundBreakTypeOffset);
}
void JSCollator::JSCollatorVerify(Isolate* isolate) {
CHECK(IsJSCollator());
JSObjectVerify(isolate);
VerifyObjectField(isolate, kICUCollatorOffset);
VerifyObjectField(isolate, kBoundCompareOffset);
}
void JSDateTimeFormat::JSDateTimeFormatVerify(Isolate* isolate) { void JSDateTimeFormat::JSDateTimeFormatVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::JSDateTimeFormatVerify(*this, isolate); TorqueGeneratedClassVerifiers::JSDateTimeFormatVerify(*this, isolate);
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include 'src/objects/js-break-iterator.h'
#include 'src/objects/js-collator.h'
#include 'src/objects/js-number-format.h' #include 'src/objects/js-number-format.h'
#include 'src/objects/js-objects.h' #include 'src/objects/js-objects.h'
#include 'src/objects/js-plural-rules.h' #include 'src/objects/js-plural-rules.h'
...@@ -62,3 +64,20 @@ extern class JSSegmentIterator extends JSObject { ...@@ -62,3 +64,20 @@ extern class JSSegmentIterator extends JSObject {
unicode_string: Foreign; // Managed<icu::UnicodeString> unicode_string: Foreign; // Managed<icu::UnicodeString>
flags: Smi; flags: Smi;
} }
extern class JSV8BreakIterator extends JSObject {
locale: String;
break_iterator: Foreign; // Managed<icu::BreakIterator>;
unicode_string: Foreign; // Managed<icu::UnicodeString>;
bound_adopt_text: Undefined | JSFunction;
bound_first: Undefined | JSFunction;
bound_next: Undefined | JSFunction;
bound_current: Undefined | JSFunction;
bound_break_type: Undefined | JSFunction;
break_iterator_type: Smi;
}
extern class JSCollator extends JSObject {
icu_collator: Foreign; // Managed<icu::Collator>
bound_compare: Undefined | JSFunction;
}
...@@ -22,11 +22,12 @@ OBJECT_CONSTRUCTORS_IMPL(JSV8BreakIterator, JSObject) ...@@ -22,11 +22,12 @@ OBJECT_CONSTRUCTORS_IMPL(JSV8BreakIterator, JSObject)
inline void JSV8BreakIterator::set_type(Type type) { inline void JSV8BreakIterator::set_type(Type type) {
DCHECK_GT(JSV8BreakIterator::Type::COUNT, type); DCHECK_GT(JSV8BreakIterator::Type::COUNT, type);
WRITE_FIELD(*this, kTypeOffset, Smi::FromInt(static_cast<int>(type))); WRITE_FIELD(*this, kBreakIteratorTypeOffset,
Smi::FromInt(static_cast<int>(type)));
} }
inline JSV8BreakIterator::Type JSV8BreakIterator::type() const { inline JSV8BreakIterator::Type JSV8BreakIterator::type() const {
Object value = READ_FIELD(*this, kTypeOffset); Object value = READ_FIELD(*this, kBreakIteratorTypeOffset);
return static_cast<JSV8BreakIterator::Type>(Smi::ToInt(value)); return static_cast<JSV8BreakIterator::Type>(Smi::ToInt(value));
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "src/objects.h" #include "src/objects.h"
#include "src/objects/intl-objects.h" #include "src/objects/intl-objects.h"
#include "src/objects/managed.h" #include "src/objects/managed.h"
#include "torque-generated/field-offsets-tq.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"
...@@ -70,22 +71,8 @@ class JSV8BreakIterator : public JSObject { ...@@ -70,22 +71,8 @@ class JSV8BreakIterator : public JSObject {
DECL_ACCESSORS(bound_break_type, Object) DECL_ACCESSORS(bound_break_type, Object)
// Layout description. // Layout description.
#define BREAK_ITERATOR_FIELDS(V) \ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
/* Pointer fields. */ \ TORQUE_GENERATED_JSV8BREAK_ITERATOR_FIELDS)
V(kLocaleOffset, kTaggedSize) \
V(kTypeOffset, kTaggedSize) \
V(kBreakIteratorOffset, kTaggedSize) \
V(kUnicodeStringOffset, kTaggedSize) \
V(kBoundAdoptTextOffset, kTaggedSize) \
V(kBoundFirstOffset, kTaggedSize) \
V(kBoundNextOffset, kTaggedSize) \
V(kBoundCurrentOffset, kTaggedSize) \
V(kBoundBreakTypeOffset, kTaggedSize) \
/* Total Size */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, BREAK_ITERATOR_FIELDS)
#undef BREAK_ITERATOR_FIELDS
OBJECT_CONSTRUCTORS(JSV8BreakIterator, JSObject); OBJECT_CONSTRUCTORS(JSV8BreakIterator, JSObject);
}; };
......
...@@ -20,7 +20,7 @@ namespace internal { ...@@ -20,7 +20,7 @@ namespace internal {
OBJECT_CONSTRUCTORS_IMPL(JSCollator, JSObject) OBJECT_CONSTRUCTORS_IMPL(JSCollator, JSObject)
ACCESSORS(JSCollator, icu_collator, Managed<icu::Collator>, kICUCollatorOffset) ACCESSORS(JSCollator, icu_collator, Managed<icu::Collator>, kIcuCollatorOffset)
ACCESSORS(JSCollator, bound_compare, Object, kBoundCompareOffset) ACCESSORS(JSCollator, bound_compare, Object, kBoundCompareOffset)
CAST_ACCESSOR(JSCollator) CAST_ACCESSOR(JSCollator)
......
...@@ -47,14 +47,8 @@ class JSCollator : public JSObject { ...@@ -47,14 +47,8 @@ class JSCollator : public JSObject {
DECL_VERIFIER(JSCollator) DECL_VERIFIER(JSCollator)
// Layout description. // Layout description.
#define JS_COLLATOR_FIELDS(V) \ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
V(kICUCollatorOffset, kTaggedSize) \ TORQUE_GENERATED_JSCOLLATOR_FIELDS)
V(kBoundCompareOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_COLLATOR_FIELDS)
#undef JS_COLLATOR_FIELDS
DECL_ACCESSORS(icu_collator, Managed<icu::Collator>) DECL_ACCESSORS(icu_collator, Managed<icu::Collator>)
DECL_ACCESSORS(bound_compare, Object) DECL_ACCESSORS(bound_compare, Object)
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "src/objects/fixed-array.h" #include "src/objects/fixed-array.h"
#include "src/objects/js-objects.h" #include "src/objects/js-objects.h"
#include "src/objects/struct.h" #include "src/objects/struct.h"
#include "torque-generated/field-offsets-tq.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"
...@@ -126,25 +127,8 @@ class Module : public Struct { ...@@ -126,25 +127,8 @@ class Module : public Struct {
Handle<Module> module); Handle<Module> module);
// Layout description. // Layout description.
#define MODULE_FIELDS(V) \ DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
V(kCodeOffset, kTaggedSize) \ TORQUE_GENERATED_MODULE_FIELDS)
V(kExportsOffset, kTaggedSize) \
V(kRegularExportsOffset, kTaggedSize) \
V(kRegularImportsOffset, kTaggedSize) \
V(kHashOffset, kTaggedSize) \
V(kModuleNamespaceOffset, kTaggedSize) \
V(kRequestedModulesOffset, kTaggedSize) \
V(kStatusOffset, kTaggedSize) \
V(kDfsIndexOffset, kTaggedSize) \
V(kDfsAncestorIndexOffset, kTaggedSize) \
V(kExceptionOffset, kTaggedSize) \
V(kScriptOffset, kTaggedSize) \
V(kImportMetaOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, MODULE_FIELDS)
#undef MODULE_FIELDS
private: private:
friend class Factory; friend class Factory;
...@@ -245,23 +229,14 @@ class JSModuleNamespace : public JSObject { ...@@ -245,23 +229,14 @@ class JSModuleNamespace : public JSObject {
LookupIterator* it); LookupIterator* it);
// In-object fields. // In-object fields.
enum { static constexpr int kToStringTagFieldIndex = 0;
kToStringTagFieldIndex, static constexpr int kInObjectFieldCount = 1;
kInObjectFieldCount,
};
// Layout description.
#define JS_MODULE_NAMESPACE_FIELDS(V) \
V(kModuleOffset, kTaggedSize) \
/* Header size. */ \
V(kHeaderSize, 0) \
V(kInObjectFieldsOffset, kTaggedSize* kInObjectFieldCount) \
/* Total size. */ \
V(kSize, 0)
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
JS_MODULE_NAMESPACE_FIELDS) TORQUE_GENERATED_JSMODULE_NAMESPACE_FIELDS)
#undef JS_MODULE_NAMESPACE_FIELDS
static const int kHeaderSize = kToStringTagFieldOffset;
OBJECT_CONSTRUCTORS(JSModuleNamespace, JSObject); OBJECT_CONSTRUCTORS(JSModuleNamespace, JSObject);
}; };
...@@ -309,6 +284,7 @@ class ModuleInfo : public FixedArray { ...@@ -309,6 +284,7 @@ class ModuleInfo : public FixedArray {
kRegularExportExportNamesOffset, kRegularExportExportNamesOffset,
kRegularExportLength kRegularExportLength
}; };
OBJECT_CONSTRUCTORS(ModuleInfo, FixedArray); OBJECT_CONSTRUCTORS(ModuleInfo, FixedArray);
}; };
......
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