Bug 1207827 - Remove ARM temporary offset buffers. r=nbp
authorJakob Olesen <jolesen@mozilla.com>
Mon, 26 Oct 2015 17:06:09 -0700
changeset 269675 0c6da2dc2bc49cd7c79496cac9ec6e6f597047d7
parent 269674 3bb6cd5b7e5635c826c630a0ab237af4aec768de
child 269676 97366c8fa024314ee9f130e542e1e150e96f7e6d
push id15905
push usercbook@mozilla.com
push dateTue, 27 Oct 2015 09:59:36 +0000
treeherderfx-team@60acc8a9cfb5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1207827
milestone44.0a1
Bug 1207827 - Remove ARM temporary offset buffers. r=nbp The ARM assembler no longer needs to keep track of code offsets for later translation to 'actual' offsets. The AssemblerBuffer offsets are directly usable now. Remove tmpDataRelocations_, tmpPreBarriers_, and tmpJumpRelocations_.
js/src/jit/arm/Assembler-arm.cpp
js/src/jit/arm/Assembler-arm.h
--- a/js/src/jit/arm/Assembler-arm.cpp
+++ b/js/src/jit/arm/Assembler-arm.cpp
@@ -626,31 +626,16 @@ jit::PatchJump(CodeLocationJump& jump_, 
 }
 
 void
 Assembler::finish()
 {
     flush();
     MOZ_ASSERT(!isFinished);
     isFinished = true;
-
-    for (unsigned int i = 0; i < tmpDataRelocations_.length(); i++) {
-        size_t offset = tmpDataRelocations_[i].getOffset();
-        dataRelocations_.writeUnsigned(offset);
-    }
-
-    for (unsigned int i = 0; i < tmpJumpRelocations_.length(); i++) {
-        size_t offset = tmpJumpRelocations_[i].getOffset();
-        jumpRelocations_.writeUnsigned(offset);
-    }
-
-    for (unsigned int i = 0; i < tmpPreBarriers_.length(); i++) {
-        size_t offset = tmpPreBarriers_[i].getOffset();
-        preBarriers_.writeUnsigned(offset);
-    }
 }
 
 void
 Assembler::executableCopy(uint8_t* buffer)
 {
     MOZ_ASSERT(isFinished);
     m_buffer.executableCopy(buffer);
     AutoFlushICache::setRange(uintptr_t(buffer), m_buffer.size());
@@ -888,22 +873,21 @@ TraceDataRelocations(JSTracer* trc, uint
     while (reader.more()) {
         size_t offset = reader.readUnsigned();
         InstructionIterator iter((Instruction*)(buffer + offset));
         TraceOneDataRelocation(trc, &iter);
     }
 }
 
 static void
-TraceDataRelocations(JSTracer* trc, ARMBuffer* buffer,
-                     Vector<BufferOffset, 0, SystemAllocPolicy>* locs)
+TraceDataRelocations(JSTracer* trc, ARMBuffer* buffer, CompactBufferReader& reader)
 {
-    for (unsigned int idx = 0; idx < locs->length(); idx++) {
-        BufferOffset bo = (*locs)[idx];
-        ARMBuffer::AssemblerBufferInstIterator iter(bo, buffer);
+    while (reader.more()) {
+        BufferOffset offset(reader.readUnsigned());
+        ARMBuffer::AssemblerBufferInstIterator iter(offset, buffer);
         TraceOneDataRelocation(trc, &iter);
     }
 }
 
 void
 Assembler::TraceDataRelocations(JSTracer* trc, JitCode* code, CompactBufferReader& reader)
 {
     ::TraceDataRelocations(trc, code->raw(), reader);
@@ -937,26 +921,28 @@ Assembler::trace(JSTracer* trc)
         RelativePatch& rp = jumps_[i];
         if (rp.kind == Relocation::JITCODE) {
             JitCode* code = JitCode::FromExecutable((uint8_t*)rp.target);
             TraceManuallyBarrieredEdge(trc, &code, "masmrel32");
             MOZ_ASSERT(code == JitCode::FromExecutable((uint8_t*)rp.target));
         }
     }
 
-    if (tmpDataRelocations_.length())
-        ::TraceDataRelocations(trc, &m_buffer, &tmpDataRelocations_);
+    if (dataRelocations_.length()) {
+        CompactBufferReader reader(dataRelocations_);
+        ::TraceDataRelocations(trc, &m_buffer, reader);
+    }
 }
 
 void
 Assembler::processCodeLabels(uint8_t* rawCode)
 {
     for (size_t i = 0; i < codeLabels_.length(); i++) {
         CodeLabel label = codeLabels_[i];
-        Bind(rawCode, label.dest(), rawCode + actualOffset(label.src()->offset()));
+        Bind(rawCode, label.dest(), rawCode + label.src()->offset());
     }
 }
 
 void
 Assembler::writeCodePointer(AbsoluteLabel* absoluteLabel) {
     MOZ_ASSERT(!absoluteLabel->bound());
     BufferOffset off = writeInst(LabelBase::INVALID_OFFSET);
 
@@ -968,18 +954,17 @@ Assembler::writeCodePointer(AbsoluteLabe
     LabelBase* label = absoluteLabel;
     label->bind(off.getOffset());
 }
 
 void
 Assembler::Bind(uint8_t* rawCode, AbsoluteLabel* label, const void* address)
 {
     // See writeCodePointer comment.
-    uint32_t off = actualOffset(label->offset());
-    *reinterpret_cast<const void**>(rawCode + off) = address;
+    *reinterpret_cast<const void**>(rawCode + label->offset()) = address;
 }
 
 Assembler::Condition
 Assembler::InvertCondition(Condition cond)
 {
     const uint32_t ConditionInversionBit = 0x10000000;
     return Condition(ConditionInversionBit ^ cond);
 }
--- a/js/src/jit/arm/Assembler-arm.h
+++ b/js/src/jit/arm/Assembler-arm.h
@@ -1269,19 +1269,16 @@ class Assembler : public AssemblerShared
         RelativePatch(void* target, Relocation::Kind kind)
             : target(target), kind(kind)
         { }
     };
 
     // TODO: this should actually be a pool-like object. It is currently a big
     // hack, and probably shouldn't exist.
     js::Vector<RelativePatch, 8, SystemAllocPolicy> jumps_;
-    js::Vector<BufferOffset, 0, SystemAllocPolicy> tmpJumpRelocations_;
-    js::Vector<BufferOffset, 0, SystemAllocPolicy> tmpDataRelocations_;
-    js::Vector<BufferOffset, 0, SystemAllocPolicy> tmpPreBarriers_;
 
     CompactBufferWriter jumpRelocations_;
     CompactBufferWriter dataRelocations_;
     CompactBufferWriter preBarriers_;
 
     ARMBuffer m_buffer;
 
 #ifdef JS_DISASM_ARM
@@ -1336,31 +1333,31 @@ class Assembler : public AssemblerShared
         m_buffer.initWithAllocator();
     }
 
     static Condition InvertCondition(Condition cond);
 
     // MacroAssemblers hold onto gcthings, so they are traced by the GC.
     void trace(JSTracer* trc);
     void writeRelocation(BufferOffset src) {
-        tmpJumpRelocations_.append(src);
+        jumpRelocations_.writeUnsigned(src.getOffset());
     }
 
     // As opposed to x86/x64 version, the data relocation has to be executed
     // before to recover the pointer, and not after.
     void writeDataRelocation(ImmGCPtr ptr) {
         if (ptr.value) {
             if (gc::IsInsideNursery(ptr.value))
                 embedsNurseryPointers_ = true;
             if (ptr.value)
-                tmpDataRelocations_.append(nextOffset());
+                dataRelocations_.writeUnsigned(nextOffset().getOffset());
         }
     }
     void writePrebarrierOffset(CodeOffsetLabel label) {
-        tmpPreBarriers_.append(BufferOffset(label.offset()));
+        preBarriers_.writeUnsigned(label.offset());
     }
 
     enum RelocBranchStyle {
         B_MOVWT,
         B_LDR_BX,
         B_LDR,
         B_MOVW_ADD
     };