Change compiler tests to have aligned code item

Previously, the code item was not necessarily 32 bit aligned. This
caused bus errors on armv7.

Also create a real dexfile object instead of casting 0 initialized
memory to a dex file pointer. We just got lucky before that the cdex
boolean was false.

Test: test-art-target-gtest
Bug: 63756964
Bug: 71605148

Change-Id: Ic7199f2b97bbd421de1d702efa5c6531ff45c022
diff --git a/compiler/optimizing/codegen_test.cc b/compiler/optimizing/codegen_test.cc
index 6eda289..ba4040a 100644
--- a/compiler/optimizing/codegen_test.cc
+++ b/compiler/optimizing/codegen_test.cc
@@ -74,8 +74,8 @@
 
 class CodegenTest : public OptimizingUnitTest {
  protected:
-  void TestCode(const uint16_t* data, bool has_result = false, int32_t expected = 0);
-  void TestCodeLong(const uint16_t* data, bool has_result, int64_t expected);
+  void TestCode(const std::vector<uint16_t>& data, bool has_result = false, int32_t expected = 0);
+  void TestCodeLong(const std::vector<uint16_t>& data, bool has_result, int64_t expected);
   void TestComparison(IfCondition condition,
                       int64_t i,
                       int64_t j,
@@ -83,7 +83,7 @@
                       const CodegenTargetConfig target_config);
 };
 
-void CodegenTest::TestCode(const uint16_t* data, bool has_result, int32_t expected) {
+void CodegenTest::TestCode(const std::vector<uint16_t>& data, bool has_result, int32_t expected) {
   for (const CodegenTargetConfig& target_config : GetTargetConfigs()) {
     ResetPoolAndAllocator();
     HGraph* graph = CreateCFG(data);
@@ -93,7 +93,8 @@
   }
 }
 
-void CodegenTest::TestCodeLong(const uint16_t* data, bool has_result, int64_t expected) {
+void CodegenTest::TestCodeLong(const std::vector<uint16_t>& data,
+                               bool has_result, int64_t expected) {
   for (const CodegenTargetConfig& target_config : GetTargetConfigs()) {
     ResetPoolAndAllocator();
     HGraph* graph = CreateCFG(data, DataType::Type::kInt64);
@@ -104,12 +105,12 @@
 }
 
 TEST_F(CodegenTest, ReturnVoid) {
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(Instruction::RETURN_VOID);
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(Instruction::RETURN_VOID);
   TestCode(data);
 }
 
 TEST_F(CodegenTest, CFG1) {
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO | 0x100,
     Instruction::RETURN_VOID);
 
@@ -117,7 +118,7 @@
 }
 
 TEST_F(CodegenTest, CFG2) {
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO | 0x100,
     Instruction::GOTO | 0x100,
     Instruction::RETURN_VOID);
@@ -126,21 +127,21 @@
 }
 
 TEST_F(CodegenTest, CFG3) {
-  const uint16_t data1[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data1 = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO | 0x200,
     Instruction::RETURN_VOID,
     Instruction::GOTO | 0xFF00);
 
   TestCode(data1);
 
-  const uint16_t data2[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data2 = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO_16, 3,
     Instruction::RETURN_VOID,
     Instruction::GOTO_16, 0xFFFF);
 
   TestCode(data2);
 
-  const uint16_t data3[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data3 = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO_32, 4, 0,
     Instruction::RETURN_VOID,
     Instruction::GOTO_32, 0xFFFF, 0xFFFF);
@@ -149,7 +150,7 @@
 }
 
 TEST_F(CodegenTest, CFG4) {
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
     Instruction::RETURN_VOID,
     Instruction::GOTO | 0x100,
     Instruction::GOTO | 0xFE00);
@@ -158,7 +159,7 @@
 }
 
 TEST_F(CodegenTest, CFG5) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::GOTO | 0x100,
@@ -168,7 +169,7 @@
 }
 
 TEST_F(CodegenTest, IntConstant) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::RETURN_VOID);
 
@@ -176,7 +177,7 @@
 }
 
 TEST_F(CodegenTest, Return1) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::RETURN | 0);
 
@@ -184,7 +185,7 @@
 }
 
 TEST_F(CodegenTest, Return2) {
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::CONST_4 | 0 | 1 << 8,
     Instruction::RETURN | 1 << 8);
@@ -193,7 +194,7 @@
 }
 
 TEST_F(CodegenTest, Return3) {
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::CONST_4 | 1 << 8 | 1 << 12,
     Instruction::RETURN | 1 << 8);
@@ -202,7 +203,7 @@
 }
 
 TEST_F(CodegenTest, ReturnIf1) {
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::CONST_4 | 1 << 8 | 1 << 12,
     Instruction::IF_EQ, 3,
@@ -213,7 +214,7 @@
 }
 
 TEST_F(CodegenTest, ReturnIf2) {
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::CONST_4 | 1 << 8 | 1 << 12,
     Instruction::IF_EQ | 0 << 4 | 1 << 8, 3,
@@ -224,17 +225,17 @@
 }
 
 // Exercise bit-wise (one's complement) not-int instruction.
