Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(710)

Unified Diff: src/compiler/js-context-specialization.h

Issue 2841613002: [compiler][modules] Constant-fold the loads of module cells. (Closed)
Patch Set: Address feedback. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/compiler/js-context-specialization.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-context-specialization.h
diff --git a/src/compiler/js-context-specialization.h b/src/compiler/js-context-specialization.h
index a38aca80bb30aef953ec618954ac3b8d28af01ce..0cf2bc1e54cb1300307f46db77ec1cfffdfe3cdf 100644
--- a/src/compiler/js-context-specialization.h
+++ b/src/compiler/js-context-specialization.h
@@ -15,17 +15,29 @@ namespace compiler {
class JSGraph;
class JSOperatorBuilder;
+// Pair of a context and its distance from some point of reference.
+struct OuterContext {
+ OuterContext() : context(), distance() {}
+ OuterContext(Handle<Context> context_, size_t distance_)
+ : context(context_), distance(distance_) {}
+ Handle<Context> context;
+ size_t distance;
+};
// Specializes a given JSGraph to a given context, potentially constant folding
// some {LoadContext} nodes or strength reducing some {StoreContext} nodes.
+// Additionally, constant-folds the function parameter if {closure} is given.
+//
+// The context can be the incoming function context or any outer context
+// thereof, as indicated by {outer}'s {distance}.
class JSContextSpecialization final : public AdvancedReducer {
public:
JSContextSpecialization(Editor* editor, JSGraph* jsgraph,
- MaybeHandle<Context> context,
+ Maybe<OuterContext> outer,
MaybeHandle<JSFunction> closure)
: AdvancedReducer(editor),
jsgraph_(jsgraph),
- context_(context),
+ outer_(outer),
closure_(closure) {}
Reduction Reduce(Node* node) final;
@@ -43,11 +55,11 @@ class JSContextSpecialization final : public AdvancedReducer {
Isolate* isolate() const;
JSOperatorBuilder* javascript() const;
JSGraph* jsgraph() const { return jsgraph_; }
- MaybeHandle<Context> context() const { return context_; }
+ Maybe<OuterContext> outer() const { return outer_; }
MaybeHandle<JSFunction> closure() const { return closure_; }
JSGraph* const jsgraph_;
- MaybeHandle<Context> context_;
+ Maybe<OuterContext> outer_;
MaybeHandle<JSFunction> closure_;
DISALLOW_COPY_AND_ASSIGN(JSContextSpecialization);
« no previous file with comments | « no previous file | src/compiler/js-context-specialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698