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.h" | 9 #include "src/compiler/instruction.h" |
9 #include "src/compiler/instruction-selector.h" | |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
11 #include "src/compiler/schedule.h" | 11 #include "src/compiler/schedule.h" |
12 #include "src/macro-assembler.h" | 12 #include "src/macro-assembler.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
| 16 |
| 17 class SourcePosition; |
| 18 |
16 namespace compiler { | 19 namespace compiler { |
17 | 20 |
18 // Helper struct containing data about a table or lookup switch. | 21 // Helper struct containing data about a table or lookup switch. |
19 struct SwitchInfo { | 22 struct SwitchInfo { |
20 int32_t min_value; // minimum value of {case_values} | 23 int32_t min_value; // minimum value of {case_values} |
21 int32_t max_value; // maximum value of {case_values} | 24 int32_t max_value; // maximum value of {case_values} |
22 size_t value_range; // |max_value - min_value| + 1 | 25 size_t value_range; // |max_value - min_value| + 1 |
23 size_t case_count; // number of cases | 26 size_t case_count; // number of cases |
24 int32_t* case_values; // actual case values, unsorted | 27 int32_t* case_values; // actual case values, unsorted |
25 BasicBlock** case_branches; // basic blocks corresponding to case values | 28 BasicBlock** case_branches; // basic blocks corresponding to case values |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 DeoptimizeReason reason, | 341 DeoptimizeReason reason, |
339 Node* frame_state) { | 342 Node* frame_state) { |
340 return FlagsContinuation(condition, reason, frame_state); | 343 return FlagsContinuation(condition, reason, frame_state); |
341 } | 344 } |
342 | 345 |
343 // Creates a new flags continuation for a boolean value. | 346 // Creates a new flags continuation for a boolean value. |
344 static FlagsContinuation ForSet(FlagsCondition condition, Node* result) { | 347 static FlagsContinuation ForSet(FlagsCondition condition, Node* result) { |
345 return FlagsContinuation(condition, result); | 348 return FlagsContinuation(condition, result); |
346 } | 349 } |
347 | 350 |
| 351 // Creates a new flags continuation for a wasm trap. |
| 352 static FlagsContinuation ForTrap(FlagsCondition condition, |
| 353 Runtime::FunctionId trap_id, |
| 354 SourcePosition* source_position, |
| 355 Node* result) { |
| 356 return FlagsContinuation(condition, trap_id, source_position, result); |
| 357 } |
| 358 |
348 bool IsNone() const { return mode_ == kFlags_none; } | 359 bool IsNone() const { return mode_ == kFlags_none; } |
349 bool IsBranch() const { return mode_ == kFlags_branch; } | 360 bool IsBranch() const { return mode_ == kFlags_branch; } |
350 bool IsDeoptimize() const { return mode_ == kFlags_deoptimize; } | 361 bool IsDeoptimize() const { return mode_ == kFlags_deoptimize; } |
351 bool IsSet() const { return mode_ == kFlags_set; } | 362 bool IsSet() const { return mode_ == kFlags_set; } |
| 363 bool IsTrap() const { return mode_ == kFlags_trap; } |
352 FlagsCondition condition() const { | 364 FlagsCondition condition() const { |
353 DCHECK(!IsNone()); | 365 DCHECK(!IsNone()); |
354 return condition_; | 366 return condition_; |
355 } | 367 } |
356 DeoptimizeReason reason() const { | 368 DeoptimizeReason reason() const { |
357 DCHECK(IsDeoptimize()); | 369 DCHECK(IsDeoptimize()); |
358 return reason_; | 370 return reason_; |
359 } | 371 } |
360 Node* frame_state() const { | 372 Node* frame_state() const { |
361 DCHECK(IsDeoptimize()); | 373 DCHECK(IsDeoptimize()); |
362 return frame_state_or_result_; | 374 return frame_state_or_result_; |
363 } | 375 } |
364 Node* result() const { | 376 Node* result() const { |
365 DCHECK(IsSet()); | 377 DCHECK(IsSet()); |
366 return frame_state_or_result_; | 378 return frame_state_or_result_; |
367 } | 379 } |
| 380 int trap_id() const { |
| 381 DCHECK(IsTrap()); |
| 382 return trap_id_; |
| 383 } |
| 384 SourcePosition* source_position() const { |
| 385 DCHECK(IsTrap()); |
| 386 return source_position_; |
| 387 } |
368 BasicBlock* true_block() const { | 388 BasicBlock* true_block() const { |
369 DCHECK(IsBranch()); | 389 DCHECK(IsBranch()); |
370 return true_block_; | 390 return true_block_; |
371 } | 391 } |
372 BasicBlock* false_block() const { | 392 BasicBlock* false_block() const { |
373 DCHECK(IsBranch()); | 393 DCHECK(IsBranch()); |
374 return false_block_; | 394 return false_block_; |
375 } | 395 } |
376 | 396 |
377 void Negate() { | 397 void Negate() { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 frame_state_or_result_(frame_state) { | 450 frame_state_or_result_(frame_state) { |
431 DCHECK_NOT_NULL(frame_state); | 451 DCHECK_NOT_NULL(frame_state); |
432 } | 452 } |
433 FlagsContinuation(FlagsCondition condition, Node* result) | 453 FlagsContinuation(FlagsCondition condition, Node* result) |
434 : mode_(kFlags_set), | 454 : mode_(kFlags_set), |
435 condition_(condition), | 455 condition_(condition), |
436 frame_state_or_result_(result) { | 456 frame_state_or_result_(result) { |
437 DCHECK_NOT_NULL(result); | 457 DCHECK_NOT_NULL(result); |
438 } | 458 } |
439 | 459 |
| 460 FlagsContinuation(FlagsCondition condition, int32_t trap_id, |
| 461 SourcePosition* source_position, Node* result) |
| 462 : mode_(kFlags_trap), |
| 463 condition_(condition), |
| 464 frame_state_or_result_(result), |
| 465 trap_id_(trap_id), |
| 466 source_position_(source_position) { |
| 467 DCHECK_NOT_NULL(result); |
| 468 } |
| 469 |
440 FlagsMode const mode_; | 470 FlagsMode const mode_; |
441 FlagsCondition condition_; | 471 FlagsCondition condition_; |
442 DeoptimizeReason reason_; // Only value if mode_ == kFlags_deoptimize | 472 DeoptimizeReason reason_; // Only value if mode_ == kFlags_deoptimize |
443 Node* frame_state_or_result_; // Only valid if mode_ == kFlags_deoptimize | 473 Node* frame_state_or_result_; // Only valid if mode_ == kFlags_deoptimize |
444 // or mode_ == kFlags_set. | 474 // or mode_ == kFlags_set. |
445 BasicBlock* true_block_; // Only valid if mode_ == kFlags_branch. | 475 BasicBlock* true_block_; // Only valid if mode_ == kFlags_branch. |
446 BasicBlock* false_block_; // Only valid if mode_ == kFlags_branch. | 476 BasicBlock* false_block_; // Only valid if mode_ == kFlags_branch. |
| 477 int32_t trap_id_; // Only valid if mode_ == kFlags_trap. |
| 478 SourcePosition* source_position_; // Only valid if mode_ == kFlags_trap. |
447 }; | 479 }; |
448 | 480 |
449 } // namespace compiler | 481 } // namespace compiler |
450 } // namespace internal | 482 } // namespace internal |
451 } // namespace v8 | 483 } // namespace v8 |
452 | 484 |
453 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ | 485 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ |
OLD | NEW |