[cleanup] Replace ZoneList with ZoneChunkList in DeoptimizationInfo

Drive-by change: Add std::iterator_traits typedefs to ZoneChunkListIterator
so we can use <algorithm>.

R=mstarzinger@chromium.org

Bug: v8:7754
Change-Id: Ib7d1c622fdb761fc99bea373dbdef206f15bd4a0
Reviewed-on: https://chromium-review.googlesource.com/1145075
Commit-Queue: Simon Zünd <szuend@google.com>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54601}
This commit is contained in:
Simon Zünd 2018-07-21 09:58:12 +02:00 committed by Commit Bot
parent 453038181a
commit a298405a68
4 changed files with 35 additions and 31 deletions

View File

@ -439,10 +439,10 @@ void CodeGenerator::RecordSafepoint(ReferenceMap* references,
// we also don't need to worry about them, since the GC has special
// knowledge about those fields anyway.
if (index < stackSlotToSpillSlotDelta) continue;
safepoint.DefinePointerSlot(index, zone());
safepoint.DefinePointerSlot(index);
} else if (operand.IsRegister() && (kind & Safepoint::kWithRegisters)) {
Register reg = LocationOperand::cast(operand).GetRegister();
safepoint.DefinePointerRegister(reg, zone());
safepoint.DefinePointerRegister(reg);
}
}
}

View File

@ -121,9 +121,8 @@ void SafepointTable::PrintBits(std::ostream& os, // NOLINT
}
}
void Safepoint::DefinePointerRegister(Register reg, Zone* zone) {
registers_->Add(reg.code(), zone);
void Safepoint::DefinePointerRegister(Register reg) {
registers_->push_back(reg.code());
}
@ -201,8 +200,8 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) {
// Emit table of bitmaps.
ZoneVector<uint8_t> bits(bytes_per_entry, 0, zone_);
for (int i = 0; i < length; i++) {
ZoneList<int>* indexes = deoptimization_info_[i].indexes;
ZoneList<int>* registers = deoptimization_info_[i].registers;
ZoneChunkList<int>* indexes = deoptimization_info_[i].indexes;
ZoneChunkList<int>* registers = deoptimization_info_[i].registers;
std::fill(bits.begin(), bits.end(), 0);
// Run through the registers (if any).
@ -213,8 +212,7 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) {
bits[j] = SafepointTable::kNoRegisters;
}
} else {
for (int j = 0; j < registers->length(); j++) {
int index = registers->at(j);
for (int index : *registers) {
DCHECK(index >= 0 && index < kNumSafepointRegisters);
int byte_index = index >> kBitsPerByteLog2;
int bit_index = index & (kBitsPerByte - 1);
@ -223,8 +221,8 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) {
}
// Run through the indexes and build a bitmap.
for (int j = 0; j < indexes->length(); j++) {
int index = bits_per_entry - 1 - indexes->at(j);
for (int idx : *indexes) {
int index = bits_per_entry - 1 - idx;
int byte_index = index >> kBitsPerByteLog2;
int bit_index = index & (kBitsPerByte - 1);
bits[byte_index] |= (1U << bit_index);
@ -272,20 +270,21 @@ bool SafepointTableBuilder::IsIdenticalExceptForPc(
if (info1.deopt_index != info2.deopt_index) return false;
ZoneList<int>* indexes1 = info1.indexes;
ZoneList<int>* indexes2 = info2.indexes;
if (indexes1->length() != indexes2->length()) return false;
for (int i = 0; i < indexes1->length(); ++i) {
if (indexes1->at(i) != indexes2->at(i)) return false;
ZoneChunkList<int>* indexes1 = info1.indexes;
ZoneChunkList<int>* indexes2 = info2.indexes;
if (indexes1->size() != indexes2->size()) return false;
if (!std::equal(indexes1->begin(), indexes1->end(), indexes2->begin())) {
return false;
}
ZoneList<int>* registers1 = info1.registers;
ZoneList<int>* registers2 = info2.registers;
ZoneChunkList<int>* registers1 = info1.registers;
ZoneChunkList<int>* registers2 = info2.registers;
if (registers1) {
if (!registers2) return false;
if (registers1->length() != registers2->length()) return false;
for (int i = 0; i < registers1->length(); ++i) {
if (registers1->at(i) != registers2->at(i)) return false;
if (registers1->size() != registers2->size()) return false;
if (!std::equal(registers1->begin(), registers1->end(),
registers2->begin())) {
return false;
}
} else if (registers2) {
return false;

View File

@ -9,6 +9,7 @@
#include "src/assert-scope.h"
#include "src/utils.h"
#include "src/v8memory.h"
#include "src/zone/zone-chunk-list.h"
#include "src/zone/zone.h"
namespace v8 {
@ -188,14 +189,14 @@ class Safepoint BASE_EMBEDDED {
static const int kNoDeoptimizationIndex =
(1 << (SafepointEntry::kDeoptIndexBits)) - 1;
void DefinePointerSlot(int index, Zone* zone) { indexes_->Add(index, zone); }
void DefinePointerRegister(Register reg, Zone* zone);
void DefinePointerSlot(int index) { indexes_->push_back(index); }
void DefinePointerRegister(Register reg);
private:
Safepoint(ZoneList<int>* indexes, ZoneList<int>* registers)
Safepoint(ZoneChunkList<int>* indexes, ZoneChunkList<int>* registers)
: indexes_(indexes), registers_(registers) {}
ZoneList<int>* const indexes_;
ZoneList<int>* const registers_;
ZoneChunkList<int>* const indexes_;
ZoneChunkList<int>* const registers_;
friend class SafepointTableBuilder;
};
@ -241,8 +242,8 @@ class SafepointTableBuilder BASE_EMBEDDED {
unsigned arguments;
bool has_doubles;
int trampoline;
ZoneList<int>* indexes;
ZoneList<int>* registers;
ZoneChunkList<int>* indexes;
ZoneChunkList<int>* registers;
unsigned deopt_index;
DeoptimizationInfo(Zone* zone, unsigned pc, unsigned arguments,
Safepoint::Kind kind)
@ -250,9 +251,11 @@ class SafepointTableBuilder BASE_EMBEDDED {
arguments(arguments),
has_doubles(kind & Safepoint::kWithDoubles),
trampoline(-1),
indexes(new (zone) ZoneList<int>(8, zone)),
indexes(new (zone) ZoneChunkList<int>(
zone, ZoneChunkList<int>::StartMode::kSmall)),
registers(kind & Safepoint::kWithRegisters
? new (zone) ZoneList<int>(4, zone)
? new (zone) ZoneChunkList<int>(
zone, ZoneChunkList<int>::StartMode::kSmall)
: nullptr),
deopt_index(Safepoint::kNoDeoptimizationIndex) {}
};

View File

@ -4,6 +4,7 @@
#include <stdlib.h>
#include "src/base/iterator.h"
#include "src/globals.h"
#include "src/utils.h"
#include "src/zone/zone.h"
@ -145,7 +146,8 @@ class ZoneChunkList : public ZoneObject {
};
template <typename T, bool backwards, bool modifiable>
class ZoneChunkListIterator {
class ZoneChunkListIterator
: public base::iterator<std::bidirectional_iterator_tag, T> {
private:
template <typename S>
using maybe_const =