Back out a90fac2a088b:759555fe9d38 (bug 760642) for Android/b2g build bustage
authorPhil Ringnalda <philringnalda@gmail.com>
Thu, 27 Jun 2013 14:25:33 -0700
changeset 136688 54c2f0363dca4e360e13ebfb196ca3f86d72757f
parent 136687 b0761624565ce11e5f7f23e985ccacdfd9963465
child 136723 0535801a2d9fc3066d09a7a01c6e42e72f944662
push id30236
push userphilringnalda@gmail.com
push dateThu, 27 Jun 2013 21:25:44 +0000
treeherdermozilla-inbound@54c2f0363dca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs760642
milestone25.0a1
backs outa90fac2a088b12c6ba76aead8bbab99a39a1fca4
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Back out a90fac2a088b:759555fe9d38 (bug 760642) for Android/b2g build bustage CLOSED TREE
js/src/ion/shared/IonAssemblerBuffer.h
--- a/js/src/ion/shared/IonAssemblerBuffer.h
+++ b/js/src/ion/shared/IonAssemblerBuffer.h
@@ -46,37 +46,31 @@ class BufferOffset
     explicit BufferOffset(RepatchLabel *l) : offset(l->offset()) {
     }
 
     BufferOffset() : offset(INT_MIN) {}
     bool assigned() const { return offset != INT_MIN; };
 };
 
 template<int SliceSize>
-struct BufferSlice {
+struct BufferSlice : public InlineForwardListNode<BufferSlice<SliceSize> > {
   protected:
-    BufferSlice<SliceSize> *prev;
-    BufferSlice<SliceSize> *next;
     // How much data has been added to the current node.
     uint32_t nodeSize;
   public:
-    BufferSlice *getNext() { return this->next; }
-    BufferSlice *getPrev() { return this->prev; }
+    BufferSlice *getNext() { return static_cast<BufferSlice *>(this->next); }
     void setNext(BufferSlice<SliceSize> *next_) {
         JS_ASSERT(this->next == NULL);
-        JS_ASSERT(next_->prev == NULL);
         this->next = next_;
-        next_->prev = this;
     }
-
     uint8_t instructions [SliceSize];
     unsigned int size() {
         return nodeSize;
     }
-    BufferSlice() : next(NULL), prev(NULL), nodeSize(0) {}
+    BufferSlice() : InlineForwardListNode<BufferSlice<SliceSize> >(NULL), nodeSize(0) {}
     void putBlob(uint32_t instSize, uint8_t* inst) {
         if (inst != NULL)
             memcpy(&instructions[size()], inst, instSize);
         nodeSize += instSize;
     }
 };
 
 template<int SliceSize, class Inst>
@@ -115,21 +109,18 @@ struct AssemblerBuffer
         Slice *tmp = newSlice(LifoAlloc_);
         if (tmp == NULL)
             return false;
         if (tail != NULL) {
             bufferSize += tail->size();
             tail->setNext(tmp);
         }
         tail = tmp;
-        if (head == NULL) {
-            finger = tmp;
-            finger_offset = 0;
+        if (head == NULL)
             head = tmp;
-        }
         return true;
     }
 
     BufferOffset putByte(uint8_t value) {
         return putBlob(sizeof(value), (uint8_t*)&value);
     }
 
     BufferOffset putShort(uint16_t value) {
@@ -164,73 +155,29 @@ struct AssemblerBuffer
         return m_bail;
     }
     void fail_oom() {
         m_oom = true;
     }
     void fail_bail() {
         m_bail = true;
     }
-    // finger for speeding up accesses
-    Slice *finger;
-    unsigned int finger_offset;
     Inst *getInst(BufferOffset off) {
-        int local_off = off.getOffset();
-        // don't update the structure's finger in place, so there is the option
-        // to not update it.
+        unsigned int local_off = off.getOffset();
         Slice *cur = NULL;
-        int cur_off;
-        // get the offset that we'd be dealing with by walking through backwards
-        int end_off = bufferSize - local_off;
-        // If end_off is negative, then it is in the last chunk, and there is no
-        // real work to be done.
-        if (end_off <= 0) {
-            return (Inst*)&tail->instructions[-end_off];
-        }
-        bool used_finger = false;
-        int finger_off = abs(local_off - finger_offset);
-        if (finger_off < Min(local_off, end_off)) {
-            // The finger offset is minimal, use the finger.
-            cur = finger;
-            cur_off = finger_offset;
-            used_finger = true;
-        } else if (local_off < end_off) {
-            // it is closest to the start
-            cur = head;
-            cur_off = 0;
+        if (local_off > bufferSize) {
+            local_off -= bufferSize;
+            cur = tail;
         } else {
-            // it is closest to the end
-            cur = tail;
-            cur_off = bufferSize;
-        }
-        int count = 0;
-        char sigil;
-        if (local_off < cur_off) {
-            for (; cur != NULL; cur = cur->getPrev(), cur_off -= cur->size()) {
-                if (local_off >= cur_off) {
-                    local_off -= cur_off;
+            for (cur = head; cur != NULL; cur = cur->getNext()) {
+                if (local_off < cur->size())
                     break;
-                }
-                count++;
+                local_off -= cur->size();
             }
             JS_ASSERT(cur != NULL);
-        } else {
-            for (; cur != NULL; cur = cur->getNext()) {
-                if (local_off < cur_off + cur->size()) {
-                    local_off -= cur_off;
-                    break;
-                }
-                cur_off += cur->size();
-                count++;
-            }
-            JS_ASSERT(cur != NULL);
-        }
-        if (count > 2 || used_finger) {
-            finger = cur;
-            finger_offset = cur_off;
         }
         // the offset within this node should not be larger than the node itself.
         JS_ASSERT(local_off < cur->size());
         return (Inst*)&cur->instructions[local_off];
     }
     BufferOffset nextOffset() const {
         if (tail != NULL)
             return BufferOffset(bufferSize + tail->size());