| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_INSTRUCTION_SELECTOR_IMPL_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ |
| 6 #define V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ | 6 #define V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ |
| 7 | 7 |
| 8 #include "src/compiler/instruction.h" | 8 #include "src/compiler/instruction.h" |
| 9 #include "src/compiler/instruction-selector.h" | 9 #include "src/compiler/instruction-selector.h" |
| 10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 FlagsContinuation(FlagsCondition condition, BasicBlock* true_block, | 296 FlagsContinuation(FlagsCondition condition, BasicBlock* true_block, |
| 297 BasicBlock* false_block) | 297 BasicBlock* false_block) |
| 298 : mode_(kFlags_branch), | 298 : mode_(kFlags_branch), |
| 299 condition_(condition), | 299 condition_(condition), |
| 300 true_block_(true_block), | 300 true_block_(true_block), |
| 301 false_block_(false_block) { | 301 false_block_(false_block) { |
| 302 DCHECK_NOT_NULL(true_block); | 302 DCHECK_NOT_NULL(true_block); |
| 303 DCHECK_NOT_NULL(false_block); | 303 DCHECK_NOT_NULL(false_block); |
| 304 } | 304 } |
| 305 | 305 |
| 306 // Creates a new flags continuation from the given condition and result node. | 306 // Creates a new flags continuation for an eager deoptimization exit. |
| 307 FlagsContinuation(FlagsCondition condition, Node* result) | 307 static FlagsContinuation ForDeoptimize(FlagsCondition condition, |
| 308 : mode_(kFlags_set), condition_(condition), result_(result) { | 308 Node* frame_state) { |
| 309 DCHECK_NOT_NULL(result); | 309 return FlagsContinuation(kFlags_deoptimize, condition, frame_state); |
| 310 } |
| 311 |
| 312 // Creates a new flags continuation for a boolean value. |
| 313 static FlagsContinuation ForSet(FlagsCondition condition, Node* result) { |
| 314 return FlagsContinuation(kFlags_set, condition, result); |
| 310 } | 315 } |
| 311 | 316 |
| 312 bool IsNone() const { return mode_ == kFlags_none; } | 317 bool IsNone() const { return mode_ == kFlags_none; } |
| 313 bool IsBranch() const { return mode_ == kFlags_branch; } | 318 bool IsBranch() const { return mode_ == kFlags_branch; } |
| 319 bool IsDeoptimize() const { return mode_ == kFlags_deoptimize; } |
| 314 bool IsSet() const { return mode_ == kFlags_set; } | 320 bool IsSet() const { return mode_ == kFlags_set; } |
| 315 FlagsCondition condition() const { | 321 FlagsCondition condition() const { |
| 316 DCHECK(!IsNone()); | 322 DCHECK(!IsNone()); |
| 317 return condition_; | 323 return condition_; |
| 318 } | 324 } |
| 325 Node* frame_state() const { |
| 326 DCHECK(IsDeoptimize()); |
| 327 return frame_state_or_result_; |
| 328 } |
| 319 Node* result() const { | 329 Node* result() const { |
| 320 DCHECK(IsSet()); | 330 DCHECK(IsSet()); |
| 321 return result_; | 331 return frame_state_or_result_; |
| 322 } | 332 } |
| 323 BasicBlock* true_block() const { | 333 BasicBlock* true_block() const { |
| 324 DCHECK(IsBranch()); | 334 DCHECK(IsBranch()); |
| 325 return true_block_; | 335 return true_block_; |
| 326 } | 336 } |
| 327 BasicBlock* false_block() const { | 337 BasicBlock* false_block() const { |
| 328 DCHECK(IsBranch()); | 338 DCHECK(IsBranch()); |
| 329 return false_block_; | 339 return false_block_; |
| 330 } | 340 } |
| 331 | 341 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 348 // Encodes this flags continuation into the given opcode. | 358 // Encodes this flags continuation into the given opcode. |
| 349 InstructionCode Encode(InstructionCode opcode) { | 359 InstructionCode Encode(InstructionCode opcode) { |
| 350 opcode |= FlagsModeField::encode(mode_); | 360 opcode |= FlagsModeField::encode(mode_); |
| 351 if (mode_ != kFlags_none) { | 361 if (mode_ != kFlags_none) { |
| 352 opcode |= FlagsConditionField::encode(condition_); | 362 opcode |= FlagsConditionField::encode(condition_); |
| 353 } | 363 } |
| 354 return opcode; | 364 return opcode; |
| 355 } | 365 } |
| 356 | 366 |
| 357 private: | 367 private: |
| 358 FlagsMode mode_; | 368 FlagsContinuation(FlagsMode mode, FlagsCondition condition, |
| 369 Node* frame_state_or_result) |
| 370 : mode_(mode), |
| 371 condition_(condition), |
| 372 frame_state_or_result_(frame_state_or_result) { |
| 373 DCHECK_NOT_NULL(frame_state_or_result); |
| 374 } |
| 375 |
| 376 FlagsMode const mode_; |
| 359 FlagsCondition condition_; | 377 FlagsCondition condition_; |
| 360 Node* result_; // Only valid if mode_ == kFlags_set. | 378 Node* frame_state_or_result_; // Only valid if mode_ == kFlags_deoptimize |
| 361 BasicBlock* true_block_; // Only valid if mode_ == kFlags_branch. | 379 // or mode_ == kFlags_set. |
| 362 BasicBlock* false_block_; // Only valid if mode_ == kFlags_branch. | 380 BasicBlock* true_block_; // Only valid if mode_ == kFlags_branch. |
| 381 BasicBlock* false_block_; // Only valid if mode_ == kFlags_branch. |
| 363 }; | 382 }; |
| 364 | 383 |
| 365 } // namespace compiler | 384 } // namespace compiler |
| 366 } // namespace internal | 385 } // namespace internal |
| 367 } // namespace v8 | 386 } // namespace v8 |
| 368 | 387 |
| 369 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ | 388 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ |
| OLD | NEW |