Commit 763d4c7f authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

[compiler] Remove dead code / refactors in JSHeapBroker

Bug: v8:7790
Change-Id: I9bd852d42cbc81ba12dc81166990a49a6b91168a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3089153
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76247}
parent 069c6396
...@@ -384,7 +384,7 @@ AccessInfoFactory::AccessInfoFactory(JSHeapBroker* broker, ...@@ -384,7 +384,7 @@ AccessInfoFactory::AccessInfoFactory(JSHeapBroker* broker,
base::Optional<ElementAccessInfo> AccessInfoFactory::ComputeElementAccessInfo( base::Optional<ElementAccessInfo> AccessInfoFactory::ComputeElementAccessInfo(
MapRef map, AccessMode access_mode) const { MapRef map, AccessMode access_mode) const {
if (!CanInlineElementAccess(map)) return {}; if (!map.CanInlineElementAccess()) return {};
return ElementAccessInfo({{map}, zone()}, map.elements_kind(), zone()); return ElementAccessInfo({{map}, zone()}, map.elements_kind(), zone());
} }
...@@ -1050,7 +1050,7 @@ base::Optional<ElementAccessInfo> AccessInfoFactory::ConsolidateElementLoad( ...@@ -1050,7 +1050,7 @@ base::Optional<ElementAccessInfo> AccessInfoFactory::ConsolidateElementLoad(
base::Optional<MapRef> map = TryMakeRef(broker(), map_handle); base::Optional<MapRef> map = TryMakeRef(broker(), map_handle);
if (!map.has_value()) return {}; if (!map.has_value()) return {};
if (map->instance_type() != instance_type || if (map->instance_type() != instance_type ||
!CanInlineElementAccess(*map)) { !map->CanInlineElementAccess()) {
return {}; return {};
} }
if (!GeneralizeElementsKind(elements_kind, map->elements_kind()) if (!GeneralizeElementsKind(elements_kind, map->elements_kind())
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/codegen/code-factory.h" #include "src/codegen/code-factory.h"
#include "src/compiler/compilation-dependencies.h" #include "src/compiler/compilation-dependencies.h"
#include "src/compiler/graph-reducer.h"
#include "src/compiler/js-heap-broker.h" #include "src/compiler/js-heap-broker.h"
#include "src/execution/protectors-inl.h" #include "src/execution/protectors-inl.h"
#include "src/objects/allocation-site-inl.h" #include "src/objects/allocation-site-inl.h"
...@@ -1815,6 +1814,19 @@ int ObjectRef::AsSmi() const { ...@@ -1815,6 +1814,19 @@ int ObjectRef::AsSmi() const {
INSTANCE_TYPE_CHECKERS(DEF_TESTER) INSTANCE_TYPE_CHECKERS(DEF_TESTER)
#undef DEF_TESTER #undef DEF_TESTER
bool MapRef::CanInlineElementAccess() const {
if (!IsJSObjectMap()) return false;
if (is_access_check_needed()) return false;
if (has_indexed_interceptor()) return false;
ElementsKind kind = elements_kind();
if (IsFastElementsKind(kind)) return true;
if (IsTypedArrayElementsKind(kind) && kind != BIGUINT64_ELEMENTS &&
kind != BIGINT64_ELEMENTS) {
return true;
}
return false;
}
base::Optional<MapRef> MapRef::AsElementsKind(ElementsKind kind) const { base::Optional<MapRef> MapRef::AsElementsKind(ElementsKind kind) const {
const ElementsKind current_kind = elements_kind(); const ElementsKind current_kind = elements_kind();
if (kind == current_kind) return *this; if (kind == current_kind) return *this;
...@@ -3091,12 +3103,6 @@ Handle<T> TinyRef<T>::object() const { ...@@ -3091,12 +3103,6 @@ Handle<T> TinyRef<T>::object() const {
HEAP_BROKER_OBJECT_LIST(V) HEAP_BROKER_OBJECT_LIST(V)
#undef V #undef V
Reduction NoChangeBecauseOfMissingData(JSHeapBroker* broker,
const char* function, int line) {
TRACE_MISSING(broker, "data in function " << function << " at line " << line);
return AdvancedReducer::NoChange();
}
bool JSBoundFunctionRef::Serialize(NotConcurrentInliningTag tag) { bool JSBoundFunctionRef::Serialize(NotConcurrentInliningTag tag) {
if (data_->should_access_heap()) { if (data_->should_access_heap()) {
return true; return true;
......
...@@ -733,6 +733,8 @@ class V8_EXPORT_PRIVATE MapRef : public HeapObjectRef { ...@@ -733,6 +733,8 @@ class V8_EXPORT_PRIVATE MapRef : public HeapObjectRef {
OddballType oddball_type() const; OddballType oddball_type() const;
bool CanInlineElementAccess() const;
// Note: Only returns a value if the requested elements kind matches the // Note: Only returns a value if the requested elements kind matches the
// current kind, or if the current map is an unmodified JSArray initial map. // current kind, or if the current map is an unmodified JSArray initial map.
base::Optional<MapRef> AsElementsKind(ElementsKind kind) const; base::Optional<MapRef> AsElementsKind(ElementsKind kind) const;
......
...@@ -466,9 +466,10 @@ Reduction JSCreateLowering::ReduceNewArray( ...@@ -466,9 +466,10 @@ Reduction JSCreateLowering::ReduceNewArray(
// Constructing an Array via new Array(N) where N is an unsigned // Constructing an Array via new Array(N) where N is an unsigned
// integer, always creates a holey backing store. // integer, always creates a holey backing store.
ASSIGN_RETURN_NO_CHANGE_IF_DATA_MISSING( base::Optional<MapRef> maybe_initial_map =
initial_map, initial_map.AsElementsKind(GetHoleyElementsKind(elements_kind));
initial_map.AsElementsKind(GetHoleyElementsKind(elements_kind))); if (!maybe_initial_map.has_value()) return NoChange();
initial_map = maybe_initial_map.value();
// Because CheckBounds performs implicit conversion from string to number, an // Because CheckBounds performs implicit conversion from string to number, an
// additional CheckNumber is required to behave correctly for calls with a // additional CheckNumber is required to behave correctly for calls with a
...@@ -525,8 +526,12 @@ Reduction JSCreateLowering::ReduceNewArray( ...@@ -525,8 +526,12 @@ Reduction JSCreateLowering::ReduceNewArray(
if (NodeProperties::GetType(length).Max() > 0.0) { if (NodeProperties::GetType(length).Max() > 0.0) {
elements_kind = GetHoleyElementsKind(elements_kind); elements_kind = GetHoleyElementsKind(elements_kind);
} }
ASSIGN_RETURN_NO_CHANGE_IF_DATA_MISSING(
initial_map, initial_map.AsElementsKind(elements_kind)); base::Optional<MapRef> maybe_initial_map =
initial_map.AsElementsKind(elements_kind);
if (!maybe_initial_map.has_value()) return NoChange();
initial_map = maybe_initial_map.value();
DCHECK(IsFastElementsKind(elements_kind)); DCHECK(IsFastElementsKind(elements_kind));
// Setup elements and properties. // Setup elements and properties.
...@@ -566,8 +571,11 @@ Reduction JSCreateLowering::ReduceNewArray( ...@@ -566,8 +571,11 @@ Reduction JSCreateLowering::ReduceNewArray(
// Determine the appropriate elements kind. // Determine the appropriate elements kind.
DCHECK(IsFastElementsKind(elements_kind)); DCHECK(IsFastElementsKind(elements_kind));
ASSIGN_RETURN_NO_CHANGE_IF_DATA_MISSING(
initial_map, initial_map.AsElementsKind(elements_kind)); base::Optional<MapRef> maybe_initial_map =
initial_map.AsElementsKind(elements_kind);
if (!maybe_initial_map.has_value()) return NoChange();
initial_map = maybe_initial_map.value();
// Check {values} based on the {elements_kind}. These checks are guarded // Check {values} based on the {elements_kind}. These checks are guarded
// by the {elements_kind} feedback on the {site}, so it's safe to just // by the {elements_kind} feedback on the {site}, so it's safe to just
......
...@@ -50,12 +50,10 @@ JSHeapBroker::JSHeapBroker(Isolate* isolate, Zone* broker_zone, ...@@ -50,12 +50,10 @@ JSHeapBroker::JSHeapBroker(Isolate* isolate, Zone* broker_zone,
array_and_object_prototypes_(zone()), array_and_object_prototypes_(zone()),
tracing_enabled_(tracing_enabled), tracing_enabled_(tracing_enabled),
is_concurrent_inlining_(is_concurrent_inlining), is_concurrent_inlining_(is_concurrent_inlining),
is_isolate_bootstrapping_(isolate->bootstrapper()->IsActive()),
code_kind_(code_kind), code_kind_(code_kind),
feedback_(zone()), feedback_(zone()),
property_access_infos_(zone()), property_access_infos_(zone()),
minimorphic_property_access_infos_(zone()), minimorphic_property_access_infos_(zone()) {
typed_array_string_tags_(zone()) {
// Note that this initialization of {refs_} with the minimal initial capacity // Note that this initialization of {refs_} with the minimal initial capacity
// is redundant in the normal use case (concurrent compilation enabled, // is redundant in the normal use case (concurrent compilation enabled,
// standard objects to be serialized), as the map is going to be replaced // standard objects to be serialized), as the map is going to be replaced
...@@ -220,20 +218,6 @@ bool JSHeapBroker::ObjectMayBeUninitialized(HeapObject object) const { ...@@ -220,20 +218,6 @@ bool JSHeapBroker::ObjectMayBeUninitialized(HeapObject object) const {
return !IsMainThread() && isolate()->heap()->IsPendingAllocation(object); return !IsMainThread() && isolate()->heap()->IsPendingAllocation(object);
} }
bool CanInlineElementAccess(MapRef const& map) {
if (!map.IsJSObjectMap()) return false;
if (map.is_access_check_needed()) return false;
if (map.has_indexed_interceptor()) return false;
ElementsKind const elements_kind = map.elements_kind();
if (IsFastElementsKind(elements_kind)) return true;
if (IsTypedArrayElementsKind(elements_kind) &&
elements_kind != BIGUINT64_ELEMENTS &&
elements_kind != BIGINT64_ELEMENTS) {
return true;
}
return false;
}
ProcessedFeedback::ProcessedFeedback(Kind kind, FeedbackSlotKind slot_kind) ProcessedFeedback::ProcessedFeedback(Kind kind, FeedbackSlotKind slot_kind)
: kind_(kind), slot_kind_(slot_kind) {} : kind_(kind), slot_kind_(slot_kind) {}
...@@ -884,7 +868,7 @@ ElementAccessFeedback const& JSHeapBroker::ProcessFeedbackMapsForElementAccess( ...@@ -884,7 +868,7 @@ ElementAccessFeedback const& JSHeapBroker::ProcessFeedbackMapsForElementAccess(
map.SerializeRootMap(NotConcurrentInliningTag{this}); map.SerializeRootMap(NotConcurrentInliningTag{this});
} }
if (CanInlineElementAccess(map) && if (map.CanInlineElementAccess() &&
IsFastElementsKind(map.elements_kind()) && IsFastElementsKind(map.elements_kind()) &&
GetInitialFastElementsKind() != map.elements_kind()) { GetInitialFastElementsKind() != map.elements_kind()) {
possible_transition_targets.push_back(map.object()); possible_transition_targets.push_back(map.object());
......
...@@ -117,7 +117,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker { ...@@ -117,7 +117,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
Zone* zone() const { return zone_; } Zone* zone() const { return zone_; }
bool tracing_enabled() const { return tracing_enabled_; } bool tracing_enabled() const { return tracing_enabled_; }
bool is_concurrent_inlining() const { return is_concurrent_inlining_; } bool is_concurrent_inlining() const { return is_concurrent_inlining_; }
bool is_isolate_bootstrapping() const { return is_isolate_bootstrapping_; }
bool is_turboprop() const { return code_kind_ == CodeKind::TURBOPROP; } bool is_turboprop() const { return code_kind_ == CodeKind::TURBOPROP; }
NexusConfig feedback_nexus_config() const { NexusConfig feedback_nexus_config() const {
...@@ -291,8 +290,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker { ...@@ -291,8 +290,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
void IncrementTracingIndentation(); void IncrementTracingIndentation();
void DecrementTracingIndentation(); void DecrementTracingIndentation();
RootIndexMap const& root_index_map() { return root_index_map_; }
// Locks {mutex} through the duration of this scope iff it is the first // Locks {mutex} through the duration of this scope iff it is the first
// occurrence. This is done to have a recursive shared lock on {mutex}. // occurrence. This is done to have a recursive shared lock on {mutex}.
class V8_NODISCARD RecursiveSharedMutexGuardIfNeeded { class V8_NODISCARD RecursiveSharedMutexGuardIfNeeded {
...@@ -389,8 +386,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker { ...@@ -389,8 +386,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
void CollectArrayAndObjectPrototypes(); void CollectArrayAndObjectPrototypes();
PerIsolateCompilerCache* compiler_cache() const { return compiler_cache_; }
void set_persistent_handles( void set_persistent_handles(
std::unique_ptr<PersistentHandles> persistent_handles) { std::unique_ptr<PersistentHandles> persistent_handles) {
DCHECK_NULL(ph_); DCHECK_NULL(ph_);
...@@ -419,7 +414,7 @@ class V8_EXPORT_PRIVATE JSHeapBroker { ...@@ -419,7 +414,7 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
std::unique_ptr<CanonicalHandlesMap> canonical_handles); std::unique_ptr<CanonicalHandlesMap> canonical_handles);
Isolate* const isolate_; Isolate* const isolate_;
Zone* const zone_ = nullptr; Zone* const zone_;
base::Optional<NativeContextRef> target_native_context_; base::Optional<NativeContextRef> target_native_context_;
RefsMap* refs_; RefsMap* refs_;
RootIndexMap root_index_map_; RootIndexMap root_index_map_;
...@@ -429,13 +424,11 @@ class V8_EXPORT_PRIVATE JSHeapBroker { ...@@ -429,13 +424,11 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
BrokerMode mode_ = kDisabled; BrokerMode mode_ = kDisabled;
bool const tracing_enabled_; bool const tracing_enabled_;
bool const is_concurrent_inlining_; bool const is_concurrent_inlining_;
bool const is_isolate_bootstrapping_;
CodeKind const code_kind_; CodeKind const code_kind_;
std::unique_ptr<PersistentHandles> ph_; std::unique_ptr<PersistentHandles> ph_;
LocalIsolate* local_isolate_ = nullptr; LocalIsolate* local_isolate_ = nullptr;
std::unique_ptr<CanonicalHandlesMap> canonical_handles_; std::unique_ptr<CanonicalHandlesMap> canonical_handles_;
unsigned trace_indentation_ = 0; unsigned trace_indentation_ = 0;
PerIsolateCompilerCache* compiler_cache_ = nullptr;
ZoneUnorderedMap<FeedbackSource, ProcessedFeedback const*, ZoneUnorderedMap<FeedbackSource, ProcessedFeedback const*,
FeedbackSource::Hash, FeedbackSource::Equal> FeedbackSource::Hash, FeedbackSource::Equal>
feedback_; feedback_;
...@@ -446,8 +439,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker { ...@@ -446,8 +439,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
FeedbackSource::Hash, FeedbackSource::Equal> FeedbackSource::Hash, FeedbackSource::Equal>
minimorphic_property_access_infos_; minimorphic_property_access_infos_;
ZoneVector<ObjectData*> typed_array_string_tags_;
CompilationDependencies* dependencies_ = nullptr; CompilationDependencies* dependencies_ = nullptr;
// The MapUpdater mutex is used in recursive patterns; for example, // The MapUpdater mutex is used in recursive patterns; for example,
...@@ -460,7 +451,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker { ...@@ -460,7 +451,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
// Likewise for boilerplate migrations. // Likewise for boilerplate migrations.
int boilerplate_migration_mutex_depth_ = 0; int boilerplate_migration_mutex_depth_ = 0;
static constexpr size_t kMaxSerializedFunctionsCacheSize = 200;
static constexpr uint32_t kMinimalRefsBucketCount = 8; static constexpr uint32_t kMinimalRefsBucketCount = 8;
STATIC_ASSERT(base::bits::IsPowerOfTwo(kMinimalRefsBucketCount)); STATIC_ASSERT(base::bits::IsPowerOfTwo(kMinimalRefsBucketCount));
static constexpr uint32_t kInitialRefsBucketCount = 1024; static constexpr uint32_t kInitialRefsBucketCount = 1024;
...@@ -487,21 +477,6 @@ class V8_NODISCARD TraceScope { ...@@ -487,21 +477,6 @@ class V8_NODISCARD TraceScope {
JSHeapBroker* const broker_; JSHeapBroker* const broker_;
}; };
#define ASSIGN_RETURN_NO_CHANGE_IF_DATA_MISSING(something_var, \
optionally_something) \
auto optionally_something_ = optionally_something; \
if (!optionally_something_) \
return NoChangeBecauseOfMissingData(broker(), __FUNCTION__, __LINE__); \
something_var = *optionally_something_;
class Reduction;
Reduction NoChangeBecauseOfMissingData(JSHeapBroker* broker,
const char* function, int line);
// Miscellaneous definitions that should be moved elsewhere once concurrent
// compilation is finished.
bool CanInlineElementAccess(MapRef const& map);
// Scope that unparks the LocalHeap, if: // Scope that unparks the LocalHeap, if:
// a) We have a JSHeapBroker, // a) We have a JSHeapBroker,
// b) Said JSHeapBroker has a LocalIsolate and thus a LocalHeap, // b) Said JSHeapBroker has a LocalIsolate and thus a LocalHeap,
......
...@@ -998,9 +998,9 @@ Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) { ...@@ -998,9 +998,9 @@ Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) {
HeapObjectMatcher m(input); HeapObjectMatcher m(input);
if (m.HasResolvedValue() && m.Ref(broker()).IsString()) { if (m.HasResolvedValue() && m.Ref(broker()).IsString()) {
StringRef input_value = m.Ref(broker()).AsString(); StringRef input_value = m.Ref(broker()).AsString();
double number; base::Optional<double> number = input_value.ToNumber();
ASSIGN_RETURN_NO_CHANGE_IF_DATA_MISSING(number, input_value.ToNumber()); if (!number.has_value()) return NoChange();
return Replace(jsgraph()->Constant(number)); return Replace(jsgraph()->Constant(number.value()));
} }
} }
if (input_type.IsHeapConstant()) { if (input_type.IsHeapConstant()) {
......
...@@ -814,9 +814,9 @@ Reduction TypedOptimization::ReduceJSToNumberInput(Node* input) { ...@@ -814,9 +814,9 @@ Reduction TypedOptimization::ReduceJSToNumberInput(Node* input) {
HeapObjectMatcher m(input); HeapObjectMatcher m(input);
if (m.HasResolvedValue() && m.Ref(broker()).IsString()) { if (m.HasResolvedValue() && m.Ref(broker()).IsString()) {
StringRef input_value = m.Ref(broker()).AsString(); StringRef input_value = m.Ref(broker()).AsString();
double number; base::Optional<double> number = input_value.ToNumber();
ASSIGN_RETURN_NO_CHANGE_IF_DATA_MISSING(number, input_value.ToNumber()); if (!number.has_value()) return NoChange();
return Replace(jsgraph()->Constant(number)); return Replace(jsgraph()->Constant(number.value()));
} }
} }
if (input_type.IsHeapConstant()) { if (input_type.IsHeapConstant()) {
......
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