Reviewers: Jakob,
Message:
PTAL, on arm64 the MacroAssembler happened to be 560 bytes.
Description:
[arm] Decrease the size of the assembler class by allocating buffers of
pending
constants on the heap.
BUG=chromium:521828
LOG=N
Please review this at https://codereview.chromium.org/1310863005/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+33, -2 lines):
M src/arm/assembler-arm.h
M src/arm/assembler-arm.cc
M src/ic/access-compiler.h
Index: src/arm/assembler-arm.cc
diff --git a/src/arm/assembler-arm.cc b/src/arm/assembler-arm.cc
index
8768e8a124f1b61b6f5b129f6ff601bf88610030..b5910d05be5de63c9092aedecdec05ec9e487239
100644
--- a/src/arm/assembler-arm.cc
+++ b/src/arm/assembler-arm.cc
@@ -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;
Index: src/arm/assembler-arm.h
diff --git a/src/arm/assembler-arm.h b/src/arm/assembler-arm.h
index
d0fcac206e0b7916995c3c9cf09482769273ea91..c54e51df78cb57c146f1f9f815214ca899057e49
100644
--- a/src/arm/assembler-arm.h
+++ b/src/arm/assembler-arm.h
@@ -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.
Index: src/ic/access-compiler.h
diff --git a/src/ic/access-compiler.h b/src/ic/access-compiler.h
index
32700f4588983e55e07c0392caefbdd1abbb45b8..a5beb714f8239f7a238889769b5fe47a2f26f658
100644
--- a/src/ic/access-compiler.h
+++ b/src/ic/access-compiler.h
@@ -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
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.