[ubsan] Port UncompiledData and PreParsedScopeData

to the new design.

Bug: v8:3770
Change-Id: I8483d47ac77e756395656628a80257e6462de22c
Reviewed-on: https://chromium-review.googlesource.com/c/1355630
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58002}
This commit is contained in:
Jakob Kummerow 2018-11-30 12:17:12 -08:00 committed by Commit Bot
parent 2de45f214c
commit 2cae6038c5
6 changed files with 83 additions and 82 deletions

View File

@ -32,50 +32,50 @@ class UncompiledDataWithoutPreParsedScope;
class UncompiledDataWithPreParsedScope;
class WasmInstanceObject;
#define TYPED_VISITOR_ID_LIST(V) \
V(AllocationSite, AllocationSite*) \
V(BigInt, BigInt) \
V(ByteArray, ByteArray) \
V(BytecodeArray, BytecodeArray) \
V(Cell, Cell*) \
V(Code, Code) \
V(CodeDataContainer, CodeDataContainer) \
V(ConsString, ConsString) \
V(Context, Context) \
V(DataHandler, DataHandler*) \
V(DescriptorArray, DescriptorArray) \
V(EmbedderDataArray, EmbedderDataArray) \
V(EphemeronHashTable, EphemeronHashTable) \
V(FeedbackCell, FeedbackCell*) \
V(FeedbackVector, FeedbackVector) \
V(FixedArray, FixedArray) \
V(FixedDoubleArray, FixedDoubleArray) \
V(FixedFloat64Array, FixedFloat64Array) \
V(FixedTypedArrayBase, FixedTypedArrayBase) \
V(JSArrayBuffer, JSArrayBuffer*) \
V(JSDataView, JSDataView*) \
V(JSObject, JSObject*) \
V(JSTypedArray, JSTypedArray*) \
V(JSWeakCollection, JSWeakCollection*) \
V(Map, Map) \
V(NativeContext, NativeContext) \
V(Oddball, Oddball*) \
V(PreParsedScopeData, PreParsedScopeData*) \
V(PropertyArray, PropertyArray) \
V(PropertyCell, PropertyCell*) \
V(PrototypeInfo, PrototypeInfo*) \
V(SeqOneByteString, SeqOneByteString) \
V(SeqTwoByteString, SeqTwoByteString) \
V(SharedFunctionInfo, SharedFunctionInfo) \
V(SlicedString, SlicedString) \
V(SmallOrderedHashMap, SmallOrderedHashMap) \
V(SmallOrderedHashSet, SmallOrderedHashSet) \
V(SmallOrderedNameDictionary, SmallOrderedNameDictionary) \
V(Symbol, Symbol) \
V(ThinString, ThinString) \
V(TransitionArray, TransitionArray) \
V(UncompiledDataWithoutPreParsedScope, UncompiledDataWithoutPreParsedScope*) \
V(UncompiledDataWithPreParsedScope, UncompiledDataWithPreParsedScope*) \
#define TYPED_VISITOR_ID_LIST(V) \
V(AllocationSite, AllocationSite*) \
V(BigInt, BigInt) \
V(ByteArray, ByteArray) \
V(BytecodeArray, BytecodeArray) \
V(Cell, Cell*) \
V(Code, Code) \
V(CodeDataContainer, CodeDataContainer) \
V(ConsString, ConsString) \
V(Context, Context) \
V(DataHandler, DataHandler*) \
V(DescriptorArray, DescriptorArray) \
V(EmbedderDataArray, EmbedderDataArray) \
V(EphemeronHashTable, EphemeronHashTable) \
V(FeedbackCell, FeedbackCell*) \
V(FeedbackVector, FeedbackVector) \
V(FixedArray, FixedArray) \
V(FixedDoubleArray, FixedDoubleArray) \
V(FixedFloat64Array, FixedFloat64Array) \
V(FixedTypedArrayBase, FixedTypedArrayBase) \
V(JSArrayBuffer, JSArrayBuffer*) \
V(JSDataView, JSDataView*) \
V(JSObject, JSObject*) \
V(JSTypedArray, JSTypedArray*) \
V(JSWeakCollection, JSWeakCollection*) \
V(Map, Map) \
V(NativeContext, NativeContext) \
V(Oddball, Oddball*) \
V(PreParsedScopeData, PreParsedScopeData) \
V(PropertyArray, PropertyArray) \
V(PropertyCell, PropertyCell*) \
V(PrototypeInfo, PrototypeInfo*) \
V(SeqOneByteString, SeqOneByteString) \
V(SeqTwoByteString, SeqTwoByteString) \
V(SharedFunctionInfo, SharedFunctionInfo) \
V(SlicedString, SlicedString) \
V(SmallOrderedHashMap, SmallOrderedHashMap) \
V(SmallOrderedHashSet, SmallOrderedHashSet) \
V(SmallOrderedNameDictionary, SmallOrderedNameDictionary) \
V(Symbol, Symbol) \
V(ThinString, ThinString) \
V(TransitionArray, TransitionArray) \
V(UncompiledDataWithoutPreParsedScope, UncompiledDataWithoutPreParsedScope) \
V(UncompiledDataWithPreParsedScope, UncompiledDataWithPreParsedScope) \
V(WasmInstanceObject, WasmInstanceObject*)
// The base class for visitors that need to dispatch on object type. The default

