1 // Copyright 2015 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_INTRINSIC_LOWERING_H_ 6 #define V8_COMPILER_JS_INTRINSIC_LOWERING_H_ 7 8 #include "src/compiler/common-operator.h" 9 #include "src/compiler/graph-reducer.h" 10 11 namespace v8 { 12 namespace internal { 13 14 // Forward declarations. 15 class Callable; 16 17 18 namespace compiler { 19 20 // Forward declarations. 21 class CommonOperatorBuilder; 22 class JSOperatorBuilder; 23 class JSGraph; 24 class MachineOperatorBuilder; 25 class SimplifiedOperatorBuilder; 26 27 28 // Lowers certain JS-level runtime calls. 29 class JSIntrinsicLowering final : public AdvancedReducer { 30 public: 31 enum DeoptimizationMode { kDeoptimizationEnabled, kDeoptimizationDisabled }; 32 33 JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph, 34 DeoptimizationMode mode); 35 ~JSIntrinsicLowering() final {} 36 37 Reduction Reduce(Node* node) final; 38 39 private: 40 Reduction ReduceCreateIterResultObject(Node* node); 41 Reduction ReduceDeoptimizeNow(Node* node); 42 Reduction ReduceDoubleHi(Node* node); 43 Reduction ReduceDoubleLo(Node* node); 44 Reduction ReduceGeneratorClose(Node* node); 45 Reduction ReduceGeneratorGetInputOrDebugPos(Node* node); 46 Reduction ReduceGeneratorGetResumeMode(Node* node); 47 Reduction ReduceIsInstanceType(Node* node, InstanceType instance_type); 48 Reduction ReduceIsJSReceiver(Node* node); 49 Reduction ReduceIsSmi(Node* node); 50 Reduction ReduceValueOf(Node* node); 51 Reduction ReduceFixedArrayGet(Node* node); 52 Reduction ReduceFixedArraySet(Node* node); 53 Reduction ReduceRegExpConstructResult(Node* node); 54 Reduction ReduceRegExpExec(Node* node); 55 Reduction ReduceRegExpFlags(Node* node); 56 Reduction ReduceRegExpSource(Node* node); 57 Reduction ReduceSubString(Node* node); 58 Reduction ReduceToInteger(Node* node); 59 Reduction ReduceToLength(Node* node); 60 Reduction ReduceToName(Node* node); 61 Reduction ReduceToNumber(Node* node); 62 Reduction ReduceToObject(Node* node); 63 Reduction ReduceToPrimitive(Node* node); 64 Reduction ReduceToString(Node* node); 65 Reduction ReduceCall(Node* node); 66 Reduction ReduceNewObject(Node* node); 67 Reduction ReduceGetSuperConstructor(Node* node); 68 69 Reduction Change(Node* node, const Operator* op); 70 Reduction Change(Node* node, const Operator* op, Node* a, Node* b); 71 Reduction Change(Node* node, const Operator* op, Node* a, Node* b, Node* c); 72 Reduction Change(Node* node, const Operator* op, Node* a, Node* b, Node* c, 73 Node* d); 74 Reduction Change(Node* node, Callable const& callable, 75 int stack_parameter_count); 76 77 Graph* graph() const; 78 JSGraph* jsgraph() const { return jsgraph_; } 79 Isolate* isolate() const; 80 CommonOperatorBuilder* common() const; 81 JSOperatorBuilder* javascript() const; 82 MachineOperatorBuilder* machine() const; 83 SimplifiedOperatorBuilder* simplified() const; 84 DeoptimizationMode mode() const { return mode_; } 85 86 JSGraph* const jsgraph_; 87 DeoptimizationMode const mode_; 88 }; 89 90 } // namespace compiler 91 } // namespace internal 92 } // namespace v8 93 94 #endif // V8_COMPILER_JS_INTRINSIC_LOWERING_H_ 95