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

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

Issue 1232613002: [turbofan] Fix undefined behavior in InstructionSequence::GetInstructionBlock. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | no next file » | 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 9
10 namespace v8 { 10 namespace v8 {
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 reference_maps_.push_back(reference_map); 559 reference_maps_.push_back(reference_map);
560 } 560 }
561 return index; 561 return index;
562 } 562 }
563 563
564 564
565 InstructionBlock* InstructionSequence::GetInstructionBlock( 565 InstructionBlock* InstructionSequence::GetInstructionBlock(
566 int instruction_index) const { 566 int instruction_index) const {
567 DCHECK(instruction_blocks_->size() == block_starts_.size()); 567 DCHECK(instruction_blocks_->size() == block_starts_.size());
568 auto begin = block_starts_.begin(); 568 auto begin = block_starts_.begin();
569 auto end = std::lower_bound(begin, block_starts_.end(), instruction_index, 569 auto end = std::lower_bound(begin, block_starts_.end(), instruction_index);
570 std::less_equal<int>()); 570 // Post condition of std::lower_bound:
571 size_t index = std::distance(begin, end) - 1; 571 DCHECK(end == block_starts_.end() || *end >= instruction_index);
572 if (end == block_starts_.end() || *end > instruction_index) --end;
573 DCHECK(*end <= instruction_index);
574 size_t index = std::distance(begin, end);
572 auto block = instruction_blocks_->at(index); 575 auto block = instruction_blocks_->at(index);
573 DCHECK(block->code_start() <= instruction_index && 576 DCHECK(block->code_start() <= instruction_index &&
574 instruction_index < block->code_end()); 577 instruction_index < block->code_end());
575 return block; 578 return block;
576 } 579 }
577 580
578 581
579 static MachineType FilterRepresentation(MachineType rep) { 582 static MachineType FilterRepresentation(MachineType rep) {
580 DCHECK_EQ(rep, RepresentationOf(rep)); 583 DCHECK_EQ(rep, RepresentationOf(rep));
581 switch (rep) { 584 switch (rep) {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 os << " B" << succ.ToInt(); 808 os << " B" << succ.ToInt();
806 } 809 }
807 os << "\n"; 810 os << "\n";
808 } 811 }
809 return os; 812 return os;
810 } 813 }
811 814
812 } // namespace compiler 815 } // namespace compiler
813 } // namespace internal 816 } // namespace internal
814 } // namespace v8 817 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698