Commit a298405a authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[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: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54601}
parent 45303818
...@@ -439,10 +439,10 @@ void CodeGenerator::RecordSafepoint(ReferenceMap* references, ...@@ -439,10 +439,10 @@ void CodeGenerator::RecordSafepoint(ReferenceMap* references,
// we also don't need to worry about them, since the GC has special // we also don't need to worry about them, since the GC has special
// knowledge about those fields anyway. // knowledge about those fields anyway.
if (index < stackSlotToSpillSlotDelta) continue; if (index < stackSlotToSpillSlotDelta) continue;
safepoint.DefinePointerSlot(index, zone()); safepoint.DefinePointerSlot(index);
} else if (operand.IsRegister() && (kind & Safepoint::kWithRegisters)) { } else if (operand.IsRegister() && (kind & Safepoint::kWithRegisters)) {
Register reg = LocationOperand::cast(operand).GetRegister(); Register reg = LocationOperand::cast(operand).GetRegister();
safepoint.DefinePointerRegister(reg, zone()); safepoint.DefinePointerRegister(reg);
} }
} }
} }
......
...@@ -121,9 +121,8 @@ void SafepointTable::PrintBits(std::ostream& os, // NOLINT ...@@ -121,9 +121,8 @@ void SafepointTable::PrintBits(std::ostream& os, // NOLINT
} }
} }
void Safepoint::DefinePointerRegister(Register reg) {
void Safepoint::DefinePointerRegister(Register reg, Zone* zone) { registers_->push_back(reg.code());
registers_->Add(reg.code(), zone);
} }
...@@ -201,8 +200,8 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) { ...@@ -201,8 +200,8 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) {
// Emit table of bitmaps. // Emit table of bitmaps.
ZoneVector<uint8_t> bits(bytes_per_entry, 0, zone_); ZoneVector<uint8_t> bits(bytes_per_entry, 0, zone_);
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
ZoneList<int>* indexes = deoptimization_info_[i].indexes; ZoneChunkList<int>* indexes = deoptimization_info_[i].indexes;
ZoneList<int>* registers = deoptimization_info_[i].registers; ZoneChunkList<int>* registers = deoptimization_info_[i].registers;
std::fill(bits.begin(), bits.end(), 0); std::fill(bits.begin(), bits.end(), 0);
// Run through the registers (if any). // Run through the registers (if any).
...@@ -213,8 +212,7 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) { ...@@ -213,8 +212,7 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) {
bits[j] = SafepointTable::kNoRegisters; bits[j] = SafepointTable::kNoRegisters;
} }
} else { } else {
for (int j = 0; j < registers->length(); j++) { for (int index : *registers) {
int index = registers->at(j);
DCHECK(index >= 0 && index < kNumSafepointRegisters); DCHECK(index >= 0 && index < kNumSafepointRegisters);
int byte_index = index >> kBitsPerByteLog2; int byte_index = index >> kBitsPerByteLog2;
int bit_index = index & (kBitsPerByte - 1); int bit_index = index & (kBitsPerByte - 1);
...@@ -223,8 +221,8 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) { ...@@ -223,8 +221,8 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) {
} }
// Run through the indexes and build a bitmap. // Run through the indexes and build a bitmap.
for (int j = 0; j < indexes->length(); j++) { for (int idx : *indexes) {
int index = bits_per_entry - 1 - indexes->at(j); int index = bits_per_entry - 1 - idx;
int byte_index = index >> kBitsPerByteLog2; int byte_index = index >> kBitsPerByteLog2;
int bit_index = index & (kBitsPerByte - 1); int bit_index = index & (kBitsPerByte - 1);
bits[byte_index] |= (1U << bit_index); bits[byte_index] |= (1U << bit_index);
...@@ -272,20 +270,21 @@ bool SafepointTableBuilder::IsIdenticalExceptForPc( ...@@ -272,20 +270,21 @@ bool SafepointTableBuilder::IsIdenticalExceptForPc(
if (info1.deopt_index != info2.deopt_index) return false; if (info1.deopt_index != info2.deopt_index) return false;
ZoneList<int>* indexes1 = info1.indexes; ZoneChunkList<int>* indexes1 = info1.indexes;
ZoneList<int>* indexes2 = info2.indexes; ZoneChunkList<int>* indexes2 = info2.indexes;
if (indexes1->length() != indexes2->length()) return false; if (indexes1->size() != indexes2->size()) return false;
for (int i = 0; i < indexes1->length(); ++i) { if (!std::equal(indexes1->begin(), indexes1->end(), indexes2->begin())) {
if (indexes1->at(i) != indexes2->at(i)) return false; return false;
} }
ZoneList<int>* registers1 = info1.registers; ZoneChunkList<int>* registers1 = info1.registers;
ZoneList<int>* registers2 = info2.registers; ZoneChunkList<int>* registers2 = info2.registers;
if (registers1) { if (registers1) {
if (!registers2) return false; if (!registers2) return false;
if (registers1->length() != registers2->length()) return false; if (registers1->size() != registers2->size()) return false;
for (int i = 0; i < registers1->length(); ++i) { if (!std::equal(registers1->begin(), registers1->end(),
if (registers1->at(i) != registers2->at(i)) return false; registers2->begin())) {
return false;
} }
} else if (registers2) { } else if (registers2) {
return false; return false;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "src/assert-scope.h" #include "src/assert-scope.h"
#include "src/utils.h" #include "src/utils.h"
#include "src/v8memory.h" #include "src/v8memory.h"
#include "src/zone/zone-chunk-list.h"
#include "src/zone/zone.h" #include "src/zone/zone.h"
namespace v8 { namespace v8 {
...@@ -188,14 +189,14 @@ class Safepoint BASE_EMBEDDED { ...@@ -188,14 +189,14 @@ class Safepoint BASE_EMBEDDED {
static const int kNoDeoptimizationIndex = static const int kNoDeoptimizationIndex =
(1 << (SafepointEntry::kDeoptIndexBits)) - 1; (1 << (SafepointEntry::kDeoptIndexBits)) - 1;
void DefinePointerSlot(int index, Zone* zone) { indexes_->Add(index, zone); } void DefinePointerSlot(int index) { indexes_->push_back(index); }
void DefinePointerRegister(Register reg, Zone* zone); void DefinePointerRegister(Register reg);
private: private:
Safepoint(ZoneList<int>* indexes, ZoneList<int>* registers) Safepoint(ZoneChunkList<int>* indexes, ZoneChunkList<int>* registers)
: indexes_(indexes), registers_(registers) {} : indexes_(indexes), registers_(registers) {}
ZoneList<int>* const indexes_; ZoneChunkList<int>* const indexes_;
ZoneList<int>* const registers_; ZoneChunkList<int>* const registers_;
friend class SafepointTableBuilder; friend class SafepointTableBuilder;
}; };
...@@ -241,8 +242,8 @@ class SafepointTableBuilder BASE_EMBEDDED { ...@@ -241,8 +242,8 @@ class SafepointTableBuilder BASE_EMBEDDED {
unsigned arguments; unsigned arguments;
bool has_doubles; bool has_doubles;
int trampoline; int trampoline;
ZoneList<int>* indexes; ZoneChunkList<int>* indexes;
ZoneList<int>* registers; ZoneChunkList<int>* registers;
unsigned deopt_index; unsigned deopt_index;
DeoptimizationInfo(Zone* zone, unsigned pc, unsigned arguments, DeoptimizationInfo(Zone* zone, unsigned pc, unsigned arguments,
Safepoint::Kind kind) Safepoint::Kind kind)
...@@ -250,9 +251,11 @@ class SafepointTableBuilder BASE_EMBEDDED { ...@@ -250,9 +251,11 @@ class SafepointTableBuilder BASE_EMBEDDED {
arguments(arguments), arguments(arguments),
has_doubles(kind & Safepoint::kWithDoubles), has_doubles(kind & Safepoint::kWithDoubles),
trampoline(-1), trampoline(-1),
indexes(new (zone) ZoneList<int>(8, zone)), indexes(new (zone) ZoneChunkList<int>(
zone, ZoneChunkList<int>::StartMode::kSmall)),
registers(kind & Safepoint::kWithRegisters registers(kind & Safepoint::kWithRegisters
? new (zone) ZoneList<int>(4, zone) ? new (zone) ZoneChunkList<int>(
zone, ZoneChunkList<int>::StartMode::kSmall)
: nullptr), : nullptr),
deopt_index(Safepoint::kNoDeoptimizationIndex) {} deopt_index(Safepoint::kNoDeoptimizationIndex) {}
}; };
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "src/base/iterator.h"
#include "src/globals.h" #include "src/globals.h"
#include "src/utils.h" #include "src/utils.h"
#include "src/zone/zone.h" #include "src/zone/zone.h"
...@@ -145,7 +146,8 @@ class ZoneChunkList : public ZoneObject { ...@@ -145,7 +146,8 @@ class ZoneChunkList : public ZoneObject {
}; };
template <typename T, bool backwards, bool modifiable> template <typename T, bool backwards, bool modifiable>
class ZoneChunkListIterator { class ZoneChunkListIterator
: public base::iterator<std::bidirectional_iterator_tag, T> {
private: private:
template <typename S> template <typename S>
using maybe_const = using maybe_const =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment