Commit 15f0263f authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Brokerize parts of JSCallReducer.

Bug: v8:7790
Change-Id: I1e168132f5d3c90e1a3ee5c13ebc6dbc11e9daa1
Reviewed-on: https://chromium-review.googlesource.com/c/1288250
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56859}
parent 50f713c9
This diff is collapsed.
...@@ -39,13 +39,11 @@ class V8_EXPORT_PRIVATE JSCallReducer final : public AdvancedReducer { ...@@ -39,13 +39,11 @@ class V8_EXPORT_PRIVATE JSCallReducer final : public AdvancedReducer {
typedef base::Flags<Flag> Flags; typedef base::Flags<Flag> Flags;
JSCallReducer(Editor* editor, JSGraph* jsgraph, JSHeapBroker* broker, JSCallReducer(Editor* editor, JSGraph* jsgraph, JSHeapBroker* broker,
Flags flags, Handle<Context> native_context, Flags flags, CompilationDependencies* dependencies)
CompilationDependencies* dependencies)
: AdvancedReducer(editor), : AdvancedReducer(editor),
jsgraph_(jsgraph), jsgraph_(jsgraph),
broker_(broker), broker_(broker),
flags_(flags), flags_(flags),
native_context_(native_context),
dependencies_(dependencies) {} dependencies_(dependencies) {}
const char* reducer_name() const override { return "JSCallReducer"; } const char* reducer_name() const override { return "JSCallReducer"; }
...@@ -237,8 +235,7 @@ class V8_EXPORT_PRIVATE JSCallReducer final : public AdvancedReducer { ...@@ -237,8 +235,7 @@ class V8_EXPORT_PRIVATE JSCallReducer final : public AdvancedReducer {
JSHeapBroker* broker() const { return broker_; } JSHeapBroker* broker() const { return broker_; }
Isolate* isolate() const; Isolate* isolate() const;
Factory* factory() const; Factory* factory() const;
Handle<Context> native_context() const { return native_context_; } NativeContextRef native_context() const { return broker()->native_context(); }
Handle<JSGlobalProxy> global_proxy() const;
CommonOperatorBuilder* common() const; CommonOperatorBuilder* common() const;
JSOperatorBuilder* javascript() const; JSOperatorBuilder* javascript() const;
SimplifiedOperatorBuilder* simplified() const; SimplifiedOperatorBuilder* simplified() const;
...@@ -248,7 +245,6 @@ class V8_EXPORT_PRIVATE JSCallReducer final : public AdvancedReducer { ...@@ -248,7 +245,6 @@ class V8_EXPORT_PRIVATE JSCallReducer final : public AdvancedReducer {
JSGraph* const jsgraph_; JSGraph* const jsgraph_;
JSHeapBroker* const broker_; JSHeapBroker* const broker_;
Flags const flags_; Flags const flags_;
Handle<Context> const native_context_;
CompilationDependencies* const dependencies_; CompilationDependencies* const dependencies_;
std::set<Node*> waitlist_; std::set<Node*> waitlist_;
}; };
......
...@@ -47,7 +47,7 @@ bool IsAllocationInlineable(const JSFunctionRef& target, ...@@ -47,7 +47,7 @@ bool IsAllocationInlineable(const JSFunctionRef& target,
CHECK_IMPLIES(new_target.has_initial_map(), CHECK_IMPLIES(new_target.has_initial_map(),
!new_target.initial_map().is_dictionary_map()); !new_target.initial_map().is_dictionary_map());
return new_target.has_initial_map() && return new_target.has_initial_map() &&
new_target.initial_map().constructor_or_backpointer().equals(target); new_target.initial_map().GetConstructor().equals(target);
} }
// When initializing arrays, we'll unfold the loop if the number of // When initializing arrays, we'll unfold the loop if the number of
......
...@@ -628,10 +628,10 @@ class MapData : public HeapObjectData { ...@@ -628,10 +628,10 @@ class MapData : public HeapObjectData {
return instance_descriptors_; return instance_descriptors_;
} }
void SerializeConstructorOrBackpointer(JSHeapBroker* broker); void SerializeConstructor(JSHeapBroker* broker);
ObjectData* constructor_or_backpointer() const { ObjectData* GetConstructor() const {
CHECK(serialized_constructor_or_backpointer_); CHECK(serialized_constructor_);
return constructor_or_backpointer_; return constructor_;
} }
void SerializePrototype(JSHeapBroker* broker); void SerializePrototype(JSHeapBroker* broker);
...@@ -658,8 +658,8 @@ class MapData : public HeapObjectData { ...@@ -658,8 +658,8 @@ class MapData : public HeapObjectData {
bool serialized_own_descriptors_ = false; bool serialized_own_descriptors_ = false;
DescriptorArrayData* instance_descriptors_ = nullptr; DescriptorArrayData* instance_descriptors_ = nullptr;
bool serialized_constructor_or_backpointer_ = false; bool serialized_constructor_ = false;
ObjectData* constructor_or_backpointer_ = nullptr; ObjectData* constructor_ = nullptr;
bool serialized_prototype_ = false; bool serialized_prototype_ = false;
ObjectData* prototype_ = nullptr; ObjectData* prototype_ = nullptr;
...@@ -769,7 +769,7 @@ void JSFunctionData::Serialize(JSHeapBroker* broker) { ...@@ -769,7 +769,7 @@ void JSFunctionData::Serialize(JSHeapBroker* broker) {
if (initial_map_->instance_type() == JS_ARRAY_TYPE) { if (initial_map_->instance_type() == JS_ARRAY_TYPE) {
initial_map_->SerializeElementsKindGeneralizations(broker); initial_map_->SerializeElementsKindGeneralizations(broker);
} }
initial_map_->SerializeConstructorOrBackpointer(broker); initial_map_->SerializeConstructor(broker);
// TODO(neis): This is currently only needed for native_context's // TODO(neis): This is currently only needed for native_context's
// object_function, as used by GetObjectCreateMap. If no further use sites // object_function, as used by GetObjectCreateMap. If no further use sites
// show up, we should move this into NativeContextData::Serialize. // show up, we should move this into NativeContextData::Serialize.
...@@ -1187,15 +1187,14 @@ void JSObjectData::SerializeElements(JSHeapBroker* broker) { ...@@ -1187,15 +1187,14 @@ void JSObjectData::SerializeElements(JSHeapBroker* broker) {
elements_ = broker->GetOrCreateData(elements_object)->AsFixedArrayBase(); elements_ = broker->GetOrCreateData(elements_object)->AsFixedArrayBase();
} }
void MapData::SerializeConstructorOrBackpointer(JSHeapBroker* broker) { void MapData::SerializeConstructor(JSHeapBroker* broker) {
if (serialized_constructor_or_backpointer_) return; if (serialized_constructor_) return;
serialized_constructor_or_backpointer_ = true; serialized_constructor_ = true;
TraceScope tracer(broker, this, "MapData::SerializeConstructorOrBackpointer"); TraceScope tracer(broker, this, "MapData::SerializeConstructor");
Handle<Map> map = Handle<Map>::cast(object()); Handle<Map> map = Handle<Map>::cast(object());
DCHECK_NULL(constructor_or_backpointer_); DCHECK_NULL(constructor_);
constructor_or_backpointer_ = constructor_ = broker->GetOrCreateData(map->GetConstructor());
broker->GetOrCreateData(map->constructor_or_backpointer());
} }
void MapData::SerializePrototype(JSHeapBroker* broker) { void MapData::SerializePrototype(JSHeapBroker* broker) {
...@@ -2070,18 +2069,21 @@ BIMODAL_ACCESSOR_C(JSTypedArray, size_t, length_value) ...@@ -2070,18 +2069,21 @@ BIMODAL_ACCESSOR_C(JSTypedArray, size_t, length_value)
BIMODAL_ACCESSOR(JSTypedArray, HeapObject, buffer) BIMODAL_ACCESSOR(JSTypedArray, HeapObject, buffer)
BIMODAL_ACCESSOR_B(Map, bit_field2, elements_kind, Map::ElementsKindBits) BIMODAL_ACCESSOR_B(Map, bit_field2, elements_kind, Map::ElementsKindBits)
BIMODAL_ACCESSOR_B(Map, bit_field2, is_extensible, Map::IsExtensibleBit)
BIMODAL_ACCESSOR_B(Map, bit_field3, is_deprecated, Map::IsDeprecatedBit) BIMODAL_ACCESSOR_B(Map, bit_field3, is_deprecated, Map::IsDeprecatedBit)
BIMODAL_ACCESSOR_B(Map, bit_field3, is_dictionary_map, Map::IsDictionaryMapBit) BIMODAL_ACCESSOR_B(Map, bit_field3, is_dictionary_map, Map::IsDictionaryMapBit)
BIMODAL_ACCESSOR_B(Map, bit_field3, NumberOfOwnDescriptors, BIMODAL_ACCESSOR_B(Map, bit_field3, NumberOfOwnDescriptors,
Map::NumberOfOwnDescriptorsBits) Map::NumberOfOwnDescriptorsBits)
BIMODAL_ACCESSOR_B(Map, bit_field, has_prototype_slot, Map::HasPrototypeSlotBit) BIMODAL_ACCESSOR_B(Map, bit_field, has_prototype_slot, Map::HasPrototypeSlotBit)
BIMODAL_ACCESSOR_B(Map, bit_field, is_access_check_needed,
Map::IsAccessCheckNeededBit)
BIMODAL_ACCESSOR_B(Map, bit_field, is_callable, Map::IsCallableBit) BIMODAL_ACCESSOR_B(Map, bit_field, is_callable, Map::IsCallableBit)
BIMODAL_ACCESSOR_B(Map, bit_field, is_constructor, Map::IsConstructorBit) BIMODAL_ACCESSOR_B(Map, bit_field, is_constructor, Map::IsConstructorBit)
BIMODAL_ACCESSOR_B(Map, bit_field, is_undetectable, Map::IsUndetectableBit) BIMODAL_ACCESSOR_B(Map, bit_field, is_undetectable, Map::IsUndetectableBit)
BIMODAL_ACCESSOR_C(Map, int, instance_size) BIMODAL_ACCESSOR_C(Map, int, instance_size)
BIMODAL_ACCESSOR(Map, Object, prototype) BIMODAL_ACCESSOR(Map, Object, prototype)
BIMODAL_ACCESSOR_C(Map, InstanceType, instance_type) BIMODAL_ACCESSOR_C(Map, InstanceType, instance_type)
BIMODAL_ACCESSOR(Map, Object, constructor_or_backpointer) BIMODAL_ACCESSOR(Map, Object, GetConstructor)
#define DEF_NATIVE_CONTEXT_ACCESSOR(type, name) \ #define DEF_NATIVE_CONTEXT_ACCESSOR(type, name) \
BIMODAL_ACCESSOR(NativeContext, type, name) BIMODAL_ACCESSOR(NativeContext, type, name)
...@@ -2456,16 +2458,20 @@ void NativeContextData::Serialize(JSHeapBroker* broker) { ...@@ -2456,16 +2458,20 @@ void NativeContextData::Serialize(JSHeapBroker* broker) {
TraceScope tracer(broker, this, "NativeContextData::Serialize"); TraceScope tracer(broker, this, "NativeContextData::Serialize");
Handle<NativeContext> context = Handle<NativeContext>::cast(object()); Handle<NativeContext> context = Handle<NativeContext>::cast(object());
#define SERIALIZE_MEMBER(type, name) \ #define SERIALIZE_MEMBER(type, name) \
DCHECK_NULL(name##_); \ DCHECK_NULL(name##_); \
name##_ = broker->GetOrCreateData(context->name())->As##type(); \ name##_ = broker->GetOrCreateData(context->name())->As##type(); \
if (name##_->IsJSFunction()) name##_->AsJSFunction()->Serialize(broker); if (name##_->IsJSFunction()) name##_->AsJSFunction()->Serialize(broker); \
if (name##_->IsMap()) name##_->AsMap()->SerializeConstructor(broker);
BROKER_COMPULSORY_NATIVE_CONTEXT_FIELDS(SERIALIZE_MEMBER) BROKER_COMPULSORY_NATIVE_CONTEXT_FIELDS(SERIALIZE_MEMBER)
if (!broker->isolate()->bootstrapper()->IsActive()) { if (!broker->isolate()->bootstrapper()->IsActive()) {
BROKER_OPTIONAL_NATIVE_CONTEXT_FIELDS(SERIALIZE_MEMBER) BROKER_OPTIONAL_NATIVE_CONTEXT_FIELDS(SERIALIZE_MEMBER)
} }
#undef SERIALIZE_MEMBER #undef SERIALIZE_MEMBER
bound_function_with_constructor_map_->SerializePrototype(broker);
bound_function_without_constructor_map_->SerializePrototype(broker);
DCHECK(function_maps_.empty()); DCHECK(function_maps_.empty());
int const first = Context::FIRST_FUNCTION_MAP_INDEX; int const first = Context::FIRST_FUNCTION_MAP_INDEX;
int const last = Context::LAST_FUNCTION_MAP_INDEX; int const last = Context::LAST_FUNCTION_MAP_INDEX;
......
...@@ -251,30 +251,38 @@ class ContextRef : public HeapObjectRef { ...@@ -251,30 +251,38 @@ class ContextRef : public HeapObjectRef {
ObjectRef get(int index) const; ObjectRef get(int index) const;
}; };
#define BROKER_COMPULSORY_NATIVE_CONTEXT_FIELDS(V) \ #define BROKER_COMPULSORY_NATIVE_CONTEXT_FIELDS(V) \
V(JSFunction, array_function) \ V(JSFunction, array_function) \
V(JSFunction, boolean_function) \ V(JSFunction, boolean_function) \
V(JSFunction, bigint_function) \ V(JSFunction, bigint_function) \
V(JSFunction, number_function) \ V(JSFunction, number_function) \
V(JSFunction, object_function) \ V(JSFunction, object_function) \
V(JSFunction, promise_function) \ V(JSFunction, promise_function) \
V(JSFunction, string_function) \ V(JSFunction, promise_then) \
V(JSFunction, symbol_function) \ V(JSFunction, string_function) \
V(JSGlobalProxy, global_proxy_object) \ V(JSFunction, symbol_function) \
V(Map, fast_aliased_arguments_map) \ V(JSGlobalProxy, global_proxy_object) \
V(Map, initial_array_iterator_map) \ V(JSObject, promise_prototype) \
V(Map, initial_string_iterator_map) \ V(Map, bound_function_with_constructor_map) \
V(Map, iterator_result_map) \ V(Map, bound_function_without_constructor_map) \
V(Map, js_array_holey_double_elements_map) \ V(Map, fast_aliased_arguments_map) \
V(Map, js_array_holey_elements_map) \ V(Map, initial_array_iterator_map) \
V(Map, js_array_holey_smi_elements_map) \ V(Map, initial_string_iterator_map) \
V(Map, js_array_packed_double_elements_map) \ V(Map, iterator_result_map) \
V(Map, js_array_packed_elements_map) \ V(Map, js_array_holey_double_elements_map) \
V(Map, js_array_packed_smi_elements_map) \ V(Map, js_array_holey_elements_map) \
V(Map, sloppy_arguments_map) \ V(Map, js_array_holey_smi_elements_map) \
V(Map, slow_object_with_null_prototype_map) \ V(Map, js_array_packed_double_elements_map) \
V(Map, strict_arguments_map) \ V(Map, js_array_packed_elements_map) \
V(ScriptContextTable, script_context_table) V(Map, js_array_packed_smi_elements_map) \
V(Map, sloppy_arguments_map) \
V(Map, slow_object_with_null_prototype_map) \
V(Map, strict_arguments_map) \
V(ScriptContextTable, script_context_table) \
V(SharedFunctionInfo, promise_capability_default_reject_shared_fun) \
V(SharedFunctionInfo, promise_catch_finally_shared_fun) \
V(SharedFunctionInfo, promise_then_finally_shared_fun) \
V(SharedFunctionInfo, promise_capability_default_resolve_shared_fun)
// Those are set by Bootstrapper::ExportFromRuntime, which may not yet have // Those are set by Bootstrapper::ExportFromRuntime, which may not yet have
// happened when Turbofan is invoked via --always-opt. // happened when Turbofan is invoked via --always-opt.
...@@ -378,8 +386,10 @@ class MapRef : public HeapObjectRef { ...@@ -378,8 +386,10 @@ class MapRef : public HeapObjectRef {
int constructor_function_index() const; int constructor_function_index() const;
ElementsKind elements_kind() const; ElementsKind elements_kind() const;
bool is_stable() const; bool is_stable() const;
bool is_extensible() const;
bool is_constructor() const; bool is_constructor() const;
bool has_prototype_slot() const; bool has_prototype_slot() const;
bool is_access_check_needed() const;
bool is_deprecated() const; bool is_deprecated() const;
bool CanBeDeprecated() const; bool CanBeDeprecated() const;
bool CanTransition() const; bool CanTransition() const;
...@@ -394,7 +404,7 @@ class MapRef : public HeapObjectRef { ...@@ -394,7 +404,7 @@ class MapRef : public HeapObjectRef {
INSTANCE_TYPE_CHECKERS(DEF_TESTER) INSTANCE_TYPE_CHECKERS(DEF_TESTER)
#undef DEF_TESTER #undef DEF_TESTER
ObjectRef constructor_or_backpointer() const; ObjectRef GetConstructor() const;
void SerializePrototype(); void SerializePrototype();
ObjectRef prototype() const; ObjectRef prototype() const;
......
...@@ -416,8 +416,7 @@ NodeProperties::InferReceiverMapsResult NodeProperties::InferReceiverMaps( ...@@ -416,8 +416,7 @@ NodeProperties::InferReceiverMapsResult NodeProperties::InferReceiverMaps(
if (original_constructor.has_initial_map()) { if (original_constructor.has_initial_map()) {
original_constructor.Serialize(); original_constructor.Serialize();
MapRef initial_map = original_constructor.initial_map(); MapRef initial_map = original_constructor.initial_map();
if (initial_map.constructor_or_backpointer().equals( if (initial_map.GetConstructor().equals(mtarget.Ref(broker))) {
mtarget.Ref(broker))) {
*maps_return = ZoneHandleSet<Map>(initial_map.object()); *maps_return = ZoneHandleSet<Map>(initial_map.object());
return result; return result;
} }
......
...@@ -1213,7 +1213,7 @@ struct InliningPhase { ...@@ -1213,7 +1213,7 @@ struct InliningPhase {
data->info()->is_bailout_on_uninitialized() data->info()->is_bailout_on_uninitialized()
? JSCallReducer::kBailoutOnUninitialized ? JSCallReducer::kBailoutOnUninitialized
: JSCallReducer::kNoFlags, : JSCallReducer::kNoFlags,
data->native_context(), data->dependencies()); data->dependencies());
JSContextSpecialization context_specialization( JSContextSpecialization context_specialization(
&graph_reducer, data->jsgraph(), data->broker(), &graph_reducer, data->jsgraph(), data->broker(),
ChooseSpecializationContext(isolate, data->info()), ChooseSpecializationContext(isolate, data->info()),
......
...@@ -38,7 +38,7 @@ class JSCallReducerTest : public TypedGraphTest { ...@@ -38,7 +38,7 @@ class JSCallReducerTest : public TypedGraphTest {
GraphReducer graph_reducer(zone(), graph()); GraphReducer graph_reducer(zone(), graph());
JSCallReducer reducer(&graph_reducer, &jsgraph, broker(), JSCallReducer reducer(&graph_reducer, &jsgraph, broker(),
JSCallReducer::kNoFlags, native_context(), &deps_); JSCallReducer::kNoFlags, &deps_);
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
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