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.
5 #ifndef V8_COMPILER_JS_GENERIC_LOWERING_H_
6 #define V8_COMPILER_JS_GENERIC_LOWERING_H_
8 #include "src/allocation.h"
9 #include "src/code-factory.h"
10 #include "src/compiler/graph.h"
11 #include "src/compiler/graph-reducer.h"
12 #include "src/compiler/js-graph.h"
13 #include "src/compiler/linkage.h"
14 #include "src/compiler/opcodes.h"
20 // Forward declarations.
21 class CommonOperatorBuilder;
22 class MachineOperatorBuilder;
26 // Lowers JS-level operators to runtime and IC calls in the "generic" case.
27 class JSGenericLowering FINAL : public Reducer {
29 JSGenericLowering(bool is_typing_enabled, JSGraph* graph);
30 ~JSGenericLowering() FINAL {}
32 Reduction Reduce(Node* node) FINAL;
35 #define DECLARE_LOWER(x) void Lower##x(Node* node);
36 // Dispatched depending on opcode.
37 JS_OP_LIST(DECLARE_LOWER)
40 // Helpers to replace existing nodes with a generic call.
41 void ReplaceWithCompareIC(Node* node, Token::Value token);
42 void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags);
43 void ReplaceWithBuiltinCall(Node* node, Builtins::JavaScript id, int args);
44 void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1);
46 // Helper for optimization of JSCallFunction.
47 bool TryLowerDirectJSCall(Node* node);
49 Zone* zone() const { return graph()->zone(); }
50 Isolate* isolate() const { return jsgraph()->isolate(); }
51 JSGraph* jsgraph() const { return jsgraph_; }
52 Graph* graph() const { return jsgraph()->graph(); }
53 CommonOperatorBuilder* common() const { return jsgraph()->common(); }
54 MachineOperatorBuilder* machine() const { return jsgraph()->machine(); }
57 bool is_typing_enabled_;
61 } // namespace compiler
62 } // namespace internal
65 #endif // V8_COMPILER_JS_GENERIC_LOWERING_H_