js-context-specialization.h 1.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_
#define V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_

#include "src/compiler/graph-reducer.h"

namespace v8 {
namespace internal {
namespace compiler {

14 15 16 17 18
// Forward declarations.
class JSGraph;
class JSOperatorBuilder;


19
// Specializes a given JSGraph to a given context, potentially constant folding
20
// some {LoadContext} nodes or strength reducing some {StoreContext} nodes.
21
class JSContextSpecialization final : public AdvancedReducer {
22
 public:
23 24 25
  JSContextSpecialization(Editor* editor, JSGraph* jsgraph,
                          MaybeHandle<Context> context)
      : AdvancedReducer(editor), jsgraph_(jsgraph), context_(context) {}
26

27
  Reduction Reduce(Node* node) final;
28

29
 private:
30
  Reduction ReduceJSLoadContext(Node* node);
31
  Reduction ReduceJSStoreContext(Node* node);
32

33 34 35
  // Returns the {Context} to specialize {node} to (if any).
  MaybeHandle<Context> GetSpecializationContext(Node* node);

36 37 38
  Isolate* isolate() const;
  JSOperatorBuilder* javascript() const;
  JSGraph* jsgraph() const { return jsgraph_; }
39
  MaybeHandle<Context> context() const { return context_; }
40 41

  JSGraph* const jsgraph_;
42
  MaybeHandle<Context> context_;
43

44
  DISALLOW_COPY_AND_ASSIGN(JSContextSpecialization);
45
};
46 47 48 49

}  // namespace compiler
}  // namespace internal
}  // namespace v8
50 51

#endif  // V8_COMPILER_JS_CONTEXT_SPECIALIZATION_H_