-#define NOT_INT_TEST(TEST_NAME, INPUT, EXPECTED_OUTPUT) \
-TEST_F(CodegenTest, TEST_NAME) {                        \
-  const int32_t input = INPUT;                          \
-  const uint16_t input_lo = Low16Bits(input);           \
-  const uint16_t input_hi = High16Bits(input);          \
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(      \
-      Instruction::CONST | 0 << 8, input_lo, input_hi,  \
-      Instruction::NOT_INT | 1 << 8 | 0 << 12 ,         \
-      Instruction::RETURN | 1 << 8);                    \
-                                                        \
-  TestCode(data, true, EXPECTED_OUTPUT);                \
+#define NOT_INT_TEST(TEST_NAME, INPUT, EXPECTED_OUTPUT)           \
+TEST_F(CodegenTest, TEST_NAME) {                                  \
+  const int32_t input = INPUT;                                    \
+  const uint16_t input_lo = Low16Bits(input);                     \
+  const uint16_t input_hi = High16Bits(input);                    \
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(     \
+      Instruction::CONST | 0 << 8, input_lo, input_hi,            \
+      Instruction::NOT_INT | 1 << 8 | 0 << 12 ,                   \
+      Instruction::RETURN | 1 << 8);                              \
+                                                                  \
+  TestCode(data, true, EXPECTED_OUTPUT);                          \
 }
 
 NOT_INT_TEST(ReturnNotIntMinus2, -2, 1)
@@ -256,7 +257,7 @@
   const uint16_t word1 = High16Bits(Low32Bits(input));                   \
   const uint16_t word2 = Low16Bits(High32Bits(input));                   \
   const uint16_t word3 = High16Bits(High32Bits(input)); /* MSW. */       \
-  const uint16_t data[] = FOUR_REGISTERS_CODE_ITEM(                      \
+  const std::vector<uint16_t> data = FOUR_REGISTERS_CODE_ITEM(           \
       Instruction::CONST_WIDE | 0 << 8, word0, word1, word2, word3,      \
       Instruction::NOT_LONG | 2 << 8 | 0 << 12,                          \
       Instruction::RETURN_WIDE | 2 << 8);                                \
@@ -306,7 +307,7 @@
   const uint16_t word1 = High16Bits(Low32Bits(input));
   const uint16_t word2 = Low16Bits(High32Bits(input));
   const uint16_t word3 = High16Bits(High32Bits(input));  // MSW.
-  const uint16_t data[] = FIVE_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = FIVE_REGISTERS_CODE_ITEM(
       Instruction::CONST_WIDE | 0 << 8, word0, word1, word2, word3,
       Instruction::CONST_WIDE | 2 << 8, 1, 0, 0, 0,
       Instruction::ADD_LONG | 0, 0 << 8 | 2,             // v0 <- 2^32 + 1
@@ -318,7 +319,7 @@
 }
 
 TEST_F(CodegenTest, ReturnAdd1) {
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 3 << 12 | 0,
     Instruction::CONST_4 | 4 << 12 | 1 << 8,
     Instruction::ADD_INT, 1 << 8 | 0,
@@ -328,7 +329,7 @@
 }
 
 TEST_F(CodegenTest, ReturnAdd2) {
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 3 << 12 | 0,
     Instruction::CONST_4 | 4 << 12 | 1 << 8,
     Instruction::ADD_INT_2ADDR | 1 << 12,
@@ -338,7 +339,7 @@
 }
 
 TEST_F(CodegenTest, ReturnAdd3) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 4 << 12 | 0 << 8,
     Instruction::ADD_INT_LIT8, 3 << 8 | 0,
     Instruction::RETURN);
@@ -347,7 +348,7 @@
 }
 
 TEST_F(CodegenTest, ReturnAdd4) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 4 << 12 | 0 << 8,
     Instruction::ADD_INT_LIT16, 3,
     Instruction::RETURN);
@@ -356,7 +357,7 @@
 }
 
 TEST_F(CodegenTest, ReturnMulInt) {
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 3 << 12 | 0,
     Instruction::CONST_4 | 4 << 12 | 1 << 8,
     Instruction::MUL_INT, 1 << 8 | 0,
@@ -366,7 +367,7 @@
 }
 
 TEST_F(CodegenTest, ReturnMulInt2addr) {
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 3 << 12 | 0,
     Instruction::CONST_4 | 4 << 12 | 1 << 8,
     Instruction::MUL_INT_2ADDR | 1 << 12,
@@ -376,7 +377,7 @@
 }
 
 TEST_F(CodegenTest, ReturnMulLong) {
-  const uint16_t data[] = FOUR_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = FOUR_REGISTERS_CODE_ITEM(
     Instruction::CONST_WIDE | 0 << 8, 3, 0, 0, 0,
     Instruction::CONST_WIDE | 2 << 8, 4, 0, 0, 0,
     Instruction::MUL_LONG, 2 << 8 | 0,
@@ -386,7 +387,7 @@
 }
 
 TEST_F(CodegenTest, ReturnMulLong2addr) {
-  const uint16_t data[] = FOUR_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = FOUR_REGISTERS_CODE_ITEM(
     Instruction::CONST_WIDE | 0 << 8, 3, 0, 0, 0,
     Instruction::CONST_WIDE | 2 << 8, 4, 0, 0, 0,
     Instruction::MUL_LONG_2ADDR | 2 << 12,
@@ -396,7 +397,7 @@
 }
 
 TEST_F(CodegenTest, ReturnMulIntLit8) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 4 << 12 | 0 << 8,
     Instruction::MUL_INT_LIT8, 3 << 8 | 0,
     Instruction::RETURN);
@@ -405,7 +406,7 @@
 }
 
 TEST_F(CodegenTest, ReturnMulIntLit16) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 4 << 12 | 0 << 8,
     Instruction::MUL_INT_LIT16, 3,
     Instruction::RETURN);
@@ -578,7 +579,7 @@
 }
 
 TEST_F(CodegenTest, ReturnDivIntLit8) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 4 << 12 | 0 << 8,
     Instruction::DIV_INT_LIT8, 3 << 8 | 0,
     Instruction::RETURN);
