Commit e66c6ef7 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[ubsan] Port Struct subclasses, part 11

InterpreterData, Module, ModuleInfoEntry, PromiseCapability,
PromiseReaction, PrototypeInfo, StackFrameInfo

Bug: v8:3770
Change-Id: I5da03b082b1497ac68a218e26dbc702c7746bf5a
Reviewed-on: https://chromium-review.googlesource.com/c/1377460Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58311}
parent 0b1b88cb
......@@ -108,7 +108,7 @@ ScopeInfo Context::scope_info() {
return ScopeInfo::cast(get(SCOPE_INFO_INDEX));
}
Module* Context::module() {
Module Context::module() {
Context current = *this;
while (!current->IsModuleContext()) {
current = current->previous();
......
......@@ -561,7 +561,7 @@ class Context : public HeapObjectPtr {
// Find the module context (assuming there is one) and return the associated
// module object.
Module* module();
Module module();
// Get the context where var declarations will be hoisted to, which
// may be the context itself.
......
......@@ -167,7 +167,7 @@ class Handle final : public HandleBase {
std::is_same<S, JSGlobalProxy>::value ||
std::is_same<S, JSObject>::value ||
std::is_same<S, JSReceiver>::value || std::is_same<S, Map>::value ||
std::is_same<S, Name>::value ||
std::is_same<S, Module>::value || std::is_same<S, Name>::value ||
std::is_same<S, NumberDictionary>::value ||
std::is_same<S, ObjectBoilerplateDescription>::value ||
std::is_same<S, OrderedHashMap>::value ||
......
......@@ -4795,7 +4795,7 @@ void Heap::CompactWeakArrayLists(PretenureFlag pretenure) {
HeapIterator iterator(this);
for (HeapObject* o = iterator.next(); o != nullptr; o = iterator.next()) {
if (o->IsPrototypeInfo()) {
PrototypeInfo* prototype_info = PrototypeInfo::cast(o);
PrototypeInfo prototype_info = PrototypeInfo::cast(o);
if (prototype_info->prototype_users()->IsWeakArrayList()) {
prototype_infos.emplace_back(handle(prototype_info, isolate()));
}
......
......@@ -787,7 +787,7 @@ void ObjectStatsCollectorImpl::RecordVirtualMapDetails(Map map) {
if (map->is_prototype_map()) {
if (map->prototype_info()->IsPrototypeInfo()) {
PrototypeInfo* info = PrototypeInfo::cast(map->prototype_info());
PrototypeInfo info = PrototypeInfo::cast(map->prototype_info());
Object* users = info->prototype_users();
if (users->IsWeakFixedArray()) {
RecordSimpleVirtualObjectStats(map, WeakArrayList::cast(users),
......
......@@ -66,7 +66,7 @@ class WasmInstanceObject;
V(PreParsedScopeData, PreParsedScopeData) \
V(PropertyArray, PropertyArray) \
V(PropertyCell, PropertyCell*) \
V(PrototypeInfo, PrototypeInfo*) \
V(PrototypeInfo, PrototypeInfo) \
V(SeqOneByteString, SeqOneByteString) \
V(SeqTwoByteString, SeqTwoByteString) \
V(SharedFunctionInfo, SharedFunctionInfo) \
......
......@@ -1706,7 +1706,7 @@ void Module::ModuleVerify(Isolate* isolate) {
module_namespace()->IsJSModuleNamespace());
if (module_namespace()->IsJSModuleNamespace()) {
CHECK_LE(kInstantiating, status());
CHECK_EQ(JSModuleNamespace::cast(module_namespace())->module(), this);
CHECK_EQ(JSModuleNamespace::cast(module_namespace())->module(), *this);
}
CHECK_EQ(requested_modules()->length(), info()->module_requests()->length());
......
......@@ -1652,7 +1652,7 @@ void PromiseResolveThenableJobTask::PromiseResolveThenableJobTaskPrint(
}
void PromiseCapability::PromiseCapabilityPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "PromiseCapability");
PrintHeader(os, "PromiseCapability");
os << "\n - promise: " << Brief(promise());
os << "\n - resolve: " << Brief(resolve());
os << "\n - reject: " << Brief(reject());
......@@ -1660,7 +1660,7 @@ void PromiseCapability::PromiseCapabilityPrint(std::ostream& os) { // NOLINT
}
void PromiseReaction::PromiseReactionPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "PromiseReaction");
PrintHeader(os, "PromiseReaction");
os << "\n - next: " << Brief(next());
os << "\n - reject_handler: " << Brief(reject_handler());
os << "\n - fulfill_handler: " << Brief(fulfill_handler());
......@@ -1690,7 +1690,7 @@ void AsyncGeneratorRequest::AsyncGeneratorRequestPrint(
}
void ModuleInfoEntry::ModuleInfoEntryPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "ModuleInfoEntry");
PrintHeader(os, "ModuleInfoEntry");
os << "\n - export_name: " << Brief(export_name());
os << "\n - local_name: " << Brief(local_name());
os << "\n - import_name: " << Brief(import_name());
......@@ -1702,7 +1702,7 @@ void ModuleInfoEntry::ModuleInfoEntryPrint(std::ostream& os) { // NOLINT
}
void Module::ModulePrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "Module");
PrintHeader(os, "Module");
os << "\n - origin: " << Brief(script()->GetNameOrSourceURL());
os << "\n - code: " << Brief(code());
os << "\n - exports: " << Brief(exports());
......@@ -1721,7 +1721,7 @@ void JSModuleNamespace::JSModuleNamespacePrint(std::ostream& os) { // NOLINT
}
void PrototypeInfo::PrototypeInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "PrototypeInfo");
PrintHeader(os, "PrototypeInfo");
os << "\n - module namespace: " << Brief(module_namespace());
os << "\n - prototype users: " << Brief(prototype_users());
os << "\n - registry slot: " << registry_slot();
......@@ -2212,7 +2212,7 @@ void DebugInfo::DebugInfoPrint(std::ostream& os) { // NOLINT
void StackFrameInfo::StackFrameInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "StackFrame");
PrintHeader(os, "StackFrame");
os << "\n - line_number: " << line_number();
os << "\n - column_number: " << column_number();
os << "\n - script_id: " << script_id();
......@@ -2296,7 +2296,7 @@ void UncompiledDataWithPreParsedScope::UncompiledDataWithPreParsedScopePrint(
}
void InterpreterData::InterpreterDataPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "InterpreterData");
PrintHeader(os, "InterpreterData");
os << "\n - bytecode_array: " << Brief(bytecode_array());
os << "\n - interpreter_trampoline: " << Brief(interpreter_trampoline());
os << "\n";
......
......@@ -10481,7 +10481,7 @@ void JSObject::PrototypeRegistryCompactionCallback(HeapObject* value,
DCHECK(value->IsMap() && Map::cast(value)->is_prototype_map());
Map map = Map::cast(value);
DCHECK(map->prototype_info()->IsPrototypeInfo());
PrototypeInfo* proto_info = PrototypeInfo::cast(map->prototype_info());
PrototypeInfo proto_info = PrototypeInfo::cast(map->prototype_info());
DCHECK_EQ(old_index, proto_info->registry_slot());
proto_info->set_registry_slot(new_index);
}
......@@ -12975,7 +12975,7 @@ void InvalidatePrototypeChainsInternal(Map map) {
Object* maybe_proto_info = map->prototype_info();
if (!maybe_proto_info->IsPrototypeInfo()) return;
PrototypeInfo* proto_info = PrototypeInfo::cast(maybe_proto_info);
PrototypeInfo proto_info = PrototypeInfo::cast(maybe_proto_info);
if (!proto_info->prototype_users()->IsWeakArrayList()) {
return;
}
......
......@@ -16,9 +16,13 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(Module, StructPtr)
OBJECT_CONSTRUCTORS_IMPL(ModuleInfoEntry, StructPtr)
OBJECT_CONSTRUCTORS_IMPL(JSModuleNamespace, JSObject)
CAST_ACCESSOR(Module)
NEVER_READ_ONLY_SPACE_IMPL(Module)
CAST_ACCESSOR2(Module)
ACCESSORS(Module, code, Object, kCodeOffset)
ACCESSORS2(Module, exports, ObjectHashTable, kExportsOffset)
ACCESSORS2(Module, regular_exports, FixedArray, kRegularExportsOffset)
......@@ -40,9 +44,9 @@ ModuleInfo Module::info() const {
}
CAST_ACCESSOR2(JSModuleNamespace)
ACCESSORS(JSModuleNamespace, module, Module, kModuleOffset)
ACCESSORS2(JSModuleNamespace, module, Module, kModuleOffset)
CAST_ACCESSOR(ModuleInfoEntry)
CAST_ACCESSOR2(ModuleInfoEntry)
ACCESSORS(ModuleInfoEntry, export_name, Object, kExportNameOffset)
ACCESSORS(ModuleInfoEntry, local_name, Object, kLocalNameOffset)
ACCESSORS(ModuleInfoEntry, import_name, Object, kImportNameOffset)
......
......@@ -27,9 +27,10 @@ class String;
class Zone;
// The runtime representation of an ECMAScript module.
class Module : public Struct, public NeverReadOnlySpaceObject {
class Module : public StructPtr {
public:
DECL_CAST(Module)
NEVER_READ_ONLY_SPACE
DECL_CAST2(Module)
DECL_VERIFIER(Module)
DECL_PRINTER(Module)
......@@ -216,7 +217,7 @@ class Module : public Struct, public NeverReadOnlySpaceObject {
void PrintStatusTransition(Status new_status);
#endif // DEBUG
DISALLOW_IMPLICIT_CONSTRUCTORS(Module);
OBJECT_CONSTRUCTORS(Module, StructPtr);
};
// When importing a module namespace (import * as foo from "bar"), a
......@@ -229,7 +230,7 @@ class JSModuleNamespace : public JSObject {
DECL_VERIFIER(JSModuleNamespace)
// The actual module whose namespace is being represented.
DECL_ACCESSORS(module, Module)
DECL_ACCESSORS2(module, Module)
// Retrieve the value exported by [module] under the given [name]. If there is
// no such export, return Just(undefined). If the export is uninitialized,
......@@ -311,9 +312,9 @@ class ModuleInfo : public FixedArray {
OBJECT_CONSTRUCTORS(ModuleInfo, FixedArray);
};
class ModuleInfoEntry : public Struct {
class ModuleInfoEntry : public StructPtr {
public:
DECL_CAST(ModuleInfoEntry)
DECL_CAST2(ModuleInfoEntry)
DECL_PRINTER(ModuleInfoEntry)
DECL_VERIFIER(ModuleInfoEntry)
......@@ -347,8 +348,7 @@ class ModuleInfoEntry : public Struct {
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, MODULE_INFO_FIELDS)
#undef MODULE_INFO_FIELDS
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ModuleInfoEntry);
OBJECT_CONSTRUCTORS(ModuleInfoEntry, StructPtr);
};
} // namespace internal
......
......@@ -20,9 +20,11 @@ OBJECT_CONSTRUCTORS_IMPL(PromiseReactionJobTask, Microtask)
OBJECT_CONSTRUCTORS_IMPL(PromiseFulfillReactionJobTask, PromiseReactionJobTask)
OBJECT_CONSTRUCTORS_IMPL(PromiseRejectReactionJobTask, PromiseReactionJobTask)
OBJECT_CONSTRUCTORS_IMPL(PromiseResolveThenableJobTask, Microtask)
OBJECT_CONSTRUCTORS_IMPL(PromiseCapability, StructPtr)
OBJECT_CONSTRUCTORS_IMPL(PromiseReaction, StructPtr)
CAST_ACCESSOR(PromiseCapability)
CAST_ACCESSOR(PromiseReaction)
CAST_ACCESSOR2(PromiseCapability)
CAST_ACCESSOR2(PromiseReaction)
CAST_ACCESSOR2(PromiseReactionJobTask)
CAST_ACCESSOR2(PromiseFulfillReactionJobTask)
CAST_ACCESSOR2(PromiseRejectReactionJobTask)
......
......@@ -105,7 +105,7 @@ class PromiseResolveThenableJobTask : public Microtask {
};
// Struct to hold the state of a PromiseCapability.
class PromiseCapability : public Struct {
class PromiseCapability : public StructPtr {
public:
DECL_ACCESSORS(promise, HeapObject)
DECL_ACCESSORS(resolve, Object)
......@@ -123,12 +123,11 @@ class PromiseCapability : public Struct {
#undef PROMISE_CAPABILITY_FIELDS
// Dispatched behavior.
DECL_CAST(PromiseCapability)
DECL_CAST2(PromiseCapability)
DECL_PRINTER(PromiseCapability)
DECL_VERIFIER(PromiseCapability)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(PromiseCapability);
OBJECT_CONSTRUCTORS(PromiseCapability, StructPtr);
};
// A representation of promise reaction. This differs from the specification
......@@ -148,7 +147,7 @@ class PromiseCapability : public Struct {
// Smi 0. On the JSPromise instance they are linked in reverse order,
// and are turned into the proper order again when scheduling them on
// the microtask queue.
class PromiseReaction : public Struct {
class PromiseReaction : public StructPtr {
public:
enum Type { kFulfill, kReject };
......@@ -172,12 +171,11 @@ class PromiseReaction : public Struct {
#undef PROMISE_REACTION_FIELDS
// Dispatched behavior.
DECL_CAST(PromiseReaction)
DECL_CAST2(PromiseReaction)
DECL_PRINTER(PromiseReaction)
DECL_VERIFIER(PromiseReaction)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(PromiseReaction);
OBJECT_CONSTRUCTORS(PromiseReaction, StructPtr);
};
} // namespace internal
......
......@@ -17,7 +17,9 @@
namespace v8 {
namespace internal {
CAST_ACCESSOR(PrototypeInfo)
OBJECT_CONSTRUCTORS_IMPL(PrototypeInfo, StructPtr)
CAST_ACCESSOR2(PrototypeInfo)
Map PrototypeInfo::ObjectCreateMap() {
return Map::cast(object_create_map()->GetHeapObjectAssumeWeak());
......
......@@ -16,7 +16,7 @@ namespace v8 {
namespace internal {
// Container for metadata stored on each prototype map.
class PrototypeInfo : public Struct {
class PrototypeInfo : public StructPtr {
public:
static const int UNREGISTERED = -1;
......@@ -47,7 +47,7 @@ class PrototypeInfo : public Struct {
DECL_BOOLEAN_ACCESSORS(should_be_fast_map)
DECL_CAST(PrototypeInfo)
DECL_CAST2(PrototypeInfo)
// Dispatched behavior.
DECL_PRINTER(PrototypeInfo)
......@@ -75,7 +75,7 @@ class PrototypeInfo : public Struct {
private:
DECL_ACCESSORS2(object_create_map, MaybeObject)
DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo);
OBJECT_CONSTRUCTORS(PrototypeInfo, StructPtr);
};
// A growing array with an additional API for marking slots "empty". When adding
......
......@@ -78,7 +78,9 @@ CAST_ACCESSOR2(UncompiledDataWithPreParsedScope)
ACCESSORS2(UncompiledDataWithPreParsedScope, pre_parsed_scope_data,
PreParsedScopeData, kPreParsedScopeDataOffset)
CAST_ACCESSOR(InterpreterData)
OBJECT_CONSTRUCTORS_IMPL(InterpreterData, StructPtr)
CAST_ACCESSOR2(InterpreterData)
ACCESSORS2(InterpreterData, bytecode_array, BytecodeArray, kBytecodeArrayOffset)
ACCESSORS2(InterpreterData, interpreter_trampoline, Code,
kInterpreterTrampolineOffset)
......@@ -494,13 +496,13 @@ bool SharedFunctionInfo::HasInterpreterData() const {
return function_data()->IsInterpreterData();
}
InterpreterData* SharedFunctionInfo::interpreter_data() const {
InterpreterData SharedFunctionInfo::interpreter_data() const {
DCHECK(HasInterpreterData());
return InterpreterData::cast(function_data());
}
void SharedFunctionInfo::set_interpreter_data(
InterpreterData* interpreter_data) {
InterpreterData interpreter_data) {
DCHECK(FLAG_interpreted_frames_native_stack);
set_function_data(interpreter_data);
}
......
......@@ -173,7 +173,7 @@ class UncompiledDataWithPreParsedScope : public UncompiledData {
OBJECT_CONSTRUCTORS(UncompiledDataWithPreParsedScope, UncompiledData);
};
class InterpreterData : public Struct {
class InterpreterData : public StructPtr {
public:
DECL_ACCESSORS2(bytecode_array, BytecodeArray)
DECL_ACCESSORS2(interpreter_trampoline, Code)
......@@ -188,12 +188,11 @@ class InterpreterData : public Struct {
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, INTERPRETER_DATA_FIELDS)
#undef INTERPRETER_DATA_FIELDS
DECL_CAST(InterpreterData)
DECL_CAST2(InterpreterData)
DECL_PRINTER(InterpreterData)
DECL_VERIFIER(InterpreterData)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(InterpreterData);
OBJECT_CONSTRUCTORS(InterpreterData, StructPtr);
};
// SharedFunctionInfo describes the JSFunction information that can be
......@@ -324,8 +323,8 @@ class SharedFunctionInfo : public HeapObjectPtr {
inline void set_bytecode_array(BytecodeArray bytecode);
inline Code InterpreterTrampoline() const;
inline bool HasInterpreterData() const;
inline InterpreterData* interpreter_data() const;
inline void set_interpreter_data(InterpreterData* interpreter_data);
inline InterpreterData interpreter_data() const;
inline void set_interpreter_data(InterpreterData interpreter_data);
inline BytecodeArray GetDebugBytecodeArray() const;
inline void SetDebugBytecodeArray(BytecodeArray bytecode);
inline bool HasAsmWasmData() const;
......
......@@ -15,7 +15,11 @@
namespace v8 {
namespace internal {
CAST_ACCESSOR(StackFrameInfo)
OBJECT_CONSTRUCTORS_IMPL(StackFrameInfo, StructPtr)
NEVER_READ_ONLY_SPACE_IMPL(StackFrameInfo)
CAST_ACCESSOR2(StackFrameInfo)
SMI_ACCESSORS(StackFrameInfo, line_number, kLineNumberIndex)
SMI_ACCESSORS(StackFrameInfo, column_number, kColumnNumberIndex)
......
......@@ -13,8 +13,9 @@
namespace v8 {
namespace internal {
class StackFrameInfo : public Struct, public NeverReadOnlySpaceObject {
class StackFrameInfo : public StructPtr {
public:
NEVER_READ_ONLY_SPACE
DECL_INT_ACCESSORS(line_number)
DECL_INT_ACCESSORS(column_number)
DECL_INT_ACCESSORS(script_id)
......@@ -27,7 +28,7 @@ class StackFrameInfo : public Struct, public NeverReadOnlySpaceObject {
DECL_INT_ACCESSORS(flag)
DECL_INT_ACCESSORS(id)
DECL_CAST(StackFrameInfo)
DECL_CAST2(StackFrameInfo)
// Dispatched behavior.
DECL_PRINTER(StackFrameInfo)
......@@ -55,7 +56,7 @@ class StackFrameInfo : public Struct, public NeverReadOnlySpaceObject {
static const int kIsConstructorBit = 1;
static const int kIsWasmBit = 2;
DISALLOW_IMPLICIT_CONSTRUCTORS(StackFrameInfo);
OBJECT_CONSTRUCTORS(StackFrameInfo, StructPtr);
};
} // namespace internal
......
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