Commit 3f2df833 authored by Daniel Clark's avatar Daniel Clark Committed by Commit Bot

Torquify SourceTextModuleRecord

Convert the new class SourceTextModuleRecord to use Torque
to define its fields.

Bug: v8:9292
Change-Id: Iddad3b266dd0dc122aee510cc41c69be27988c4a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1668011
Commit-Queue: Dan Clark <daniec@microsoft.com>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Auto-Submit: Dan Clark <daniec@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#62318}
parent 76c1e829
...@@ -447,9 +447,9 @@ extern class CallHandlerInfo extends Struct { ...@@ -447,9 +447,9 @@ extern class CallHandlerInfo extends Struct {
data: Object; data: Object;
} }
type ModuleInfo extends FixedArray;
type ObjectHashTable extends FixedArray; type ObjectHashTable extends FixedArray;
@abstract
extern class Module extends HeapObject { extern class Module extends HeapObject {
exports: ObjectHashTable; exports: ObjectHashTable;
hash: Smi; hash: Smi;
...@@ -458,6 +458,20 @@ extern class Module extends HeapObject { ...@@ -458,6 +458,20 @@ extern class Module extends HeapObject {
exception: Object; exception: Object;
} }
type SourceTextModuleInfo extends FixedArray;
extern class SourceTextModule extends Module {
code: SharedFunctionInfo | JSFunction |
JSGeneratorObject | SourceTextModuleInfo;
regular_exports: FixedArray;
regular_imports: FixedArray;
requested_modules: FixedArray;
script: Script;
import_meta: TheHole | JSObject;
dfs_index: Smi;
dfs_ancestor_index: Smi;
}
@abstract @abstract
extern class JSModuleNamespace extends JSObject { extern class JSModuleNamespace extends JSObject {
module: Module; module: Module;
......
...@@ -1555,32 +1555,23 @@ void SourceTextModuleInfoEntry::SourceTextModuleInfoEntryVerify( ...@@ -1555,32 +1555,23 @@ void SourceTextModuleInfoEntry::SourceTextModuleInfoEntryVerify(
local_name().IsUndefined(isolate)); local_name().IsUndefined(isolate));
} }
static void ModuleVerify(Module module, Isolate* isolate) { void Module::ModuleVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::ModuleVerify(module, isolate); TorqueGeneratedClassVerifiers::ModuleVerify(*this, isolate);
CHECK_EQ(module.status() == Module::kErrored, CHECK_EQ(status() == Module::kErrored, !exception().IsTheHole(isolate));
!module.exception().IsTheHole(isolate));
CHECK(module.module_namespace().IsUndefined(isolate) || CHECK(module_namespace().IsUndefined(isolate) ||
module.module_namespace().IsJSModuleNamespace()); module_namespace().IsJSModuleNamespace());
if (module.module_namespace().IsJSModuleNamespace()) { if (module_namespace().IsJSModuleNamespace()) {
CHECK_LE(Module::kInstantiating, module.status()); CHECK_LE(Module::kInstantiating, status());
CHECK_EQ(JSModuleNamespace::cast(module.module_namespace()).module(), CHECK_EQ(JSModuleNamespace::cast(module_namespace()).module(), *this);
module);
} }
CHECK_NE(module.hash(), 0); CHECK_NE(hash(), 0);
} }
void SourceTextModule::SourceTextModuleVerify(Isolate* isolate) { void SourceTextModule::SourceTextModuleVerify(Isolate* isolate) {
ModuleVerify(*this, isolate); TorqueGeneratedClassVerifiers::SourceTextModuleVerify(*this, isolate);
CHECK(IsSourceTextModule());
VerifyPointer(isolate, code());
VerifyPointer(isolate, requested_modules());
VerifyPointer(isolate, script());
VerifyPointer(isolate, import_meta());
CHECK((status() >= kEvaluating && code().IsSourceTextModuleInfo()) || CHECK((status() >= kEvaluating && code().IsSourceTextModuleInfo()) ||
(status() == kInstantiated && code().IsJSGeneratorObject()) || (status() == kInstantiated && code().IsJSGeneratorObject()) ||
...@@ -1588,8 +1579,6 @@ void SourceTextModule::SourceTextModuleVerify(Isolate* isolate) { ...@@ -1588,8 +1579,6 @@ void SourceTextModule::SourceTextModuleVerify(Isolate* isolate) {
(code().IsSharedFunctionInfo())); (code().IsSharedFunctionInfo()));
CHECK_EQ(requested_modules().length(), info().module_requests().length()); CHECK_EQ(requested_modules().length(), info().module_requests().length());
CHECK(import_meta().IsTheHole(isolate) || import_meta().IsJSObject());
} }
void PrototypeInfo::PrototypeInfoVerify(Isolate* isolate) { void PrototypeInfo::PrototypeInfoVerify(Isolate* isolate) {
......
...@@ -34,6 +34,7 @@ class Module : public HeapObject { ...@@ -34,6 +34,7 @@ class Module : public HeapObject {
public: public:
NEVER_READ_ONLY_SPACE NEVER_READ_ONLY_SPACE
DECL_CAST(Module) DECL_CAST(Module)
DECL_VERIFIER(Module)
DECL_PRINTER(Module) DECL_PRINTER(Module)
// The complete export table, mapping an export name to its cell. // The complete export table, mapping an export name to its cell.
...@@ -83,7 +84,8 @@ class Module : public HeapObject { ...@@ -83,7 +84,8 @@ class Module : public HeapObject {
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
TORQUE_GENERATED_MODULE_FIELDS) TORQUE_GENERATED_MODULE_FIELDS)
using BodyDescriptor = FixedBodyDescriptor<kExportsOffset, kSize, kSize>; using BodyDescriptor =
FixedBodyDescriptor<kExportsOffset, kHeaderSize, kHeaderSize>;
protected: protected:
friend class Factory; friend class Factory;
......
...@@ -27,7 +27,7 @@ class SourceTextModule : public Module { ...@@ -27,7 +27,7 @@ class SourceTextModule : public Module {
// The code representing this module, or an abstraction thereof. // The code representing this module, or an abstraction thereof.
// This is either a SharedFunctionInfo, a JSFunction, a JSGeneratorObject, or // This is either a SharedFunctionInfo, a JSFunction, a JSGeneratorObject, or
// a SourceTextModuleInfo, depending on the state (status) the module is in. // a SourceTextModuleInfo, depending on the state (status) the module is in.
// See Module::ModuleVerify() for the precise invariant. // See SourceTextModule::SourceTextModuleVerify() for the precise invariant.
DECL_ACCESSORS(code, Object) DECL_ACCESSORS(code, Object)
// Arrays of cells corresponding to regular exports and regular imports. // Arrays of cells corresponding to regular exports and regular imports.
...@@ -73,20 +73,8 @@ class SourceTextModule : public Module { ...@@ -73,20 +73,8 @@ class SourceTextModule : public Module {
Isolate* isolate, Handle<SourceTextModule> module, int module_request); Isolate* isolate, Handle<SourceTextModule> module, int module_request);
// Layout description. // Layout description.
#define SOURCE_TEXT_MODULE_FIELDS(V) \ DEFINE_FIELD_OFFSET_CONSTANTS(Module::kHeaderSize,
V(kCodeOffset, kTaggedSize) \ TORQUE_GENERATED_SOURCE_TEXT_MODULE_FIELDS)
V(kRegularExportsOffset, kTaggedSize) \
V(kRegularImportsOffset, kTaggedSize) \
V(kRequestedModulesOffset, kTaggedSize) \
V(kScriptOffset, kTaggedSize) \
V(kImportMetaOffset, kTaggedSize) \
V(kDfsIndexOffset, kTaggedSize) \
V(kDfsAncestorIndexOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Module::kSize, SOURCE_TEXT_MODULE_FIELDS)
#undef SOURCE_TEXT_MODULE_FIELDS
using BodyDescriptor = using BodyDescriptor =
SubclassBodyDescriptor<Module::BodyDescriptor, SubclassBodyDescriptor<Module::BodyDescriptor,
......
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