Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_COMMON_OPERATOR_H_ | 5 #ifndef V8_COMPILER_COMMON_OPERATOR_H_ |
| 6 #define V8_COMPILER_COMMON_OPERATOR_H_ | 6 #define V8_COMPILER_COMMON_OPERATOR_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 : Operator1<CallDescriptor*>( | 37 : Operator1<CallDescriptor*>( |
| 38 IrOpcode::kCall, descriptor->properties(), | 38 IrOpcode::kCall, descriptor->properties(), |
| 39 descriptor->InputCount() + descriptor->FrameStateCount(), | 39 descriptor->InputCount() + descriptor->FrameStateCount(), |
| 40 descriptor->ReturnCount(), mnemonic, descriptor) {} | 40 descriptor->ReturnCount(), mnemonic, descriptor) {} |
| 41 | 41 |
| 42 virtual OStream& PrintParameter(OStream& os) const { // NOLINT | 42 virtual OStream& PrintParameter(OStream& os) const { // NOLINT |
| 43 return os << "[" << *parameter() << "]"; | 43 return os << "[" << *parameter() << "]"; |
| 44 } | 44 } |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // Flag that describes how to combine the current environment with | |
| 48 // the output of a node to obtain a framestate for lazy bailout. | |
| 49 enum OutputFrameStateCombine { | |
| 50 PUSH_OUTPUT, // Push the output on the expression stack. | |
|
Benedikt Meurer
2014/09/01 09:07:05
Nit: Can we use kPushOutput and kIgnoreOutput here
Jarin
2014/09/01 09:23:34
Done.
| |
| 51 IGNORE_OUTPUT // Use the frame state as-is. | |
| 52 }; | |
| 53 | |
| 54 | |
| 55 class FrameStateCallInfo { | |
| 56 public: | |
| 57 FrameStateCallInfo(BailoutId bailout_id, | |
| 58 OutputFrameStateCombine state_combine) | |
| 59 : bailout_id_(bailout_id), frame_state_combine_(state_combine) {} | |
| 60 | |
| 61 BailoutId bailout_id() const { return bailout_id_; } | |
| 62 OutputFrameStateCombine state_combine() const { return frame_state_combine_; } | |
| 63 | |
| 64 private: | |
| 65 BailoutId bailout_id_; | |
| 66 OutputFrameStateCombine frame_state_combine_; | |
| 67 }; | |
| 68 | |
| 47 // Interface for building common operators that can be used at any level of IR, | 69 // Interface for building common operators that can be used at any level of IR, |
| 48 // including JavaScript, mid-level, and low-level. | 70 // including JavaScript, mid-level, and low-level. |
| 49 // TODO(titzer): Move the mnemonics into SimpleOperator and Operator1 classes. | 71 // TODO(titzer): Move the mnemonics into SimpleOperator and Operator1 classes. |
| 50 class CommonOperatorBuilder { | 72 class CommonOperatorBuilder { |
| 51 public: | 73 public: |
| 52 explicit CommonOperatorBuilder(Zone* zone) : zone_(zone) {} | 74 explicit CommonOperatorBuilder(Zone* zone) : zone_(zone) {} |
| 53 | 75 |
| 54 #define CONTROL_OP(name, inputs, controls) \ | 76 #define CONTROL_OP(name, inputs, controls) \ |
| 55 return new (zone_) ControlOperator(IrOpcode::k##name, Operator::kFoldable, \ | 77 return new (zone_) ControlOperator(IrOpcode::k##name, Operator::kFoldable, \ |
| 56 inputs, 0, controls, #name); | 78 inputs, 0, controls, #name); |
| 57 | 79 |
| 58 Operator* Start(int num_formal_parameters) { | 80 Operator* Start(int num_formal_parameters) { |
| 59 // Outputs are formal parameters, plus context, receiver, and JSFunction. | 81 // Outputs are formal parameters, plus context, receiver, and JSFunction. |
| 60 int outputs = num_formal_parameters + 3; | 82 int outputs = num_formal_parameters + 3; |
| 61 return new (zone_) ControlOperator(IrOpcode::kStart, Operator::kFoldable, 0, | 83 return new (zone_) ControlOperator(IrOpcode::kStart, Operator::kFoldable, 0, |
| 62 outputs, 0, "Start"); | 84 outputs, 0, "Start"); |
| 63 } | 85 } |
| 64 Operator* Dead() { CONTROL_OP(Dead, 0, 0); } | 86 Operator* Dead() { CONTROL_OP(Dead, 0, 0); } |
| 65 Operator* End() { CONTROL_OP(End, 0, 1); } | 87 Operator* End() { CONTROL_OP(End, 0, 1); } |
| 66 Operator* Branch() { CONTROL_OP(Branch, 1, 1); } | 88 Operator* Branch() { CONTROL_OP(Branch, 1, 1); } |
| 67 Operator* IfTrue() { CONTROL_OP(IfTrue, 0, 1); } | 89 Operator* IfTrue() { CONTROL_OP(IfTrue, 0, 1); } |
| 68 Operator* IfFalse() { CONTROL_OP(IfFalse, 0, 1); } | 90 Operator* IfFalse() { CONTROL_OP(IfFalse, 0, 1); } |
| 69 Operator* Throw() { CONTROL_OP(Throw, 1, 1); } | 91 Operator* Throw() { CONTROL_OP(Throw, 1, 1); } |
| 70 Operator* LazyDeoptimization() { CONTROL_OP(LazyDeoptimization, 0, 1); } | |
| 71 Operator* Continuation() { CONTROL_OP(Continuation, 0, 1); } | |
| 72 | |
| 73 Operator* Deoptimize() { | |
| 74 return new (zone_) | |
| 75 ControlOperator(IrOpcode::kDeoptimize, 0, 1, 0, 1, "Deoptimize"); | |
| 76 } | |
| 77 | 92 |
| 78 Operator* Return() { | 93 Operator* Return() { |
| 79 return new (zone_) ControlOperator(IrOpcode::kReturn, 0, 1, 0, 1, "Return"); | 94 return new (zone_) ControlOperator(IrOpcode::kReturn, 0, 1, 0, 1, "Return"); |
| 80 } | 95 } |
| 81 | 96 |
| 82 Operator* Merge(int controls) { | 97 Operator* Merge(int controls) { |
| 83 return new (zone_) ControlOperator(IrOpcode::kMerge, Operator::kFoldable, 0, | 98 return new (zone_) ControlOperator(IrOpcode::kMerge, Operator::kFoldable, 0, |
| 84 0, controls, "Merge"); | 99 0, controls, "Merge"); |
| 85 } | 100 } |
| 86 | 101 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 } | 157 } |
| 143 Operator* Finish(int arguments) { | 158 Operator* Finish(int arguments) { |
| 144 DCHECK(arguments > 0); // Disallow empty finishes. | 159 DCHECK(arguments > 0); // Disallow empty finishes. |
| 145 return new (zone_) Operator1<int>(IrOpcode::kFinish, Operator::kPure, 1, 1, | 160 return new (zone_) Operator1<int>(IrOpcode::kFinish, Operator::kPure, 1, 1, |
| 146 "Finish", arguments); | 161 "Finish", arguments); |
| 147 } | 162 } |
| 148 Operator* StateValues(int arguments) { | 163 Operator* StateValues(int arguments) { |
| 149 return new (zone_) Operator1<int>(IrOpcode::kStateValues, Operator::kPure, | 164 return new (zone_) Operator1<int>(IrOpcode::kStateValues, Operator::kPure, |
| 150 arguments, 1, "StateValues", arguments); | 165 arguments, 1, "StateValues", arguments); |
| 151 } | 166 } |
| 152 Operator* FrameState(BailoutId ast_id) { | 167 Operator* FrameState(BailoutId bailout_id, OutputFrameStateCombine combine) { |
| 153 return new (zone_) Operator1<BailoutId>( | 168 return new (zone_) Operator1<FrameStateCallInfo>( |
| 154 IrOpcode::kFrameState, Operator::kPure, 3, 1, "FrameState", ast_id); | 169 IrOpcode::kFrameState, Operator::kPure, 4, 1, "FrameState", |
| 170 FrameStateCallInfo(bailout_id, combine)); | |
| 155 } | 171 } |
| 156 Operator* Call(CallDescriptor* descriptor) { | 172 Operator* Call(CallDescriptor* descriptor) { |
| 157 return new (zone_) CallOperator(descriptor, "Call"); | 173 return new (zone_) CallOperator(descriptor, "Call"); |
| 158 } | 174 } |
| 159 Operator* Projection(int index) { | 175 Operator* Projection(int index) { |
| 160 return new (zone_) Operator1<int>(IrOpcode::kProjection, Operator::kPure, 1, | 176 return new (zone_) Operator1<int>(IrOpcode::kProjection, Operator::kPure, 1, |
| 161 1, "Projection", index); | 177 1, "Projection", index); |
| 162 } | 178 } |
| 163 | 179 |
| 164 private: | 180 private: |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 | 306 |
| 291 template <typename T> | 307 template <typename T> |
| 292 inline T ValueOf(Operator* op) { | 308 inline T ValueOf(Operator* op) { |
| 293 return CommonOperatorTraits<T>::ValueOf(op); | 309 return CommonOperatorTraits<T>::ValueOf(op); |
| 294 } | 310 } |
| 295 } | 311 } |
| 296 } | 312 } |
| 297 } // namespace v8::internal::compiler | 313 } // namespace v8::internal::compiler |
| 298 | 314 |
| 299 #endif // V8_COMPILER_COMMON_OPERATOR_H_ | 315 #endif // V8_COMPILER_COMMON_OPERATOR_H_ |
| OLD | NEW |