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