Commit 7f21bbc1 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[ubsan] Port Foreign and Managed to the new design

Bug: v8:3770
Change-Id: Ie80ce957ff1d2bcd3596491066f6562ce0ad129a
Reviewed-on: https://chromium-review.googlesource.com/c/1380114
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58294}
parent 766ef168
...@@ -8900,7 +8900,7 @@ void Isolate::RemoveMessageListeners(MessageCallback that) { ...@@ -8900,7 +8900,7 @@ void Isolate::RemoveMessageListeners(MessageCallback that) {
for (int i = 0; i < listeners->length(); i++) { for (int i = 0; i < listeners->length(); i++) {
if (listeners->get(i)->IsUndefined(isolate)) continue; // skip deleted ones if (listeners->get(i)->IsUndefined(isolate)) continue; // skip deleted ones
i::FixedArray listener = i::FixedArray::cast(listeners->get(i)); i::FixedArray listener = i::FixedArray::cast(listeners->get(i));
i::Foreign* callback_obj = i::Foreign::cast(listener->get(0)); i::Foreign callback_obj = i::Foreign::cast(listener->get(0));
if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) { if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) {
listeners->set(i, i::ReadOnlyRoots(isolate).undefined_value()); listeners->set(i, i::ReadOnlyRoots(isolate).undefined_value());
} }
......
...@@ -1128,7 +1128,7 @@ class RecordMigratedSlotVisitor : public ObjectVisitor { ...@@ -1128,7 +1128,7 @@ class RecordMigratedSlotVisitor : public ObjectVisitor {
// Entries that are skipped for recording. // Entries that are skipped for recording.
inline void VisitExternalReference(Code host, RelocInfo* rinfo) final {} inline void VisitExternalReference(Code host, RelocInfo* rinfo) final {}
inline void VisitExternalReference(Foreign* host, Address* p) final {} inline void VisitExternalReference(Foreign host, Address* p) final {}
inline void VisitRuntimeEntry(Code host, RelocInfo* rinfo) final {} inline void VisitRuntimeEntry(Code host, RelocInfo* rinfo) final {}
inline void VisitInternalReference(Code host, RelocInfo* rinfo) final {} inline void VisitInternalReference(Code host, RelocInfo* rinfo) final {}
......
...@@ -150,7 +150,7 @@ void MessageHandler::ReportMessageNoExceptions( ...@@ -150,7 +150,7 @@ void MessageHandler::ReportMessageNoExceptions(
HandleScope scope(isolate); HandleScope scope(isolate);
if (global_listeners->get(i)->IsUndefined(isolate)) continue; if (global_listeners->get(i)->IsUndefined(isolate)) continue;
FixedArray listener = FixedArray::cast(global_listeners->get(i)); FixedArray listener = FixedArray::cast(global_listeners->get(i));
Foreign* callback_obj = Foreign::cast(listener->get(0)); Foreign callback_obj = Foreign::cast(listener->get(0));
int32_t message_levels = int32_t message_levels =
static_cast<int32_t>(Smi::ToInt(listener->get(2))); static_cast<int32_t>(Smi::ToInt(listener->get(2)));
if (!(message_levels & error_level)) { if (!(message_levels & error_level)) {
......
...@@ -536,7 +536,7 @@ typedef AbstractCode AbstractCodeArgType; ...@@ -536,7 +536,7 @@ typedef AbstractCode AbstractCodeArgType;
typedef ByteArray ByteArrayArgType; typedef ByteArray ByteArrayArgType;
typedef FixedArray FixedArrayArgType; typedef FixedArray FixedArrayArgType;
typedef FixedDoubleArray FixedDoubleArrayArgType; typedef FixedDoubleArray FixedDoubleArrayArgType;
typedef Foreign* ForeignArgType; typedef Foreign ForeignArgType;
typedef HeapObject* HeapObjectArgType; typedef HeapObject* HeapObjectArgType;
typedef JSArray JSArrayArgType; typedef JSArray JSArrayArgType;
typedef JSAsyncGeneratorObject JSAsyncGeneratorObjectArgType; typedef JSAsyncGeneratorObject JSAsyncGeneratorObjectArgType;
......
...@@ -15,7 +15,9 @@ ...@@ -15,7 +15,9 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
CAST_ACCESSOR(Foreign) OBJECT_CONSTRUCTORS_IMPL(Foreign, HeapObjectPtr)
CAST_ACCESSOR2(Foreign)
// static // static
bool Foreign::IsNormalized(Object* value) { bool Foreign::IsNormalized(Object* value) {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#ifndef V8_OBJECTS_FOREIGN_H_ #ifndef V8_OBJECTS_FOREIGN_H_
#define V8_OBJECTS_FOREIGN_H_ #define V8_OBJECTS_FOREIGN_H_
#include "src/objects.h" #include "src/objects/heap-object.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"
...@@ -14,14 +14,14 @@ namespace v8 { ...@@ -14,14 +14,14 @@ namespace v8 {
namespace internal { namespace internal {
// Foreign describes objects pointing from JavaScript to C structures. // Foreign describes objects pointing from JavaScript to C structures.
class Foreign : public HeapObject { class Foreign : public HeapObjectPtr {
public: public:
// [address]: field containing the address. // [address]: field containing the address.
inline Address foreign_address(); inline Address foreign_address();
static inline bool IsNormalized(Object* object); static inline bool IsNormalized(Object* object);
DECL_CAST(Foreign) DECL_CAST2(Foreign)
// Dispatched behavior. // Dispatched behavior.
DECL_PRINTER(Foreign) DECL_PRINTER(Foreign)
...@@ -43,7 +43,7 @@ class Foreign : public HeapObject { ...@@ -43,7 +43,7 @@ class Foreign : public HeapObject {
inline void set_foreign_address(Address value); inline void set_foreign_address(Address value);
DISALLOW_IMPLICIT_CONSTRUCTORS(Foreign); OBJECT_CONSTRUCTORS(Foreign, HeapObjectPtr);
}; };
} // namespace internal } // namespace internal
......
...@@ -1642,7 +1642,7 @@ Intl::ResolvedLocale Intl::ResolveLocale( ...@@ -1642,7 +1642,7 @@ Intl::ResolvedLocale Intl::ResolveLocale(
return Intl::ResolvedLocale{canonicalized_locale, icu_locale, extensions}; return Intl::ResolvedLocale{canonicalized_locale, icu_locale, extensions};
} }
Managed<icu::UnicodeString>* Intl::SetTextToBreakIterator( Managed<icu::UnicodeString> Intl::SetTextToBreakIterator(
Isolate* isolate, Handle<String> text, icu::BreakIterator* break_iterator) { Isolate* isolate, Handle<String> text, icu::BreakIterator* break_iterator) {
icu::UnicodeString* u_text = icu::UnicodeString* u_text =
(icu::UnicodeString*)(Intl::ToICUUnicodeString(isolate, text).clone()); (icu::UnicodeString*)(Intl::ToICUUnicodeString(isolate, text).clone());
......
...@@ -248,7 +248,7 @@ class Intl { ...@@ -248,7 +248,7 @@ class Intl {
const std::set<std::string>& relevant_extension_keys); const std::set<std::string>& relevant_extension_keys);
// Utility function to set text to BreakIterator. // Utility function to set text to BreakIterator.
static Managed<icu::UnicodeString>* SetTextToBreakIterator( static Managed<icu::UnicodeString> SetTextToBreakIterator(
Isolate* isolate, Handle<String> text, Isolate* isolate, Handle<String> text,
icu::BreakIterator* break_iterator); icu::BreakIterator* break_iterator);
......
...@@ -31,10 +31,10 @@ inline JSV8BreakIterator::Type JSV8BreakIterator::type() const { ...@@ -31,10 +31,10 @@ inline JSV8BreakIterator::Type JSV8BreakIterator::type() const {
} }
ACCESSORS2(JSV8BreakIterator, locale, String, kLocaleOffset) ACCESSORS2(JSV8BreakIterator, locale, String, kLocaleOffset)
ACCESSORS(JSV8BreakIterator, break_iterator, Managed<icu::BreakIterator>, ACCESSORS2(JSV8BreakIterator, break_iterator, Managed<icu::BreakIterator>,
kBreakIteratorOffset) kBreakIteratorOffset)
ACCESSORS(JSV8BreakIterator, unicode_string, Managed<icu::UnicodeString>, ACCESSORS2(JSV8BreakIterator, unicode_string, Managed<icu::UnicodeString>,
kUnicodeStringOffset) kUnicodeStringOffset)
ACCESSORS(JSV8BreakIterator, bound_adopt_text, Object, kBoundAdoptTextOffset) ACCESSORS(JSV8BreakIterator, bound_adopt_text, Object, kBoundAdoptTextOffset)
ACCESSORS(JSV8BreakIterator, bound_first, Object, kBoundFirstOffset) ACCESSORS(JSV8BreakIterator, bound_first, Object, kBoundFirstOffset)
ACCESSORS(JSV8BreakIterator, bound_next, Object, kBoundNextOffset) ACCESSORS(JSV8BreakIterator, bound_next, Object, kBoundNextOffset)
......
...@@ -126,7 +126,7 @@ void JSV8BreakIterator::AdoptText( ...@@ -126,7 +126,7 @@ void JSV8BreakIterator::AdoptText(
icu::BreakIterator* break_iterator = icu::BreakIterator* break_iterator =
break_iterator_holder->break_iterator()->raw(); break_iterator_holder->break_iterator()->raw();
CHECK_NOT_NULL(break_iterator); CHECK_NOT_NULL(break_iterator);
Managed<icu::UnicodeString>* unicode_string = Managed<icu::UnicodeString> unicode_string =
Intl::SetTextToBreakIterator(isolate, text, break_iterator); Intl::SetTextToBreakIterator(isolate, text, break_iterator);
break_iterator_holder->set_unicode_string(unicode_string); break_iterator_holder->set_unicode_string(unicode_string);
} }
......
...@@ -61,8 +61,8 @@ class JSV8BreakIterator : public JSObject { ...@@ -61,8 +61,8 @@ class JSV8BreakIterator : public JSObject {
DECL_VERIFIER(JSV8BreakIterator) DECL_VERIFIER(JSV8BreakIterator)
DECL_ACCESSORS2(locale, String) DECL_ACCESSORS2(locale, String)
DECL_ACCESSORS(break_iterator, Managed<icu::BreakIterator>) DECL_ACCESSORS2(break_iterator, Managed<icu::BreakIterator>)
DECL_ACCESSORS(unicode_string, Managed<icu::UnicodeString>) DECL_ACCESSORS2(unicode_string, Managed<icu::UnicodeString>)
DECL_ACCESSORS(bound_adopt_text, Object) DECL_ACCESSORS(bound_adopt_text, Object)
DECL_ACCESSORS(bound_first, Object) DECL_ACCESSORS(bound_first, Object)
DECL_ACCESSORS(bound_next, Object) DECL_ACCESSORS(bound_next, Object)
......
...@@ -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) ACCESSORS2(JSCollator, icu_collator, Managed<icu::Collator>, kICUCollatorOffset)
ACCESSORS(JSCollator, bound_compare, Object, kBoundCompareOffset); ACCESSORS(JSCollator, bound_compare, Object, kBoundCompareOffset);
ACCESSORS2(JSCollator, locale, String, kLocaleOffset) ACCESSORS2(JSCollator, locale, String, kLocaleOffset)
......
...@@ -57,7 +57,7 @@ class JSCollator : public JSObject { ...@@ -57,7 +57,7 @@ class JSCollator : public JSObject {
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_COLLATOR_FIELDS) DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_COLLATOR_FIELDS)
#undef JS_COLLATOR_FIELDS #undef JS_COLLATOR_FIELDS
DECL_ACCESSORS(icu_collator, Managed<icu::Collator>) DECL_ACCESSORS2(icu_collator, Managed<icu::Collator>)
DECL_ACCESSORS(bound_compare, Object); DECL_ACCESSORS(bound_compare, Object);
DECL_ACCESSORS2(locale, String) DECL_ACCESSORS2(locale, String)
......
...@@ -20,9 +20,10 @@ namespace internal { ...@@ -20,9 +20,10 @@ namespace internal {
OBJECT_CONSTRUCTORS_IMPL(JSDateTimeFormat, JSObject) OBJECT_CONSTRUCTORS_IMPL(JSDateTimeFormat, JSObject)
ACCESSORS(JSDateTimeFormat, icu_locale, Managed<icu::Locale>, kICULocaleOffset); ACCESSORS2(JSDateTimeFormat, icu_locale, Managed<icu::Locale>,
ACCESSORS(JSDateTimeFormat, icu_simple_date_format, kICULocaleOffset);
Managed<icu::SimpleDateFormat>, kICUSimpleDateFormatOffset) ACCESSORS2(JSDateTimeFormat, icu_simple_date_format,
Managed<icu::SimpleDateFormat>, kICUSimpleDateFormatOffset)
ACCESSORS(JSDateTimeFormat, bound_format, Object, kBoundFormatOffset); ACCESSORS(JSDateTimeFormat, bound_format, Object, kBoundFormatOffset);
SMI_ACCESSORS(JSDateTimeFormat, flags, kFlagsOffset) SMI_ACCESSORS(JSDateTimeFormat, flags, kFlagsOffset)
......
...@@ -282,7 +282,7 @@ MaybeHandle<JSObject> JSDateTimeFormat::ResolvedOptions( ...@@ -282,7 +282,7 @@ MaybeHandle<JSObject> JSDateTimeFormat::ResolvedOptions(
Handle<Object> resolved_obj; Handle<Object> resolved_obj;
CHECK_NOT_NULL(date_time_format->icu_locale()); CHECK(!date_time_format->icu_locale().is_null());
CHECK_NOT_NULL(date_time_format->icu_locale()->raw()); CHECK_NOT_NULL(date_time_format->icu_locale()->raw());
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
char language[ULOC_FULLNAME_CAPACITY]; char language[ULOC_FULLNAME_CAPACITY];
......
...@@ -104,8 +104,8 @@ class JSDateTimeFormat : public JSObject { ...@@ -104,8 +104,8 @@ class JSDateTimeFormat : public JSObject {
STATIC_ASSERT(Intl::HourCycle::kH23 <= HourCycleBits::kMax); STATIC_ASSERT(Intl::HourCycle::kH23 <= HourCycleBits::kMax);
STATIC_ASSERT(Intl::HourCycle::kH24 <= HourCycleBits::kMax); STATIC_ASSERT(Intl::HourCycle::kH24 <= HourCycleBits::kMax);
DECL_ACCESSORS(icu_locale, Managed<icu::Locale>) DECL_ACCESSORS2(icu_locale, Managed<icu::Locale>)
DECL_ACCESSORS(icu_simple_date_format, Managed<icu::SimpleDateFormat>) DECL_ACCESSORS2(icu_simple_date_format, Managed<icu::SimpleDateFormat>)
DECL_ACCESSORS(bound_format, Object) DECL_ACCESSORS(bound_format, Object)
DECL_INT_ACCESSORS(flags) DECL_INT_ACCESSORS(flags)
......
...@@ -22,8 +22,8 @@ OBJECT_CONSTRUCTORS_IMPL(JSListFormat, JSObject) ...@@ -22,8 +22,8 @@ OBJECT_CONSTRUCTORS_IMPL(JSListFormat, JSObject)
// Base list format accessors. // Base list format accessors.
ACCESSORS2(JSListFormat, locale, String, kLocaleOffset) ACCESSORS2(JSListFormat, locale, String, kLocaleOffset)
ACCESSORS(JSListFormat, icu_formatter, Managed<icu::ListFormatter>, ACCESSORS2(JSListFormat, icu_formatter, Managed<icu::ListFormatter>,
kICUFormatterOffset) kICUFormatterOffset)
SMI_ACCESSORS(JSListFormat, flags, kFlagsOffset) SMI_ACCESSORS(JSListFormat, flags, kFlagsOffset)
inline void JSListFormat::set_style(Style style) { inline void JSListFormat::set_style(Style style) {
......
...@@ -58,7 +58,7 @@ class JSListFormat : public JSObject { ...@@ -58,7 +58,7 @@ class JSListFormat : public JSObject {
// ListFormat accessors. // ListFormat accessors.
DECL_ACCESSORS2(locale, String) DECL_ACCESSORS2(locale, String)
DECL_ACCESSORS(icu_formatter, Managed<icu::ListFormatter>) DECL_ACCESSORS2(icu_formatter, Managed<icu::ListFormatter>)
// Style: identifying the relative time format style used. // Style: identifying the relative time format style used.
// //
......
...@@ -21,8 +21,8 @@ namespace internal { ...@@ -21,8 +21,8 @@ namespace internal {
OBJECT_CONSTRUCTORS_IMPL(JSNumberFormat, JSObject) OBJECT_CONSTRUCTORS_IMPL(JSNumberFormat, JSObject)
ACCESSORS2(JSNumberFormat, locale, String, kLocaleOffset) ACCESSORS2(JSNumberFormat, locale, String, kLocaleOffset)
ACCESSORS(JSNumberFormat, icu_number_format, Managed<icu::NumberFormat>, ACCESSORS2(JSNumberFormat, icu_number_format, Managed<icu::NumberFormat>,
kICUNumberFormatOffset) kICUNumberFormatOffset)
ACCESSORS(JSNumberFormat, bound_format, Object, kBoundFormatOffset) ACCESSORS(JSNumberFormat, bound_format, Object, kBoundFormatOffset)
SMI_ACCESSORS(JSNumberFormat, flags, kFlagsOffset) SMI_ACCESSORS(JSNumberFormat, flags, kFlagsOffset)
......
...@@ -123,7 +123,7 @@ class JSNumberFormat : public JSObject { ...@@ -123,7 +123,7 @@ class JSNumberFormat : public JSObject {
STATIC_ASSERT(CurrencyDisplay::NAME <= CurrencyDisplayBits::kMax); STATIC_ASSERT(CurrencyDisplay::NAME <= CurrencyDisplayBits::kMax);
DECL_ACCESSORS2(locale, String) DECL_ACCESSORS2(locale, String)
DECL_ACCESSORS(icu_number_format, Managed<icu::NumberFormat>) DECL_ACCESSORS2(icu_number_format, Managed<icu::NumberFormat>)
DECL_ACCESSORS(bound_format, Object) DECL_ACCESSORS(bound_format, Object)
DECL_INT_ACCESSORS(flags) DECL_INT_ACCESSORS(flags)
......
...@@ -23,10 +23,10 @@ OBJECT_CONSTRUCTORS_IMPL(JSPluralRules, JSObject) ...@@ -23,10 +23,10 @@ OBJECT_CONSTRUCTORS_IMPL(JSPluralRules, JSObject)
ACCESSORS2(JSPluralRules, locale, String, kLocaleOffset) ACCESSORS2(JSPluralRules, locale, String, kLocaleOffset)
SMI_ACCESSORS(JSPluralRules, flags, kFlagsOffset) SMI_ACCESSORS(JSPluralRules, flags, kFlagsOffset)
ACCESSORS(JSPluralRules, icu_plural_rules, Managed<icu::PluralRules>, ACCESSORS2(JSPluralRules, icu_plural_rules, Managed<icu::PluralRules>,
kICUPluralRulesOffset) kICUPluralRulesOffset)
ACCESSORS(JSPluralRules, icu_decimal_format, Managed<icu::DecimalFormat>, ACCESSORS2(JSPluralRules, icu_decimal_format, Managed<icu::DecimalFormat>,
kICUDecimalFormatOffset) kICUDecimalFormatOffset)
inline void JSPluralRules::set_type(Type type) { inline void JSPluralRules::set_type(Type type) {
DCHECK_LT(type, Type::COUNT); DCHECK_LT(type, Type::COUNT);
......
...@@ -82,8 +82,8 @@ class JSPluralRules : public JSObject { ...@@ -82,8 +82,8 @@ class JSPluralRules : public JSObject {
DECL_ACCESSORS2(locale, String) DECL_ACCESSORS2(locale, String)
DECL_INT_ACCESSORS(flags) DECL_INT_ACCESSORS(flags)
DECL_ACCESSORS(icu_plural_rules, Managed<icu::PluralRules>) DECL_ACCESSORS2(icu_plural_rules, Managed<icu::PluralRules>)
DECL_ACCESSORS(icu_decimal_format, Managed<icu::DecimalFormat>) DECL_ACCESSORS2(icu_decimal_format, Managed<icu::DecimalFormat>)
OBJECT_CONSTRUCTORS(JSPluralRules, JSObject); OBJECT_CONSTRUCTORS(JSPluralRules, JSObject);
}; };
......
...@@ -22,8 +22,8 @@ OBJECT_CONSTRUCTORS_IMPL(JSRelativeTimeFormat, JSObject) ...@@ -22,8 +22,8 @@ OBJECT_CONSTRUCTORS_IMPL(JSRelativeTimeFormat, JSObject)
// Base relative time format accessors. // Base relative time format accessors.
ACCESSORS2(JSRelativeTimeFormat, locale, String, kLocaleOffset) ACCESSORS2(JSRelativeTimeFormat, locale, String, kLocaleOffset)
ACCESSORS(JSRelativeTimeFormat, icu_formatter, ACCESSORS2(JSRelativeTimeFormat, icu_formatter,
Managed<icu::RelativeDateTimeFormatter>, kICUFormatterOffset) Managed<icu::RelativeDateTimeFormatter>, kICUFormatterOffset)
SMI_ACCESSORS(JSRelativeTimeFormat, flags, kFlagsOffset) SMI_ACCESSORS(JSRelativeTimeFormat, flags, kFlagsOffset)
inline void JSRelativeTimeFormat::set_style(Style style) { inline void JSRelativeTimeFormat::set_style(Style style) {
......
...@@ -57,7 +57,7 @@ class JSRelativeTimeFormat : public JSObject { ...@@ -57,7 +57,7 @@ class JSRelativeTimeFormat : public JSObject {
// RelativeTimeFormat accessors. // RelativeTimeFormat accessors.
DECL_ACCESSORS2(locale, String) DECL_ACCESSORS2(locale, String)
DECL_ACCESSORS(icu_formatter, Managed<icu::RelativeDateTimeFormatter>) DECL_ACCESSORS2(icu_formatter, Managed<icu::RelativeDateTimeFormatter>)
// Style: identifying the relative time format style used. // Style: identifying the relative time format style used.
// //
......
...@@ -21,10 +21,10 @@ namespace internal { ...@@ -21,10 +21,10 @@ namespace internal {
OBJECT_CONSTRUCTORS_IMPL(JSSegmentIterator, JSObject) OBJECT_CONSTRUCTORS_IMPL(JSSegmentIterator, JSObject)
// Base segment iterator accessors. // Base segment iterator accessors.
ACCESSORS(JSSegmentIterator, icu_break_iterator, Managed<icu::BreakIterator>, ACCESSORS2(JSSegmentIterator, icu_break_iterator, Managed<icu::BreakIterator>,
kICUBreakIteratorOffset) kICUBreakIteratorOffset)
ACCESSORS(JSSegmentIterator, unicode_string, Managed<icu::UnicodeString>, ACCESSORS2(JSSegmentIterator, unicode_string, Managed<icu::UnicodeString>,
kUnicodeStringOffset) kUnicodeStringOffset)
SMI_ACCESSORS(JSSegmentIterator, flags, kFlagsOffset) SMI_ACCESSORS(JSSegmentIterator, flags, kFlagsOffset)
......
...@@ -64,7 +64,7 @@ MaybeHandle<JSSegmentIterator> JSSegmentIterator::Create( ...@@ -64,7 +64,7 @@ MaybeHandle<JSSegmentIterator> JSSegmentIterator::Create(
segment_iterator->set_icu_break_iterator(*managed_break_iterator); segment_iterator->set_icu_break_iterator(*managed_break_iterator);
// 3. Let iterator.[[SegmentIteratorString]] be string. // 3. Let iterator.[[SegmentIteratorString]] be string.
Managed<icu::UnicodeString>* unicode_string = Managed<icu::UnicodeString> unicode_string =
Intl::SetTextToBreakIterator(isolate, text, break_iterator); Intl::SetTextToBreakIterator(isolate, text, break_iterator);
segment_iterator->set_unicode_string(unicode_string); segment_iterator->set_unicode_string(unicode_string);
......
...@@ -64,8 +64,8 @@ class JSSegmentIterator : public JSObject { ...@@ -64,8 +64,8 @@ class JSSegmentIterator : public JSObject {
DECL_CAST2(JSSegmentIterator) DECL_CAST2(JSSegmentIterator)
// SegmentIterator accessors. // SegmentIterator accessors.
DECL_ACCESSORS(icu_break_iterator, Managed<icu::BreakIterator>) DECL_ACCESSORS2(icu_break_iterator, Managed<icu::BreakIterator>)
DECL_ACCESSORS(unicode_string, Managed<icu::UnicodeString>) DECL_ACCESSORS2(unicode_string, Managed<icu::UnicodeString>)
DECL_PRINTER(JSSegmentIterator) DECL_PRINTER(JSSegmentIterator)
DECL_VERIFIER(JSSegmentIterator) DECL_VERIFIER(JSSegmentIterator)
......
...@@ -22,8 +22,8 @@ OBJECT_CONSTRUCTORS_IMPL(JSSegmenter, JSObject) ...@@ -22,8 +22,8 @@ OBJECT_CONSTRUCTORS_IMPL(JSSegmenter, JSObject)
// Base segmenter accessors. // Base segmenter accessors.
ACCESSORS2(JSSegmenter, locale, String, kLocaleOffset) ACCESSORS2(JSSegmenter, locale, String, kLocaleOffset)
ACCESSORS(JSSegmenter, icu_break_iterator, Managed<icu::BreakIterator>, ACCESSORS2(JSSegmenter, icu_break_iterator, Managed<icu::BreakIterator>,
kICUBreakIteratorOffset) kICUBreakIteratorOffset)
SMI_ACCESSORS(JSSegmenter, flags, kFlagsOffset) SMI_ACCESSORS(JSSegmenter, flags, kFlagsOffset)
inline void JSSegmenter::set_line_break_style(LineBreakStyle line_break_style) { inline void JSSegmenter::set_line_break_style(LineBreakStyle line_break_style) {
......
...@@ -50,7 +50,7 @@ class JSSegmenter : public JSObject { ...@@ -50,7 +50,7 @@ class JSSegmenter : public JSObject {
// Segmenter accessors. // Segmenter accessors.
DECL_ACCESSORS2(locale, String) DECL_ACCESSORS2(locale, String)
DECL_ACCESSORS(icu_break_iterator, Managed<icu::BreakIterator>) DECL_ACCESSORS2(icu_break_iterator, Managed<icu::BreakIterator>)
// LineBreakStyle: identifying the style used for line break. // LineBreakStyle: identifying the style used for line break.
// //
......
...@@ -48,15 +48,19 @@ void ManagedObjectFinalizer(const v8::WeakCallbackInfo<void>& data); ...@@ -48,15 +48,19 @@ void ManagedObjectFinalizer(const v8::WeakCallbackInfo<void>& data);
template <class CppType> template <class CppType>
class Managed : public Foreign { class Managed : public Foreign {
public: public:
Managed() : Foreign() {}
explicit Managed(Address ptr) : Foreign(ptr) {}
Managed* operator->() { return this; }
// Get a raw pointer to the C++ object. // Get a raw pointer to the C++ object.
V8_INLINE CppType* raw() { return GetSharedPtrPtr()->get(); } V8_INLINE CppType* raw() { return GetSharedPtrPtr()->get(); }
// Get a copy of the shared pointer to the C++ object. // Get a copy of the shared pointer to the C++ object.
V8_INLINE std::shared_ptr<CppType> get() { return *GetSharedPtrPtr(); } V8_INLINE std::shared_ptr<CppType> get() { return *GetSharedPtrPtr(); }
static Managed<CppType>* cast(Object* obj) { static Managed cast(Object* obj) { return Managed(obj->ptr()); }
SLOW_DCHECK(obj->IsForeign()); static Managed unchecked_cast(ObjectPtr obj) {
return reinterpret_cast<Managed<CppType>*>(obj); return bit_cast<Managed>(obj);
} }
// Allocate a new {CppType} and wrap it in a {Managed<CppType>}. // Allocate a new {CppType} and wrap it in a {Managed<CppType>}.
......
...@@ -27,8 +27,8 @@ CAST_ACCESSOR2(CallableTask) ...@@ -27,8 +27,8 @@ CAST_ACCESSOR2(CallableTask)
ACCESSORS2(CallableTask, callable, JSReceiver, kCallableOffset) ACCESSORS2(CallableTask, callable, JSReceiver, kCallableOffset)
ACCESSORS2(CallableTask, context, Context, kContextOffset) ACCESSORS2(CallableTask, context, Context, kContextOffset)
ACCESSORS(CallbackTask, callback, Foreign, kCallbackOffset) ACCESSORS2(CallbackTask, callback, Foreign, kCallbackOffset)
ACCESSORS(CallbackTask, data, Foreign, kDataOffset) ACCESSORS2(CallbackTask, data, Foreign, kDataOffset)
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -31,8 +31,8 @@ class Microtask : public StructPtr { ...@@ -31,8 +31,8 @@ class Microtask : public StructPtr {
// used by Blink for example. // used by Blink for example.
class CallbackTask : public Microtask { class CallbackTask : public Microtask {
public: public:
DECL_ACCESSORS(callback, Foreign) DECL_ACCESSORS2(callback, Foreign)
DECL_ACCESSORS(data, Foreign) DECL_ACCESSORS2(data, Foreign)
// Layout description. // Layout description.
#define CALLBACK_TASK_FIELDS(V) \ #define CALLBACK_TASK_FIELDS(V) \
......
...@@ -733,7 +733,7 @@ void Serializer::ObjectSerializer::VisitEmbeddedPointer(Code host, ...@@ -733,7 +733,7 @@ void Serializer::ObjectSerializer::VisitEmbeddedPointer(Code host,
bytes_processed_so_far_ += rinfo->target_address_size(); bytes_processed_so_far_ += rinfo->target_address_size();
} }
void Serializer::ObjectSerializer::VisitExternalReference(Foreign* host, void Serializer::ObjectSerializer::VisitExternalReference(Foreign host,
Address* p) { Address* p) {
int skip = SkipTo(reinterpret_cast<Address>(p)); int skip = SkipTo(reinterpret_cast<Address>(p));
Address target = *p; Address target = *p;
......
...@@ -325,7 +325,7 @@ class Serializer::ObjectSerializer : public ObjectVisitor { ...@@ -325,7 +325,7 @@ class Serializer::ObjectSerializer : public ObjectVisitor {
void VisitPointers(HeapObject* host, MaybeObjectSlot start, void VisitPointers(HeapObject* host, MaybeObjectSlot start,
MaybeObjectSlot end) override; MaybeObjectSlot end) override;
void VisitEmbeddedPointer(Code host, RelocInfo* target) override; void VisitEmbeddedPointer(Code host, RelocInfo* target) override;
void VisitExternalReference(Foreign* host, Address* p) override; void VisitExternalReference(Foreign host, Address* p) override;
void VisitExternalReference(Code host, RelocInfo* rinfo) override; void VisitExternalReference(Code host, RelocInfo* rinfo) override;
void VisitInternalReference(Code host, RelocInfo* rinfo) override; void VisitInternalReference(Code host, RelocInfo* rinfo) override;
void VisitCodeTarget(Code host, RelocInfo* target) override; void VisitCodeTarget(Code host, RelocInfo* target) override;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "src/globals.h" #include "src/globals.h"
#include "src/objects/code.h" #include "src/objects/code.h"
#include "src/objects/foreign.h"
#include "src/objects/slots.h" #include "src/objects/slots.h"
namespace v8 { namespace v8 {
...@@ -133,7 +134,7 @@ class ObjectVisitor { ...@@ -133,7 +134,7 @@ class ObjectVisitor {
virtual void VisitExternalReference(Code host, RelocInfo* rinfo) {} virtual void VisitExternalReference(Code host, RelocInfo* rinfo) {}
// Visits an external reference. // Visits an external reference.
virtual void VisitExternalReference(Foreign* host, Address* p) {} virtual void VisitExternalReference(Foreign host, Address* p) {}
// Visits an (encoded) internal reference. // Visits an (encoded) internal reference.
virtual void VisitInternalReference(Code host, RelocInfo* rinfo) {} virtual void VisitInternalReference(Code host, RelocInfo* rinfo) {}
......
...@@ -75,8 +75,8 @@ CAST_ACCESSOR2(AsmWasmData) ...@@ -75,8 +75,8 @@ CAST_ACCESSOR2(AsmWasmData)
} }
// WasmModuleObject // WasmModuleObject
ACCESSORS(WasmModuleObject, managed_native_module, Managed<wasm::NativeModule>, ACCESSORS2(WasmModuleObject, managed_native_module, Managed<wasm::NativeModule>,
kNativeModuleOffset) kNativeModuleOffset)
ACCESSORS2(WasmModuleObject, export_wrappers, FixedArray, kExportWrappersOffset) ACCESSORS2(WasmModuleObject, export_wrappers, FixedArray, kExportWrappersOffset)
ACCESSORS2(WasmModuleObject, script, Script, kScriptOffset) ACCESSORS2(WasmModuleObject, script, Script, kScriptOffset)
ACCESSORS2(WasmModuleObject, weak_instance_list, WeakArrayList, ACCESSORS2(WasmModuleObject, weak_instance_list, WeakArrayList,
...@@ -216,8 +216,8 @@ ACCESSORS2(WasmInstanceObject, imported_function_refs, FixedArray, ...@@ -216,8 +216,8 @@ ACCESSORS2(WasmInstanceObject, imported_function_refs, FixedArray,
kImportedFunctionRefsOffset) kImportedFunctionRefsOffset)
OPTIONAL_ACCESSORS2(WasmInstanceObject, indirect_function_table_refs, OPTIONAL_ACCESSORS2(WasmInstanceObject, indirect_function_table_refs,
FixedArray, kIndirectFunctionTableRefsOffset) FixedArray, kIndirectFunctionTableRefsOffset)
OPTIONAL_ACCESSORS(WasmInstanceObject, managed_native_allocations, Foreign, OPTIONAL_ACCESSORS2(WasmInstanceObject, managed_native_allocations, Foreign,
kManagedNativeAllocationsOffset) kManagedNativeAllocationsOffset)
OPTIONAL_ACCESSORS2(WasmInstanceObject, exceptions_table, FixedArray, OPTIONAL_ACCESSORS2(WasmInstanceObject, exceptions_table, FixedArray,
kExceptionsTableOffset) kExceptionsTableOffset)
ACCESSORS(WasmInstanceObject, undefined_value, Oddball, kUndefinedValueOffset) ACCESSORS(WasmInstanceObject, undefined_value, Oddball, kUndefinedValueOffset)
...@@ -269,8 +269,8 @@ ACCESSORS2(WasmDebugInfo, interpreted_functions, FixedArray, ...@@ -269,8 +269,8 @@ ACCESSORS2(WasmDebugInfo, interpreted_functions, FixedArray,
OPTIONAL_ACCESSORS2(WasmDebugInfo, locals_names, FixedArray, kLocalsNamesOffset) OPTIONAL_ACCESSORS2(WasmDebugInfo, locals_names, FixedArray, kLocalsNamesOffset)
OPTIONAL_ACCESSORS2(WasmDebugInfo, c_wasm_entries, FixedArray, OPTIONAL_ACCESSORS2(WasmDebugInfo, c_wasm_entries, FixedArray,
kCWasmEntriesOffset) kCWasmEntriesOffset)
OPTIONAL_ACCESSORS(WasmDebugInfo, c_wasm_entry_map, Managed<wasm::SignatureMap>, OPTIONAL_ACCESSORS2(WasmDebugInfo, c_wasm_entry_map,
kCWasmEntryMapOffset) Managed<wasm::SignatureMap>, kCWasmEntryMapOffset)
#undef OPTIONAL_ACCESSORS #undef OPTIONAL_ACCESSORS
#undef READ_PRIMITIVE_FIELD #undef READ_PRIMITIVE_FIELD
...@@ -285,8 +285,8 @@ bool WasmMemoryObject::has_maximum_pages() { return maximum_pages() >= 0; } ...@@ -285,8 +285,8 @@ bool WasmMemoryObject::has_maximum_pages() { return maximum_pages() >= 0; }
SMI_ACCESSORS(WasmExceptionTag, index, kIndexOffset) SMI_ACCESSORS(WasmExceptionTag, index, kIndexOffset)
// AsmWasmData // AsmWasmData
ACCESSORS(AsmWasmData, managed_native_module, Managed<wasm::NativeModule>, ACCESSORS2(AsmWasmData, managed_native_module, Managed<wasm::NativeModule>,
kManagedNativeModuleOffset) kManagedNativeModuleOffset)
ACCESSORS2(AsmWasmData, export_wrappers, FixedArray, kExportWrappersOffset) ACCESSORS2(AsmWasmData, export_wrappers, FixedArray, kExportWrappersOffset)
ACCESSORS2(AsmWasmData, asm_js_offset_table, ByteArray, kAsmJsOffsetTableOffset) ACCESSORS2(AsmWasmData, asm_js_offset_table, ByteArray, kAsmJsOffsetTableOffset)
ACCESSORS(AsmWasmData, uses_bitset, HeapNumber, kUsesBitsetOffset) ACCESSORS(AsmWasmData, uses_bitset, HeapNumber, kUsesBitsetOffset)
......
...@@ -158,7 +158,7 @@ size_t EstimateNativeAllocationsSize(const WasmModule* module) { ...@@ -158,7 +158,7 @@ size_t EstimateNativeAllocationsSize(const WasmModule* module) {
WasmInstanceNativeAllocations* GetNativeAllocations( WasmInstanceNativeAllocations* GetNativeAllocations(
WasmInstanceObject instance) { WasmInstanceObject instance) {
return reinterpret_cast<Managed<WasmInstanceNativeAllocations>*>( return Managed<WasmInstanceNativeAllocations>::cast(
instance->managed_native_allocations()) instance->managed_native_allocations())
->raw(); ->raw();
} }
......
...@@ -110,7 +110,7 @@ class WasmModuleObject : public JSObject { ...@@ -110,7 +110,7 @@ class WasmModuleObject : public JSObject {
public: public:
DECL_CAST2(WasmModuleObject) DECL_CAST2(WasmModuleObject)
DECL_ACCESSORS(managed_native_module, Managed<wasm::NativeModule>) DECL_ACCESSORS2(managed_native_module, Managed<wasm::NativeModule>)
DECL_ACCESSORS2(export_wrappers, FixedArray) DECL_ACCESSORS2(export_wrappers, FixedArray)
DECL_ACCESSORS2(script, Script) DECL_ACCESSORS2(script, Script)
DECL_ACCESSORS2(weak_instance_list, WeakArrayList) DECL_ACCESSORS2(weak_instance_list, WeakArrayList)
...@@ -400,7 +400,7 @@ class WasmInstanceObject : public JSObject { ...@@ -400,7 +400,7 @@ class WasmInstanceObject : public JSObject {
DECL_OPTIONAL_ACCESSORS2(table_object, WasmTableObject) DECL_OPTIONAL_ACCESSORS2(table_object, WasmTableObject)
DECL_ACCESSORS2(imported_function_refs, FixedArray) DECL_ACCESSORS2(imported_function_refs, FixedArray)
DECL_OPTIONAL_ACCESSORS2(indirect_function_table_refs, FixedArray) DECL_OPTIONAL_ACCESSORS2(indirect_function_table_refs, FixedArray)
DECL_OPTIONAL_ACCESSORS(managed_native_allocations, Foreign) DECL_OPTIONAL_ACCESSORS2(managed_native_allocations, Foreign)
DECL_OPTIONAL_ACCESSORS2(exceptions_table, FixedArray) DECL_OPTIONAL_ACCESSORS2(exceptions_table, FixedArray)
DECL_ACCESSORS(undefined_value, Oddball) DECL_ACCESSORS(undefined_value, Oddball)
DECL_ACCESSORS(null_value, Oddball) DECL_ACCESSORS(null_value, Oddball)
...@@ -584,7 +584,7 @@ class WasmDebugInfo : public StructPtr { ...@@ -584,7 +584,7 @@ class WasmDebugInfo : public StructPtr {
DECL_ACCESSORS2(interpreted_functions, FixedArray); DECL_ACCESSORS2(interpreted_functions, FixedArray);
DECL_OPTIONAL_ACCESSORS2(locals_names, FixedArray) DECL_OPTIONAL_ACCESSORS2(locals_names, FixedArray)
DECL_OPTIONAL_ACCESSORS2(c_wasm_entries, FixedArray) DECL_OPTIONAL_ACCESSORS2(c_wasm_entries, FixedArray)
DECL_OPTIONAL_ACCESSORS(c_wasm_entry_map, Managed<wasm::SignatureMap>) DECL_OPTIONAL_ACCESSORS2(c_wasm_entry_map, Managed<wasm::SignatureMap>)
DECL_CAST2(WasmDebugInfo) DECL_CAST2(WasmDebugInfo)
...@@ -710,7 +710,7 @@ class AsmWasmData : public StructPtr { ...@@ -710,7 +710,7 @@ class AsmWasmData : public StructPtr {
Handle<FixedArray> export_wrappers, Handle<ByteArray> asm_js_offset_table, Handle<FixedArray> export_wrappers, Handle<ByteArray> asm_js_offset_table,
Handle<HeapNumber> uses_bitset); Handle<HeapNumber> uses_bitset);
DECL_ACCESSORS(managed_native_module, Managed<wasm::NativeModule>) DECL_ACCESSORS2(managed_native_module, Managed<wasm::NativeModule>)
DECL_ACCESSORS2(export_wrappers, FixedArray) DECL_ACCESSORS2(export_wrappers, FixedArray)
DECL_ACCESSORS2(asm_js_offset_table, ByteArray) DECL_ACCESSORS2(asm_js_offset_table, ByteArray)
DECL_ACCESSORS(uses_bitset, HeapNumber) DECL_ACCESSORS(uses_bitset, HeapNumber)
......
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