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/common/globals.h" 10 #include "src/compiler/common-operator.h" 11 #include "src/compiler/graph-reducer.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, JSHeapBroker* broker); 35 ~JSIntrinsicLowering() final = default; 36 37 const char* reducer_name() const override { return "JSIntrinsicLowering"; } 38 39 Reduction Reduce(Node* node) final; 40 41 private: 42 Reduction ReduceCopyDataProperties(Node* node); 43 Reduction ReduceCopyDataPropertiesWithExcludedPropertiesOnStack(Node* node); 44 Reduction ReduceCreateIterResultObject(Node* node); 45 Reduction ReduceDeoptimizeNow(Node* node); 46 Reduction ReduceCreateJSGeneratorObject(Node* node); 47 Reduction ReduceGeneratorClose(Node* node); 48 Reduction ReduceAsyncFunctionAwaitCaught(Node* node); 49 Reduction ReduceAsyncFunctionAwaitUncaught(Node* node); 50 Reduction ReduceAsyncFunctionEnter(Node* node); 51 Reduction ReduceAsyncFunctionReject(Node* node); 52 Reduction ReduceAsyncFunctionResolve(Node* node); 53 Reduction ReduceAsyncGeneratorAwaitCaught(Node* node); 54 Reduction ReduceAsyncGeneratorAwaitUncaught(Node* node); 55 Reduction ReduceAsyncGeneratorReject(Node* node); 56 Reduction ReduceAsyncGeneratorResolve(Node* node); 57 Reduction ReduceAsyncGeneratorYield(Node* node); 58 Reduction ReduceGeneratorGetResumeMode(Node* node); 59 Reduction ReduceIsInstanceType(Node* node, InstanceType instance_type); 60 Reduction ReduceIsJSReceiver(Node* node); 61 Reduction ReduceIsBeingInterpreted(Node* node); 62 Reduction ReduceTurbofanStaticAssert(Node* node); 63 Reduction ReduceVerifyType(Node* node); 64 Reduction ReduceToLength(Node* node); 65 Reduction ReduceToObject(Node* node); 66 Reduction ReduceToString(Node* node); 67 Reduction ReduceCall(Node* node); 68 Reduction ReduceIncBlockCounter(Node* node); 69 Reduction ReduceGetImportMetaObject(Node* node); 70 71 Reduction Change(Node* node, const Operator* op); 72 Reduction Change(Node* node, const Operator* op, Node* a, Node* b); 73 Reduction Change(Node* node, const Operator* op, Node* a, Node* b, Node* c); 74 Reduction Change(Node* node, const Operator* op, Node* a, Node* b, Node* c, 75 Node* d); 76 77 enum FrameStateFlag { 78 kNeedsFrameState, 79 kDoesNotNeedFrameState, 80 }; 81 Reduction Change(Node* node, Callable const& callable, 82 int stack_parameter_count, 83 enum FrameStateFlag frame_state_flag = kNeedsFrameState); 84 85 Graph* graph() const; 86 JSGraph* jsgraph() const { return jsgraph_; } 87 JSHeapBroker* broker() const { return broker_; } 88 Isolate* isolate() const; 89 CommonOperatorBuilder* common() const; 90 JSOperatorBuilder* javascript() const; 91 SimplifiedOperatorBuilder* simplified() const; 92 93 JSGraph* const jsgraph_; 94 JSHeapBroker* const broker_; 95 }; 96 97 } // namespace compiler 98 } // namespace internal 99 } // namespace v8 100 101 #endif // V8_COMPILER_JS_INTRINSIC_LOWERING_H_ 102