Commit f5da460b authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[offthread] Make AccessorInfo roots available to OffThreadFactory

Although AccessorInfos are technically mutable, in practice they are not
mutated after initialization, and they are guaranteed to be immortal and
immovable. So, we can safely make them accessible from the off-thread
factory, as long as the user promises to not try to mutate them. This is
necessary for off-thread class boilerplate creation.

Bug: v8:10218
Bug: chromium:1011762
Change-Id: Id3108a2324a000ea0616b472dd77aed65b1f908e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2080351
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66563}
parent 65238018
......@@ -78,6 +78,8 @@ class V8_EXPORT_PRIVATE OffThreadIsolate final
ThreadId thread_id() { return thread_id_; }
private:
friend class v8::internal::OffThreadFactory;
// TODO(leszeks): Extract out the fields of the Isolate we want and store
// those instead of the whole thing.
Isolate* isolate_;
......
......@@ -13,13 +13,23 @@
namespace v8 {
namespace internal {
#define ROOT_ACCESSOR(Type, name, CamelName) \
Handle<Type> OffThreadFactory::name() { \
return Handle<Type>(read_only_roots().name##_handle()); \
#define ROOT_ACCESSOR(Type, name, CamelName) \
Handle<Type> OffThreadFactory::name() { \
return read_only_roots().name##_handle(); \
}
READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR
#define ACCESSOR_INFO_ACCESSOR(Type, name, CamelName) \
Handle<Type> OffThreadFactory::name() { \
/* Do a bit of handle location magic to cast the Handle without having */ \
/* to pull in Type::cast. We know the type is right by construction. */ \
return Handle<Type>( \
isolate()->isolate_->root_handle(RootIndex::k##CamelName).location()); \
}
ACCESSOR_INFO_ROOT_LIST(ACCESSOR_INFO_ACCESSOR)
#undef ACCESSOR_INFO_ACCESSOR
#endif // V8_HEAP_OFF_THREAD_FACTORY_INL_H_
} // namespace internal
......
......@@ -46,6 +46,11 @@ class V8_EXPORT_PRIVATE OffThreadFactory
#define ROOT_ACCESSOR(Type, name, CamelName) inline Handle<Type> name();
READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
// AccessorInfos appear mutable, but they're actually not mutated once they
// finish initializing. In particular, the root accessors are not mutated and
// are safe to access (as long as the off-thread job doesn't try to mutate
// them).
ACCESSOR_INFO_ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR
void FinishOffThread();
......
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