| 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-selector.h" | 8 #include "src/compiler/instruction-selector.h" |
| 9 #include "src/compiler/instruction.h" | 9 #include "src/compiler/instruction.h" |
| 10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 : mode_(kFlags_branch), | 343 : mode_(kFlags_branch), |
| 344 condition_(condition), | 344 condition_(condition), |
| 345 true_block_(true_block), | 345 true_block_(true_block), |
| 346 false_block_(false_block) { | 346 false_block_(false_block) { |
| 347 DCHECK_NOT_NULL(true_block); | 347 DCHECK_NOT_NULL(true_block); |
| 348 DCHECK_NOT_NULL(false_block); | 348 DCHECK_NOT_NULL(false_block); |
| 349 } | 349 } |
| 350 | 350 |
| 351 // Creates a new flags continuation for an eager deoptimization exit. | 351 // Creates a new flags continuation for an eager deoptimization exit. |
| 352 static FlagsContinuation ForDeoptimize(FlagsCondition condition, | 352 static FlagsContinuation ForDeoptimize(FlagsCondition condition, |
| 353 DeoptimizeKind kind, | |
| 354 DeoptimizeReason reason, | 353 DeoptimizeReason reason, |
| 355 Node* frame_state) { | 354 Node* frame_state) { |
| 356 return FlagsContinuation(condition, kind, reason, frame_state); | 355 return FlagsContinuation(condition, reason, frame_state); |
| 357 } | 356 } |
| 358 | 357 |
| 359 // Creates a new flags continuation for a boolean value. | 358 // Creates a new flags continuation for a boolean value. |
| 360 static FlagsContinuation ForSet(FlagsCondition condition, Node* result) { | 359 static FlagsContinuation ForSet(FlagsCondition condition, Node* result) { |
| 361 return FlagsContinuation(condition, result); | 360 return FlagsContinuation(condition, result); |
| 362 } | 361 } |
| 363 | 362 |
| 364 // Creates a new flags continuation for a wasm trap. | 363 // Creates a new flags continuation for a wasm trap. |
| 365 static FlagsContinuation ForTrap(FlagsCondition condition, | 364 static FlagsContinuation ForTrap(FlagsCondition condition, |
| 366 Runtime::FunctionId trap_id, Node* result) { | 365 Runtime::FunctionId trap_id, Node* result) { |
| 367 return FlagsContinuation(condition, trap_id, result); | 366 return FlagsContinuation(condition, trap_id, result); |
| 368 } | 367 } |
| 369 | 368 |
| 370 bool IsNone() const { return mode_ == kFlags_none; } | 369 bool IsNone() const { return mode_ == kFlags_none; } |
| 371 bool IsBranch() const { return mode_ == kFlags_branch; } | 370 bool IsBranch() const { return mode_ == kFlags_branch; } |
| 372 bool IsDeoptimize() const { return mode_ == kFlags_deoptimize; } | 371 bool IsDeoptimize() const { return mode_ == kFlags_deoptimize; } |
| 373 bool IsSet() const { return mode_ == kFlags_set; } | 372 bool IsSet() const { return mode_ == kFlags_set; } |
| 374 bool IsTrap() const { return mode_ == kFlags_trap; } | 373 bool IsTrap() const { return mode_ == kFlags_trap; } |
| 375 FlagsCondition condition() const { | 374 FlagsCondition condition() const { |
| 376 DCHECK(!IsNone()); | 375 DCHECK(!IsNone()); |
| 377 return condition_; | 376 return condition_; |
| 378 } | 377 } |
| 379 DeoptimizeKind kind() const { | |
| 380 DCHECK(IsDeoptimize()); | |
| 381 return kind_; | |
| 382 } | |
| 383 DeoptimizeReason reason() const { | 378 DeoptimizeReason reason() const { |
| 384 DCHECK(IsDeoptimize()); | 379 DCHECK(IsDeoptimize()); |
| 385 return reason_; | 380 return reason_; |
| 386 } | 381 } |
| 387 Node* frame_state() const { | 382 Node* frame_state() const { |
| 388 DCHECK(IsDeoptimize()); | 383 DCHECK(IsDeoptimize()); |
| 389 return frame_state_or_result_; | 384 return frame_state_or_result_; |
| 390 } | 385 } |
| 391 Node* result() const { | 386 Node* result() const { |
| 392 DCHECK(IsSet()); | 387 DCHECK(IsSet()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 // Encodes this flags continuation into the given opcode. | 441 // Encodes this flags continuation into the given opcode. |
| 447 InstructionCode Encode(InstructionCode opcode) { | 442 InstructionCode Encode(InstructionCode opcode) { |
| 448 opcode |= FlagsModeField::encode(mode_); | 443 opcode |= FlagsModeField::encode(mode_); |
| 449 if (mode_ != kFlags_none) { | 444 if (mode_ != kFlags_none) { |
| 450 opcode |= FlagsConditionField::encode(condition_); | 445 opcode |= FlagsConditionField::encode(condition_); |
| 451 } | 446 } |
| 452 return opcode; | 447 return opcode; |
| 453 } | 448 } |
| 454 | 449 |
| 455 private: | 450 private: |
| 456 FlagsContinuation(FlagsCondition condition, DeoptimizeKind kind, | 451 FlagsContinuation(FlagsCondition condition, DeoptimizeReason reason, |
| 457 DeoptimizeReason reason, Node* frame_state) | 452 Node* frame_state) |
| 458 : mode_(kFlags_deoptimize), | 453 : mode_(kFlags_deoptimize), |
| 459 condition_(condition), | 454 condition_(condition), |
| 460 kind_(kind), | |
| 461 reason_(reason), | 455 reason_(reason), |
| 462 frame_state_or_result_(frame_state) { | 456 frame_state_or_result_(frame_state) { |
| 463 DCHECK_NOT_NULL(frame_state); | 457 DCHECK_NOT_NULL(frame_state); |
| 464 } | 458 } |
| 465 FlagsContinuation(FlagsCondition condition, Node* result) | 459 FlagsContinuation(FlagsCondition condition, Node* result) |
| 466 : mode_(kFlags_set), | 460 : mode_(kFlags_set), |
| 467 condition_(condition), | 461 condition_(condition), |
| 468 frame_state_or_result_(result) { | 462 frame_state_or_result_(result) { |
| 469 DCHECK_NOT_NULL(result); | 463 DCHECK_NOT_NULL(result); |
| 470 } | 464 } |
| 471 | 465 |
| 472 FlagsContinuation(FlagsCondition condition, Runtime::FunctionId trap_id, | 466 FlagsContinuation(FlagsCondition condition, Runtime::FunctionId trap_id, |
| 473 Node* result) | 467 Node* result) |
| 474 : mode_(kFlags_trap), | 468 : mode_(kFlags_trap), |
| 475 condition_(condition), | 469 condition_(condition), |
| 476 frame_state_or_result_(result), | 470 frame_state_or_result_(result), |
| 477 trap_id_(trap_id) { | 471 trap_id_(trap_id) { |
| 478 DCHECK_NOT_NULL(result); | 472 DCHECK_NOT_NULL(result); |
| 479 } | 473 } |
| 480 | 474 |
| 481 FlagsMode const mode_; | 475 FlagsMode const mode_; |
| 482 FlagsCondition condition_; | 476 FlagsCondition condition_; |
| 483 DeoptimizeKind kind_; // Only valid if mode_ == kFlags_deoptimize | 477 DeoptimizeReason reason_; // Only value if mode_ == kFlags_deoptimize |
| 484 DeoptimizeReason reason_; // Only valid if mode_ == kFlags_deoptimize | |
| 485 Node* frame_state_or_result_; // Only valid if mode_ == kFlags_deoptimize | 478 Node* frame_state_or_result_; // Only valid if mode_ == kFlags_deoptimize |
| 486 // or mode_ == kFlags_set. | 479 // or mode_ == kFlags_set. |
| 487 BasicBlock* true_block_; // Only valid if mode_ == kFlags_branch. | 480 BasicBlock* true_block_; // Only valid if mode_ == kFlags_branch. |
| 488 BasicBlock* false_block_; // Only valid if mode_ == kFlags_branch. | 481 BasicBlock* false_block_; // Only valid if mode_ == kFlags_branch. |
| 489 Runtime::FunctionId trap_id_; // Only valid if mode_ == kFlags_trap. | 482 Runtime::FunctionId trap_id_; // Only valid if mode_ == kFlags_trap. |
| 490 }; | 483 }; |
| 491 | 484 |
| 492 } // namespace compiler | 485 } // namespace compiler |
| 493 } // namespace internal | 486 } // namespace internal |
| 494 } // namespace v8 | 487 } // namespace v8 |
| 495 | 488 |
| 496 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ | 489 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ |
| OLD | NEW |