Commit 757771f7 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[factory] Dehandlify object initializers in factory

Clang cannot optimise across handle derefs and produces quite
inefficient code when setting multiple properties in a row.

We are already dealing with a lot of raw pointers in factory, thus
adding further DisallowGarbageCollection and will not significantly
increase the risk of stale pointers.

Bug: v8:11263
Change-Id: I2b62f79ecde95faa84a182c09d89c03423900d98
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2581963
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73127}
parent eb976c3e
This diff is collapsed.
......@@ -67,7 +67,9 @@ Handle<Object> Factory::NewURIError() {
MessageTemplate::kURIMalformed);
}
ReadOnlyRoots Factory::read_only_roots() { return ReadOnlyRoots(isolate()); }
ReadOnlyRoots Factory::read_only_roots() const {
return ReadOnlyRoots(isolate());
}
} // namespace internal
} // namespace v8
......
This diff is collapsed.
......@@ -99,7 +99,7 @@ enum class NumberCacheMode { kIgnore, kSetOnly, kBoth };
// Interface for handle based allocation.
class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
public:
inline ReadOnlyRoots read_only_roots();
inline ReadOnlyRoots read_only_roots() const;
template <typename T>
Handle<T> MakeHandle(T obj) {
......@@ -915,7 +915,7 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
HeapObject AllocateRaw(int size, AllocationType allocation,
AllocationAlignment alignment = kWordAligned);
Isolate* isolate() {
Isolate* isolate() const {
// Downcast to the privately inherited sub-class using c-style casts to
// avoid undefined behavior (as static_cast cannot cast across private
// bases).
......@@ -936,10 +936,12 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
Handle<Map> map, Handle<FixedArrayBase> elements,
Handle<JSArrayBuffer> buffer, size_t byte_offset, size_t byte_length);
Symbol NewSymbolInternal(AllocationType allocation = AllocationType::kOld);
// Allocates new context with given map, sets length and initializes the
// after-header part with uninitialized values and leaves the context header
// uninitialized.
Handle<Context> NewContext(Handle<Map> map, int size,
Context NewContextInternal(Handle<Map> map, int size,
int variadic_part_length,
AllocationType allocation);
......
......@@ -4303,7 +4303,7 @@ template Handle<DescriptorArray> DescriptorArray::Allocate(
LocalIsolate* isolate, int nof_descriptors, int slack,
AllocationType allocation);
void DescriptorArray::Initialize(EnumCache enum_cache,
void DescriptorArray::Initialize(EnumCache empty_enum_cache,
HeapObject undefined_value,
int nof_descriptors, int slack) {
DCHECK_GE(nof_descriptors, 0);
......@@ -4313,13 +4313,13 @@ void DescriptorArray::Initialize(EnumCache enum_cache,
set_number_of_descriptors(nof_descriptors);
set_raw_number_of_marked_descriptors(0);
set_filler16bits(0);
set_enum_cache(enum_cache);
set_enum_cache(empty_enum_cache, SKIP_WRITE_BARRIER);
MemsetTagged(GetDescriptorSlot(0), undefined_value,
number_of_all_descriptors() * kEntrySize);
}
void DescriptorArray::ClearEnumCache() {
set_enum_cache(GetReadOnlyRoots().empty_enum_cache());
set_enum_cache(GetReadOnlyRoots().empty_enum_cache(), SKIP_WRITE_BARRIER);
}
void DescriptorArray::Replace(InternalIndex index, Descriptor* descriptor) {
......
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