View File

@ -1609,7 +1609,7 @@ int HeapObject::SizeFromMap(Map map) const {
}
if (instance_type == PRE_PARSED_SCOPE_DATA_TYPE) {
return PreParsedScopeData::SizeFor(
reinterpret_cast<const PreParsedScopeData*>(this)->length());
PreParsedScopeData::unchecked_cast(this)->length());
}
if (instance_type == CODE_TYPE) {
return Code::unchecked_cast(this)->CodeSize();

View File

@ -2253,7 +2253,7 @@ void LayoutDescriptor::Print(std::ostream& os) { // NOLINT
}
void PreParsedScopeData::PreParsedScopeDataPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "PreParsedScopeData");
PrintHeader(os, "PreParsedScopeData");
os << "\n - scope_data: " << Brief(scope_data());
os << "\n - length: " << length();
for (int i = 0; i < length(); ++i) {
@ -2264,7 +2264,7 @@ void PreParsedScopeData::PreParsedScopeDataPrint(std::ostream& os) { // NOLINT
void UncompiledDataWithoutPreParsedScope::
UncompiledDataWithoutPreParsedScopePrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "UncompiledDataWithoutPreParsedScope");
PrintHeader(os, "UncompiledDataWithoutPreParsedScope");
os << "\n - start position: " << start_position();
os << "\n - end position: " << end_position();
os << "\n";
@ -2272,7 +2272,7 @@ void UncompiledDataWithoutPreParsedScope::
void UncompiledDataWithPreParsedScope::UncompiledDataWithPreParsedScopePrint(
std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "UncompiledDataWithPreParsedScope");
PrintHeader(os, "UncompiledDataWithPreParsedScope");
os << "\n - start position: " << start_position();
os << "\n - end position: " << end_position();
os << "\n - pre_parsed_scope_data: " << Brief(pre_parsed_scope_data());

View File

@ -3597,13 +3597,13 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
#undef TYPED_ARRAY_SHORT_PRINT
case PRE_PARSED_SCOPE_DATA_TYPE: {
PreParsedScopeData* data = PreParsedScopeData::cast(this);
PreParsedScopeData data = PreParsedScopeData::cast(this);
os << "<PreParsedScopeData[" << data->length() << "]>";
break;
}
case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE: {
UncompiledDataWithoutPreParsedScope* data =
UncompiledDataWithoutPreParsedScope data =
UncompiledDataWithoutPreParsedScope::cast(this);
os << "<UncompiledDataWithoutPreParsedScope (" << data->start_position()
<< ", " << data->end_position() << ")]>";
@ -3611,7 +3611,7 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
}
case UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE: {
UncompiledDataWithPreParsedScope* data =
UncompiledDataWithPreParsedScope data =
UncompiledDataWithPreParsedScope::cast(this);
os << "<UncompiledDataWithPreParsedScope (" << data->start_position()
<< ", " << data->end_position()

View File

@ -21,7 +21,9 @@
namespace v8 {
namespace internal {
CAST_ACCESSOR(PreParsedScopeData)
OBJECT_CONSTRUCTORS_IMPL(PreParsedScopeData, HeapObjectPtr)
CAST_ACCESSOR2(PreParsedScopeData)
ACCESSORS2(PreParsedScopeData, scope_data, PodArray<uint8_t>, kScopeDataOffset)
INT_ACCESSORS(PreParsedScopeData, length, kLengthOffset)
@ -42,7 +44,7 @@ void PreParsedScopeData::set_child_data(int index, Object* value,
}
ObjectSlot PreParsedScopeData::child_data_start() const {
return HeapObject::RawField(this, kChildDataStartOffset);
return RawField(kChildDataStartOffset);
}
void PreParsedScopeData::clear_padding() {
@ -53,7 +55,10 @@ void PreParsedScopeData::clear_padding() {
}
}
CAST_ACCESSOR(UncompiledData)
OBJECT_CONSTRUCTORS_IMPL(UncompiledData, HeapObjectPtr)
OBJECT_CONSTRUCTORS_IMPL(UncompiledDataWithoutPreParsedScope, UncompiledData)
OBJECT_CONSTRUCTORS_IMPL(UncompiledDataWithPreParsedScope, UncompiledData)
CAST_ACCESSOR2(UncompiledData)
ACCESSORS2(UncompiledData, inferred_name, String, kInferredNameOffset)
INT32_ACCESSORS(UncompiledData, start_position, kStartPositionOffset)
INT32_ACCESSORS(UncompiledData, end_position, kEndPositionOffset)
@ -67,11 +72,11 @@ void UncompiledData::clear_padding() {
}
}
CAST_ACCESSOR(UncompiledDataWithoutPreParsedScope)
CAST_ACCESSOR2(UncompiledDataWithoutPreParsedScope)
CAST_ACCESSOR(UncompiledDataWithPreParsedScope)
ACCESSORS(UncompiledDataWithPreParsedScope, pre_parsed_scope_data,
PreParsedScopeData, kPreParsedScopeDataOffset)
CAST_ACCESSOR2(UncompiledDataWithPreParsedScope)
ACCESSORS2(UncompiledDataWithPreParsedScope, pre_parsed_scope_data,
PreParsedScopeData, kPreParsedScopeDataOffset)
CAST_ACCESSOR(InterpreterData)
ACCESSORS2(InterpreterData, bytecode_array, BytecodeArray, kBytecodeArrayOffset)
@ -503,12 +508,12 @@ bool SharedFunctionInfo::HasUncompiledData() const {
return function_data()->IsUncompiledData();
}
UncompiledData* SharedFunctionInfo::uncompiled_data() const {
UncompiledData SharedFunctionInfo::uncompiled_data() const {
DCHECK(HasUncompiledData());
return UncompiledData::cast(function_data());
}
void SharedFunctionInfo::set_uncompiled_data(UncompiledData* uncompiled_data) {
void SharedFunctionInfo::set_uncompiled_data(UncompiledData uncompiled_data) {
DCHECK(function_data() == Smi::FromEnum(Builtins::kCompileLazy));
DCHECK(uncompiled_data->IsUncompiledData());
set_function_data(uncompiled_data);
@ -518,14 +523,14 @@ bool SharedFunctionInfo::HasUncompiledDataWithPreParsedScope() const {
return function_data()->IsUncompiledDataWithPreParsedScope();
}
UncompiledDataWithPreParsedScope*
UncompiledDataWithPreParsedScope
SharedFunctionInfo::uncompiled_data_with_pre_parsed_scope() const {
DCHECK(HasUncompiledDataWithPreParsedScope());
return UncompiledDataWithPreParsedScope::cast(function_data());
}
void SharedFunctionInfo::set_uncompiled_data_with_pre_parsed_scope(
UncompiledDataWithPreParsedScope* uncompiled_data_with_pre_parsed_scope) {
UncompiledDataWithPreParsedScope uncompiled_data_with_pre_parsed_scope) {
DCHECK(function_data() == Smi::FromEnum(Builtins::kCompileLazy));
DCHECK(uncompiled_data_with_pre_parsed_scope
->IsUncompiledDataWithPreParsedScope());
@ -538,7 +543,7 @@ bool SharedFunctionInfo::HasUncompiledDataWithoutPreParsedScope() const {
void SharedFunctionInfo::ClearPreParsedScopeData() {
DCHECK(HasUncompiledDataWithPreParsedScope());
UncompiledDataWithPreParsedScope* data =
UncompiledDataWithPreParsedScope data =
uncompiled_data_with_pre_parsed_scope();
// Trim off the pre-parsed scope data from the uncompiled data by swapping the

View File

@ -26,7 +26,7 @@ class WasmExportedFunctionData;
// Data collected by the pre-parser storing information about scopes and inner
// functions.
class PreParsedScopeData : public HeapObject {
class PreParsedScopeData : public HeapObjectPtr {
public:
DECL_ACCESSORS2(scope_data, PodArray<uint8_t>)
DECL_INT_ACCESSORS(length)
@ -40,7 +40,7 @@ class PreParsedScopeData : public HeapObject {
// Clear uninitialized padding space.
inline void clear_padding();
DECL_CAST(PreParsedScopeData)
DECL_CAST2(PreParsedScopeData)
DECL_PRINTER(PreParsedScopeData)
DECL_VERIFIER(PreParsedScopeData)
@ -62,20 +62,19 @@ class PreParsedScopeData : public HeapObject {
return kChildDataStartOffset + length * kTaggedSize;
}
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(PreParsedScopeData);
OBJECT_CONSTRUCTORS(PreParsedScopeData, HeapObjectPtr);
};
// Abstract class representing extra data for an uncompiled function, which is
// not stored in the SharedFunctionInfo.
class UncompiledData : public HeapObject {
class UncompiledData : public HeapObjectPtr {
public:
DECL_ACCESSORS2(inferred_name, String)
DECL_INT32_ACCESSORS(start_position)
DECL_INT32_ACCESSORS(end_position)
DECL_INT32_ACCESSORS(function_literal_id)
DECL_CAST(UncompiledData)
DECL_CAST2(UncompiledData)
// Layout description.
#define UNCOMPILED_DATA_FIELDS(V) \
@ -100,8 +99,7 @@ class UncompiledData : public HeapObject {
// Clear uninitialized padding space.
inline void clear_padding();
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(UncompiledData);
OBJECT_CONSTRUCTORS(UncompiledData, HeapObjectPtr);
};
// Class representing data for an uncompiled function that does not have any
@ -109,7 +107,7 @@ class UncompiledData : public HeapObject {
// pre-parser bailed out.
class UncompiledDataWithoutPreParsedScope : public UncompiledData {
public:
DECL_CAST(UncompiledDataWithoutPreParsedScope)
DECL_CAST2(UncompiledDataWithoutPreParsedScope)
DECL_PRINTER(UncompiledDataWithoutPreParsedScope)
DECL_VERIFIER(UncompiledDataWithoutPreParsedScope)
@ -118,17 +116,16 @@ class UncompiledDataWithoutPreParsedScope : public UncompiledData {
// No extra fields compared to UncompiledData.
typedef UncompiledData::BodyDescriptor BodyDescriptor;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(UncompiledDataWithoutPreParsedScope);
OBJECT_CONSTRUCTORS(UncompiledDataWithoutPreParsedScope, UncompiledData);
};
// Class representing data for an uncompiled function that has pre-parsed scope
// data.
class UncompiledDataWithPreParsedScope : public UncompiledData {
public:
DECL_ACCESSORS(pre_parsed_scope_data, PreParsedScopeData)
DECL_ACCESSORS2(pre_parsed_scope_data, PreParsedScopeData)
DECL_CAST(UncompiledDataWithPreParsedScope)
DECL_CAST2(UncompiledDataWithPreParsedScope)
DECL_PRINTER(UncompiledDataWithPreParsedScope)
DECL_VERIFIER(UncompiledDataWithPreParsedScope)
@ -153,8 +150,7 @@ class UncompiledDataWithPreParsedScope : public UncompiledData {
kSize>>
BodyDescriptor;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(UncompiledDataWithPreParsedScope);
OBJECT_CONSTRUCTORS(UncompiledDataWithPreParsedScope, UncompiledData);
};
class InterpreterData : public Struct {
@ -325,13 +321,13 @@ class SharedFunctionInfo : public HeapObjectPtr {
inline int builtin_id() const;
inline void set_builtin_id(int builtin_id);
inline bool HasUncompiledData() const;
inline UncompiledData* uncompiled_data() const;
inline void set_uncompiled_data(UncompiledData* data);
inline UncompiledData uncompiled_data() const;
inline void set_uncompiled_data(UncompiledData data);
inline bool HasUncompiledDataWithPreParsedScope() const;
inline UncompiledDataWithPreParsedScope*
inline UncompiledDataWithPreParsedScope
uncompiled_data_with_pre_parsed_scope() const;
inline void set_uncompiled_data_with_pre_parsed_scope(
UncompiledDataWithPreParsedScope* data);
UncompiledDataWithPreParsedScope data);
inline bool HasUncompiledDataWithoutPreParsedScope() const;
inline bool HasWasmExportedFunctionData() const;
WasmExportedFunctionData* wasm_exported_function_data() const;