Commit 8e50bdb8 authored by Jakob Linke's avatar Jakob Linke Committed by V8 LUCI CQ

[maglev] Implement function context specialization

See also Turbofan's JSContextSpecialization reducer.

For all context loads and stores, this CL implements:

1) depth reduction through graph walks (even without FCS)
2) conversion from the context node to a heap constant
3) if possible, conversion of a load of an immutable context slot load
   to a heap constant

Bug: v8:7700
Change-Id: Ie4d1acd0ff206f25dd5373a860d23b006a31dcee
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3904914Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83418}
parent 985aec31
...@@ -477,7 +477,7 @@ DEFINE_BOOL(trace_maglev_graph_building, false, "trace maglev graph building") ...@@ -477,7 +477,7 @@ DEFINE_BOOL(trace_maglev_graph_building, false, "trace maglev graph building")
DEFINE_BOOL(trace_maglev_regalloc, false, "trace maglev register allocation") DEFINE_BOOL(trace_maglev_regalloc, false, "trace maglev register allocation")
// TODO(v8:7700): Remove once stable. // TODO(v8:7700): Remove once stable.
DEFINE_BOOL(maglev_function_context_specialization, false, DEFINE_BOOL(maglev_function_context_specialization, true,
"enable function context specialization in maglev") "enable function context specialization in maglev")
#if ENABLE_SPARKPLUG #if ENABLE_SPARKPLUG
......
This diff is collapsed.
...@@ -408,6 +408,13 @@ class MaglevGraphBuilder { ...@@ -408,6 +408,13 @@ class MaglevGraphBuilder {
return node; return node;
} }
enum ContextSlotMutability { kImmutable, kMutable };
bool TrySpecializeLoadContextSlotToFunctionContext(
ValueNode** context, size_t* depth, int slot_index,
ContextSlotMutability slot_mutability);
void BuildLoadContextSlot(ValueNode* context, size_t depth, int slot_index,
ContextSlotMutability slot_mutability);
template <Builtin kBuiltin> template <Builtin kBuiltin>
CallBuiltin* BuildCallBuiltin(std::initializer_list<ValueNode*> inputs) { CallBuiltin* BuildCallBuiltin(std::initializer_list<ValueNode*> inputs) {
using Descriptor = typename CallInterfaceDescriptorFor<kBuiltin>::type; using Descriptor = typename CallInterfaceDescriptorFor<kBuiltin>::type;
......
...@@ -2253,6 +2253,8 @@ class Constant : public FixedInputValueNodeT<0, Constant> { ...@@ -2253,6 +2253,8 @@ class Constant : public FixedInputValueNodeT<0, Constant> {
void DoLoadToRegister(MaglevAssembler*, OutputRegister); void DoLoadToRegister(MaglevAssembler*, OutputRegister);
Handle<Object> DoReify(LocalIsolate* isolate); Handle<Object> DoReify(LocalIsolate* isolate);
const compiler::HeapObjectRef& ref() const { return object_; }
private: private:
const compiler::HeapObjectRef object_; const compiler::HeapObjectRef object_;
}; };
......
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