Commit 04233e10 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Minor broker cleanups

Such as making the Disallow* scope always the first thing in a function,
and const-ifying a few members.

Bug: v8:7790
Change-Id: I78e0701101ee63475bfa30230a2da54da730ba73
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1679508
Auto-Submit: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62418}
parent 72e84bc1
...@@ -2735,10 +2735,9 @@ Reduction JSCallReducer::ReduceArraySome(Node* node, ...@@ -2735,10 +2735,9 @@ Reduction JSCallReducer::ReduceArraySome(Node* node,
Reduction JSCallReducer::ReduceCallApiFunction( Reduction JSCallReducer::ReduceCallApiFunction(
Node* node, const SharedFunctionInfoRef& shared) { Node* node, const SharedFunctionInfoRef& shared) {
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
DisallowHeapAccessIf no_heap_acess(FLAG_concurrent_inlining); DisallowHeapAccessIf no_heap_acess(FLAG_concurrent_inlining);
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
CallParameters const& p = CallParametersOf(node->op()); CallParameters const& p = CallParametersOf(node->op());
int const argc = static_cast<int>(p.arity()) - 2; int const argc = static_cast<int>(p.arity()) - 2;
Node* target = NodeProperties::GetValueInput(node, 0); Node* target = NodeProperties::GetValueInput(node, 0);
...@@ -5583,16 +5582,16 @@ Node* JSCallReducer::CreateArtificialFrameState( ...@@ -5583,16 +5582,16 @@ Node* JSCallReducer::CreateArtificialFrameState(
} }
Reduction JSCallReducer::ReducePromiseConstructor(Node* node) { Reduction JSCallReducer::ReducePromiseConstructor(Node* node) {
DisallowHeapAccessIf no_heap_access(FLAG_concurrent_inlining);
DCHECK_EQ(IrOpcode::kJSConstruct, node->opcode()); DCHECK_EQ(IrOpcode::kJSConstruct, node->opcode());
ConstructParameters const& p = ConstructParametersOf(node->op()); ConstructParameters const& p = ConstructParametersOf(node->op());
DisallowHeapAccessIf no_heap_access(FLAG_concurrent_inlining);
int arity = static_cast<int>(p.arity() - 2); int arity = static_cast<int>(p.arity() - 2);
// We only inline when we have the executor. // We only inline when we have the executor.
if (arity < 1) return NoChange(); if (arity < 1) return NoChange();
Node* target = NodeProperties::GetValueInput(node, 0); Node* target = NodeProperties::GetValueInput(node, 0);
Node* executor = NodeProperties::GetValueInput(node, 1); Node* executor = NodeProperties::GetValueInput(node, 1);
Node* new_target = NodeProperties::GetValueInput(node, arity + 1); Node* new_target = NodeProperties::GetValueInput(node, arity + 1);
Node* context = NodeProperties::GetContextInput(node); Node* context = NodeProperties::GetContextInput(node);
Node* outer_frame_state = NodeProperties::GetFrameStateInput(node); Node* outer_frame_state = NodeProperties::GetFrameStateInput(node);
Node* effect = NodeProperties::GetEffectInput(node); Node* effect = NodeProperties::GetEffectInput(node);
...@@ -5816,8 +5815,7 @@ bool JSCallReducer::DoPromiseChecks(MapInference* inference) { ...@@ -5816,8 +5815,7 @@ bool JSCallReducer::DoPromiseChecks(MapInference* inference) {
if (!FLAG_concurrent_inlining) { if (!FLAG_concurrent_inlining) {
receiver_map.SerializePrototype(); receiver_map.SerializePrototype();
} else if (!receiver_map.serialized_prototype()) { } else if (!receiver_map.serialized_prototype()) {
TRACE_BROKER_MISSING(broker(), TRACE_BROKER_MISSING(broker(), "prototype for map " << receiver_map);
"Unserialized prototype for map " << receiver_map);
return false; return false;
} }
if (!receiver_map.prototype().equals( if (!receiver_map.prototype().equals(
...@@ -5880,9 +5878,10 @@ Node* JSCallReducer::CreateClosureFromBuiltinSharedFunctionInfo( ...@@ -5880,9 +5878,10 @@ Node* JSCallReducer::CreateClosureFromBuiltinSharedFunctionInfo(
// ES section #sec-promise.prototype.finally // ES section #sec-promise.prototype.finally
Reduction JSCallReducer::ReducePromisePrototypeFinally(Node* node) { Reduction JSCallReducer::ReducePromisePrototypeFinally(Node* node) {
DisallowHeapAccessIf no_heap_access(FLAG_concurrent_inlining);
DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
CallParameters const& p = CallParametersOf(node->op()); CallParameters const& p = CallParametersOf(node->op());
DisallowHeapAccessIf no_heap_access(FLAG_concurrent_inlining);
int arity = static_cast<int>(p.arity() - 2); int arity = static_cast<int>(p.arity() - 2);
Node* receiver = NodeProperties::GetValueInput(node, 1); Node* receiver = NodeProperties::GetValueInput(node, 1);
Node* on_finally = arity >= 1 ? NodeProperties::GetValueInput(node, 2) Node* on_finally = arity >= 1 ? NodeProperties::GetValueInput(node, 2)
...@@ -5994,6 +5993,8 @@ Reduction JSCallReducer::ReducePromisePrototypeFinally(Node* node) { ...@@ -5994,6 +5993,8 @@ Reduction JSCallReducer::ReducePromisePrototypeFinally(Node* node) {
} }
Reduction JSCallReducer::ReducePromisePrototypeThen(Node* node) { Reduction JSCallReducer::ReducePromisePrototypeThen(Node* node) {
DisallowHeapAccessIf no_heap_acess(FLAG_concurrent_inlining);
DCHECK_EQ(IrOpcode::kJSCall, node->opcode()); DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
CallParameters const& p = CallParametersOf(node->op()); CallParameters const& p = CallParametersOf(node->op());
if (p.speculation_mode() == SpeculationMode::kDisallowSpeculation) { if (p.speculation_mode() == SpeculationMode::kDisallowSpeculation) {
...@@ -6012,7 +6013,6 @@ Reduction JSCallReducer::ReducePromisePrototypeThen(Node* node) { ...@@ -6012,7 +6013,6 @@ Reduction JSCallReducer::ReducePromisePrototypeThen(Node* node) {
Node* control = NodeProperties::GetControlInput(node); Node* control = NodeProperties::GetControlInput(node);
Node* frame_state = NodeProperties::GetFrameStateInput(node); Node* frame_state = NodeProperties::GetFrameStateInput(node);
DisallowHeapAccessIf no_heap_acess(FLAG_concurrent_inlining);
MapInference inference(broker(), receiver, effect); MapInference inference(broker(), receiver, effect);
if (!DoPromiseChecks(&inference)) return inference.NoChange(); if (!DoPromiseChecks(&inference)) return inference.NoChange();
...@@ -6061,9 +6061,9 @@ Reduction JSCallReducer::ReducePromisePrototypeThen(Node* node) { ...@@ -6061,9 +6061,9 @@ Reduction JSCallReducer::ReducePromisePrototypeThen(Node* node) {
// ES section #sec-promise.resolve // ES section #sec-promise.resolve
Reduction JSCallReducer::ReducePromiseResolveTrampoline(Node* node) { Reduction JSCallReducer::ReducePromiseResolveTrampoline(Node* node) {
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
DisallowHeapAccessIf no_heap_acess(FLAG_concurrent_inlining); DisallowHeapAccessIf no_heap_acess(FLAG_concurrent_inlining);
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
Node* receiver = NodeProperties::GetValueInput(node, 1); Node* receiver = NodeProperties::GetValueInput(node, 1);
Node* value = node->op()->ValueInputCount() > 2 Node* value = node->op()->ValueInputCount() > 2
? NodeProperties::GetValueInput(node, 2) ? NodeProperties::GetValueInput(node, 2)
......
...@@ -2003,8 +2003,8 @@ JSHeapBroker::JSHeapBroker(Isolate* isolate, Zone* broker_zone, ...@@ -2003,8 +2003,8 @@ JSHeapBroker::JSHeapBroker(Isolate* isolate, Zone* broker_zone,
refs_(new (zone()) refs_(new (zone())
RefsMap(kMinimalRefsBucketCount, AddressMatcher(), zone())), RefsMap(kMinimalRefsBucketCount, AddressMatcher(), zone())),
array_and_object_prototypes_(zone()), array_and_object_prototypes_(zone()),
feedback_(zone()), tracing_enabled_(tracing_enabled),
tracing_enabled_(tracing_enabled) { feedback_(zone()) {
// Note that this initialization of the refs_ pointer with the minimal // Note that this initialization of the refs_ pointer with the minimal
// initial capacity is redundant in the normal use case (concurrent // initial capacity is redundant in the normal use case (concurrent
// compilation enabled, standard objects to be serialized), as the map // compilation enabled, standard objects to be serialized), as the map
......
...@@ -974,13 +974,13 @@ class V8_EXPORT_PRIVATE JSHeapBroker { ...@@ -974,13 +974,13 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
Handle<JSObject>::equal_to> Handle<JSObject>::equal_to>
array_and_object_prototypes_; array_and_object_prototypes_;
BrokerMode mode_ = kDisabled; BrokerMode mode_ = kDisabled;
bool const tracing_enabled_;
StdoutStream trace_out_; StdoutStream trace_out_;
unsigned trace_indentation_ = 0; unsigned trace_indentation_ = 0;
PerIsolateCompilerCache* compiler_cache_; PerIsolateCompilerCache* compiler_cache_;
ZoneUnorderedMap<FeedbackSource, ProcessedFeedback const*, ZoneUnorderedMap<FeedbackSource, ProcessedFeedback const*,
FeedbackSource::Hash, FeedbackSource::Equal> FeedbackSource::Hash, FeedbackSource::Equal>
feedback_; feedback_;
bool tracing_enabled_;
static const size_t kMinimalRefsBucketCount = 8; // must be power of 2 static const size_t kMinimalRefsBucketCount = 8; // must be power of 2
static const size_t kInitialRefsBucketCount = 1024; // must be power of 2 static const size_t kInitialRefsBucketCount = 1024; // must be power of 2
......
...@@ -1133,32 +1133,25 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall( ...@@ -1133,32 +1133,25 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall(
Handle<SharedFunctionInfo> target, const HintsVector& arguments) { Handle<SharedFunctionInfo> target, const HintsVector& arguments) {
DCHECK(target->HasBuiltinId()); DCHECK(target->HasBuiltinId());
const int builtin_id = target->builtin_id(); const int builtin_id = target->builtin_id();
const char* name = Builtins::name(builtin_id);
TRACE_BROKER(broker(), "Serializing for call to builtin " << name);
switch (builtin_id) { switch (builtin_id) {
case Builtins::kPromisePrototypeCatch: { case Builtins::kPromisePrototypeCatch: {
TRACE_BROKER(broker(),
"Serializing data for builtin PromisePrototypeCatch");
// For JSCallReducer::ReducePromisePrototypeCatch. // For JSCallReducer::ReducePromisePrototypeCatch.
CHECK_GE(arguments.size(), 1); CHECK_GE(arguments.size(), 1);
Hints const& receiver_hints = arguments[0]; ProcessMapHintsForPromises(arguments[0]);
ProcessMapHintsForPromises(receiver_hints);
break; break;
} }
case Builtins::kPromisePrototypeFinally: { case Builtins::kPromisePrototypeFinally: {
TRACE_BROKER(broker(),
"Serializing data for builtin PromisePrototypeFinally");
// For JSCallReducer::ReducePromisePrototypeFinally. // For JSCallReducer::ReducePromisePrototypeFinally.
CHECK_GE(arguments.size(), 1); CHECK_GE(arguments.size(), 1);
Hints const& receiver_hints = arguments[0]; ProcessMapHintsForPromises(arguments[0]);
ProcessMapHintsForPromises(receiver_hints);
break; break;
} }
case Builtins::kPromisePrototypeThen: { case Builtins::kPromisePrototypeThen: {
TRACE_BROKER(broker(),
"Serializing data for builtin PromisePrototypeThen");
// For JSCallReducer::ReducePromisePrototypeThen. // For JSCallReducer::ReducePromisePrototypeThen.
CHECK_GE(arguments.size(), 1); CHECK_GE(arguments.size(), 1);
Hints const& receiver_hints = arguments[0]; ProcessMapHintsForPromises(arguments[0]);
ProcessMapHintsForPromises(receiver_hints);
break; break;
} }
default: default:
...@@ -1169,17 +1162,15 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall( ...@@ -1169,17 +1162,15 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall(
void SerializerForBackgroundCompilation::ProcessMapHintsForPromises( void SerializerForBackgroundCompilation::ProcessMapHintsForPromises(
Hints const& receiver_hints) { Hints const& receiver_hints) {
// We need to serialize the prototypes on each receiver map. // We need to serialize the prototypes on each receiver map.
for (auto hint : receiver_hints.constants()) { for (auto constant : receiver_hints.constants()) {
if (!hint->IsJSPromise()) continue; if (!constant->IsJSPromise()) continue;
Handle<JSReceiver> receiver(Handle<JSReceiver>::cast(hint)); Handle<Map> map(Handle<HeapObject>::cast(constant)->map(),
MapRef receiver_mapref(broker(), broker()->isolate());
handle(receiver->map(), broker()->isolate())); MapRef(broker(), map).SerializePrototype();
receiver_mapref.SerializePrototype(); }
} for (auto map : receiver_hints.maps()) {
for (auto receiver_map : receiver_hints.maps()) { if (!map->IsJSPromiseMap()) continue;
if (!receiver_map->IsJSPromiseMap()) continue; MapRef(broker(), map).SerializePrototype();
MapRef receiver_mapref(broker(), receiver_map);
receiver_mapref.SerializePrototype();
} }
} }
......
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