| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 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_INTERPRETER_BYTECODE_PIPELINE_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_PIPELINE_H_ |
| 6 #define V8_INTERPRETER_BYTECODE_PIPELINE_H_ | 6 #define V8_INTERPRETER_BYTECODE_PIPELINE_H_ |
| 7 | 7 |
| 8 #include "src/base/compiler-specific.h" | 8 #include "src/base/compiler-specific.h" |
| 9 #include "src/globals.h" | 9 #include "src/globals.h" |
| 10 #include "src/interpreter/bytecode-register-allocator.h" | 10 #include "src/interpreter/bytecode-register-allocator.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 operand_count_(4), | 184 operand_count_(4), |
| 185 operand_scale_(OperandScale::kSingle), | 185 operand_scale_(OperandScale::kSingle), |
| 186 source_info_(source_info) { | 186 source_info_(source_info) { |
| 187 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count()); | 187 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count()); |
| 188 SetOperand(0, operand0); | 188 SetOperand(0, operand0); |
| 189 SetOperand(1, operand1); | 189 SetOperand(1, operand1); |
| 190 SetOperand(2, operand2); | 190 SetOperand(2, operand2); |
| 191 SetOperand(3, operand3); | 191 SetOperand(3, operand3); |
| 192 } | 192 } |
| 193 | 193 |
| 194 INLINE(BytecodeNode(Bytecode bytecode, uint32_t operand0, uint32_t operand1, | |
| 195 uint32_t operand2, uint32_t operand3, uint32_t operand4, | |
| 196 BytecodeSourceInfo source_info = BytecodeSourceInfo())) | |
| 197 : bytecode_(bytecode), | |
| 198 operand_count_(5), | |
| 199 operand_scale_(OperandScale::kSingle), | |
| 200 source_info_(source_info) { | |
| 201 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count()); | |
| 202 SetOperand(0, operand0); | |
| 203 SetOperand(1, operand1); | |
| 204 SetOperand(2, operand2); | |
| 205 SetOperand(3, operand3); | |
| 206 SetOperand(4, operand4); | |
| 207 } | |
| 208 | |
| 209 #define DEFINE_BYTECODE_NODE_CREATOR(Name, ...) \ | 194 #define DEFINE_BYTECODE_NODE_CREATOR(Name, ...) \ |
| 210 template <typename... Operands> \ | 195 template <typename... Operands> \ |
| 211 INLINE(static BytecodeNode Name(BytecodeSourceInfo source_info, \ | 196 INLINE(static BytecodeNode Name(BytecodeSourceInfo source_info, \ |
| 212 Operands... operands)) { \ | 197 Operands... operands)) { \ |
| 213 return Create<Bytecode::k##Name, __VA_ARGS__>(source_info, operands...); \ | 198 return Create<Bytecode::k##Name, __VA_ARGS__>(source_info, operands...); \ |
| 214 } | 199 } |
| 215 BYTECODE_LIST(DEFINE_BYTECODE_NODE_CREATOR) | 200 BYTECODE_LIST(DEFINE_BYTECODE_NODE_CREATOR) |
| 216 #undef DEFINE_BYTECODE_NODE_CREATOR | 201 #undef DEFINE_BYTECODE_NODE_CREATOR |
| 217 | 202 |
| 218 // Replace the bytecode of this node with |bytecode| and keep the operands. | 203 // Replace the bytecode of this node with |bytecode| and keep the operands. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 254 |
| 270 private: | 255 private: |
| 271 template <Bytecode bytecode, AccumulatorUse accumulator_use, | 256 template <Bytecode bytecode, AccumulatorUse accumulator_use, |
| 272 OperandType... operand_types> | 257 OperandType... operand_types> |
| 273 friend class BytecodeNodeBuilder; | 258 friend class BytecodeNodeBuilder; |
| 274 | 259 |
| 275 INLINE(BytecodeNode(Bytecode bytecode, int operand_count, | 260 INLINE(BytecodeNode(Bytecode bytecode, int operand_count, |
| 276 OperandScale operand_scale, | 261 OperandScale operand_scale, |
| 277 BytecodeSourceInfo source_info, uint32_t operand0 = 0, | 262 BytecodeSourceInfo source_info, uint32_t operand0 = 0, |
| 278 uint32_t operand1 = 0, uint32_t operand2 = 0, | 263 uint32_t operand1 = 0, uint32_t operand2 = 0, |
| 279 uint32_t operand3 = 0, uint32_t operand4 = 0)) | 264 uint32_t operand3 = 0)) |
| 280 : bytecode_(bytecode), | 265 : bytecode_(bytecode), |
| 281 operand_count_(operand_count), | 266 operand_count_(operand_count), |
| 282 operand_scale_(operand_scale), | 267 operand_scale_(operand_scale), |
| 283 source_info_(source_info) { | 268 source_info_(source_info) { |
| 284 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count); | 269 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count); |
| 285 operands_[0] = operand0; | 270 operands_[0] = operand0; |
| 286 operands_[1] = operand1; | 271 operands_[1] = operand1; |
| 287 operands_[2] = operand2; | 272 operands_[2] = operand2; |
| 288 operands_[3] = operand3; | 273 operands_[3] = operand3; |
| 289 operands_[4] = operand4; | |
| 290 } | 274 } |
| 291 | 275 |
| 292 template <Bytecode bytecode, AccumulatorUse accum_use> | 276 template <Bytecode bytecode, AccumulatorUse accum_use> |
| 293 INLINE(static BytecodeNode Create(BytecodeSourceInfo source_info)) { | 277 INLINE(static BytecodeNode Create(BytecodeSourceInfo source_info)) { |
| 294 return BytecodeNode(bytecode, 0, OperandScale::kSingle, source_info); | 278 return BytecodeNode(bytecode, 0, OperandScale::kSingle, source_info); |
| 295 } | 279 } |
| 296 | 280 |
| 297 template <Bytecode bytecode, AccumulatorUse accum_use, | 281 template <Bytecode bytecode, AccumulatorUse accum_use, |
| 298 OperandType operand0_type> | 282 OperandType operand0_type> |
| 299 INLINE(static BytecodeNode Create(BytecodeSourceInfo source_info, | 283 INLINE(static BytecodeNode Create(BytecodeSourceInfo source_info, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 3), operand3_type); | 329 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 3), operand3_type); |
| 346 OperandScale scale = OperandScale::kSingle; | 330 OperandScale scale = OperandScale::kSingle; |
| 347 scale = std::max(scale, ScaleForOperand<operand0_type>(operand0)); | 331 scale = std::max(scale, ScaleForOperand<operand0_type>(operand0)); |
| 348 scale = std::max(scale, ScaleForOperand<operand1_type>(operand1)); | 332 scale = std::max(scale, ScaleForOperand<operand1_type>(operand1)); |
| 349 scale = std::max(scale, ScaleForOperand<operand2_type>(operand2)); | 333 scale = std::max(scale, ScaleForOperand<operand2_type>(operand2)); |
| 350 scale = std::max(scale, ScaleForOperand<operand3_type>(operand3)); | 334 scale = std::max(scale, ScaleForOperand<operand3_type>(operand3)); |
| 351 return BytecodeNode(bytecode, 4, scale, source_info, operand0, operand1, | 335 return BytecodeNode(bytecode, 4, scale, source_info, operand0, operand1, |
| 352 operand2, operand3); | 336 operand2, operand3); |
| 353 } | 337 } |
| 354 | 338 |
| 355 template <Bytecode bytecode, AccumulatorUse accum_use, | |
| 356 OperandType operand0_type, OperandType operand1_type, | |
| 357 OperandType operand2_type, OperandType operand3_type, | |
| 358 OperandType operand4_type> | |
| 359 INLINE(static BytecodeNode Create(BytecodeSourceInfo source_info, | |
| 360 uint32_t operand0, uint32_t operand1, | |
| 361 uint32_t operand2, uint32_t operand3, | |
| 362 uint32_t operand4)) { | |
| 363 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 0), operand0_type); | |
| 364 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 1), operand1_type); | |
| 365 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 2), operand2_type); | |
| 366 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 3), operand3_type); | |
| 367 DCHECK_EQ(Bytecodes::GetOperandType(bytecode, 4), operand4_type); | |
| 368 OperandScale scale = OperandScale::kSingle; | |
| 369 scale = std::max(scale, ScaleForOperand<operand0_type>(operand0)); | |
| 370 scale = std::max(scale, ScaleForOperand<operand1_type>(operand1)); | |
| 371 scale = std::max(scale, ScaleForOperand<operand2_type>(operand2)); | |
| 372 scale = std::max(scale, ScaleForOperand<operand3_type>(operand3)); | |
| 373 scale = std::max(scale, ScaleForOperand<operand4_type>(operand4)); | |
| 374 return BytecodeNode(bytecode, 5, scale, source_info, operand0, operand1, | |
| 375 operand2, operand3, operand4); | |
| 376 } | |
| 377 | |
| 378 template <OperandType operand_type> | 339 template <OperandType operand_type> |
| 379 INLINE(static OperandScale ScaleForOperand(uint32_t operand)) { | 340 INLINE(static OperandScale ScaleForOperand(uint32_t operand)) { |
| 380 if (BytecodeOperands::IsScalableUnsignedByte(operand_type)) { | 341 if (BytecodeOperands::IsScalableUnsignedByte(operand_type)) { |
| 381 return Bytecodes::ScaleForUnsignedOperand(operand); | 342 return Bytecodes::ScaleForUnsignedOperand(operand); |
| 382 } else if (BytecodeOperands::IsScalableSignedByte(operand_type)) { | 343 } else if (BytecodeOperands::IsScalableSignedByte(operand_type)) { |
| 383 return Bytecodes::ScaleForSignedOperand(operand); | 344 return Bytecodes::ScaleForSignedOperand(operand); |
| 384 } else { | 345 } else { |
| 385 return OperandScale::kSingle; | 346 return OperandScale::kSingle; |
| 386 } | 347 } |
| 387 } | 348 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 412 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, | 373 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, |
| 413 const BytecodeSourceInfo& info); | 374 const BytecodeSourceInfo& info); |
| 414 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, | 375 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, |
| 415 const BytecodeNode& node); | 376 const BytecodeNode& node); |
| 416 | 377 |
| 417 } // namespace interpreter | 378 } // namespace interpreter |
| 418 } // namespace internal | 379 } // namespace internal |
| 419 } // namespace v8 | 380 } // namespace v8 |
| 420 | 381 |
| 421 #endif // V8_INTERPRETER_BYTECODE_PIPELINE_H_ | 382 #endif // V8_INTERPRETER_BYTECODE_PIPELINE_H_ |
| OLD | NEW |