| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_JS_GENERIC_LOWERING_H_ | 5 #ifndef V8_COMPILER_JS_GENERIC_LOWERING_H_ |
| 6 #define V8_COMPILER_JS_GENERIC_LOWERING_H_ | 6 #define V8_COMPILER_JS_GENERIC_LOWERING_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| 11 #include "src/compiler/graph-reducer.h" | 11 #include "src/compiler/graph-reducer.h" |
| 12 #include "src/compiler/js-graph.h" | 12 #include "src/compiler/js-graph.h" |
| 13 #include "src/compiler/linkage.h" | 13 #include "src/compiler/linkage.h" |
| 14 #include "src/compiler/opcodes.h" | 14 #include "src/compiler/opcodes.h" |
| 15 | 15 |
| 16 namespace v8 { | 16 namespace v8 { |
| 17 namespace internal { | 17 namespace internal { |
| 18 namespace compiler { | 18 namespace compiler { |
| 19 | 19 |
| 20 // Forward declarations. | 20 // Forward declarations. |
| 21 class CommonOperatorBuilder; | 21 class CommonOperatorBuilder; |
| 22 class MachineOperatorBuilder; | 22 class MachineOperatorBuilder; |
| 23 class Linkage; | 23 class Linkage; |
| 24 | 24 |
| 25 | 25 |
| 26 // Lowers JS-level operators to runtime and IC calls in the "generic" case. | 26 // Lowers JS-level operators to runtime and IC calls in the "generic" case. |
| 27 class JSGenericLowering FINAL : public Reducer { | 27 class JSGenericLowering FINAL : public Reducer { |
| 28 public: | 28 public: |
| 29 JSGenericLowering(CompilationInfo* info, JSGraph* graph); | 29 JSGenericLowering(bool is_typing_enabled, JSGraph* graph); |
| 30 ~JSGenericLowering() FINAL {} | 30 ~JSGenericLowering() FINAL {} |
| 31 | 31 |
| 32 Reduction Reduce(Node* node) FINAL; | 32 Reduction Reduce(Node* node) FINAL; |
| 33 | 33 |
| 34 protected: | 34 protected: |
| 35 #define DECLARE_LOWER(x) void Lower##x(Node* node); | 35 #define DECLARE_LOWER(x) void Lower##x(Node* node); |
| 36 // Dispatched depending on opcode. | 36 // Dispatched depending on opcode. |
| 37 JS_OP_LIST(DECLARE_LOWER) | 37 JS_OP_LIST(DECLARE_LOWER) |
| 38 #undef DECLARE_LOWER | 38 #undef DECLARE_LOWER |
| 39 | 39 |
| 40 // Helpers to patch existing nodes in the graph. | 40 // Helpers to patch existing nodes in the graph. |
| 41 void PatchOperator(Node* node, const Operator* new_op); | 41 void PatchOperator(Node* node, const Operator* new_op); |
| 42 void PatchInsertInput(Node* node, int index, Node* input); | 42 void PatchInsertInput(Node* node, int index, Node* input); |
| 43 | 43 |
| 44 // Helpers to replace existing nodes with a generic call. | 44 // Helpers to replace existing nodes with a generic call. |
| 45 void ReplaceWithCompareIC(Node* node, Token::Value token); | 45 void ReplaceWithCompareIC(Node* node, Token::Value token); |
| 46 void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags); | 46 void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags); |
| 47 void ReplaceWithBuiltinCall(Node* node, Builtins::JavaScript id, int args); | 47 void ReplaceWithBuiltinCall(Node* node, Builtins::JavaScript id, int args); |
| 48 void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1); | 48 void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1); |
| 49 | 49 |
| 50 // Helper for optimization of JSCallFunction. | 50 // Helper for optimization of JSCallFunction. |
| 51 bool TryLowerDirectJSCall(Node* node); | 51 bool TryLowerDirectJSCall(Node* node); |
| 52 | 52 |
| 53 Zone* zone() const { return graph()->zone(); } | 53 Zone* zone() const { return graph()->zone(); } |
| 54 Isolate* isolate() const { return info_->isolate(); } | 54 Isolate* isolate() const { return jsgraph()->isolate(); } |
| 55 JSGraph* jsgraph() const { return jsgraph_; } | 55 JSGraph* jsgraph() const { return jsgraph_; } |
| 56 Graph* graph() const { return jsgraph()->graph(); } | 56 Graph* graph() const { return jsgraph()->graph(); } |
| 57 Linkage* linkage() const { return linkage_; } | |
| 58 CompilationInfo* info() const { return info_; } | |
| 59 CommonOperatorBuilder* common() const { return jsgraph()->common(); } | 57 CommonOperatorBuilder* common() const { return jsgraph()->common(); } |
| 60 MachineOperatorBuilder* machine() const { return jsgraph()->machine(); } | 58 MachineOperatorBuilder* machine() const { return jsgraph()->machine(); } |
| 61 | 59 |
| 62 private: | 60 private: |
| 63 CompilationInfo* info_; | 61 bool is_typing_enabled_; |
| 64 JSGraph* jsgraph_; | 62 JSGraph* jsgraph_; |
| 65 Linkage* linkage_; | |
| 66 }; | 63 }; |
| 67 | 64 |
| 68 } // namespace compiler | 65 } // namespace compiler |
| 69 } // namespace internal | 66 } // namespace internal |
| 70 } // namespace v8 | 67 } // namespace v8 |
| 71 | 68 |
| 72 #endif // V8_COMPILER_JS_GENERIC_LOWERING_H_ | 69 #endif // V8_COMPILER_JS_GENERIC_LOWERING_H_ |
| OLD | NEW |