Reviewers: ulan,

Description:
A64: Force emission of the veneer pool emission when required.

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

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

Affected files (+20, -12 lines):
  M src/a64/assembler-a64-inl.h
  M src/a64/assembler-a64.h
  M src/a64/assembler-a64.cc
  M src/a64/full-codegen-a64.cc
  M src/a64/lithium-codegen-a64.cc
  M src/a64/macro-assembler-a64-inl.h


Index: src/a64/assembler-a64-inl.h
diff --git a/src/a64/assembler-a64-inl.h b/src/a64/assembler-a64-inl.h
index 2a930b2e7dcef3b76413f0290b232f03d650d616..feb6bbb467fbc14c875afbe382fd33256f61da85 100644
--- a/src/a64/assembler-a64-inl.h
+++ b/src/a64/assembler-a64-inl.h
@@ -1207,7 +1207,7 @@ inline void Assembler::CheckBuffer() {
     GrowBuffer();
   }
   if (pc_offset() >= next_veneer_pool_check_) {
-    CheckVeneerPool(true);
+    CheckVeneerPool(false, true);
   }
   if (pc_offset() >= next_constant_pool_check_) {
     CheckConstPool(false, true);
Index: src/a64/assembler-a64.cc
diff --git a/src/a64/assembler-a64.cc b/src/a64/assembler-a64.cc
index 51542b27da0d1cdc5230cc5a6d3f8c149644cdfe..2bffc587f28e8069457c3c08a1d0751beaa66217 100644
--- a/src/a64/assembler-a64.cc
+++ b/src/a64/assembler-a64.cc
@@ -2548,7 +2548,7 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {

// Emit veneers for branches that would go out of range during emission of the
   // constant pool.
-  CheckVeneerPool(require_jump, kVeneerDistanceMargin + pool_size);
+  CheckVeneerPool(false, require_jump, kVeneerDistanceMargin + pool_size);

   Label size_check;
   bind(&size_check);
@@ -2641,7 +2641,7 @@ void Assembler::RecordVeneerPool(int location_offset, int size) {
 }


-void Assembler::EmitVeneers(bool need_protection, int margin) {
+void Assembler::EmitVeneers(bool force_emit, bool need_protection, int margin) {
   BlockPoolsScope scope(this);
   RecordComment("[ Veneers");

@@ -2667,7 +2667,7 @@ void Assembler::EmitVeneers(bool need_protection, int margin) {

   it = unresolved_branches_.begin();
   while (it != unresolved_branches_.end()) {
-    if (ShouldEmitVeneer(it->first, margin)) {
+    if (force_emit || ShouldEmitVeneer(it->first, margin)) {
       Instruction* branch = InstructionAt(it->second.pc_offset_);
       Label* label = it->second.label_;

@@ -2710,7 +2710,7 @@ void Assembler::EmitVeneers(bool need_protection, int margin) {
 }


-void Assembler::CheckVeneerPool(bool require_jump,
+void Assembler::CheckVeneerPool(bool force_emit, bool require_jump,
                                 int margin) {
   // There is nothing to do if there are no pending veneer pool entries.
   if (unresolved_branches_.empty())  {
@@ -2724,6 +2724,7 @@ void Assembler::CheckVeneerPool(bool require_jump,
// emission, such sequences are protected by calls to BlockVeneerPoolFor and
   // BlockVeneerPoolScope.
   if (is_veneer_pool_blocked()) {
+    ASSERT(!force_emit);
     return;
   }

@@ -2731,8 +2732,8 @@ void Assembler::CheckVeneerPool(bool require_jump,
     // Prefer emitting veneers protected by an existing instruction.
     margin *= kVeneerNoProtectionFactor;
   }
-  if (ShouldEmitVeneers(margin)) {
-    EmitVeneers(require_jump, margin);
+  if (force_emit || ShouldEmitVeneers(margin)) {
+    EmitVeneers(force_emit, require_jump, margin);
   } else {
     next_veneer_pool_check_ =
       unresolved_branches_first_limit() - kVeneerDistanceCheckMargin;
Index: src/a64/assembler-a64.h
diff --git a/src/a64/assembler-a64.h b/src/a64/assembler-a64.h
index 31d7f17e071612e503c8fbfba88fdf27f1a5b018..47f9694e054c3b7ed5bef92205fa7f87e41b4a66 100644
--- a/src/a64/assembler-a64.h
+++ b/src/a64/assembler-a64.h
@@ -1808,10 +1808,13 @@ class Assembler : public AssemblerBase {
   // Emits veneers for branches that are approaching their maximum range.
// If need_protection is true, the veneers are protected by a branch jumping
   // over the code.
- void EmitVeneers(bool need_protection, int margin = kVeneerDistanceMargin);
+  void EmitVeneers(bool force_emit, bool need_protection,
+                   int margin = kVeneerDistanceMargin);
   void EmitVeneersGuard() { EmitPoolGuard(); }
   // Checks whether veneers need to be emitted at this point.
- void CheckVeneerPool(bool require_jump, int margin = kVeneerDistanceMargin); + // If force_emit is set, a veneer is generated for *all* unresolved branches.
+  void CheckVeneerPool(bool force_emit, bool require_jump,
+                       int margin = kVeneerDistanceMargin);


   class BlockPoolsScope {
Index: src/a64/full-codegen-a64.cc
diff --git a/src/a64/full-codegen-a64.cc b/src/a64/full-codegen-a64.cc
index dcab182e6770f3b6999302cdd0d9e250c6a559f6..ed6153c23a843d0a1fdfab5e6d65878909a4f9b5 100644
--- a/src/a64/full-codegen-a64.cc
+++ b/src/a64/full-codegen-a64.cc
@@ -314,8 +314,9 @@ void FullCodeGenerator::Generate() {
   }
   EmitReturnSequence();

-  // Force emit the constant pool, so it doesn't get emitted in the middle
+  // Force emission of the pools, so they don't get emitted in the middle
   // of the back edge table.
+  masm()->CheckVeneerPool(true, false);
   masm()->CheckConstPool(true, false);
 }

Index: src/a64/lithium-codegen-a64.cc
diff --git a/src/a64/lithium-codegen-a64.cc b/src/a64/lithium-codegen-a64.cc
index 0bb420cf590a83f799d0225af6866643f9aa32ab..23d2848c7c7fbe64f59511e5d15de71372490a31 100644
--- a/src/a64/lithium-codegen-a64.cc
+++ b/src/a64/lithium-codegen-a64.cc
@@ -895,6 +895,9 @@ bool LCodeGen::GenerateDeoptJumpTable() {

 bool LCodeGen::GenerateSafepointTable() {
   ASSERT(is_done());
+ // We do not know how much data will be emitted for the safepoint table, so
+  // force emission of the veneer pool.
+  masm()->CheckVeneerPool(true, true);
   safepoints_.Emit(masm(), GetStackSlotCount());
   return !is_aborted();
 }
Index: src/a64/macro-assembler-a64-inl.h
diff --git a/src/a64/macro-assembler-a64-inl.h b/src/a64/macro-assembler-a64-inl.h index 18d1d0d2c44efd585ca6c7c7c987a93d3b1f4161..0dbab71716d25de5cdd60580fa379801d593932c 100644
--- a/src/a64/macro-assembler-a64-inl.h
+++ b/src/a64/macro-assembler-a64-inl.h
@@ -346,7 +346,7 @@ void MacroAssembler::Asr(const Register& rd,

 void MacroAssembler::B(Label* label) {
   b(label);
-  CheckVeneerPool(false);
+  CheckVeneerPool(false, false);
 }


@@ -1036,7 +1036,7 @@ void MacroAssembler::Ret(const Register& xn) {
   ASSERT(allow_macro_instructions_);
   ASSERT(!xn.IsZero());
   ret(xn);
-  CheckVeneerPool(false);
+  CheckVeneerPool(false, false);
 }




--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to