Reviewers: rmcilroy, Rodolph Perfetta (ARM),

Message:
Hi Ross, Rodolph.

Could you please take a look? This fixes chrome crashes. Another solution would
be to reduce FLAG_stack_size by 120KB for ARM.

I will check benchmarks before landing.

Description:
ARM: Do not stack allocate big buffers in Assembler.

Currently Assembler stack allocates 120KB for pending reloc infos.
This can lead to stack-overflow in C++ since the stack guard limit
is only 40K smaller than the stack size.

BUG=405338
LOG=Y

Please review this at https://codereview.chromium.org/555943003/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+14, -4 lines):
  M src/arm/assembler-arm.h
  M src/arm/assembler-arm.cc


Index: src/arm/assembler-arm.cc
diff --git a/src/arm/assembler-arm.cc b/src/arm/assembler-arm.cc
index 96f28f968391a8021e4e5b2b69a78ba0c9cf50c7..95e410dfafff1c370b8df6f6de74fadff0a0ecea 100644
--- a/src/arm/assembler-arm.cc
+++ b/src/arm/assembler-arm.cc
@@ -474,11 +474,19 @@ Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size)
   last_bound_pos_ = 0;
   constant_pool_available_ = !FLAG_enable_ool_constant_pool;
   ClearRecordedAstId();
+  max_num_32_bit_reloc_info_ =
+      Min(kMaxNumPending32RelocInfo, buffer_size_ / kInstrSize);
+  max_num_64_bit_reloc_info_ =
+      Min(kMaxNumPending64RelocInfo, buffer_size_ / kInstrSize);
+ pending_32_bit_reloc_info_ = NewArray<RelocInfo>(max_num_32_bit_reloc_info_); + pending_64_bit_reloc_info_ = NewArray<RelocInfo>(max_num_64_bit_reloc_info_);
 }


 Assembler::~Assembler() {
   DCHECK(const_pool_blocked_nesting_ == 0);
+  DeleteArray(pending_32_bit_reloc_info_);
+  DeleteArray(pending_64_bit_reloc_info_);
 }


@@ -3363,13 +3371,13 @@ ConstantPoolArray::LayoutSection Assembler::ConstantPoolAddEntry(
     return constant_pool_builder_.AddEntry(this, rinfo);
   } else {
     if (rinfo.rmode() == RelocInfo::NONE64) {
-      DCHECK(num_pending_64_bit_reloc_info_ < kMaxNumPending64RelocInfo);
+      DCHECK(num_pending_64_bit_reloc_info_ < max_num_64_bit_reloc_info_);
       if (num_pending_64_bit_reloc_info_ == 0) {
         first_const_pool_64_use_ = pc_offset();
       }
       pending_64_bit_reloc_info_[num_pending_64_bit_reloc_info_++] = rinfo;
     } else {
-      DCHECK(num_pending_32_bit_reloc_info_ < kMaxNumPending32RelocInfo);
+      DCHECK(num_pending_32_bit_reloc_info_ < max_num_32_bit_reloc_info_);
       if (num_pending_32_bit_reloc_info_ == 0) {
         first_const_pool_32_use_ = pc_offset();
       }
Index: src/arm/assembler-arm.h
diff --git a/src/arm/assembler-arm.h b/src/arm/assembler-arm.h
index 108d5cb0908045353a618e5e05868162697dccbe..81bf62fb755c003f4af6656725ea21f9601607a3 100644
--- a/src/arm/assembler-arm.h
+++ b/src/arm/assembler-arm.h
@@ -1598,8 +1598,10 @@ class Assembler : public AssemblerBase {
   // pending relocation entry per instruction.

   // The buffers of pending relocation info.
-  RelocInfo pending_32_bit_reloc_info_[kMaxNumPending32RelocInfo];
-  RelocInfo pending_64_bit_reloc_info_[kMaxNumPending64RelocInfo];
+  RelocInfo* pending_32_bit_reloc_info_;
+  RelocInfo* pending_64_bit_reloc_info_;
+  int max_num_32_bit_reloc_info_;
+  int max_num_64_bit_reloc_info_;
   // Number of pending reloc info entries in the 32 bits buffer.
   int num_pending_32_bit_reloc_info_;
   // Number of pending reloc info entries in the 64 bits buffer.


--
--
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.

Reply via email to