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

Unified Diff: src/arm/assembler-arm.cc

Issue 2044283003: Use standard datastructures for tracking constant pool entries. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/arm/assembler-arm.h ('k') | src/arm/macro-assembler-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm/assembler-arm.cc
diff --git a/src/arm/assembler-arm.cc b/src/arm/assembler-arm.cc
index 4ad0d706ebff29a3706a34e605ad732e9b128ed9..a511db6f2cfcd850434544a62f5c39689750d96f 100644
--- a/src/arm/assembler-arm.cc
+++ b/src/arm/assembler-arm.cc
@@ -483,17 +483,16 @@ const Instr kStrRegFpNegOffsetPattern =
al | B26 | NegOffset | Register::kCode_fp * B16;
const Instr kLdrStrInstrTypeMask = 0xffff0000;
-
Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size)
: AssemblerBase(isolate, buffer, buffer_size),
recorded_ast_id_(TypeFeedbackId::None()),
- pending_32_bit_constants_(&pending_32_bit_constants_buffer_[0]),
- pending_64_bit_constants_(&pending_64_bit_constants_buffer_[0]),
+ pending_32_bit_constants_(),
+ pending_64_bit_constants_(),
constant_pool_builder_(kLdrMaxReachBits, kVldrMaxReachBits),
positions_recorder_(this) {
+ pending_32_bit_constants_.reserve(kMinNumPendingConstants);
+ pending_64_bit_constants_.reserve(kMinNumPendingConstants);
reloc_info_writer.Reposition(buffer_ + buffer_size_, pc_);
- num_pending_32_bit_constants_ = 0;
- num_pending_64_bit_constants_ = 0;
next_buffer_check_ = 0;
const_pool_blocked_nesting_ = 0;
no_const_pool_before_ = 0;
@@ -506,12 +505,6 @@ Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size)
Assembler::~Assembler() {
DCHECK(const_pool_blocked_nesting_ == 0);
- if (pending_32_bit_constants_ != &pending_32_bit_constants_buffer_[0]) {
- delete[] pending_32_bit_constants_;
- }
- if (pending_64_bit_constants_ != &pending_64_bit_constants_buffer_[0]) {
- delete[] pending_64_bit_constants_;
- }
}
@@ -524,8 +517,8 @@ void Assembler::GetCode(CodeDesc* desc) {
constant_pool_offset = EmitEmbeddedConstantPool();
} else {
CheckConstPool(true, false);
- DCHECK(num_pending_32_bit_constants_ == 0);
- DCHECK(num_pending_64_bit_constants_ == 0);
+ DCHECK(pending_32_bit_constants_.empty());
+ DCHECK(pending_64_bit_constants_.empty());
}
// Set up code descriptor.
desc->buffer = buffer_;
@@ -3880,8 +3873,8 @@ void Assembler::GrowBuffer() {
void Assembler::db(uint8_t data) {
// db is used to write raw data. The constant pool should be emitted or
// blocked before using db.
- DCHECK(is_const_pool_blocked() || (num_pending_32_bit_constants_ == 0));
- DCHECK(is_const_pool_blocked() || (num_pending_64_bit_constants_ == 0));
+ DCHECK(is_const_pool_blocked() || pending_32_bit_constants_.empty());
+ DCHECK(is_const_pool_blocked() || pending_64_bit_constants_.empty());
CheckBuffer();
*reinterpret_cast<uint8_t*>(pc_) = data;
pc_ += sizeof(uint8_t);
@@ -3891,8 +3884,8 @@ void Assembler::db(uint8_t data) {
void Assembler::dd(uint32_t data) {
// dd is used to write raw data. The constant pool should be emitted or
// blocked before using dd.
- DCHECK(is_const_pool_blocked() || (num_pending_32_bit_constants_ == 0));
- DCHECK(is_const_pool_blocked() || (num_pending_64_bit_constants_ == 0));
+ DCHECK(is_const_pool_blocked() || pending_32_bit_constants_.empty());
+ DCHECK(is_const_pool_blocked() || pending_64_bit_constants_.empty());
CheckBuffer();
*reinterpret_cast<uint32_t*>(pc_) = data;
pc_ += sizeof(uint32_t);
@@ -3902,8 +3895,8 @@ void Assembler::dd(uint32_t data) {
void Assembler::dq(uint64_t value) {
// dq is used to write raw data. The constant pool should be emitted or
// blocked before using dq.
- DCHECK(is_const_pool_blocked() || (num_pending_32_bit_constants_ == 0));
- DCHECK(is_const_pool_blocked() || (num_pending_64_bit_constants_ == 0));
+ DCHECK(is_const_pool_blocked() || pending_32_bit_constants_.empty());
+ DCHECK(is_const_pool_blocked() || pending_64_bit_constants_.empty());
CheckBuffer();
*reinterpret_cast<uint64_t*>(pc_) = value;
pc_ += sizeof(uint64_t);
@@ -3946,21 +3939,12 @@ ConstantPoolEntry::Access Assembler::ConstantPoolAddEntry(int position,
if (FLAG_enable_embedded_constant_pool) {
return constant_pool_builder_.AddEntry(position, value, sharing_ok);
} else {
- DCHECK(num_pending_32_bit_constants_ < kMaxNumPending32Constants);
- if (num_pending_32_bit_constants_ == 0) {
+ DCHECK(pending_32_bit_constants_.size() < kMaxNumPending32Constants);
+ if (pending_32_bit_constants_.empty()) {
first_const_pool_32_use_ = position;
- } else if (num_pending_32_bit_constants_ == kMinNumPendingConstants &&
- pending_32_bit_constants_ ==
- &pending_32_bit_constants_buffer_[0]) {
- // Inline buffer is full, switch to dynamically allocated buffer.
- pending_32_bit_constants_ =
- new ConstantPoolEntry[kMaxNumPending32Constants];
- std::copy(&pending_32_bit_constants_buffer_[0],
- &pending_32_bit_constants_buffer_[kMinNumPendingConstants],
- &pending_32_bit_constants_[0]);
}
ConstantPoolEntry entry(position, value, sharing_ok);
- pending_32_bit_constants_[num_pending_32_bit_constants_++] = entry;
+ pending_32_bit_constants_.push_back(entry);
// Make sure the constant pool is not emitted in place of the next
// instruction for which we just recorded relocation info.
@@ -3975,21 +3959,12 @@ ConstantPoolEntry::Access Assembler::ConstantPoolAddEntry(int position,
if (FLAG_enable_embedded_constant_pool) {
return constant_pool_builder_.AddEntry(position, value);
} else {
- DCHECK(num_pending_64_bit_constants_ < kMaxNumPending64Constants);
- if (num_pending_64_bit_constants_ == 0) {
+ DCHECK(pending_64_bit_constants_.size() < kMaxNumPending64Constants);
+ if (pending_64_bit_constants_.empty()) {
first_const_pool_64_use_ = position;
- } else if (num_pending_64_bit_constants_ == kMinNumPendingConstants &&
- pending_64_bit_constants_ ==
- &pending_64_bit_constants_buffer_[0]) {
- // Inline buffer is full, switch to dynamically allocated buffer.
- pending_64_bit_constants_ =
- new ConstantPoolEntry[kMaxNumPending64Constants];
- std::copy(&pending_64_bit_constants_buffer_[0],
- &pending_64_bit_constants_buffer_[kMinNumPendingConstants],
- &pending_64_bit_constants_[0]);
}
ConstantPoolEntry entry(position, value);
- pending_64_bit_constants_[num_pending_64_bit_constants_++] = entry;
+ pending_64_bit_constants_.push_back(entry);
// Make sure the constant pool is not emitted in place of the next
// instruction for which we just recorded relocation info.
@@ -4002,8 +3977,8 @@ ConstantPoolEntry::Access Assembler::ConstantPoolAddEntry(int position,
void Assembler::BlockConstPoolFor(int instructions) {
if (FLAG_enable_embedded_constant_pool) {
// Should be a no-op if using an embedded constant pool.
- DCHECK(num_pending_32_bit_constants_ == 0);
- DCHECK(num_pending_64_bit_constants_ == 0);
+ DCHECK(pending_32_bit_constants_.empty());
+ DCHECK(pending_64_bit_constants_.empty());
return;
}
@@ -4012,11 +3987,11 @@ void Assembler::BlockConstPoolFor(int instructions) {
// Max pool start (if we need a jump and an alignment).
#ifdef DEBUG
int start = pc_limit + kInstrSize + 2 * kPointerSize;
- DCHECK((num_pending_32_bit_constants_ == 0) ||
+ DCHECK(pending_32_bit_constants_.empty() ||
(start - first_const_pool_32_use_ +
- num_pending_64_bit_constants_ * kDoubleSize <
+ pending_64_bit_constants_.size() * kDoubleSize <
kMaxDistToIntPool));
- DCHECK((num_pending_64_bit_constants_ == 0) ||
+ DCHECK(pending_64_bit_constants_.empty() ||
(start - first_const_pool_64_use_ < kMaxDistToFPPool));
#endif
no_const_pool_before_ = pc_limit;
@@ -4031,8 +4006,8 @@ void Assembler::BlockConstPoolFor(int instructions) {
void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
if (FLAG_enable_embedded_constant_pool) {
// Should be a no-op if using an embedded constant pool.
- DCHECK(num_pending_32_bit_constants_ == 0);
- DCHECK(num_pending_64_bit_constants_ == 0);
+ DCHECK(pending_32_bit_constants_.empty());
+ DCHECK(pending_64_bit_constants_.empty());
return;
}
@@ -4046,8 +4021,7 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
}
// There is nothing to do if there are no pending constant pool entries.
- if ((num_pending_32_bit_constants_ == 0) &&
- (num_pending_64_bit_constants_ == 0)) {
+ if (pending_32_bit_constants_.empty() && pending_64_bit_constants_.empty()) {
// Calculate the offset of the next check.
next_buffer_check_ = pc_offset() + kCheckPoolInterval;
return;
@@ -4059,9 +4033,9 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
int jump_instr = require_jump ? kInstrSize : 0;
int size_up_to_marker = jump_instr + kInstrSize;
int estimated_size_after_marker =
- num_pending_32_bit_constants_ * kPointerSize;
- bool has_int_values = (num_pending_32_bit_constants_ > 0);
- bool has_fp_values = (num_pending_64_bit_constants_ > 0);
+ pending_32_bit_constants_.size() * kPointerSize;
+ bool has_int_values = !pending_32_bit_constants_.empty();
+ bool has_fp_values = !pending_64_bit_constants_.empty();
bool require_64_bit_align = false;
if (has_fp_values) {
require_64_bit_align =
@@ -4070,7 +4044,8 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
if (require_64_bit_align) {
estimated_size_after_marker += kInstrSize;
}
- estimated_size_after_marker += num_pending_64_bit_constants_ * kDoubleSize;
+ estimated_size_after_marker +=
+ pending_64_bit_constants_.size() * kDoubleSize;
}
int estimated_size = size_up_to_marker + estimated_size_after_marker;
@@ -4089,7 +4064,7 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
// The 64-bit constants are always emitted before the 32-bit constants, so
// we can ignore the effect of the 32-bit constants on estimated_size.
int dist64 = pc_offset() + estimated_size -
- num_pending_32_bit_constants_ * kPointerSize -
+ pending_32_bit_constants_.size() * kPointerSize -
first_const_pool_64_use_;
if ((dist64 >= kMaxDistToFPPool - kCheckPoolInterval) ||
(!require_jump && (dist64 >= kMaxDistToFPPool / 2))) {
@@ -4108,7 +4083,7 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
// Deduplicate constants.
int size_after_marker = estimated_size_after_marker;
- for (int i = 0; i < num_pending_64_bit_constants_; i++) {
+ for (int i = 0; i < pending_64_bit_constants_.size(); i++) {
ConstantPoolEntry& entry = pending_64_bit_constants_[i];
DCHECK(!entry.is_merged());
for (int j = 0; j < i; j++) {
@@ -4121,7 +4096,7 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
}
}
- for (int i = 0; i < num_pending_32_bit_constants_; i++) {
+ for (int i = 0; i < pending_32_bit_constants_.size(); i++) {
ConstantPoolEntry& entry = pending_32_bit_constants_[i];
DCHECK(!entry.is_merged());
if (!entry.sharing_ok()) continue;
@@ -4166,7 +4141,7 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
// Emit 64-bit constant pool entries first: their range is smaller than
// 32-bit entries.
- for (int i = 0; i < num_pending_64_bit_constants_; i++) {
+ for (int i = 0; i < pending_64_bit_constants_.size(); i++) {
ConstantPoolEntry& entry = pending_64_bit_constants_[i];
Instr instr = instr_at(entry.position());
@@ -4195,7 +4170,7 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
}
// Emit 32-bit constant pool entries.
- for (int i = 0; i < num_pending_32_bit_constants_; i++) {
+ for (int i = 0; i < pending_32_bit_constants_.size(); i++) {
ConstantPoolEntry& entry = pending_32_bit_constants_[i];
Instr instr = instr_at(entry.position());
@@ -4229,8 +4204,8 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
}
}
- num_pending_32_bit_constants_ = 0;
- num_pending_64_bit_constants_ = 0;
+ pending_32_bit_constants_.clear();
+ pending_64_bit_constants_.clear();
first_const_pool_32_use_ = -1;
first_const_pool_64_use_ = -1;
« no previous file with comments | « src/arm/assembler-arm.h ('k') | src/arm/macro-assembler-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698