Commit 683dd5fe authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[ubsan] Misc post-Object-migration cleanup

Bug: v8:3770
Change-Id: I9214212454034cf1238cab43dc34d8d9f8ed2d37
Reviewed-on: https://chromium-review.googlesource.com/c/1398222Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58627}
parent 495c24b2
...@@ -6622,17 +6622,12 @@ Local<v8::Object> v8::Object::New(Isolate* isolate, ...@@ -6622,17 +6622,12 @@ Local<v8::Object> v8::Object::New(Isolate* isolate,
// If this is the first element, allocate a proper // If this is the first element, allocate a proper
// dictionary elements backing store for {elements}. // dictionary elements backing store for {elements}.
if (!elements->IsNumberDictionary()) { if (!elements->IsNumberDictionary()) {
// TODO(3770): Drop explicit cast. elements =
elements = i::Handle<i::FixedArrayBase>( i::NumberDictionary::New(i_isolate, static_cast<int>(length));
i::NumberDictionary::New(i_isolate, static_cast<int>(length))
.location());
} }
// TODO(3770): Drop explicit cast. elements = i::NumberDictionary::Set(
elements = i::Handle<i::FixedArrayBase>( i_isolate, i::Handle<i::NumberDictionary>::cast(elements), index,
i::NumberDictionary::Set( value);
i_isolate, i::Handle<i::NumberDictionary>::cast(elements), index,
value)
.location());
} else { } else {
// Internalize the {name} first. // Internalize the {name} first.
name = i_isolate->factory()->InternalizeName(name); name = i_isolate->factory()->InternalizeName(name);
......
...@@ -353,20 +353,9 @@ typedef ZoneVector<CodeAssemblerVariable*> CodeAssemblerVariableList; ...@@ -353,20 +353,9 @@ typedef ZoneVector<CodeAssemblerVariable*> CodeAssemblerVariableList;
typedef std::function<void()> CodeAssemblerCallback; typedef std::function<void()> CodeAssemblerCallback;
// TODO(3770): The Object/HeapObject dance is temporary (while the
// incremental transition is in progress, we want to pretend that subclasses
// of HeapObject are also subclasses of Object); it can be
// removed when the migration is complete.
template <class T, class U> template <class T, class U>
struct is_subtype { struct is_subtype {
static const bool value = static const bool value = std::is_base_of<U, T>::value;
std::is_base_of<U, T>::value ||
(std::is_same<U, Object>::value && std::is_base_of<HeapObject, T>::value);
};
// TODO(3770): Temporary; remove after migration.
template <>
struct is_subtype<Smi, Object> {
static const bool value = true;
}; };
template <class T1, class T2, class U> template <class T1, class T2, class U>
struct is_subtype<UnionT<T1, T2>, U> { struct is_subtype<UnionT<T1, T2>, U> {
......
...@@ -140,15 +140,15 @@ bool Context::HasSameSecurityTokenAs(Context that) const { ...@@ -140,15 +140,15 @@ bool Context::HasSameSecurityTokenAs(Context that) const {
} }
#define NATIVE_CONTEXT_FIELD_ACCESSORS(index, type, name) \ #define NATIVE_CONTEXT_FIELD_ACCESSORS(index, type, name) \
void Context::set_##name(type##ArgType value) { \ void Context::set_##name(type value) { \
DCHECK(IsNativeContext()); \ DCHECK(IsNativeContext()); \
set(index, value); \ set(index, value); \
} \ } \
bool Context::is_##name(type##ArgType value) const { \ bool Context::is_##name(type value) const { \
DCHECK(IsNativeContext()); \ DCHECK(IsNativeContext()); \
return type::cast(get(index)) == value; \ return type::cast(get(index)) == value; \
} \ } \
type##ArgType Context::name() const { \ type Context::name() const { \
DCHECK(IsNativeContext()); \ DCHECK(IsNativeContext()); \
return type::cast(get(index)); \ return type::cast(get(index)); \
} }
......
...@@ -608,9 +608,9 @@ class Context : public HeapObject { ...@@ -608,9 +608,9 @@ class Context : public HeapObject {
static int IntrinsicIndexForName(const unsigned char* name, int length); static int IntrinsicIndexForName(const unsigned char* name, int length);
#define NATIVE_CONTEXT_FIELD_ACCESSORS(index, type, name) \ #define NATIVE_CONTEXT_FIELD_ACCESSORS(index, type, name) \
inline void set_##name(type##ArgType value); \ inline void set_##name(type value); \
inline bool is_##name(type##ArgType value) const; \ inline bool is_##name(type value) const; \
inline type##ArgType name() const; inline type name() const;
NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSORS) NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSORS)
#undef NATIVE_CONTEXT_FIELD_ACCESSORS #undef NATIVE_CONTEXT_FIELD_ACCESSORS
......
...@@ -2063,10 +2063,8 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> { ...@@ -2063,10 +2063,8 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
PropertyAttributes attributes) { PropertyAttributes attributes) {
Handle<NumberDictionary> dictionary = JSObject::NormalizeElements(object); Handle<NumberDictionary> dictionary = JSObject::NormalizeElements(object);
entry = dictionary->FindEntry(object->GetIsolate(), entry); entry = dictionary->FindEntry(object->GetIsolate(), entry);
// TODO(3770): Drop type conversion. DictionaryElementsAccessor::ReconfigureImpl(object, dictionary, entry,
DictionaryElementsAccessor::ReconfigureImpl( value, attributes);
object, Handle<FixedArrayBase>(dictionary.location()), entry, value,
attributes);
} }
static void AddImpl(Handle<JSObject> object, uint32_t index, static void AddImpl(Handle<JSObject> object, uint32_t index,
......
...@@ -117,7 +117,6 @@ class Handle final : public HandleBase { ...@@ -117,7 +117,6 @@ class Handle final : public HandleBase {
// Constructor for handling automatic up casting. // Constructor for handling automatic up casting.
// Ex. Handle<JSFunction> can be passed when Handle<Object> is expected. // Ex. Handle<JSFunction> can be passed when Handle<Object> is expected.
// TODO(3770): Remove special cases after the migration.
template <typename S, typename = typename std::enable_if< template <typename S, typename = typename std::enable_if<
std::is_convertible<S*, T*>::value>::type> std::is_convertible<S*, T*>::value>::type>
V8_INLINE Handle(Handle<S> handle) : HandleBase(handle) {} V8_INLINE Handle(Handle<S> handle) : HandleBase(handle) {}
......
...@@ -3607,9 +3607,8 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForApiFunction( ...@@ -3607,9 +3607,8 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForApiFunction(
Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForBuiltin( Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForBuiltin(
MaybeHandle<String> maybe_name, int builtin_index, FunctionKind kind) { MaybeHandle<String> maybe_name, int builtin_index, FunctionKind kind) {
// TODO(3770): Switch to MaybeHandle<Code>() after migration.
Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo( Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(
maybe_name, MaybeHandle<HeapObject>(), builtin_index, kind); maybe_name, MaybeHandle<Code>(), builtin_index, kind);
return shared; return shared;
} }
......
...@@ -843,9 +843,7 @@ class V8_EXPORT_PRIVATE Factory { ...@@ -843,9 +843,7 @@ class V8_EXPORT_PRIVATE Factory {
inline Handle<String> Uint32ToString(uint32_t value, bool check_cache = true); inline Handle<String> Uint32ToString(uint32_t value, bool check_cache = true);
// TODO(3770): Drop std::remove_pointer after the migration. #define ROOT_ACCESSOR(Type, name, CamelName) inline Handle<Type> name();
#define ROOT_ACCESSOR(Type, name, CamelName) \
inline Handle<std::remove_pointer<Type>::type> name();
ROOT_LIST(ROOT_ACCESSOR) ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR #undef ROOT_ACCESSOR
......
...@@ -118,7 +118,7 @@ Isolate::ExceptionScope::~ExceptionScope() { ...@@ -118,7 +118,7 @@ Isolate::ExceptionScope::~ExceptionScope() {
Handle<type> Isolate::name() { \ Handle<type> Isolate::name() { \
return Handle<type>(raw_native_context()->name(), this); \ return Handle<type>(raw_native_context()->name(), this); \
} \ } \
bool Isolate::is_##name(type##ArgType value) { \ bool Isolate::is_##name(type value) { \
return raw_native_context()->is_##name(value); \ return raw_native_context()->is_##name(value); \
} }
NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR) NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR)
......
...@@ -914,9 +914,7 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object, ...@@ -914,9 +914,7 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object,
} }
// TODO(yangguo): Queue this structured stack trace for preprocessing on GC. // TODO(yangguo): Queue this structured stack trace for preprocessing on GC.
// TODO(3770): Drop explicit cast. return factory()->NewJSArrayWithElements(builder.GetElements());
return factory()->NewJSArrayWithElements(
Handle<FixedArray>(builder.GetElements().location()));
} }
MaybeHandle<JSReceiver> Isolate::CaptureAndSetDetailedStackTrace( MaybeHandle<JSReceiver> Isolate::CaptureAndSetDetailedStackTrace(
......
...@@ -960,7 +960,7 @@ class Isolate final : private HiddenFactory { ...@@ -960,7 +960,7 @@ class Isolate final : private HiddenFactory {
#define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name) \ #define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name) \
inline Handle<type> name(); \ inline Handle<type> name(); \
inline bool is_##name(type##ArgType value); inline bool is_##name(type value);
NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR) NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR)
#undef NATIVE_CONTEXT_FIELD_ACCESSOR #undef NATIVE_CONTEXT_FIELD_ACCESSOR
......
...@@ -75,9 +75,7 @@ void KeyAccumulator::AddKey(Handle<Object> key, AddKeyConversion convert) { ...@@ -75,9 +75,7 @@ void KeyAccumulator::AddKey(Handle<Object> key, AddKeyConversion convert) {
} }
if (IsShadowed(key)) return; if (IsShadowed(key)) return;
if (keys_.is_null()) { if (keys_.is_null()) {
// TODO(3770): Drop explicit conversion. keys_ = OrderedHashSet::Allocate(isolate_, 16);
keys_ =
Handle<FixedArray>(OrderedHashSet::Allocate(isolate_, 16).location());
} }
uint32_t index; uint32_t index;
if (convert == CONVERT_TO_ARRAY_INDEX && key->IsString() && if (convert == CONVERT_TO_ARRAY_INDEX && key->IsString() &&
...@@ -90,8 +88,7 @@ void KeyAccumulator::AddKey(Handle<Object> key, AddKeyConversion convert) { ...@@ -90,8 +88,7 @@ void KeyAccumulator::AddKey(Handle<Object> key, AddKeyConversion convert) {
// be left-trimmer. Hence the previous Set should not keep a pointer to the // be left-trimmer. Hence the previous Set should not keep a pointer to the
// new one. // new one.
keys_->set(OrderedHashSet::NextTableIndex(), Smi::kZero); keys_->set(OrderedHashSet::NextTableIndex(), Smi::kZero);
// TODO(3770): Drop explicit conversion. keys_ = new_set;
keys_ = Handle<FixedArray>(new_set.location());
} }
} }
......
...@@ -531,33 +531,6 @@ class ZoneForwardList; ...@@ -531,33 +531,6 @@ class ZoneForwardList;
// The element types selection for CreateListFromArrayLike. // The element types selection for CreateListFromArrayLike.
enum class ElementTypes { kAll, kStringAndSymbol }; enum class ElementTypes { kAll, kStringAndSymbol };
// TODO(3770): Get rid of this indirection when the migration is complete.
typedef AbstractCode AbstractCodeArgType;
typedef ByteArray ByteArrayArgType;
typedef FixedArray FixedArrayArgType;
typedef FixedDoubleArray FixedDoubleArrayArgType;
typedef Foreign ForeignArgType;
typedef HeapObject HeapObjectArgType;
typedef JSArray JSArrayArgType;
typedef JSAsyncGeneratorObject JSAsyncGeneratorObjectArgType;
typedef JSFunction JSFunctionArgType;
typedef JSGlobalProxy JSGlobalProxyArgType;
typedef JSObject JSObjectArgType;
typedef JSPromise JSPromiseArgType;
typedef JSProxy JSProxyArgType;
typedef Map MapArgType;
typedef Object ObjectArgType;
typedef RegExpMatchInfo RegExpMatchInfoArgType;
typedef ScriptContextTable ScriptContextTableArgType;
typedef SharedFunctionInfo SharedFunctionInfoArgType;
typedef SimpleNumberDictionary SimpleNumberDictionaryArgType;
typedef Smi SmiArgType;
typedef String StringArgType;
typedef Symbol SymbolArgType;
typedef TemplateList TemplateListArgType;
typedef WasmInstanceObject WasmInstanceObjectArgType;
typedef WasmMemoryObject WasmMemoryObjectArgType;
// Object is the abstract superclass for all classes in the // Object is the abstract superclass for all classes in the
// object hierarchy. // object hierarchy.
// Object does not use any virtual functions to avoid the // Object does not use any virtual functions to avoid the
......
...@@ -20,13 +20,13 @@ OBJECT_CONSTRUCTORS_IMPL(FrameArray, FixedArray) ...@@ -20,13 +20,13 @@ OBJECT_CONSTRUCTORS_IMPL(FrameArray, FixedArray)
CAST_ACCESSOR2(FrameArray) CAST_ACCESSOR2(FrameArray)
#define DEFINE_FRAME_ARRAY_ACCESSORS(name, type) \ #define DEFINE_FRAME_ARRAY_ACCESSORS(name, type) \
type##ArgType FrameArray::name(int frame_ix) const { \ type FrameArray::name(int frame_ix) const { \
Object obj = \ Object obj = \
get(kFirstIndex + frame_ix * kElementsPerFrame + k##name##Offset); \ get(kFirstIndex + frame_ix * kElementsPerFrame + k##name##Offset); \
return type::cast(obj); \ return type::cast(obj); \
} \ } \
\ \
void FrameArray::Set##name(int frame_ix, type##ArgType value) { \ void FrameArray::Set##name(int frame_ix, type value) { \
set(kFirstIndex + frame_ix * kElementsPerFrame + k##name##Offset, value); \ set(kFirstIndex + frame_ix * kElementsPerFrame + k##name##Offset, value); \
} }
FRAME_ARRAY_FIELD_LIST(DEFINE_FRAME_ARRAY_ACCESSORS) FRAME_ARRAY_FIELD_LIST(DEFINE_FRAME_ARRAY_ACCESSORS)
......
...@@ -30,9 +30,9 @@ class Handle; ...@@ -30,9 +30,9 @@ class Handle;
// Container object for data collected during simple stack trace captures. // Container object for data collected during simple stack trace captures.
class FrameArray : public FixedArray { class FrameArray : public FixedArray {
public: public:
#define DECL_FRAME_ARRAY_ACCESSORS(name, type) \ #define DECL_FRAME_ARRAY_ACCESSORS(name, type) \
inline type##ArgType name(int frame_ix) const; \ inline type name(int frame_ix) const; \
inline void Set##name(int frame_ix, type##ArgType value); inline void Set##name(int frame_ix, type value);
FRAME_ARRAY_FIELD_LIST(DECL_FRAME_ARRAY_ACCESSORS) FRAME_ARRAY_FIELD_LIST(DECL_FRAME_ARRAY_ACCESSORS)
#undef DECL_FRAME_ARRAY_ACCESSORS #undef DECL_FRAME_ARRAY_ACCESSORS
......
...@@ -43,12 +43,6 @@ class Smi : public Object { ...@@ -43,12 +43,6 @@ class Smi : public Object {
// Convert a Smi object to an int. // Convert a Smi object to an int.
static inline int ToInt(const Object object); static inline int ToInt(const Object object);
// TODO(3770): Drop this when merging Object and Object.
bool ToInt32(int32_t* value) {
*value = this->value();
return true;
}
// Convert a value to a Smi object. // Convert a value to a Smi object.
static inline constexpr Smi FromInt(int value) { static inline constexpr Smi FromInt(int value) {
#if V8_CAN_HAVE_DCHECK_IN_CONSTEXPR #if V8_CAN_HAVE_DCHECK_IN_CONSTEXPR
......
...@@ -514,10 +514,9 @@ class ReadOnlyRoots { ...@@ -514,10 +514,9 @@ class ReadOnlyRoots {
V8_INLINE explicit ReadOnlyRoots(Heap* heap); V8_INLINE explicit ReadOnlyRoots(Heap* heap);
V8_INLINE explicit ReadOnlyRoots(Isolate* isolate); V8_INLINE explicit ReadOnlyRoots(Isolate* isolate);
// TODO(3770): Drop std::remove_pointer after the migration.
#define ROOT_ACCESSOR(Type, name, CamelName) \ #define ROOT_ACCESSOR(Type, name, CamelName) \
V8_INLINE class Type name() const; \ V8_INLINE class Type name() const; \
V8_INLINE Handle<std::remove_pointer<Type>::type> name##_handle() const; V8_INLINE Handle<Type> name##_handle() const;
READ_ONLY_ROOT_LIST(ROOT_ACCESSOR) READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR #undef ROOT_ACCESSOR
......
...@@ -18,7 +18,7 @@ namespace internal { ...@@ -18,7 +18,7 @@ namespace internal {
// expected type we crash safely. // expected type we crash safely.
#define CONVERT_ARG_CHECKED(Type, name, index) \ #define CONVERT_ARG_CHECKED(Type, name, index) \
CHECK(args[index]->Is##Type()); \ CHECK(args[index]->Is##Type()); \
Type##ArgType name = Type::cast(args[index]); Type name = Type::cast(args[index]);
#define CONVERT_ARG_HANDLE_CHECKED(Type, name, index) \ #define CONVERT_ARG_HANDLE_CHECKED(Type, name, index) \
CHECK(args[index]->Is##Type()); \ CHECK(args[index]->Is##Type()); \
......
...@@ -133,8 +133,7 @@ class Expectations { ...@@ -133,8 +133,7 @@ class Expectations {
constness = PropertyConstness::kMutable; constness = PropertyConstness::kMutable;
} }
if (representation.IsHeapObject() && !FieldType::cast(*value)->IsAny()) { if (representation.IsHeapObject() && !FieldType::cast(*value)->IsAny()) {
// TODO(3770): Drop extra Handle constructor call after migration. value = FieldType::Any(isolate_);
value = Handle<Object>(FieldType::Any(isolate_));
} }
} }
constnesses_[index] = constness; constnesses_[index] = constness;
...@@ -263,8 +262,7 @@ class Expectations { ...@@ -263,8 +262,7 @@ class Expectations {
CHECK(index < number_of_properties_); CHECK(index < number_of_properties_);
representations_[index] = Representation::Tagged(); representations_[index] = Representation::Tagged();
if (locations_[index] == kField) { if (locations_[index] == kField) {
// TODO(3770): Drop extra Handle constructor call after migration. values_[index] = FieldType::Any(isolate_);
values_[index] = Handle<Object>(FieldType::Any(isolate_));
} }
} }
......
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