Chromium Code Reviews| 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/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| 11 #include "src/code-factory.h" | 11 #include "src/code-factory.h" |
| 12 #include "src/compiler/graph.h" | 12 #include "src/compiler/graph.h" |
| 13 #include "src/compiler/graph-reducer.h" | 13 #include "src/compiler/graph-reducer.h" |
| 14 #include "src/compiler/js-graph.h" | 14 #include "src/compiler/js-graph.h" |
| 15 #include "src/compiler/opcodes.h" | 15 #include "src/compiler/opcodes.h" |
| 16 #include "src/unique.h" | |
| 17 | 16 |
| 18 namespace v8 { | 17 namespace v8 { |
| 19 namespace internal { | 18 namespace internal { |
| 20 namespace compiler { | 19 namespace compiler { |
| 21 | 20 |
| 22 // Forward declarations. | 21 // Forward declarations. |
| 23 class CommonOperatorBuilder; | 22 class CommonOperatorBuilder; |
| 24 class MachineOperatorBuilder; | 23 class MachineOperatorBuilder; |
| 25 class Linkage; | 24 class Linkage; |
| 26 | 25 |
| 27 // 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. |
| 28 class JSGenericLowering : public Reducer { | 27 class JSGenericLowering : public Reducer { |
| 29 public: | 28 public: |
| 30 JSGenericLowering(CompilationInfo* info, JSGraph* graph, | 29 JSGenericLowering(CompilationInfo* info, JSGraph* graph); |
| 31 MachineOperatorBuilder* machine); | |
| 32 virtual ~JSGenericLowering() {} | 30 virtual ~JSGenericLowering() {} |
| 33 | 31 |
| 34 virtual Reduction Reduce(Node* node); | 32 virtual Reduction Reduce(Node* node); |
| 35 | 33 |
| 36 protected: | 34 protected: |
| 37 // Dispatched depending on opcode. | 35 #define DECLARE_LOWER(x) void Lower##x(Node* node); |
| 38 #define DECLARE_LOWER(x) Node* Lower##x(Node* node); | 36 // Dispatched depending on opcode. |
| 39 ALL_OP_LIST(DECLARE_LOWER) | 37 ALL_OP_LIST(DECLARE_LOWER) |
| 40 #undef DECLARE_LOWER | 38 #undef DECLARE_LOWER |
| 41 | 39 |
| 42 // Helpers to create new constant nodes. | 40 // Helpers to create new constant nodes. |
| 43 Node* SmiConstant(int immediate); | 41 Node* SmiConstant(int immediate); |
| 44 Node* Int32Constant(int immediate); | 42 Node* Int32Constant(int immediate); |
| 45 Node* CodeConstant(Handle<Code> code); | 43 Node* CodeConstant(Handle<Code> code); |
| 46 Node* FunctionConstant(Handle<JSFunction> function); | 44 Node* FunctionConstant(Handle<JSFunction> function); |
| 47 Node* ExternalConstant(ExternalReference ref); | 45 Node* ExternalConstant(ExternalReference ref); |
| 48 | 46 |
| 49 // Helpers to patch existing nodes in the graph. | 47 // Helpers to patch existing nodes in the graph. |
| 50 void PatchOperator(Node* node, const Operator* new_op); | 48 void PatchOperator(Node* node, const Operator* new_op); |
| 51 void PatchInsertInput(Node* node, int index, Node* input); | 49 void PatchInsertInput(Node* node, int index, Node* input); |
| 52 | 50 |
| 53 // Helpers to replace existing nodes with a generic call. | 51 // Helpers to replace existing nodes with a generic call. |
| 54 void ReplaceWithCompareIC(Node* node, Token::Value token, bool pure); | 52 void ReplaceWithCompareIC(Node* node, Token::Value token, bool pure); |
| 55 void ReplaceWithStubCall(Node* node, Callable callable, | 53 void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags); |
|
mvstanton
2014/09/12 14:05:00
terseness is better than redundancy :).
| |
| 56 CallDescriptor::Flags flags); | |
| 57 void ReplaceWithBuiltinCall(Node* node, Builtins::JavaScript id, int args); | 54 void ReplaceWithBuiltinCall(Node* node, Builtins::JavaScript id, int args); |
| 58 void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1); | 55 void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1); |
| 59 | 56 |
| 60 Zone* zone() const { return graph()->zone(); } | 57 Zone* zone() const { return graph()->zone(); } |
| 61 Isolate* isolate() const { return zone()->isolate(); } | 58 Isolate* isolate() const { return zone()->isolate(); } |
| 62 JSGraph* jsgraph() const { return jsgraph_; } | 59 JSGraph* jsgraph() const { return jsgraph_; } |
| 63 Graph* graph() const { return jsgraph()->graph(); } | 60 Graph* graph() const { return jsgraph()->graph(); } |
| 64 Linkage* linkage() const { return linkage_; } | 61 Linkage* linkage() const { return linkage_; } |
| 65 CompilationInfo* info() const { return info_; } | 62 CompilationInfo* info() const { return info_; } |
| 66 CommonOperatorBuilder* common() const { return jsgraph()->common(); } | 63 CommonOperatorBuilder* common() const { return jsgraph()->common(); } |
| 67 MachineOperatorBuilder* machine() const { return machine_; } | 64 MachineOperatorBuilder* machine() const { return jsgraph()->machine(); } |
| 68 | 65 |
| 69 private: | 66 private: |
| 70 CompilationInfo* info_; | 67 CompilationInfo* info_; |
| 71 JSGraph* jsgraph_; | 68 JSGraph* jsgraph_; |
| 72 Linkage* linkage_; | 69 Linkage* linkage_; |
| 73 MachineOperatorBuilder* machine_; | |
| 74 SetOncePointer<Node> centrystub_constant_; | 70 SetOncePointer<Node> centrystub_constant_; |
| 75 }; | 71 }; |
| 76 | 72 |
| 77 } // namespace compiler | 73 } // namespace compiler |
| 78 } // namespace internal | 74 } // namespace internal |
| 79 } // namespace v8 | 75 } // namespace v8 |
| 80 | 76 |
| 81 #endif // V8_COMPILER_JS_GENERIC_LOWERING_H_ | 77 #endif // V8_COMPILER_JS_GENERIC_LOWERING_H_ |
| OLD | NEW |