js-generic-lowering.h 1.73 KB
Newer Older
1 2 3 4 5 6
// 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_GENERIC_LOWERING_H_
#define V8_COMPILER_JS_GENERIC_LOWERING_H_

7
#include "src/code-factory.h"
8
#include "src/compiler/graph-reducer.h"
9
#include "src/compiler/linkage.h"
10 11 12 13 14 15 16 17
#include "src/compiler/opcodes.h"

namespace v8 {
namespace internal {
namespace compiler {

// Forward declarations.
class CommonOperatorBuilder;
18
class JSGraph;
19 20 21
class MachineOperatorBuilder;
class Linkage;

22

23
// Lowers JS-level operators to runtime and IC calls in the "generic" case.
24
class JSGenericLowering final : public Reducer {
25
 public:
26
  explicit JSGenericLowering(JSGraph* jsgraph);
27
  ~JSGenericLowering() final;
28

29 30
  const char* reducer_name() const override { return "JSGenericLowering"; }

31
  Reduction Reduce(Node* node) final;
32 33

 protected:
34 35
#define DECLARE_LOWER(x) void Lower##x(Node* node);
  // Dispatched depending on opcode.
36
  JS_OP_LIST(DECLARE_LOWER)
37 38 39
#undef DECLARE_LOWER

  // Helpers to replace existing nodes with a generic call.
40
  void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags);
41
  void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags,
42
                           Operator::Properties properties);
43 44
  void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1);

45 46
  Zone* zone() const;
  Isolate* isolate() const;
47
  JSGraph* jsgraph() const { return jsgraph_; }
48 49 50
  Graph* graph() const;
  CommonOperatorBuilder* common() const;
  MachineOperatorBuilder* machine() const;
51 52

 private:
53
  JSGraph* const jsgraph_;
54
};
55 56 57 58

}  // namespace compiler
}  // namespace internal
}  // namespace v8
59 60

#endif  // V8_COMPILER_JS_GENERIC_LOWERING_H_