Make code buffer units 8bit rather than 16bit.

Change-Id: I1ca087c4f7f820a8816388095405603f4163b354
diff --git a/src/compiled_method.cc b/src/compiled_method.cc
index 3c3f6ef..b998b3c 100644
--- a/src/compiled_method.cc
+++ b/src/compiled_method.cc
@@ -26,7 +26,7 @@
 }
 #else
 CompiledMethod::CompiledMethod(InstructionSet instruction_set,
-                               const std::vector<uint16_t>& short_code,
+                               const std::vector<uint8_t>& code,
                                const size_t frame_size_in_bytes,
                                const uint32_t core_spill_mask,
                                const uint32_t fp_spill_mask,
@@ -34,13 +34,13 @@
                                const std::vector<uint16_t>& vmap_table)
     : instruction_set_(instruction_set), frame_size_in_bytes_(frame_size_in_bytes),
       core_spill_mask_(core_spill_mask), fp_spill_mask_(fp_spill_mask) {
-  CHECK_NE(short_code.size(), 0U);
+  CHECK_NE(code.size(), 0U);
   CHECK_GE(vmap_table.size(), 1U);  // should always contain an entry for LR
   CHECK_LE(vmap_table.size(), (1U << 16) - 1); // length must fit in 2^16-1
 
-  size_t code_byte_count = short_code.size() * sizeof(short_code[0]);
+  size_t code_byte_count = code.size() * sizeof(code[0]);
   std::vector<uint8_t> byte_code(code_byte_count);
-  memcpy(&byte_code[0], &short_code[0], code_byte_count);
+  memcpy(&byte_code[0], &code[0], code_byte_count);
 
   std::vector<uint32_t> length_prefixed_mapping_table;
   length_prefixed_mapping_table.push_back(mapping_table.size());
diff --git a/src/compiled_method.h b/src/compiled_method.h
index 9ad3139..715b5d2 100644
--- a/src/compiled_method.h
+++ b/src/compiled_method.h
@@ -37,7 +37,7 @@
 #else
   // Create a CompiledMethod from the oatCompileMethod
   CompiledMethod(InstructionSet instruction_set,
-                 const std::vector<uint16_t>& code,
+                 const std::vector<uint8_t>& code,
                  const size_t frame_size_in_bytes,
                  const uint32_t core_spill_mask,
                  const uint32_t fp_spill_mask,
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;