blob: a3659adfc2a05cc56231037a54daab292d1288be [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// 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
11namespace v8 {
12namespace internal {
13
14// Forward declarations.
15class ExternalReference;
16class OStream;
17
18
19namespace compiler {
20
21// Forward declarations.
22class CallDescriptor;
23struct CommonOperatorBuilderImpl;
24class 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.
29enum 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.
36enum FrameStateType {
37 JS_FRAME, // Represents an unoptimized JavaScriptFrame.
38 ARGUMENTS_ADAPTOR // Represents an ArgumentsAdaptorFrame.
39};
40
41
42class FrameStateCallInfo FINAL {
43 public:
44 FrameStateCallInfo(
45 FrameStateType type, BailoutId bailout_id,
46 OutputFrameStateCombine state_combine,
47 MaybeHandle<JSFunction> jsfunction = MaybeHandle<JSFunction>())
48 : type_(type),
49 bailout_id_(bailout_id),
50 frame_state_combine_(state_combine),
51 jsfunction_(jsfunction) {}
52
53 FrameStateType type() const { return type_; }
54 BailoutId bailout_id() const { return bailout_id_; }
55 OutputFrameStateCombine state_combine() const { return frame_state_combine_; }
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.
68class 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:
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_