#ifndef V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_
#define V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_
#include "src/compiler/graph-reducer.h"
#include "src/handles/maybe-handles.h"
namespace v8 {
namespace internal {
namespace compiler {
class JSGraph;
class JSOperatorBuilder;
struct OuterContext {
OuterContext() = default;
OuterContext(IndirectHandle<Context> context_, size_t distance_)
: context(context_), distance(distance_) {}
IndirectHandle<Context> context;
size_t distance = 0;
};
class V8_EXPORT_PRIVATE JSContextSpecialization final : public AdvancedReducer {
public:
JSContextSpecialization(Editor* editor, JSGraph* jsgraph,
JSHeapBroker* broker, Maybe<OuterContext> outer,
MaybeHandle<JSFunction> closure)
: AdvancedReducer(editor),
jsgraph_(jsgraph),
outer_(outer),
closure_(closure),
broker_(broker) {}
JSContextSpecialization(const JSContextSpecialization&) = delete;
JSContextSpecialization& operator=(const JSContextSpecialization&) = delete;
const char* reducer_name() const override {
return "JSContextSpecialization";
}
Reduction Reduce(Node* node) final;
private:
Reduction ReduceParameter(Node* node);
Reduction ReduceJSLoadContextNoCell(Node* node);
Reduction ReduceJSLoadContext(Node* node);
Reduction ReduceJSStoreContextNoCell(Node* node);
Reduction ReduceJSStoreContext(Node* node);
Reduction ReduceJSGetImportMeta(Node* node);
Reduction SimplifyJSLoadContextNoCell(Node* node, Node* new_context,
size_t new_depth);
Reduction SimplifyJSLoadContext(Node* node, Node* new_context,
size_t new_depth);
Reduction SimplifyJSStoreContextNoCell(Node* node, Node* new_context,
size_t new_depth);
Reduction SimplifyJSStoreContext(Node* node, Node* new_context,
size_t new_depth);
Isolate* isolate() const;
JSGraph* jsgraph() const { return jsgraph_; }
Maybe<OuterContext> outer() const { return outer_; }
MaybeHandle<JSFunction> closure() const { return closure_; }
JSHeapBroker* broker() const { return broker_; }
JSGraph* const jsgraph_;
Maybe<OuterContext> outer_;
MaybeHandle<JSFunction> closure_;
JSHeapBroker* const broker_;
};
}
}
}
#endif