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/base/compiler-specific.h" 9 #include "src/compiler/common-operator.h" 10 #include "src/compiler/graph-reducer.h" 11 #include "src/globals.h" 12 13 namespace v8 { 14 namespace internal { 15 16 // Forward declarations. 17 class Callable; 18 19 20 namespace compiler { 21 22 // Forward declarations. 23 class CommonOperatorBuilder; 24 struct FieldAccess; 25 class JSOperatorBuilder; 26 class JSGraph; 27 class SimplifiedOperatorBuilder; 28 29 30 // Lowers certain JS-level runtime calls. 31 class V8_EXPORT_PRIVATE JSIntrinsicLowering final NON_EXPORTED_BASE(AdvancedReducer)32 : public NON_EXPORTED_BASE(AdvancedReducer) { 33 public: 34 JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph); 35 ~JSIntrinsicLowering() final {} 36 37 const char* reducer_name() const override { return "JSIntrinsicLowering"; } 38 39 Reduction Reduce(Node* node) final; 40 41 private: 42 Reduction ReduceCreateIterResultObject(Node* node); 43 Reduction ReduceDebugIsActive(Node* node); 44 Reduction ReduceDeoptimizeNow(Node* node); 45 Reduction ReduceCreateJSGeneratorObject(Node* node); 46 Reduction ReduceGeneratorClose(Node* node); 47 Reduction ReduceGeneratorGetInputOrDebugPos(Node* node); 48 Reduction ReduceAsyncGeneratorReject(Node* node); 49 Reduction ReduceAsyncGeneratorResolve(Node* node); 50 Reduction ReduceAsyncGeneratorYield(Node* node); 51 Reduction ReduceGeneratorSaveInputForAwait(Node* node); 52 Reduction ReduceGeneratorGetResumeMode(Node* node); 53 Reduction ReduceIsInstanceType(Node* node, InstanceType instance_type); 54 Reduction ReduceIsJSReceiver(Node* node); 55 Reduction ReduceIsSmi(Node* node); 56 Reduction ReduceRejectPromise(Node* node); 57 Reduction ReduceResolvePromise(Node* node); 58 Reduction ReduceToInteger(Node* node); 59 Reduction ReduceToLength(Node* node); 60 Reduction ReduceToNumber(Node* node); 61 Reduction ReduceToObject(Node* node); 62 Reduction ReduceToString(Node* node); 63 Reduction ReduceCall(Node* node); 64 Reduction ReduceGetSuperConstructor(Node* node); 65 66 Reduction Change(Node* node, const Operator* op); 67 Reduction Change(Node* node, const Operator* op, Node* a, Node* b); 68 Reduction Change(Node* node, const Operator* op, Node* a, Node* b, Node* c); 69 Reduction Change(Node* node, const Operator* op, Node* a, Node* b, Node* c, 70 Node* d); 71 Reduction Change(Node* node, Callable const& callable, 72 int stack_parameter_count); 73 74 Graph* graph() const; 75 JSGraph* jsgraph() const { return jsgraph_; } 76 Isolate* isolate() const; 77 CommonOperatorBuilder* common() const; 78 JSOperatorBuilder* javascript() const; 79 SimplifiedOperatorBuilder* simplified() const; 80 81 JSGraph* const jsgraph_; 82 }; 83 84 } // namespace compiler 85 } // namespace internal 86 } // namespace v8 87 88 #endif // V8_COMPILER_JS_INTRINSIC_LOWERING_H_ 89