Line data Source code
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
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_
6 : #define V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_
7 :
8 : #include "src/compiler/graph-reducer.h"
9 :
10 : namespace v8 {
11 : namespace internal {
12 : namespace compiler {
13 :
14 : // Forward declarations.
15 : class JSGraph;
16 : class JSOperatorBuilder;
17 :
18 :
19 : // Specializes a given JSGraph to a given context, potentially constant folding
20 : // some {LoadContext} nodes or strength reducing some {StoreContext} nodes.
21 395343 : class JSContextSpecialization final : public AdvancedReducer {
22 : public:
23 : JSContextSpecialization(Editor* editor, JSGraph* jsgraph,
24 : MaybeHandle<Context> context,
25 : MaybeHandle<JSFunction> closure)
26 : : AdvancedReducer(editor),
27 : jsgraph_(jsgraph),
28 : context_(context),
29 395343 : closure_(closure) {}
30 :
31 : Reduction Reduce(Node* node) final;
32 :
33 : private:
34 : Reduction ReduceParameter(Node* node);
35 : Reduction ReduceJSLoadContext(Node* node);
36 : Reduction ReduceJSStoreContext(Node* node);
37 :
38 : Reduction SimplifyJSStoreContext(Node* node, Node* new_context,
39 : size_t new_depth);
40 : Reduction SimplifyJSLoadContext(Node* node, Node* new_context,
41 : size_t new_depth);
42 :
43 : Isolate* isolate() const;
44 : JSOperatorBuilder* javascript() const;
45 : JSGraph* jsgraph() const { return jsgraph_; }
46 773125 : MaybeHandle<Context> context() const { return context_; }
47 393276 : MaybeHandle<JSFunction> closure() const { return closure_; }
48 :
49 : JSGraph* const jsgraph_;
50 : MaybeHandle<Context> context_;
51 : MaybeHandle<JSFunction> closure_;
52 :
53 : DISALLOW_COPY_AND_ASSIGN(JSContextSpecialization);
54 : };
55 :
56 : } // namespace compiler
57 : } // namespace internal
58 : } // namespace v8
59 :
60 : #endif // V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_
|