Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: src/compiler/instruction.cc

Issue 1578723002: [turbofan] Build s/NULL/nullptr/g and CHECK(x != nullptr) to CHECK_NOT_NULL(x). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/instruction-selector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "src/compiler/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 #include "src/compiler/graph.h" 6 #include "src/compiler/graph.h"
7 #include "src/compiler/instruction.h" 7 #include "src/compiler/instruction.h"
8 #include "src/compiler/schedule.h" 8 #include "src/compiler/schedule.h"
9 #include "src/compiler/state-values-utils.h" 9 #include "src/compiler/state-values-utils.h"
10 10
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 Register::from_code(index).IsAllocatable()); 246 Register::from_code(index).IsAllocatable());
247 DCHECK_IMPLIES(kind == REGISTER && IsFloatingPoint(rep), 247 DCHECK_IMPLIES(kind == REGISTER && IsFloatingPoint(rep),
248 DoubleRegister::from_code(index).IsAllocatable()); 248 DoubleRegister::from_code(index).IsAllocatable());
249 } 249 }
250 250
251 251
252 Instruction::Instruction(InstructionCode opcode) 252 Instruction::Instruction(InstructionCode opcode)
253 : opcode_(opcode), 253 : opcode_(opcode),
254 bit_field_(OutputCountField::encode(0) | InputCountField::encode(0) | 254 bit_field_(OutputCountField::encode(0) | InputCountField::encode(0) |
255 TempCountField::encode(0) | IsCallField::encode(false)), 255 TempCountField::encode(0) | IsCallField::encode(false)),
256 reference_map_(NULL) { 256 reference_map_(nullptr) {
257 parallel_moves_[0] = nullptr; 257 parallel_moves_[0] = nullptr;
258 parallel_moves_[1] = nullptr; 258 parallel_moves_[1] = nullptr;
259 } 259 }
260 260
261 261
262 Instruction::Instruction(InstructionCode opcode, size_t output_count, 262 Instruction::Instruction(InstructionCode opcode, size_t output_count,
263 InstructionOperand* outputs, size_t input_count, 263 InstructionOperand* outputs, size_t input_count,
264 InstructionOperand* inputs, size_t temp_count, 264 InstructionOperand* inputs, size_t temp_count,
265 InstructionOperand* temps) 265 InstructionOperand* temps)
266 : opcode_(opcode), 266 : opcode_(opcode),
267 bit_field_(OutputCountField::encode(output_count) | 267 bit_field_(OutputCountField::encode(output_count) |
268 InputCountField::encode(input_count) | 268 InputCountField::encode(input_count) |
269 TempCountField::encode(temp_count) | 269 TempCountField::encode(temp_count) |
270 IsCallField::encode(false)), 270 IsCallField::encode(false)),
271 reference_map_(NULL) { 271 reference_map_(nullptr) {
272 parallel_moves_[0] = nullptr; 272 parallel_moves_[0] = nullptr;
273 parallel_moves_[1] = nullptr; 273 parallel_moves_[1] = nullptr;
274 size_t offset = 0; 274 size_t offset = 0;
275 for (size_t i = 0; i < output_count; ++i) { 275 for (size_t i = 0; i < output_count; ++i) {
276 DCHECK(!outputs[i].IsInvalid()); 276 DCHECK(!outputs[i].IsInvalid());
277 operands_[offset++] = outputs[i]; 277 operands_[offset++] = outputs[i];
278 } 278 }
279 for (size_t i = 0; i < input_count; ++i) { 279 for (size_t i = 0; i < input_count; ++i) {
280 DCHECK(!inputs[i].IsInvalid()); 280 DCHECK(!inputs[i].IsInvalid());
281 operands_[offset++] = inputs[i]; 281 operands_[offset++] = inputs[i];
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 452
453 std::ostream& operator<<(std::ostream& os, 453 std::ostream& operator<<(std::ostream& os,
454 const PrintableInstruction& printable) { 454 const PrintableInstruction& printable) {
455 const Instruction& instr = *printable.instr_; 455 const Instruction& instr = *printable.instr_;
456 PrintableInstructionOperand printable_op = {printable.register_configuration_, 456 PrintableInstructionOperand printable_op = {printable.register_configuration_,
457 InstructionOperand()}; 457 InstructionOperand()};
458 os << "gap "; 458 os << "gap ";
459 for (int i = Instruction::FIRST_GAP_POSITION; 459 for (int i = Instruction::FIRST_GAP_POSITION;
460 i <= Instruction::LAST_GAP_POSITION; i++) { 460 i <= Instruction::LAST_GAP_POSITION; i++) {
461 os << "("; 461 os << "(";
462 if (instr.parallel_moves()[i] != NULL) { 462 if (instr.parallel_moves()[i] != nullptr) {
463 PrintableParallelMove ppm = {printable.register_configuration_, 463 PrintableParallelMove ppm = {printable.register_configuration_,
464 instr.parallel_moves()[i]}; 464 instr.parallel_moves()[i]};
465 os << ppm; 465 os << ppm;
466 } 466 }
467 os << ") "; 467 os << ") ";
468 } 468 }
469 os << "\n "; 469 os << "\n ";
470 470
471 if (instr.OutputCount() > 1) os << "("; 471 if (instr.OutputCount() > 1) os << "(";
472 for (size_t i = 0; i < instr.OutputCount(); i++) { 472 for (size_t i = 0; i < instr.OutputCount(); i++) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 size_t j = 0; 561 size_t j = 0;
562 for (InstructionBlock::Predecessors::const_iterator i = predecessors_.begin(); 562 for (InstructionBlock::Predecessors::const_iterator i = predecessors_.begin();
563 i != predecessors_.end(); ++i, ++j) { 563 i != predecessors_.end(); ++i, ++j) {
564 if (*i == rpo_number) break; 564 if (*i == rpo_number) break;
565 } 565 }
566 return j; 566 return j;
567 } 567 }
568 568
569 569
570 static RpoNumber GetRpo(const BasicBlock* block) { 570 static RpoNumber GetRpo(const BasicBlock* block) {
571 if (block == NULL) return RpoNumber::Invalid(); 571 if (block == nullptr) return RpoNumber::Invalid();
572 return RpoNumber::FromInt(block->rpo_number()); 572 return RpoNumber::FromInt(block->rpo_number());
573 } 573 }
574 574
575 575
576 static RpoNumber GetLoopEndRpo(const BasicBlock* block) { 576 static RpoNumber GetLoopEndRpo(const BasicBlock* block) {
577 if (!block->IsLoopHeader()) return RpoNumber::Invalid(); 577 if (!block->IsLoopHeader()) return RpoNumber::Invalid();
578 return RpoNumber::FromInt(block->loop_end()->rpo_number()); 578 return RpoNumber::FromInt(block->loop_end()->rpo_number());
579 } 579 }
580 580
581 581
(...skipping 14 matching lines...) Expand all
596 instr_block->predecessors().push_back(GetRpo(predecessor)); 596 instr_block->predecessors().push_back(GetRpo(predecessor));
597 } 597 }
598 return instr_block; 598 return instr_block;
599 } 599 }
600 600
601 601
602 InstructionBlocks* InstructionSequence::InstructionBlocksFor( 602 InstructionBlocks* InstructionSequence::InstructionBlocksFor(
603 Zone* zone, const Schedule* schedule) { 603 Zone* zone, const Schedule* schedule) {
604 InstructionBlocks* blocks = zone->NewArray<InstructionBlocks>(1); 604 InstructionBlocks* blocks = zone->NewArray<InstructionBlocks>(1);
605 new (blocks) InstructionBlocks( 605 new (blocks) InstructionBlocks(
606 static_cast<int>(schedule->rpo_order()->size()), NULL, zone); 606 static_cast<int>(schedule->rpo_order()->size()), nullptr, zone);
607 size_t rpo_number = 0; 607 size_t rpo_number = 0;
608 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin(); 608 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin();
609 it != schedule->rpo_order()->end(); ++it, ++rpo_number) { 609 it != schedule->rpo_order()->end(); ++it, ++rpo_number) {
610 DCHECK(!(*blocks)[rpo_number]); 610 DCHECK(!(*blocks)[rpo_number]);
611 DCHECK(GetRpo(*it).ToSize() == rpo_number); 611 DCHECK(GetRpo(*it).ToSize() == rpo_number);
612 (*blocks)[rpo_number] = InstructionBlockFor(zone, *it); 612 (*blocks)[rpo_number] = InstructionBlockFor(zone, *it);
613 } 613 }
614 ComputeAssemblyOrder(blocks); 614 ComputeAssemblyOrder(blocks);
615 return blocks; 615 return blocks;
616 } 616 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 682 }
683 DCHECK(block->code_start() >= 0 && block->code_start() < end); 683 DCHECK(block->code_start() >= 0 && block->code_start() < end);
684 block->set_code_end(end); 684 block->set_code_end(end);
685 } 685 }
686 686
687 687
688 int InstructionSequence::AddInstruction(Instruction* instr) { 688 int InstructionSequence::AddInstruction(Instruction* instr) {
689 int index = static_cast<int>(instructions_.size()); 689 int index = static_cast<int>(instructions_.size());
690 instructions_.push_back(instr); 690 instructions_.push_back(instr);
691 if (instr->NeedsReferenceMap()) { 691 if (instr->NeedsReferenceMap()) {
692 DCHECK(instr->reference_map() == NULL); 692 DCHECK(instr->reference_map() == nullptr);
693 ReferenceMap* reference_map = new (zone()) ReferenceMap(zone()); 693 ReferenceMap* reference_map = new (zone()) ReferenceMap(zone());
694 reference_map->set_instruction_position(index); 694 reference_map->set_instruction_position(index);
695 instr->set_reference_map(reference_map); 695 instr->set_reference_map(reference_map);
696 reference_maps_.push_back(reference_map); 696 reference_maps_.push_back(reference_map);
697 } 697 }
698 return index; 698 return index;
699 } 699 }
700 700
701 701
702 InstructionBlock* InstructionSequence::GetInstructionBlock( 702 InstructionBlock* InstructionSequence::GetInstructionBlock(
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 break; 846 break;
847 case OutputFrameStateCombine::kPokeAt: 847 case OutputFrameStateCombine::kPokeAt:
848 break; 848 break;
849 } 849 }
850 return size; 850 return size;
851 } 851 }
852 852
853 853
854 size_t FrameStateDescriptor::GetTotalSize() const { 854 size_t FrameStateDescriptor::GetTotalSize() const {
855 size_t total_size = 0; 855 size_t total_size = 0;
856 for (const FrameStateDescriptor* iter = this; iter != NULL; 856 for (const FrameStateDescriptor* iter = this; iter != nullptr;
857 iter = iter->outer_state_) { 857 iter = iter->outer_state_) {
858 total_size += iter->GetSize(); 858 total_size += iter->GetSize();
859 } 859 }
860 return total_size; 860 return total_size;
861 } 861 }
862 862
863 863
864 size_t FrameStateDescriptor::GetFrameCount() const { 864 size_t FrameStateDescriptor::GetFrameCount() const {
865 size_t count = 0; 865 size_t count = 0;
866 for (const FrameStateDescriptor* iter = this; iter != NULL; 866 for (const FrameStateDescriptor* iter = this; iter != nullptr;
867 iter = iter->outer_state_) { 867 iter = iter->outer_state_) {
868 ++count; 868 ++count;
869 } 869 }
870 return count; 870 return count;
871 } 871 }
872 872
873 873
874 size_t FrameStateDescriptor::GetJSFrameCount() const { 874 size_t FrameStateDescriptor::GetJSFrameCount() const {
875 size_t count = 0; 875 size_t count = 0;
876 for (const FrameStateDescriptor* iter = this; iter != NULL; 876 for (const FrameStateDescriptor* iter = this; iter != nullptr;
877 iter = iter->outer_state_) { 877 iter = iter->outer_state_) {
878 if (FrameStateFunctionInfo::IsJSFunctionType(iter->type_)) { 878 if (FrameStateFunctionInfo::IsJSFunctionType(iter->type_)) {
879 ++count; 879 ++count;
880 } 880 }
881 } 881 }
882 return count; 882 return count;
883 } 883 }
884 884
885 885
886 std::ostream& operator<<(std::ostream& os, const RpoNumber& rpo) { 886 std::ostream& operator<<(std::ostream& os, const RpoNumber& rpo) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 os << " B" << succ.ToInt(); 948 os << " B" << succ.ToInt();
949 } 949 }
950 os << "\n"; 950 os << "\n";
951 } 951 }
952 return os; 952 return os;
953 } 953 }
954 954
955 } // namespace compiler 955 } // namespace compiler
956 } // namespace internal 956 } // namespace internal
957 } // namespace v8 957 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/instruction-selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698