1 // Copyright 2013 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_COMMON_OPERATOR_H_ 6 #define V8_COMPILER_COMMON_OPERATOR_H_ 7 8 #include "src/compiler/machine-type.h" 9 #include "src/unique.h" 10 11 namespace v8 { 12 namespace internal { 13 14 // Forward declarations. 15 class ExternalReference; 16 class OStream; 17 18 19 namespace compiler { 20 21 // Forward declarations. 22 class CallDescriptor; 23 struct CommonOperatorBuilderImpl; 24 class Operator; 25 26 27 // Flag that describes how to combine the current environment with 28 // the output of a node to obtain a framestate for lazy bailout. 29 enum OutputFrameStateCombine { 30 kPushOutput, // Push the output on the expression stack. 31 kIgnoreOutput // Use the frame state as-is. 32 }; 33 34 35 // The type of stack frame that a FrameState node represents. 36 enum FrameStateType { 37 JS_FRAME, // Represents an unoptimized JavaScriptFrame. 38 ARGUMENTS_ADAPTOR // Represents an ArgumentsAdaptorFrame. 39 }; 40 41 42 class FrameStateCallInfo FINAL { 43 public: 44 FrameStateCallInfo( 45 FrameStateType type, BailoutId bailout_id, 46 OutputFrameStateCombine state_combine, 47 MaybeHandle<JSFunction> jsfunction = MaybeHandle<JSFunction>()) type_(type)48 : type_(type), 49 bailout_id_(bailout_id), 50 frame_state_combine_(state_combine), 51 jsfunction_(jsfunction) {} 52 type()53 FrameStateType type() const { return type_; } bailout_id()54 BailoutId bailout_id() const { return bailout_id_; } state_combine()55 OutputFrameStateCombine state_combine() const { return frame_state_combine_; } jsfunction()56 MaybeHandle<JSFunction> jsfunction() const { return jsfunction_; } 57 58 private: 59 FrameStateType type_; 60 BailoutId bailout_id_; 61 OutputFrameStateCombine frame_state_combine_; 62 MaybeHandle<JSFunction> jsfunction_; 63 }; 64 65 66 // Interface for building common operators that can be used at any level of IR, 67 // including JavaScript, mid-level, and low-level. 68 class CommonOperatorBuilder FINAL { 69 public: 70 explicit CommonOperatorBuilder(Zone* zone); 71 72 const Operator* Dead(); 73 const Operator* End(); 74 const Operator* Branch(); 75 const Operator* IfTrue(); 76 const Operator* IfFalse(); 77 const Operator* Throw(); 78 const Operator* Return(); 79 80 const Operator* Start(int num_formal_parameters); 81 const Operator* Merge(int controls); 82 const Operator* Loop(int controls); 83 const Operator* Parameter(int index); 84 85 const Operator* Int32Constant(int32_t); 86 const Operator* Int64Constant(int64_t); 87 const Operator* Float32Constant(volatile float); 88 const Operator* Float64Constant(volatile double); 89 const Operator* ExternalConstant(const ExternalReference&); 90 const Operator* NumberConstant(volatile double); 91 const Operator* HeapConstant(const Unique<Object>&); 92 93 const Operator* Phi(MachineType type, int arguments); 94 const Operator* EffectPhi(int arguments); 95 const Operator* ControlEffect(); 96 const Operator* ValueEffect(int arguments); 97 const Operator* Finish(int arguments); 98 const Operator* StateValues(int arguments); 99 const Operator* FrameState( 100 FrameStateType type, BailoutId bailout_id, 101 OutputFrameStateCombine state_combine, 102 MaybeHandle<JSFunction> jsfunction = MaybeHandle<JSFunction>()); 103 const Operator* Call(const CallDescriptor* descriptor); 104 const Operator* Projection(size_t index); 105 106 private: zone()107 Zone* zone() const { return zone_; } 108 109 const CommonOperatorBuilderImpl& impl_; 110 Zone* const zone_; 111 }; 112 113 } // namespace compiler 114 } // namespace internal 115 } // namespace v8 116 117 #endif // V8_COMPILER_COMMON_OPERATOR_H_ 118