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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/compiler/js-context-specialization.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_ 5 #ifndef V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_
6 #define V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_ 6 #define V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_
7 7
8 #include "src/compiler/graph-reducer.h" 8 #include "src/compiler/graph-reducer.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 namespace compiler { 12 namespace compiler {
13 13
14 // Forward declarations. 14 // Forward declarations.
15 class JSGraph; 15 class JSGraph;
16 class JSOperatorBuilder; 16 class JSOperatorBuilder;
17 17
18 // Pair of a context and its distance from some point of reference.
19 struct OuterContext {
20 OuterContext() : context(), distance() {}
21 OuterContext(Handle<Context> context_, size_t distance_)
22 : context(context_), distance(distance_) {}
23 Handle<Context> context;
24 size_t distance;
25 };
18 26
19 // Specializes a given JSGraph to a given context, potentially constant folding 27 // Specializes a given JSGraph to a given context, potentially constant folding
20 // some {LoadContext} nodes or strength reducing some {StoreContext} nodes. 28 // some {LoadContext} nodes or strength reducing some {StoreContext} nodes.
29 // Additionally, constant-folds the function parameter if {closure} is given.
30 //
31 // The context can be the incoming function context or any outer context
32 // thereof, as indicated by {outer}'s {distance}.
21 class JSContextSpecialization final : public AdvancedReducer { 33 class JSContextSpecialization final : public AdvancedReducer {
22 public: 34 public:
23 JSContextSpecialization(Editor* editor, JSGraph* jsgraph, 35 JSContextSpecialization(Editor* editor, JSGraph* jsgraph,
24 MaybeHandle<Context> context, 36 Maybe<OuterContext> outer,
25 MaybeHandle<JSFunction> closure) 37 MaybeHandle<JSFunction> closure)
26 : AdvancedReducer(editor), 38 : AdvancedReducer(editor),
27 jsgraph_(jsgraph), 39 jsgraph_(jsgraph),
28 context_(context), 40 outer_(outer),
29 closure_(closure) {} 41 closure_(closure) {}
30 42
31 Reduction Reduce(Node* node) final; 43 Reduction Reduce(Node* node) final;
32 44
33 private: 45 private:
34 Reduction ReduceParameter(Node* node); 46 Reduction ReduceParameter(Node* node);
35 Reduction ReduceJSLoadContext(Node* node); 47 Reduction ReduceJSLoadContext(Node* node);
36 Reduction ReduceJSStoreContext(Node* node); 48 Reduction ReduceJSStoreContext(Node* node);
37 49
38 Reduction SimplifyJSStoreContext(Node* node, Node* new_context, 50 Reduction SimplifyJSStoreContext(Node* node, Node* new_context,
39 size_t new_depth); 51 size_t new_depth);
40 Reduction SimplifyJSLoadContext(Node* node, Node* new_context, 52 Reduction SimplifyJSLoadContext(Node* node, Node* new_context,
41 size_t new_depth); 53 size_t new_depth);
42 54
43 Isolate* isolate() const; 55 Isolate* isolate() const;
44 JSOperatorBuilder* javascript() const; 56 JSOperatorBuilder* javascript() const;
45 JSGraph* jsgraph() const { return jsgraph_; } 57 JSGraph* jsgraph() const { return jsgraph_; }
46 MaybeHandle<Context> context() const { return context_; } 58 Maybe<OuterContext> outer() const { return outer_; }
47 MaybeHandle<JSFunction> closure() const { return closure_; } 59 MaybeHandle<JSFunction> closure() const { return closure_; }
48 60
49 JSGraph* const jsgraph_; 61 JSGraph* const jsgraph_;
50 MaybeHandle<Context> context_; 62 Maybe<OuterContext> outer_;
51 MaybeHandle<JSFunction> closure_; 63 MaybeHandle<JSFunction> closure_;
52 64
53 DISALLOW_COPY_AND_ASSIGN(JSContextSpecialization); 65 DISALLOW_COPY_AND_ASSIGN(JSContextSpecialization);
54 }; 66 };
55 67
56 } // namespace compiler 68 } // namespace compiler
57 } // namespace internal 69 } // namespace internal
58 } // namespace v8 70 } // namespace v8
59 71
60 #endif // V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_ 72 #endif // V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_
OLDNEW
« 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