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/code-factory.h"
9 #include "src/compiler/graph-reducer.h"
10 #include "src/compiler/linkage.h"
11 #include "src/compiler/opcodes.h"
17 // Forward declarations.
18 class CommonOperatorBuilder;
20 class MachineOperatorBuilder;
24 // Lowers JS-level operators to runtime and IC calls in the "generic" case.
25 class JSGenericLowering FINAL : public Reducer {
27 JSGenericLowering(bool is_typing_enabled, JSGraph* jsgraph);
28 ~JSGenericLowering() FINAL;
30 Reduction Reduce(Node* node) FINAL;
33 #define DECLARE_LOWER(x) void Lower##x(Node* node);
34 // Dispatched depending on opcode.
35 JS_OP_LIST(DECLARE_LOWER)
38 // 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 void ReplaceWithBuiltinCall(Node* node, Builtins::JavaScript id, int args);
42 void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1);
44 // Helper for optimization of JSCallFunction.
45 bool TryLowerDirectJSCall(Node* node);
48 Isolate* isolate() const;
49 JSGraph* jsgraph() const { return jsgraph_; }
51 CommonOperatorBuilder* common() const;
52 MachineOperatorBuilder* machine() const;
55 bool const is_typing_enabled_;
56 JSGraph* const jsgraph_;
59 } // namespace compiler
60 } // namespace internal
63 #endif // V8_COMPILER_JS_GENERIC_LOWERING_H_