js-generic-lowering.h 1.7 KB
Newer Older
1 2 3 4 5 6 7
// 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_

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

namespace v8 {
namespace internal {
namespace compiler {

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

23

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

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

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

  // Helpers to replace existing nodes with a generic call.
39
  void ReplaceWithCompareIC(Node* node, Token::Value token);
40
  void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags);
41 42 43
  void ReplaceWithBuiltinCall(Node* node, Builtins::JavaScript id, int args);
  void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1);

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

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

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

#endif  // V8_COMPILER_JS_GENERIC_LOWERING_H_