Commit ce751ccf authored by ishell's avatar ishell Committed by Commit bot

[arm] Decrease the size of the assembler class by allocating buffers of...

[arm] Decrease the size of the assembler class by allocating buffers of pending constants on the heap.

BUG=chromium:521828
LOG=N

Review URL: https://codereview.chromium.org/1310863005

Cr-Commit-Position: refs/heads/master@{#30602}
parent d052804a
......@@ -450,6 +450,8 @@ 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]),
constant_pool_builder_(kLdrMaxReachBits, kVldrMaxReachBits),
positions_recorder_(this) {
reloc_info_writer.Reposition(buffer_ + buffer_size_, pc_);
......@@ -467,6 +469,12 @@ 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_;
}
}
......@@ -3666,6 +3674,15 @@ ConstantPoolEntry::Access Assembler::ConstantPoolAddEntry(int position,
DCHECK(num_pending_32_bit_constants_ < kMaxNumPending32Constants);
if (num_pending_32_bit_constants_ == 0) {
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;
......@@ -3686,6 +3703,15 @@ ConstantPoolEntry::Access Assembler::ConstantPoolAddEntry(int position,
DCHECK(num_pending_64_bit_constants_ < kMaxNumPending64Constants);
if (num_pending_64_bit_constants_ == 0) {
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;
......
......@@ -1465,6 +1465,7 @@ class Assembler : public AssemblerBase {
static const int kMaxDistToIntPool = 4*KB;
static const int kMaxDistToFPPool = 1*KB;
// All relocations could be integer, it therefore acts as the limit.
static const int kMinNumPendingConstants = 4;
static const int kMaxNumPending32Constants = kMaxDistToIntPool / kInstrSize;
static const int kMaxNumPending64Constants = kMaxDistToFPPool / kInstrSize;
......@@ -1598,8 +1599,10 @@ class Assembler : public AssemblerBase {
// pending relocation entry per instruction.
// The buffers of pending constant pool entries.
ConstantPoolEntry pending_32_bit_constants_[kMaxNumPending32Constants];
ConstantPoolEntry pending_64_bit_constants_[kMaxNumPending64Constants];
ConstantPoolEntry pending_32_bit_constants_buffer_[kMinNumPendingConstants];
ConstantPoolEntry pending_64_bit_constants_buffer_[kMinNumPendingConstants];
ConstantPoolEntry* pending_32_bit_constants_;
ConstantPoolEntry* pending_64_bit_constants_;
// Number of pending constant pool entries in the 32 bits buffer.
int num_pending_32_bit_constants_;
// Number of pending constant pool entries in the 64 bits buffer.
......
......@@ -78,6 +78,8 @@ class PropertyAccessCompiler BASE_EMBEDDED {
Isolate* isolate_;
MacroAssembler masm_;
// Ensure that MacroAssembler has a reasonable size.
STATIC_ASSERT(sizeof(MacroAssembler) < 128 * kPointerSize);
};
}
} // namespace v8::internal
......
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