Make code buffer units 8bit rather than 16bit.

Change-Id: I1ca087c4f7f820a8816388095405603f4163b354
diff --git a/src/compiler/CompilerIR.h b/src/compiler/CompilerIR.h
index 58eba7c..4f071b1 100644
--- a/src/compiler/CompilerIR.h
+++ b/src/compiler/CompilerIR.h
@@ -293,7 +293,7 @@
     int totalSize;                      // header + code size
     AssemblerStatus assemblerStatus;    // Success or fix and retry
     int assemblerRetries;
-    std::vector<uint16_t> codeBuffer;
+    std::vector<uint8_t> codeBuffer;
     std::vector<uint32_t> mappingTable;
     std::vector<uint16_t> coreVmapTable;
     std::vector<uint16_t> fpVmapTable;
diff --git a/src/compiler/codegen/CodegenUtil.cc b/src/compiler/codegen/CodegenUtil.cc
index bbf7c38..406c037 100644
--- a/src/compiler/codegen/CodegenUtil.cc
+++ b/src/compiler/codegen/CodegenUtil.cc
@@ -555,14 +555,17 @@
     return addWordData(cUnit, constantListP, valLo);
 }
 
-void pushWord(std::vector<uint16_t>&buf, int data) {
-    buf.push_back( data & 0xffff);
-    buf.push_back( (data >> 16) & 0xffff);
+void pushWord(std::vector<uint8_t>&buf, int data) {
+    buf.push_back( data & 0xff);
+    buf.push_back( (data >> 8) & 0xff);
+    buf.push_back( (data >> 16) & 0xff);
+    buf.push_back( (data >> 24) & 0xff);
 }
 
-void alignBuffer(std::vector<uint16_t>&buf, size_t offset) {
-    while (buf.size() < (offset/2))
+void alignBuffer(std::vector<uint8_t>&buf, size_t offset) {
+    while (buf.size() < offset) {
         buf.push_back(0);
+    }
 }
 
 /* Write the literal pool to the output stream */
@@ -638,8 +641,9 @@
              &iterator);
         if (tabRec == NULL) break;
         alignBuffer(cUnit->codeBuffer, tabRec->offset);
-        for (int i = 0; i < ((tabRec->size + 1) / 2) ; i++) {
-            cUnit->codeBuffer.push_back( tabRec->table[i]);
+        for (int i = 0; i < (tabRec->size + 1) / 2; i++) {
+            cUnit->codeBuffer.push_back( tabRec->table[i] & 0xFF);
+            cUnit->codeBuffer.push_back( (tabRec->table[i] >> 8) & 0xFF);
         }
     }
 }
diff --git a/src/compiler/codegen/arm/Assemble.cc b/src/compiler/codegen/arm/Assemble.cc
index 2a89b6a..e012c4e 100644
--- a/src/compiler/codegen/arm/Assemble.cc
+++ b/src/compiler/codegen/arm/Assemble.cc
@@ -992,7 +992,8 @@
             if ((lir->opcode == kPseudoPseudoAlign4) &&
                 /* 1 means padding is needed */
                 (lir->operands[0] == 1)) {
-                cUnit->codeBuffer.push_back(PADDING_MOV_R5_R5);
+                cUnit->codeBuffer.push_back(PADDING_MOV_R5_R5 & 0xFF);
+                cUnit->codeBuffer.push_back((PADDING_MOV_R5_R5 >> 8) & 0xFF);
             }
             continue;
         }
@@ -1355,9 +1356,11 @@
             }
         }
         if (encoder->size == 4) {
-                cUnit->codeBuffer.push_back((bits >> 16) & 0xffff);
+            cUnit->codeBuffer.push_back((bits >> 16) & 0xff);
+            cUnit->codeBuffer.push_back((bits >> 24) & 0xff);
         }
-        cUnit->codeBuffer.push_back(bits & 0xffff);
+        cUnit->codeBuffer.push_back(bits & 0xff);
+        cUnit->codeBuffer.push_back((bits >> 8) & 0xff);
     }
     return res;
 }
diff --git a/src/compiler/codegen/mips/Assemble.cc b/src/compiler/codegen/mips/Assemble.cc
index 359ec42..e064da9 100644
--- a/src/compiler/codegen/mips/Assemble.cc
+++ b/src/compiler/codegen/mips/Assemble.cc
@@ -693,14 +693,18 @@
             }
         }
         // FIXME: need multi-endian handling here
-        cUnit->codeBuffer.push_back((bits >> 16) & 0xffff);
-        cUnit->codeBuffer.push_back(bits & 0xffff);
+        cUnit->codeBuffer.push_back((bits >> 24) & 0xff);
+        cUnit->codeBuffer.push_back((bits >> 16) & 0xff);
+        cUnit->codeBuffer.push_back((bits >> 8) & 0xff);
+        cUnit->codeBuffer.push_back(bits & 0xff);
         // TUNING: replace with proper delay slot handling
         if (encoder->size == 8) {
             const MipsEncodingMap *encoder = &EncodingMap[kMipsNop];
             u4 bits = encoder->skeleton;
-            cUnit->codeBuffer.push_back((bits >> 16) & 0xffff);
-            cUnit->codeBuffer.push_back(bits & 0xffff);
+            cUnit->codeBuffer.push_back((bits >> 24) & 0xff);
+            cUnit->codeBuffer.push_back((bits >> 16) & 0xff);
+            cUnit->codeBuffer.push_back((bits >> 8) & 0xff);
+            cUnit->codeBuffer.push_back(bits & 0xff);
         }
     }
     return res;