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 reducer_name()29 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 void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1); 44 45 Zone* zone() const; 46 Isolate* isolate() const; jsgraph()47 JSGraph* jsgraph() const { return jsgraph_; } 48 Graph* graph() const; 49 CommonOperatorBuilder* common() const; 50 MachineOperatorBuilder* machine() const; 51 52 private: 53 JSGraph* const jsgraph_; 54 }; 55 56 } // namespace compiler 57 } // namespace internal 58 } // namespace v8 59 60 #endif // V8_COMPILER_JS_GENERIC_LOWERING_H_ 61