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 : #ifndef V8_COMPILER_JS_GENERIC_LOWERING_H_
5 : #define V8_COMPILER_JS_GENERIC_LOWERING_H_
6 :
7 : #include "src/code-factory.h"
8 : #include "src/compiler/graph-reducer.h"
9 : #include "src/compiler/linkage.h"
10 : #include "src/compiler/opcodes.h"
11 :
12 : namespace v8 {
13 : namespace internal {
14 : namespace compiler {
15 :
16 : // Forward declarations.
17 : class CommonOperatorBuilder;
18 : class JSGraph;
19 : class MachineOperatorBuilder;
20 : class Linkage;
21 :
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 0 : const char* reducer_name() const override { return "JSGenericLowering"; }
30 :
31 : Reduction Reduce(Node* node) final;
32 :
33 : protected:
34 : #define DECLARE_LOWER(x) void Lower##x(Node* node);
35 : // Dispatched depending on opcode.
36 : JS_OP_LIST(DECLARE_LOWER)
37 : #undef DECLARE_LOWER
38 :
39 : // 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 : int result_size = 1);
44 : void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1);
45 :
46 : Zone* zone() const;
47 : Isolate* isolate() const;
48 : JSGraph* jsgraph() const { return jsgraph_; }
49 : Graph* graph() const;
50 : CommonOperatorBuilder* common() const;
51 : MachineOperatorBuilder* machine() const;
52 :
53 : private:
54 : JSGraph* const jsgraph_;
55 : };
56 :
57 : } // namespace compiler
58 : } // namespace internal
59 : } // namespace v8
60 :
61 : #endif // V8_COMPILER_JS_GENERIC_LOWERING_H_
|