11cb0ef41Sopenharmony_ci// Copyright 2015 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_COMPILER_JS_INTRINSIC_LOWERING_H_
61cb0ef41Sopenharmony_ci#define V8_COMPILER_JS_INTRINSIC_LOWERING_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/base/compiler-specific.h"
91cb0ef41Sopenharmony_ci#include "src/common/globals.h"
101cb0ef41Sopenharmony_ci#include "src/compiler/common-operator.h"
111cb0ef41Sopenharmony_ci#include "src/compiler/graph-reducer.h"
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_cinamespace v8 {
141cb0ef41Sopenharmony_cinamespace internal {
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci// Forward declarations.
171cb0ef41Sopenharmony_ciclass Callable;
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_cinamespace compiler {
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci// Forward declarations.
231cb0ef41Sopenharmony_ciclass CommonOperatorBuilder;
241cb0ef41Sopenharmony_cistruct FieldAccess;
251cb0ef41Sopenharmony_ciclass JSOperatorBuilder;
261cb0ef41Sopenharmony_ciclass JSGraph;
271cb0ef41Sopenharmony_ciclass SimplifiedOperatorBuilder;
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci// Lowers certain JS-level runtime calls.
311cb0ef41Sopenharmony_ciclass V8_EXPORT_PRIVATE JSIntrinsicLowering final
321cb0ef41Sopenharmony_ci    : public NON_EXPORTED_BASE(AdvancedReducer) {
331cb0ef41Sopenharmony_ci public:
341cb0ef41Sopenharmony_ci  JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph, JSHeapBroker* broker);
351cb0ef41Sopenharmony_ci  ~JSIntrinsicLowering() final = default;
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ci  const char* reducer_name() const override { return "JSIntrinsicLowering"; }
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ci  Reduction Reduce(Node* node) final;
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ci private:
421cb0ef41Sopenharmony_ci  Reduction ReduceCopyDataProperties(Node* node);
431cb0ef41Sopenharmony_ci  Reduction ReduceCopyDataPropertiesWithExcludedPropertiesOnStack(Node* node);
441cb0ef41Sopenharmony_ci  Reduction ReduceCreateIterResultObject(Node* node);
451cb0ef41Sopenharmony_ci  Reduction ReduceDeoptimizeNow(Node* node);
461cb0ef41Sopenharmony_ci  Reduction ReduceCreateJSGeneratorObject(Node* node);
471cb0ef41Sopenharmony_ci  Reduction ReduceGeneratorClose(Node* node);
481cb0ef41Sopenharmony_ci  Reduction ReduceAsyncFunctionAwaitCaught(Node* node);
491cb0ef41Sopenharmony_ci  Reduction ReduceAsyncFunctionAwaitUncaught(Node* node);
501cb0ef41Sopenharmony_ci  Reduction ReduceAsyncFunctionEnter(Node* node);
511cb0ef41Sopenharmony_ci  Reduction ReduceAsyncFunctionReject(Node* node);
521cb0ef41Sopenharmony_ci  Reduction ReduceAsyncFunctionResolve(Node* node);
531cb0ef41Sopenharmony_ci  Reduction ReduceAsyncGeneratorAwaitCaught(Node* node);
541cb0ef41Sopenharmony_ci  Reduction ReduceAsyncGeneratorAwaitUncaught(Node* node);
551cb0ef41Sopenharmony_ci  Reduction ReduceAsyncGeneratorReject(Node* node);
561cb0ef41Sopenharmony_ci  Reduction ReduceAsyncGeneratorResolve(Node* node);
571cb0ef41Sopenharmony_ci  Reduction ReduceAsyncGeneratorYield(Node* node);
581cb0ef41Sopenharmony_ci  Reduction ReduceGeneratorGetResumeMode(Node* node);
591cb0ef41Sopenharmony_ci  Reduction ReduceIsInstanceType(Node* node, InstanceType instance_type);
601cb0ef41Sopenharmony_ci  Reduction ReduceIsJSReceiver(Node* node);
611cb0ef41Sopenharmony_ci  Reduction ReduceIsBeingInterpreted(Node* node);
621cb0ef41Sopenharmony_ci  Reduction ReduceTurbofanStaticAssert(Node* node);
631cb0ef41Sopenharmony_ci  Reduction ReduceVerifyType(Node* node);
641cb0ef41Sopenharmony_ci  Reduction ReduceToLength(Node* node);
651cb0ef41Sopenharmony_ci  Reduction ReduceToObject(Node* node);
661cb0ef41Sopenharmony_ci  Reduction ReduceToString(Node* node);
671cb0ef41Sopenharmony_ci  Reduction ReduceCall(Node* node);
681cb0ef41Sopenharmony_ci  Reduction ReduceIncBlockCounter(Node* node);
691cb0ef41Sopenharmony_ci  Reduction ReduceGetImportMetaObject(Node* node);
701cb0ef41Sopenharmony_ci
711cb0ef41Sopenharmony_ci  Reduction Change(Node* node, const Operator* op);
721cb0ef41Sopenharmony_ci  Reduction Change(Node* node, const Operator* op, Node* a, Node* b);
731cb0ef41Sopenharmony_ci  Reduction Change(Node* node, const Operator* op, Node* a, Node* b, Node* c);
741cb0ef41Sopenharmony_ci  Reduction Change(Node* node, const Operator* op, Node* a, Node* b, Node* c,
751cb0ef41Sopenharmony_ci                   Node* d);
761cb0ef41Sopenharmony_ci
771cb0ef41Sopenharmony_ci  enum FrameStateFlag {
781cb0ef41Sopenharmony_ci    kNeedsFrameState,
791cb0ef41Sopenharmony_ci    kDoesNotNeedFrameState,
801cb0ef41Sopenharmony_ci  };
811cb0ef41Sopenharmony_ci  Reduction Change(Node* node, Callable const& callable,
821cb0ef41Sopenharmony_ci                   int stack_parameter_count,
831cb0ef41Sopenharmony_ci                   enum FrameStateFlag frame_state_flag = kNeedsFrameState);
841cb0ef41Sopenharmony_ci
851cb0ef41Sopenharmony_ci  Graph* graph() const;
861cb0ef41Sopenharmony_ci  JSGraph* jsgraph() const { return jsgraph_; }
871cb0ef41Sopenharmony_ci  JSHeapBroker* broker() const { return broker_; }
881cb0ef41Sopenharmony_ci  Isolate* isolate() const;
891cb0ef41Sopenharmony_ci  CommonOperatorBuilder* common() const;
901cb0ef41Sopenharmony_ci  JSOperatorBuilder* javascript() const;
911cb0ef41Sopenharmony_ci  SimplifiedOperatorBuilder* simplified() const;
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ci  JSGraph* const jsgraph_;
941cb0ef41Sopenharmony_ci  JSHeapBroker* const broker_;
951cb0ef41Sopenharmony_ci};
961cb0ef41Sopenharmony_ci
971cb0ef41Sopenharmony_ci}  // namespace compiler
981cb0ef41Sopenharmony_ci}  // namespace internal
991cb0ef41Sopenharmony_ci}  // namespace v8
1001cb0ef41Sopenharmony_ci
1011cb0ef41Sopenharmony_ci#endif  // V8_COMPILER_JS_INTRINSIC_LOWERING_H_
102