@@ -587,7 +588,7 @@
 }
 
 TEST_F(CodegenTest, ReturnDivInt2Addr) {
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 4 << 12 | 0,
     Instruction::CONST_4 | 2 << 12 | 1 << 8,
     Instruction::DIV_INT_2ADDR | 1 << 12,
diff --git a/compiler/optimizing/constant_folding_test.cc b/compiler/optimizing/constant_folding_test.cc
index e1980e0..d271047 100644
--- a/compiler/optimizing/constant_folding_test.cc
+++ b/compiler/optimizing/constant_folding_test.cc
@@ -36,7 +36,7 @@
  public:
   ConstantFoldingTest() : graph_(nullptr) { }
 
-  void TestCode(const uint16_t* data,
+  void TestCode(const std::vector<uint16_t>& data,
                 const std::string& expected_before,
                 const std::string& expected_after_cf,
                 const std::string& expected_after_dce,
@@ -100,7 +100,7 @@
  *     return v1                2.      return v1
  */
 TEST_F(ConstantFoldingTest, IntConstantFoldingNegation) {
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 << 8 | 1 << 12,
     Instruction::NEG_INT | 1 << 8 | 0 << 12,
     Instruction::RETURN | 1 << 8);
@@ -161,7 +161,7 @@
   const uint16_t word1 = High16Bits(Low32Bits(input));
   const uint16_t word2 = Low16Bits(High32Bits(input));
   const uint16_t word3 = High16Bits(High32Bits(input));  // MSW.
-  const uint16_t data[] = FOUR_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = FOUR_REGISTERS_CODE_ITEM(
     Instruction::CONST_WIDE | 0 << 8, word0, word1, word2, word3,
     Instruction::NEG_LONG | 2 << 8 | 0 << 12,
     Instruction::RETURN_WIDE | 2 << 8);
@@ -219,7 +219,7 @@
  *     return v2                4.      return v2
  */
 TEST_F(ConstantFoldingTest, IntConstantFoldingOnAddition1) {
-  const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 << 8 | 1 << 12,
     Instruction::CONST_4 | 1 << 8 | 2 << 12,
     Instruction::ADD_INT | 2 << 8, 0 | 1 << 8,
@@ -284,7 +284,7 @@
  *     return v2                8.      return v2
  */
 TEST_F(ConstantFoldingTest, IntConstantFoldingOnAddition2) {
-  const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 << 8 | 1 << 12,
     Instruction::CONST_4 | 1 << 8 | 2 << 12,
     Instruction::ADD_INT_2ADDR | 0 << 8 | 1 << 12,
@@ -369,7 +369,7 @@
  *     return v2                4.      return v2
  */
 TEST_F(ConstantFoldingTest, IntConstantFoldingOnSubtraction) {
-  const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 << 8 | 3 << 12,
     Instruction::CONST_4 | 1 << 8 | 2 << 12,
     Instruction::SUB_INT | 2 << 8, 0 | 1 << 8,
@@ -432,7 +432,7 @@
  *     return (v4, v5)          6.      return-wide v4
  */
 TEST_F(ConstantFoldingTest, LongConstantFoldingOnAddition) {
-  const uint16_t data[] = SIX_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = SIX_REGISTERS_CODE_ITEM(
     Instruction::CONST_WIDE_16 | 0 << 8, 1,
     Instruction::CONST_WIDE_16 | 2 << 8, 2,
     Instruction::ADD_LONG | 4 << 8, 0 | 2 << 8,
@@ -496,7 +496,7 @@
  *     return (v4, v5)          6.      return-wide v4
  */
 TEST_F(ConstantFoldingTest, LongConstantFoldingOnSubtraction) {
-  const uint16_t data[] = SIX_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = SIX_REGISTERS_CODE_ITEM(
     Instruction::CONST_WIDE_16 | 0 << 8, 3,
     Instruction::CONST_WIDE_16 | 2 << 8, 2,
     Instruction::SUB_LONG | 4 << 8, 0 | 2 << 8,
@@ -569,7 +569,7 @@
  *     return v2                13.     return v2
  */
 TEST_F(ConstantFoldingTest, IntConstantFoldingAndJumps) {
-  const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 << 8 | 1 << 12,
     Instruction::CONST_4 | 1 << 8 | 2 << 12,
     Instruction::ADD_INT | 2 << 8, 0 | 1 << 8,
@@ -672,7 +672,7 @@
  *     return-void              7.      return
  */
 TEST_F(ConstantFoldingTest, ConstantCondition) {
-  const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 1 << 8 | 1 << 12,
     Instruction::CONST_4 | 0 << 8 | 0 << 12,
     Instruction::IF_GEZ | 1 << 8, 3,
diff --git a/compiler/optimizing/dead_code_elimination_test.cc b/compiler/optimizing/dead_code_elimination_test.cc
index 929572e..adb6ce1 100644
--- a/compiler/optimizing/dead_code_elimination_test.cc
+++ b/compiler/optimizing/dead_code_elimination_test.cc
@@ -29,12 +29,12 @@
 
 class DeadCodeEliminationTest : public OptimizingUnitTest {
  protected:
-  void TestCode(const uint16_t* data,
+  void TestCode(const std::vector<uint16_t>& data,
                 const std::string& expected_before,
                 const std::string& expected_after);
 };
 
-void DeadCodeEliminationTest::TestCode(const uint16_t* data,
+void DeadCodeEliminationTest::TestCode(const std::vector<uint16_t>& data,
                                        const std::string& expected_before,
                                        const std::string& expected_after) {
   HGraph* graph = CreateCFG(data);
@@ -73,7 +73,7 @@
  *     return-void              7.      return
  */
 TEST_F(DeadCodeEliminationTest, AdditionAndConditionalJump) {
-  const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 1 << 8 | 1 << 12,
     Instruction::CONST_4 | 0 << 8 | 0 << 12,
     Instruction::IF_GEZ | 1 << 8, 3,
@@ -135,7 +135,7 @@
  *     return                   13.     return-void
  */
 TEST_F(DeadCodeEliminationTest, AdditionsAndInconditionalJumps) {
-  const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 << 8 | 0 << 12,
     Instruction::CONST_4 | 1 << 8 | 1 << 12,
     Instruction::ADD_INT | 2 << 8, 0 | 1 << 8,
diff --git a/compiler/optimizing/dominator_test.cc b/compiler/optimizing/dominator_test.cc
index 572466e..1d72ba1 100644
--- a/compiler/optimizing/dominator_test.cc
+++ b/compiler/optimizing/dominator_test.cc
@@ -26,10 +26,12 @@
 
 class OptimizerTest : public OptimizingUnitTest {
  protected:
-  void TestCode(const uint16_t* data, const uint32_t* blocks, size_t blocks_length);
+  void TestCode(const std::vector<uint16_t>& data, const uint32_t* blocks, size_t blocks_length);
 };
 
-void OptimizerTest::TestCode(const uint16_t* data, const uint32_t* blocks, size_t blocks_length) {
+void OptimizerTest::TestCode(const std::vector<uint16_t>& data,
+                             const uint32_t* blocks,
+                             size_t blocks_length) {
   HGraph* graph = CreateCFG(data);
   ASSERT_EQ(graph->GetBlocks().size(), blocks_length);
   for (size_t i = 0, e = blocks_length; i < e; ++i) {
@@ -49,7 +51,7 @@
 }
 
 TEST_F(OptimizerTest, ReturnVoid) {
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
       Instruction::RETURN_VOID);  // Block number 1
 
   const uint32_t dominators[] = {
@@ -62,7 +64,7 @@
 }
 
 TEST_F(OptimizerTest, CFG1) {
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO | 0x100,  // Block number 1
     Instruction::RETURN_VOID);  // Block number 2
 
@@ -77,7 +79,7 @@
 }
 
 TEST_F(OptimizerTest, CFG2) {
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO | 0x100,  // Block number 1
     Instruction::GOTO | 0x100,  // Block number 2
     Instruction::RETURN_VOID);  // Block number 3
@@ -94,7 +96,7 @@
 }
 
 TEST_F(OptimizerTest, CFG3) {
-  const uint16_t data1[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data1 = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO | 0x200,    // Block number 1
     Instruction::RETURN_VOID,     // Block number 2
     Instruction::GOTO | 0xFF00);  // Block number 3
@@ -109,14 +111,14 @@
 
   TestCode(data1, dominators, sizeof(dominators) / sizeof(int));
 
-  const uint16_t data2[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data2 = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO_16, 3,
     Instruction::RETURN_VOID,
     Instruction::GOTO_16, 0xFFFF);
 
   TestCode(data2, dominators, sizeof(dominators) / sizeof(int));
 
-  const uint16_t data3[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data3 = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO_32, 4, 0,
     Instruction::RETURN_VOID,
     Instruction::GOTO_32, 0xFFFF, 0xFFFF);
@@ -125,7 +127,7 @@
 }
 
 TEST_F(OptimizerTest, CFG4) {
-  const uint16_t data1[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data1 = ZERO_REGISTER_CODE_ITEM(
     Instruction::NOP,
     Instruction::GOTO | 0xFF00);
 
@@ -138,14 +140,14 @@
 
   TestCode(data1, dominators, sizeof(dominators) / sizeof(int));
 
-  const uint16_t data2[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data2 = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO_32, 0, 0);
 
   TestCode(data2, dominators, sizeof(dominators) / sizeof(int));
 }
 
 TEST_F(OptimizerTest, CFG5) {
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
     Instruction::RETURN_VOID,     // Block number 1
     Instruction::GOTO | 0x100,    // Dead block
     Instruction::GOTO | 0xFE00);  // Block number 2
@@ -162,7 +164,7 @@
 }
 
 TEST_F(OptimizerTest, CFG6) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::GOTO | 0x100,
@@ -181,7 +183,7 @@
 }
 
 TEST_F(OptimizerTest, CFG7) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,        // Block number 1
     Instruction::GOTO | 0x100,    // Block number 2
@@ -201,7 +203,7 @@
 }
 
 TEST_F(OptimizerTest, CFG8) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,        // Block number 1
     Instruction::GOTO | 0x200,    // Block number 2
@@ -222,7 +224,7 @@
 }
 
 TEST_F(OptimizerTest, CFG9) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,        // Block number 1
     Instruction::GOTO | 0x200,    // Block number 2
@@ -243,7 +245,7 @@
 }
 
 TEST_F(OptimizerTest, CFG10) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 6,  // Block number 1
     Instruction::IF_EQ, 3,  // Block number 2
diff --git a/compiler/optimizing/find_loops_test.cc b/compiler/optimizing/find_loops_test.cc
index b799fb4..75b8e96 100644
--- a/compiler/optimizing/find_loops_test.cc
+++ b/compiler/optimizing/find_loops_test.cc
@@ -31,7 +31,7 @@
 
 TEST_F(FindLoopsTest, CFG1) {
   // Constant is not used.
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::RETURN_VOID);
 
@@ -42,7 +42,7 @@
 }
 
 TEST_F(FindLoopsTest, CFG2) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::RETURN);
 
@@ -53,7 +53,7 @@
 }
 
 TEST_F(FindLoopsTest, CFG3) {
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 3 << 12 | 0,
     Instruction::CONST_4 | 4 << 12 | 1 << 8,
     Instruction::ADD_INT_2ADDR | 1 << 12,
@@ -67,7 +67,7 @@
 }
 
 TEST_F(FindLoopsTest, CFG4) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 4,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -82,7 +82,7 @@
 }
 
 TEST_F(FindLoopsTest, CFG5) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -126,7 +126,7 @@
   // while (a == a) {
   // }
   // return;
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::GOTO | 0xFE00,
@@ -150,7 +150,7 @@
   // while (a == a) {
   // }
   // return a;
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::GOTO | 0x400,
     Instruction::IF_EQ, 4,
@@ -173,7 +173,7 @@
 TEST_F(FindLoopsTest, Loop3) {
   // Make sure we create a preheader of a loop when a header originally has two
   // incoming blocks and one back edge.
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::GOTO | 0x100,
@@ -197,7 +197,7 @@
 
 TEST_F(FindLoopsTest, Loop4) {
   // Test loop with originally two back edges.
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 6,
     Instruction::IF_EQ, 3,
@@ -221,7 +221,7 @@
 
 TEST_F(FindLoopsTest, Loop5) {
   // Test loop with two exit edges.
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 6,
     Instruction::IF_EQ, 3,
@@ -244,7 +244,7 @@
 }
 
 TEST_F(FindLoopsTest, InnerLoop) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 6,
     Instruction::IF_EQ, 3,
@@ -273,7 +273,7 @@
 }
 
 TEST_F(FindLoopsTest, TwoLoops) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::GOTO | 0xFE00,  // first loop
@@ -301,7 +301,7 @@
 }
 
 TEST_F(FindLoopsTest, NonNaturalLoop) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::GOTO | 0x0100,
@@ -317,7 +317,7 @@
 }
 
 TEST_F(FindLoopsTest, DoWhileLoop) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::GOTO | 0x0100,
     Instruction::IF_EQ, 0xFFFF,
diff --git a/compiler/optimizing/graph_checker_test.cc b/compiler/optimizing/graph_checker_test.cc
index 9ca3e49..08bfa5d 100644
--- a/compiler/optimizing/graph_checker_test.cc
+++ b/compiler/optimizing/graph_checker_test.cc
@@ -22,7 +22,7 @@
 class GraphCheckerTest : public OptimizingUnitTest {
  protected:
   HGraph* CreateSimpleCFG();
-  void TestCode(const uint16_t* data);
+  void TestCode(const std::vector<uint16_t>& data);
 };
 
 /**
@@ -48,7 +48,7 @@
   return graph;
 }
 
-void GraphCheckerTest::TestCode(const uint16_t* data) {
+void GraphCheckerTest::TestCode(const std::vector<uint16_t>& data) {
   HGraph* graph = CreateCFG(data);
   ASSERT_NE(graph, nullptr);
 
@@ -58,14 +58,14 @@
 }
 
 TEST_F(GraphCheckerTest, ReturnVoid) {
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
       Instruction::RETURN_VOID);
 
   TestCode(data);
 }
 
 TEST_F(GraphCheckerTest, CFG1) {
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
       Instruction::GOTO | 0x100,
       Instruction::RETURN_VOID);
 
@@ -73,7 +73,7 @@
 }
 
 TEST_F(GraphCheckerTest, CFG2) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::GOTO | 0x100,
@@ -83,7 +83,7 @@
 }
 
 TEST_F(GraphCheckerTest, CFG3) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::GOTO | 0x100,
@@ -128,7 +128,7 @@
 
 TEST_F(GraphCheckerTest, SSAPhi) {
   // This code creates one Phi function during the conversion to SSA form.
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::CONST_4 | 4 << 12 | 0,
diff --git a/compiler/optimizing/linearize_test.cc b/compiler/optimizing/linearize_test.cc
index 43b63a7..9fa5b74 100644
--- a/compiler/optimizing/linearize_test.cc
+++ b/compiler/optimizing/linearize_test.cc
@@ -35,11 +35,12 @@
 class LinearizeTest : public OptimizingUnitTest {
  protected:
   template <size_t number_of_blocks>
-  void TestCode(const uint16_t* data, const uint32_t (&expected_order)[number_of_blocks]);
+  void TestCode(const std::vector<uint16_t>& data,
+                const uint32_t (&expected_order)[number_of_blocks]);
 };
 
 template <size_t number_of_blocks>
-void LinearizeTest::TestCode(const uint16_t* data,
+void LinearizeTest::TestCode(const std::vector<uint16_t>& data,
                              const uint32_t (&expected_order)[number_of_blocks]) {
   HGraph* graph = CreateCFG(data);
   std::unique_ptr<const X86InstructionSetFeatures> features_x86(
@@ -68,7 +69,7 @@
   //               + /   \  +
   //           Block4   Block8
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 5,
     Instruction::IF_EQ, 0xFFFE,
@@ -93,7 +94,7 @@
   //               + /   \  +
   //           Block5   Block8
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::RETURN_VOID,
@@ -119,7 +120,7 @@
   //           Block6  + Block9
   //             |     +
   //           Block4 ++
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 4,
     Instruction::RETURN_VOID,
@@ -149,7 +150,7 @@
   //                  + /    \   +
   //                Block5  Block11
   */
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 7,
     Instruction::IF_EQ, 0xFFFE,
@@ -179,7 +180,7 @@
   //                   +/    \   +
   //                Block6  Block11
   */
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::RETURN_VOID,
@@ -205,7 +206,7 @@
   //       Block5 <- Block9 Block6  +
   //         |
   //       Block7
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::GOTO | 0x0100,
     Instruction::IF_EQ, 0x0004,
@@ -233,7 +234,7 @@
   //     |
   //   Block7
   //
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::GOTO | 0x0100,
     Instruction::IF_EQ, 0x0005,
diff --git a/compiler/optimizing/live_ranges_test.cc b/compiler/optimizing/live_ranges_test.cc
index e45d7c8..6666066 100644
--- a/compiler/optimizing/live_ranges_test.cc
+++ b/compiler/optimizing/live_ranges_test.cc
@@ -31,10 +31,10 @@
 
 class LiveRangesTest : public OptimizingUnitTest {
  public:
-  HGraph* BuildGraph(const uint16_t* data);
+  HGraph* BuildGraph(const std::vector<uint16_t>& data);
 };
 
-HGraph* LiveRangesTest::BuildGraph(const uint16_t* data) {
+HGraph* LiveRangesTest::BuildGraph(const std::vector<uint16_t>& data) {
   HGraph* graph = CreateCFG(data);
   // Suspend checks implementation may change in the future, and this test relies
   // on how instructions are ordered.
@@ -57,7 +57,7 @@
    *           |
    *       12: exit
    */
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::RETURN);
 
@@ -102,7 +102,7 @@
    *         |
    *       26: exit
    */
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::GOTO | 0x100,
@@ -151,7 +151,7 @@
    *         |
    *       28: exit
    */
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -225,7 +225,7 @@
    *       30: exit
    */
 
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 4,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -304,7 +304,7 @@
    * We want to make sure the phi at 10 has a lifetime hole after the add at 20.
    */
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 6,
     Instruction::ADD_INT, 0, 0,
@@ -378,7 +378,7 @@
    *
    * We want to make sure the constant0 has a lifetime hole after the 16: add.
    */
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::CONST_4 | 4 << 12 | 1 << 8,
     Instruction::IF_EQ, 5,
diff --git a/compiler/optimizing/liveness_test.cc b/compiler/optimizing/liveness_test.cc
index 35bc4ff..6621a03 100644
--- a/compiler/optimizing/liveness_test.cc
+++ b/compiler/optimizing/liveness_test.cc
@@ -31,7 +31,7 @@
 
 class LivenessTest : public OptimizingUnitTest {
  protected:
-  void TestCode(const uint16_t* data, const char* expected);
+  void TestCode(const std::vector<uint16_t>& data, const char* expected);
 };
 
 static void DumpBitVector(BitVector* vector,
@@ -46,7 +46,7 @@
   buffer << ")\n";
 }
 
-void LivenessTest::TestCode(const uint16_t* data, const char* expected) {
+void LivenessTest::TestCode(const std::vector<uint16_t>& data, const char* expected) {
   HGraph* graph = CreateCFG(data);
   // `Inline` conditions into ifs.
   PrepareForRegisterAllocation(graph).Run();
@@ -86,7 +86,7 @@
     "  kill: (0)\n";
 
   // Constant is not used.
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::RETURN_VOID);
 
@@ -108,7 +108,7 @@
     "  live out: (0)\n"
     "  kill: (0)\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::RETURN);
 
@@ -134,7 +134,7 @@
     "  live out: (000)\n"
     "  kill: (000)\n";
 
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 3 << 12 | 0,
     Instruction::CONST_4 | 4 << 12 | 1 << 8,
     Instruction::ADD_INT_2ADDR | 1 << 12,
@@ -181,7 +181,7 @@
     "  live out: (0000)\n"
     "  kill: (0000)\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 4,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -228,7 +228,7 @@
     "  live out: (000)\n"
     "  kill: (000)\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -273,7 +273,7 @@
     "  kill: (000)\n";
 
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 4,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -318,7 +318,7 @@
     "  live out: (0000)\n"
     "  kill: (0000)\n";
 
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 4,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -370,7 +370,7 @@
     "  live out: (000)\n"
     "  kill: (000)\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::GOTO | 0x500,
     Instruction::IF_EQ, 5,
@@ -425,7 +425,7 @@
     "  live out: (0001)\n"
     "  kill: (0001)\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 4,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -475,7 +475,7 @@
     "  live out: (0000)\n"
     "  kill: (0000)\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 8,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -530,7 +530,7 @@
     "  live out: (00000)\n"
     "  kill: (00000)\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 8,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -580,7 +580,7 @@
     "  live out: (000)\n"
     "  kill: (000)\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 6,
     Instruction::ADD_INT, 0, 0,
diff --git a/compiler/optimizing/optimizing_cfi_test.cc b/compiler/optimizing/optimizing_cfi_test.cc
index e2b2106..d20b681 100644
--- a/compiler/optimizing/optimizing_cfi_test.cc
+++ b/compiler/optimizing/optimizing_cfi_test.cc
@@ -41,7 +41,7 @@
 // Run the tests only on host.
 #ifndef ART_TARGET_ANDROID
 
-class OptimizingCFITest : public CFITest {
+class OptimizingCFITest : public CFITest, public OptimizingUnitTestHelper {
  public:
   // Enable this flag to generate the expected outputs.
   static constexpr bool kGenerateExpected = false;
@@ -63,7 +63,7 @@
     // Setup simple context.
     std::string error;
     isa_features_ = InstructionSetFeatures::FromVariant(isa, "default", &error);
-    graph_ = CreateGraph(&pool_and_allocator_);
+    graph_ = CreateGraph();
     // Generate simple frame with some spills.
     code_gen_ = CodeGenerator::Create(graph_, isa, *isa_features_, opts_);
     code_gen_->GetAssembler()->cfi().SetEnabled(true);
diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h
index 8c97d57..6dcbadb 100644
--- a/compiler/optimizing/optimizing_unit_test.h
+++ b/compiler/optimizing/optimizing_unit_test.h
@@ -17,12 +17,16 @@
 #ifndef ART_COMPILER_OPTIMIZING_OPTIMIZING_UNIT_TEST_H_
 #define ART_COMPILER_OPTIMIZING_OPTIMIZING_UNIT_TEST_H_
 
+#include <memory>
+#include <vector>
+
 #include "base/scoped_arena_allocator.h"
 #include "builder.h"
 #include "common_compiler_test.h"
 #include "dex/code_item_accessors-inl.h"
 #include "dex/dex_file.h"
 #include "dex/dex_instruction.h"
+#include "dex/standard_dex_file.h"
 #include "driver/dex_compilation_unit.h"
 #include "handle_scope-inl.h"
 #include "mirror/class_loader.h"
@@ -99,18 +103,11 @@
   ScopedArenaAllocator scoped_allocator_;
 };
 
-inline HGraph* CreateGraph(ArenaPoolAndAllocator* pool_and_allocator) {
-  return new (pool_and_allocator->GetAllocator()) HGraph(
-      pool_and_allocator->GetAllocator(),
-      pool_and_allocator->GetArenaStack(),
-      *reinterpret_cast<DexFile*>(pool_and_allocator->GetAllocator()->Alloc(sizeof(DexFile))),
-      /*method_idx*/-1,
-      kRuntimeISA);
-}
-
-class OptimizingUnitTest : public CommonCompilerTest {
- protected:
-  OptimizingUnitTest() : pool_and_allocator_(new ArenaPoolAndAllocator()) { }
+// Have a separate helper so the OptimizingCFITest can inherit it without causing
+// multiple inheritance errors from having two gtest as a parent twice.
+class OptimizingUnitTestHelper {
+ public:
+  OptimizingUnitTestHelper() : pool_and_allocator_(new ArenaPoolAndAllocator()) { }
 
   ArenaAllocator* GetAllocator() { return pool_and_allocator_->GetAllocator(); }
   ArenaStack* GetArenaStack() { return pool_and_allocator_->GetArenaStack(); }
@@ -122,14 +119,42 @@
   }
 
   HGraph* CreateGraph() {
-    return art::CreateGraph(pool_and_allocator_.get());
+    ArenaAllocator* const allocator = pool_and_allocator_->GetAllocator();
+
+    // Reserve a big array of 0s so the dex file constructor can offsets from the header.
+    static constexpr size_t kDexDataSize = 4 * KB;
+    const uint8_t* dex_data = reinterpret_cast<uint8_t*>(allocator->Alloc(kDexDataSize));
+
+    // Create the dex file based on the fake data. Call the constructor so that we can use virtual
+    // functions. Don't use the arena for the StandardDexFile otherwise the dex location leaks.
+    dex_files_.emplace_back(new StandardDexFile(
+        dex_data,
+        sizeof(StandardDexFile::Header),
+        "no_location",
+        /*location_checksum*/ 0,
+        /*oat_dex_file*/ nullptr,
+        /*container*/ nullptr));
+
+    return new (allocator) HGraph(
+        allocator,
+        pool_and_allocator_->GetArenaStack(),
+        *dex_files_.back(),
+        /*method_idx*/-1,
+        kRuntimeISA);
   }
 
   // Create a control-flow graph from Dex instructions.
-  HGraph* CreateCFG(const uint16_t* data, DataType::Type return_type = DataType::Type::kInt32) {
-    const DexFile::CodeItem* code_item = reinterpret_cast<const DexFile::CodeItem*>(data);
+  HGraph* CreateCFG(const std::vector<uint16_t>& data,
+                    DataType::Type return_type = DataType::Type::kInt32) {
     HGraph* graph = CreateGraph();
 
+    // The code item data might not aligned to 4 bytes, copy it to ensure that.
+    const size_t code_item_size = data.size() * sizeof(data.front());
+    void* aligned_data = GetAllocator()->Alloc(code_item_size);
+    memcpy(aligned_data, &data[0], code_item_size);
+    CHECK_ALIGNED(aligned_data, StandardDexFile::CodeItem::kAlignment);
+    const DexFile::CodeItem* code_item = reinterpret_cast<const DexFile::CodeItem*>(aligned_data);
+
     {
       ScopedObjectAccess soa(Thread::Current());
       if (handles_ == nullptr) {
@@ -146,7 +171,7 @@
               /* access_flags */ 0u,
               /* verified_method */ nullptr,
               handles_->NewHandle<mirror::DexCache>(nullptr));
-      CodeItemDebugInfoAccessor accessor(graph->GetDexFile(), code_item);
+      CodeItemDebugInfoAccessor accessor(graph->GetDexFile(), code_item, /*dex_method_idx*/ 0u);
       HGraphBuilder builder(graph, dex_compilation_unit, accessor, handles_.get(), return_type);
       bool graph_built = (builder.BuildGraph() == kAnalysisSuccess);
       return graph_built ? graph : nullptr;
@@ -154,10 +179,13 @@
   }
 
  private:
+  std::vector<std::unique_ptr<const StandardDexFile>> dex_files_;
   std::unique_ptr<ArenaPoolAndAllocator> pool_and_allocator_;
   std::unique_ptr<VariableSizedHandleScope> handles_;
 };
 
+class OptimizingUnitTest : public CommonCompilerTest, public OptimizingUnitTestHelper {};
+
 // Naive string diff data type.
 typedef std::list<std::pair<std::string, std::string>> diff_t;
 
diff --git a/compiler/optimizing/pretty_printer_test.cc b/compiler/optimizing/pretty_printer_test.cc
index 4fc7fe9..6ef386b 100644
--- a/compiler/optimizing/pretty_printer_test.cc
+++ b/compiler/optimizing/pretty_printer_test.cc
@@ -29,10 +29,10 @@
 
 class PrettyPrinterTest : public OptimizingUnitTest {
  protected:
-  void TestCode(const uint16_t* data, const char* expected);
+  void TestCode(const std::vector<uint16_t>& data, const char* expected);
 };
 
-void PrettyPrinterTest::TestCode(const uint16_t* data, const char* expected) {
+void PrettyPrinterTest::TestCode(const std::vector<uint16_t>& data, const char* expected) {
   HGraph* graph = CreateCFG(data);
   StringPrettyPrinter printer(graph);
   printer.VisitInsertionOrder();
@@ -40,7 +40,7 @@
 }
 
 TEST_F(PrettyPrinterTest, ReturnVoid) {
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
       Instruction::RETURN_VOID);
 
   const char* expected =
@@ -67,7 +67,7 @@
       "BasicBlock 3, pred: 2\n"
       "  4: Exit\n";
 
-  const uint16_t data[] =
+  const std::vector<uint16_t> data =
     ZERO_REGISTER_CODE_ITEM(
       Instruction::GOTO | 0x100,
       Instruction::RETURN_VOID);
@@ -89,7 +89,7 @@
       "BasicBlock 4, pred: 3\n"
       "  5: Exit\n";
 
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO | 0x100,
     Instruction::GOTO | 0x100,
     Instruction::RETURN_VOID);
@@ -111,21 +111,21 @@
       "BasicBlock 4, pred: 2\n"
       "  5: Exit\n";
 
-  const uint16_t data1[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data1 = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO | 0x200,
     Instruction::RETURN_VOID,
     Instruction::GOTO | 0xFF00);
 
   TestCode(data1, expected);
 
-  const uint16_t data2[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data2 = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO_16, 3,
     Instruction::RETURN_VOID,
     Instruction::GOTO_16, 0xFFFF);
 
   TestCode(data2, expected);
 
-  const uint16_t data3[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data3 = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO_32, 4, 0,
     Instruction::RETURN_VOID,
     Instruction::GOTO_32, 0xFFFF, 0xFFFF);
@@ -144,13 +144,13 @@
       "BasicBlock 3, pred: 0, succ: 1\n"
       "  0: Goto 1\n";
 
-  const uint16_t data1[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data1 = ZERO_REGISTER_CODE_ITEM(
     Instruction::NOP,
     Instruction::GOTO | 0xFF00);
 
   TestCode(data1, expected);
 
-  const uint16_t data2[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data2 = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO_32, 0, 0);
 
   TestCode(data2, expected);
@@ -166,7 +166,7 @@
       "BasicBlock 3, pred: 1\n"
       "  3: Exit\n";
 
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
     Instruction::RETURN_VOID,
     Instruction::GOTO | 0x100,
     Instruction::GOTO | 0xFE00);
@@ -192,7 +192,7 @@
       "BasicBlock 5, pred: 1, succ: 3\n"
       "  0: Goto 3\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::GOTO | 0x100,
@@ -220,7 +220,7 @@
       "BasicBlock 6, pred: 1, succ: 2\n"
       "  1: Goto 2\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::GOTO | 0x100,
@@ -240,7 +240,7 @@
       "BasicBlock 2, pred: 1\n"
       "  4: Exit\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::RETURN_VOID);
 
diff --git a/compiler/optimizing/register_allocator_test.cc b/compiler/optimizing/register_allocator_test.cc
index 3748d59..a70b066 100644
--- a/compiler/optimizing/register_allocator_test.cc
+++ b/compiler/optimizing/register_allocator_test.cc
@@ -46,7 +46,7 @@
   void ExpectedInRegisterHint(Strategy strategy);
 
   // Helper functions that make use of the OptimizingUnitTest's members.
-  bool Check(const uint16_t* data, Strategy strategy);
+  bool Check(const std::vector<uint16_t>& data, Strategy strategy);
   void CFG1(Strategy strategy);
   void Loop1(Strategy strategy);
   void Loop2(Strategy strategy);
@@ -79,7 +79,7 @@
   test_name(Strategy::kRegisterAllocatorGraphColor);\
 }
 
-bool RegisterAllocatorTest::Check(const uint16_t* data, Strategy strategy) {
+bool RegisterAllocatorTest::Check(const std::vector<uint16_t>& data, Strategy strategy) {
   HGraph* graph = CreateCFG(data);
   std::unique_ptr<const X86InstructionSetFeatures> features_x86(
       X86InstructionSetFeatures::FromCppDefines());
@@ -185,7 +185,7 @@
    *        |
    *       exit
    */
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::RETURN);
 
@@ -222,7 +222,7 @@
    *       exit
    */
 
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 4,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -268,7 +268,7 @@
    *       exit
    */
 
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::CONST_4 | 8 << 12 | 1 << 8,
     Instruction::IF_EQ | 1 << 8, 7,
@@ -314,7 +314,7 @@
    *       exit
    */
 
-  const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::ADD_INT_LIT8 | 1 << 8, 1 << 8,
     Instruction::CONST_4 | 5 << 12 | 2 << 8,
@@ -351,7 +351,7 @@
 TEST_ALL_STRATEGIES(Loop3);
 
 TEST_F(RegisterAllocatorTest, FirstRegisterUse) {
-  const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::XOR_INT_LIT8 | 1 << 8, 1 << 8,
     Instruction::XOR_INT_LIT8 | 0 << 8, 1 << 8,
@@ -402,7 +402,7 @@
    *  } while (true);
    */
 
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::CONST_4 | 1 << 8 | 0,
     Instruction::IF_NE | 1 << 8 | 1 << 12, 3,
@@ -432,7 +432,7 @@
  * This test only applies to the linear scan allocator.
  */
 TEST_F(RegisterAllocatorTest, FreeUntil) {
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::RETURN);
 
diff --git a/compiler/optimizing/scheduler_test.cc b/compiler/optimizing/scheduler_test.cc
index 104ebc7..fb15fc8 100644
--- a/compiler/optimizing/scheduler_test.cc
+++ b/compiler/optimizing/scheduler_test.cc
@@ -182,7 +182,9 @@
     scheduler->Schedule(graph_);
   }
 
-  void CompileWithRandomSchedulerAndRun(const uint16_t* data, bool has_result, int expected) {
+  void CompileWithRandomSchedulerAndRun(const std::vector<uint16_t>& data,
+                                        bool has_result,
+                                        int expected) {
     for (CodegenTargetConfig target_config : GetTargetConfigs()) {
       HGraph* graph = CreateCFG(data);
 
@@ -393,7 +395,7 @@
   //  }
   //  return result;
   //
-  const uint16_t data[] = SIX_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = SIX_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 << 12 | 2 << 8,          // const/4 v2, #int 0
     Instruction::CONST_HIGH16 | 0 << 8, 0x4120,       // const/high16 v0, #float 10.0 // #41200000
     Instruction::CONST_4 | 1 << 12 | 1 << 8,          // const/4 v1, #int 1
diff --git a/compiler/optimizing/ssa_test.cc b/compiler/optimizing/ssa_test.cc
index 77e70d7..85ed06e 100644
--- a/compiler/optimizing/ssa_test.cc
+++ b/compiler/optimizing/ssa_test.cc
@@ -31,7 +31,7 @@
 
 class SsaTest : public OptimizingUnitTest {
  protected:
-  void TestCode(const uint16_t* data, const char* expected);
+  void TestCode(const std::vector<uint16_t>& data, const char* expected);
 };
 
 class SsaPrettyPrinter : public HPrettyPrinter {
@@ -80,7 +80,7 @@
   }
 }
 
-void SsaTest::TestCode(const uint16_t* data, const char* expected) {
+void SsaTest::TestCode(const std::vector<uint16_t>& data, const char* expected) {
   HGraph* graph = CreateCFG(data);
   // Suspend checks implementation may change in the future, and this test relies
   // on how instructions are ordered.
@@ -119,7 +119,7 @@
     "BasicBlock 5, pred: 1, succ: 3\n"
     "  7: Goto\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::GOTO | 0x100,
@@ -150,7 +150,7 @@
     "BasicBlock 5, pred: 1, succ: 3\n"
     "  9: Goto\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -181,7 +181,7 @@
     "BasicBlock 5, pred: 4\n"
     "  10: Exit\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 4,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -214,7 +214,7 @@
     "BasicBlock 6, pred: 5\n"
     "  10: Exit\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 4,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -245,7 +245,7 @@
     "BasicBlock 5, pred: 4\n"
     "  9: Exit\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 4,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -276,7 +276,7 @@
     "BasicBlock 5, pred: 4\n"
     "  10: Exit\n";
 
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 4,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -310,7 +310,7 @@
     "BasicBlock 6, pred: 5\n"
     "  10: Exit\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::GOTO | 0x500,
     Instruction::IF_EQ, 5,
@@ -351,7 +351,7 @@
     "  13: Phi(2, 1) [11, 8, 8]\n"
     "  14: Goto\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 4,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -390,7 +390,7 @@
     "BasicBlock 7, pred: 6\n"
     "  13: Exit\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 8,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -432,7 +432,7 @@
     "BasicBlock 8, pred: 2, succ: 6\n"
     "  15: Goto\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 8,
     Instruction::CONST_4 | 4 << 12 | 0,
@@ -456,7 +456,7 @@
     "BasicBlock 2, pred: 1\n"
     "  3: Exit\n";
 
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::RETURN_VOID);
 
@@ -484,7 +484,7 @@
     "BasicBlock 5, pred: 1, succ: 3\n"
     "  8: Goto\n";
 
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 3,
     Instruction::CONST_4 | 4 << 12 | 1 << 8,
@@ -520,7 +520,7 @@
     "BasicBlock 7, pred: 3, succ: 5\n"
     "  12: Goto\n";
 
-  const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+  const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 5,
     Instruction::ADD_INT_LIT8 | 1 << 8, 0 << 8,
diff --git a/compiler/optimizing/suspend_check_test.cc b/compiler/optimizing/suspend_check_test.cc
index 7e83f8c..33823e2 100644
--- a/compiler/optimizing/suspend_check_test.cc
+++ b/compiler/optimizing/suspend_check_test.cc
@@ -30,10 +30,10 @@
 
 class SuspendCheckTest : public OptimizingUnitTest {
  protected:
-  void TestCode(const uint16_t* data);
+  void TestCode(const std::vector<uint16_t>& data);
 };
 
-void SuspendCheckTest::TestCode(const uint16_t* data) {
+void SuspendCheckTest::TestCode(const std::vector<uint16_t>& data) {
   HGraph* graph = CreateCFG(data);
   HBasicBlock* first_block = graph->GetEntryBlock()->GetSingleSuccessor();
   HBasicBlock* loop_header = first_block->GetSingleSuccessor();
@@ -43,7 +43,7 @@
 }
 
 TEST_F(SuspendCheckTest, CFG1) {
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
     Instruction::NOP,
     Instruction::GOTO | 0xFF00);
 
@@ -51,14 +51,14 @@
 }
 
 TEST_F(SuspendCheckTest, CFG2) {
-  const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
     Instruction::GOTO_32, 0, 0);
 
   TestCode(data);
 }
 
 TEST_F(SuspendCheckTest, CFG3) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQ, 0xFFFF,
     Instruction::RETURN_VOID);
@@ -67,7 +67,7 @@
 }
 
 TEST_F(SuspendCheckTest, CFG4) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_NE, 0xFFFF,
     Instruction::RETURN_VOID);
@@ -76,7 +76,7 @@
 }
 
 TEST_F(SuspendCheckTest, CFG5) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_EQZ, 0xFFFF,
     Instruction::RETURN_VOID);
@@ -85,7 +85,7 @@
 }
 
 TEST_F(SuspendCheckTest, CFG6) {
-  const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+  const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
     Instruction::CONST_4 | 0 | 0,
     Instruction::IF_NEZ, 0xFFFF,
     Instruction::RETURN_VOID);
diff --git a/runtime/dex/standard_dex_file.h b/runtime/dex/standard_dex_file.h
index fb2f720..819b721 100644
--- a/runtime/dex/standard_dex_file.h
+++ b/runtime/dex/standard_dex_file.h
@@ -33,6 +33,8 @@
   };
 
   struct CodeItem : public DexFile::CodeItem {
+    static constexpr size_t kAlignment = 4;
+
    private:
     // TODO: Insert standard dex specific fields here.
     friend class StandardDexFile;
@@ -80,6 +82,7 @@
   friend class DexFileVerifierTest;
 
   ART_FRIEND_TEST(ClassLinkerTest, RegisterDexFileName);  // for constructor
+  friend class OptimizingUnitTestHelper;  // for constructor
 
   DISALLOW_COPY_AND_ASSIGN(StandardDexFile);
 };