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