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 class TypeCache; 17 18 19 namespace compiler { 20 21 // Forward declarations. 22 class CommonOperatorBuilder; 23 class JSOperatorBuilder; 24 class JSGraph; 25 class MachineOperatorBuilder; 26 class SimplifiedOperatorBuilder; 27 28 29 // Lowers certain JS-level runtime calls. 30 class JSIntrinsicLowering final : public AdvancedReducer { 31 public: 32 enum DeoptimizationMode { kDeoptimizationEnabled, kDeoptimizationDisabled }; 33 34 JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph, 35 DeoptimizationMode mode); 36 ~JSIntrinsicLowering() final {} 37 38 Reduction Reduce(Node* node) final; 39 40 private: 41 Reduction ReduceConstructDouble(Node* node); 42 Reduction ReduceCreateIterResultObject(Node* node); 43 Reduction ReduceDeoptimizeNow(Node* node); 44 Reduction ReduceDoubleHi(Node* node); 45 Reduction ReduceDoubleLo(Node* node); 46 Reduction ReduceIncrementStatsCounter(Node* node); 47 Reduction ReduceIsMinusZero(Node* node); 48 Reduction ReduceIsInstanceType(Node* node, InstanceType instance_type); 49 Reduction ReduceIsFunction(Node* node); 50 Reduction ReduceIsJSReceiver(Node* node); 51 Reduction ReduceIsSmi(Node* node); 52 Reduction ReduceJSValueGetValue(Node* node); 53 Reduction ReduceMathClz32(Node* node); 54 Reduction ReduceMathFloor(Node* node); 55 Reduction ReduceMathSqrt(Node* node); 56 Reduction ReduceValueOf(Node* node); 57 Reduction ReduceFixedArrayGet(Node* node); 58 Reduction ReduceFixedArraySet(Node* node); 59 Reduction ReduceRegExpConstructResult(Node* node); 60 Reduction ReduceRegExpExec(Node* node); 61 Reduction ReduceRegExpFlags(Node* node); 62 Reduction ReduceRegExpSource(Node* node); 63 Reduction ReduceSubString(Node* node); 64 Reduction ReduceToInteger(Node* node); 65 Reduction ReduceToLength(Node* node); 66 Reduction ReduceToName(Node* node); 67 Reduction ReduceToNumber(Node* node); 68 Reduction ReduceToObject(Node* node); 69 Reduction ReduceToPrimitive(Node* node); 70 Reduction ReduceToString(Node* node); 71 Reduction ReduceCall(Node* node); 72 Reduction ReduceTailCall(Node* node); 73 Reduction ReduceGetSuperConstructor(Node* node); 74 75 Reduction Change(Node* node, const Operator* op); 76 Reduction Change(Node* node, const Operator* op, Node* a, Node* b); 77 Reduction Change(Node* node, const Operator* op, Node* a, Node* b, Node* c); 78 Reduction Change(Node* node, const Operator* op, Node* a, Node* b, Node* c, 79 Node* d); 80 Reduction ChangeToUndefined(Node* node, Node* effect = nullptr); 81 Reduction Change(Node* node, Callable const& callable, 82 int stack_parameter_count); 83 84 Graph* graph() const; 85 JSGraph* jsgraph() const { return jsgraph_; } 86 Isolate* isolate() const; 87 CommonOperatorBuilder* common() const; 88 JSOperatorBuilder* javascript() const; 89 MachineOperatorBuilder* machine() const; 90 SimplifiedOperatorBuilder* simplified() const; 91 DeoptimizationMode mode() const { return mode_; } 92 TypeCache const& type_cache() const { return type_cache_; } 93 94 JSGraph* const jsgraph_; 95 DeoptimizationMode const mode_; 96 TypeCache const& type_cache_; 97 }; 98 99 } // namespace compiler 100 } // namespace internal 101 } // namespace v8 102 103 #endif // V8_COMPILER_JS_INTRINSIC_LOWERING_H_ 104