diff --git a/libdexfile/dex/dex_instruction.cc b/libdexfile/dex/dex_instruction.cc
index c1bc34b..67147bb 100644
--- a/libdexfile/dex/dex_instruction.cc
+++ b/libdexfile/dex/dex_instruction.cc
@@ -24,6 +24,7 @@
 #include "android-base/stringprintf.h"
 
 #include "dex_file-inl.h"
+#include "dex_instruction_list.h"
 #include "utf.h"
 
 namespace art {
@@ -32,47 +33,12 @@
 
 const char* const Instruction::kInstructionNames[] = {
 #define INSTRUCTION_NAME(o, c, pname, f, i, a, e, v) pname,
-#include "dex_instruction_list.h"
   DEX_INSTRUCTION_LIST(INSTRUCTION_NAME)
-#undef DEX_INSTRUCTION_LIST
 #undef INSTRUCTION_NAME
 };
 
 static_assert(sizeof(Instruction::InstructionDescriptor) == 8u, "Unexpected descriptor size");
 
-static constexpr int8_t InstructionSizeInCodeUnitsByOpcode(Instruction::Code opcode,
-                                                           Instruction::Format format) {
-  if (opcode == Instruction::Code::NOP) {
-    return -1;
-  } else if ((format >= Instruction::Format::k10x) && (format <= Instruction::Format::k10t)) {
-    return 1;
-  } else if ((format >= Instruction::Format::k20t) && (format <= Instruction::Format::k22c)) {
-    return 2;
-  } else if ((format >= Instruction::Format::k32x) && (format <= Instruction::Format::k3rc)) {
-    return 3;
-  } else if ((format >= Instruction::Format::k45cc) && (format <= Instruction::Format::k4rcc)) {
-    return 4;
-  } else if (format == Instruction::Format::k51l) {
-    return 5;
-  } else {
-    return -1;
-  }
-}
-
-Instruction::InstructionDescriptor const Instruction::kInstructionDescriptors[] = {
-#define INSTRUCTION_DESCR(opcode, c, p, format, index, flags, eflags, vflags) \
-    { vflags, \
-      format, \
-      index, \
-      flags, \
-      InstructionSizeInCodeUnitsByOpcode((c), (format)), \
-    },
-#include "dex_instruction_list.h"
-  DEX_INSTRUCTION_LIST(INSTRUCTION_DESCR)
-#undef DEX_INSTRUCTION_LIST
-#undef INSTRUCTION_DESCR
-};
-
 int32_t Instruction::GetTargetOffset() const {
   switch (FormatOf(Opcode())) {
     // Cases for conditional branches follow.
@@ -490,26 +456,20 @@
     static_assert(IMPLIES((f) == k35c || (f) == k45cc, \
                           ((v) & (kVerifyVarArg | kVerifyVarArgNonZero)) != 0), \
                   "Missing var-arg verification");
-  #include "dex_instruction_list.h"
     DEX_INSTRUCTION_LIST(VAR_ARGS_CHECK)
-  #undef DEX_INSTRUCTION_LIST
   #undef VAR_ARGS_CHECK
 
   #define VAR_ARGS_RANGE_CHECK(o, c, pname, f, i, a, e, v) \
     static_assert(IMPLIES((f) == k3rc || (f) == k4rcc, \
                           ((v) & (kVerifyVarArgRange | kVerifyVarArgRangeNonZero)) != 0), \
                   "Missing var-arg verification");
-  #include "dex_instruction_list.h"
     DEX_INSTRUCTION_LIST(VAR_ARGS_RANGE_CHECK)
-  #undef DEX_INSTRUCTION_LIST
   #undef VAR_ARGS_RANGE_CHECK
 
   #define EXPERIMENTAL_CHECK(o, c, pname, f, i, a, e, v) \
     static_assert(kHaveExperimentalInstructions || (((a) & kExperimental) == 0), \
                   "Unexpected experimental instruction.");
-    #include "dex_instruction_list.h"
   DEX_INSTRUCTION_LIST(EXPERIMENTAL_CHECK)
-  #undef DEX_INSTRUCTION_LIST
   #undef EXPERIMENTAL_CHECK
 };
 
diff --git a/libdexfile/dex/dex_instruction.h b/libdexfile/dex/dex_instruction.h
index 3b7fe46..3e263ab 100644
--- a/libdexfile/dex/dex_instruction.h
+++ b/libdexfile/dex/dex_instruction.h
@@ -21,6 +21,7 @@
 
 #include "base/globals.h"
 #include "base/macros.h"
+#include "dex_instruction_list.h"
 
 using uint4_t = uint8_t;
 using int4_t = int8_t;
@@ -81,9 +82,7 @@
 
   enum Code {  // private marker to avoid generate-operator-out.py from processing.
 #define INSTRUCTION_ENUM(opcode, cname, p, f, i, a, e, v) cname = (opcode),
-#include "dex_instruction_list.h"
     DEX_INSTRUCTION_LIST(INSTRUCTION_ENUM)
-#undef DEX_INSTRUCTION_LIST
 #undef INSTRUCTION_ENUM
     RSUB_INT_LIT16 = RSUB_INT,
   };
@@ -215,7 +214,7 @@
 
   // Returns the size (in 2 byte code units) of this instruction.
   size_t SizeInCodeUnits() const {
-    int8_t result = kInstructionDescriptors[Opcode()].size_in_code_units;
+    int8_t result = InstructionDescriptorOf(Opcode()).size_in_code_units;
     if (UNLIKELY(result < 0)) {
       return SizeInCodeUnitsComplexOpcode();
     } else {
@@ -228,7 +227,7 @@
 
   // Code units required to calculate the size of the instruction.
   size_t CodeUnitsRequiredForSizeComputation() const {
-    const int8_t result = kInstructionDescriptors[Opcode()].size_in_code_units;
+    const int8_t result = InstructionDescriptorOf(Opcode()).size_in_code_units;
     return UNLIKELY(result < 0) ? CodeUnitsRequiredForSizeOfComplexOpcode() : 1;
   }
 
@@ -525,33 +524,33 @@
   }
 
   // Returns the format of the given opcode.
-  static Format FormatOf(Code opcode) {
-    return kInstructionDescriptors[opcode].format;
+  static constexpr Format FormatOf(Code opcode) {
+    return InstructionDescriptorOf(opcode).format;
   }
 
   // Returns the index type of the given opcode.
-  static IndexType IndexTypeOf(Code opcode) {
-    return kInstructionDescriptors[opcode].index_type;
+  static constexpr IndexType IndexTypeOf(Code opcode) {
+    return InstructionDescriptorOf(opcode).index_type;
   }
 
   // Returns the flags for the given opcode.
-  static uint8_t FlagsOf(Code opcode) {
-    return kInstructionDescriptors[opcode].flags;
+  static constexpr uint8_t FlagsOf(Code opcode) {
+    return InstructionDescriptorOf(opcode).flags;
   }
 
   // Return the verify flags for the given opcode.
-  static uint32_t VerifyFlagsOf(Code opcode) {
-    return kInstructionDescriptors[opcode].verify_flags;
+  static constexpr uint32_t VerifyFlagsOf(Code opcode) {
+    return InstructionDescriptorOf(opcode).verify_flags;
   }
 
   // Returns true if this instruction is a branch.
   bool IsBranch() const {
-    return (kInstructionDescriptors[Opcode()].flags & kBranch) != 0;
+    return (InstructionDescriptorOf(Opcode()).flags & kBranch) != 0;
   }
 
   // Returns true if this instruction is a unconditional branch.
   bool IsUnconditional() const {
-    return (kInstructionDescriptors[Opcode()].flags & kUnconditional) != 0;
+    return (InstructionDescriptorOf(Opcode()).flags & kUnconditional) != 0;
   }
 
   // Returns the branch offset if this instruction is a branch.
@@ -562,17 +561,17 @@
 
   // Returns true if this instruction is a switch.
   bool IsSwitch() const {
-    return (kInstructionDescriptors[Opcode()].flags & kSwitch) != 0;
+    return (InstructionDescriptorOf(Opcode()).flags & kSwitch) != 0;
   }
 
   // Returns true if this instruction can throw.
   bool IsThrow() const {
-    return (kInstructionDescriptors[Opcode()].flags & kThrow) != 0;
+    return (InstructionDescriptorOf(Opcode()).flags & kThrow) != 0;
   }
 
   // Determine if the instruction is any of 'return' instructions.
   bool IsReturn() const {
-    return (kInstructionDescriptors[Opcode()].flags & kReturn) != 0;
+    return (InstructionDescriptorOf(Opcode()).flags & kReturn) != 0;
   }
 
   // Determine if this instruction ends execution of its basic block.
@@ -582,37 +581,73 @@
 
   // Determine if this instruction is an invoke.
   bool IsInvoke() const {
-    return (kInstructionDescriptors[Opcode()].flags & kInvoke) != 0;
+    return (InstructionDescriptorOf(Opcode()).flags & kInvoke) != 0;
   }
 
   // Determine if this instruction is experimental.
   bool IsExperimental() const {
-    return (kInstructionDescriptors[Opcode()].flags & kExperimental) != 0;
+    return (InstructionDescriptorOf(Opcode()).flags & kExperimental) != 0;
   }
 
-  int GetVerifyTypeArgumentA() const {
-    return (kInstructionDescriptors[Opcode()].verify_flags & (kVerifyRegA | kVerifyRegAWide));
+  static constexpr uint32_t GetVerifyTypeArgumentAOf(Code opcode) {
+    constexpr uint32_t kMask = kVerifyRegA | kVerifyRegAWide;
+    return VerifyFlagsOf(opcode) & kMask;
   }
 
-  int GetVerifyTypeArgumentB() const {
-    return (kInstructionDescriptors[Opcode()].verify_flags & (kVerifyRegB | kVerifyRegBField |
-        kVerifyRegBMethod | kVerifyRegBNewInstance | kVerifyRegBString | kVerifyRegBType |
-        kVerifyRegBWide));
+  uint32_t GetVerifyTypeArgumentA() const {
+    return GetVerifyTypeArgumentAOf(Opcode());
   }
 
-  int GetVerifyTypeArgumentC() const {
-    return (kInstructionDescriptors[Opcode()].verify_flags & (kVerifyRegC | kVerifyRegCField |
-        kVerifyRegCNewArray | kVerifyRegCType | kVerifyRegCWide));
+  static constexpr uint32_t GetVerifyTypeArgumentBOf(Code opcode) {
+    constexpr uint32_t kMask =
+        kVerifyRegB |
+        kVerifyRegBField |
+        kVerifyRegBMethod |
+        kVerifyRegBNewInstance |
+        kVerifyRegBString |
+        kVerifyRegBType |
+        kVerifyRegBWide;
+    return VerifyFlagsOf(opcode) & kMask;
   }
 
-  int GetVerifyTypeArgumentH() const {
-    return (kInstructionDescriptors[Opcode()].verify_flags & kVerifyRegHPrototype);
+  uint32_t GetVerifyTypeArgumentB() const {
+    return GetVerifyTypeArgumentBOf(Opcode());
   }
 
-  int GetVerifyExtraFlags() const {
-    return (kInstructionDescriptors[Opcode()].verify_flags & (kVerifyArrayData |
-        kVerifyBranchTarget | kVerifySwitchTargets | kVerifyVarArg | kVerifyVarArgNonZero |
-        kVerifyVarArgRange | kVerifyVarArgRangeNonZero | kVerifyError));
+  static constexpr uint32_t GetVerifyTypeArgumentCOf(Code opcode) {
+    constexpr uint32_t kMask =
+        kVerifyRegC | kVerifyRegCField | kVerifyRegCNewArray | kVerifyRegCType | kVerifyRegCWide;
+    return VerifyFlagsOf(opcode) & kMask;
+  }
+
+  uint32_t GetVerifyTypeArgumentC() const {
+    return GetVerifyTypeArgumentCOf(Opcode());
+  }
+
+  static constexpr uint32_t GetVerifyTypeArgumentHOf(Code opcode) {
+    constexpr uint32_t kMask = kVerifyRegHPrototype;
+    return VerifyFlagsOf(opcode) & kMask;
+  }
+
+  uint32_t GetVerifyTypeArgumentH() const {
+    return GetVerifyTypeArgumentHOf(Opcode());
+  }
+
+  static constexpr uint32_t GetVerifyExtraFlagsOf(Code opcode) {
+    constexpr uint32_t kMask =
+        kVerifyArrayData |
+        kVerifyBranchTarget |
+        kVerifySwitchTargets |
+        kVerifyVarArg |
+        kVerifyVarArgNonZero |
+        kVerifyVarArgRange |
+        kVerifyVarArgRangeNonZero |
+        kVerifyError;
+    return VerifyFlagsOf(opcode) & kMask;
+  }
+
+  uint32_t GetVerifyExtraFlags() const {
+    return GetVerifyExtraFlagsOf(Opcode());
   }
 
   // Get the dex PC of this instruction as a offset in code units from the beginning of insns.
@@ -636,6 +671,10 @@
   }
 
  private:
+  static constexpr const InstructionDescriptor& InstructionDescriptorOf(Code opcode) {
+    return kInstructionDescriptors[opcode];
+  }
+
   size_t SizeInCodeUnitsComplexOpcode() const;
 
   // Return how many code unit words are required to compute the size of the opcode.
@@ -674,7 +713,39 @@
 
   static const char* const kInstructionNames[];
 
-  static const InstructionDescriptor kInstructionDescriptors[];
+  static constexpr std::array<InstructionDescriptor, 256> kInstructionDescriptors = []() constexpr {
+    auto InstructionSizeInCodeUnitsByOpcode = [](Instruction::Code opcode,
+                                                 Instruction::Format format) constexpr -> int8_t {
+      if (opcode == Instruction::Code::NOP) {
+        return -1;
+      } else if ((format >= Instruction::Format::k10x) && (format <= Instruction::Format::k10t)) {
+        return 1;
+      } else if ((format >= Instruction::Format::k20t) && (format <= Instruction::Format::k22c)) {
+        return 2;
+      } else if ((format >= Instruction::Format::k32x) && (format <= Instruction::Format::k3rc)) {
+        return 3;
+      } else if ((format >= Instruction::Format::k45cc) && (format <= Instruction::Format::k4rcc)) {
+        return 4;
+      } else if (format == Instruction::Format::k51l) {
+        return 5;
+      } else {
+        return -1;
+      }
+    };
+
+    std::array<InstructionDescriptor, 256> result;
+#define INSTRUCTION_DESCR(opcode, c, p, format, index, flags, eflags, vflags) \
+    result[opcode] = {                                                        \
+        vflags,                                                               \
+        format,                                                               \
+        index,                                                                \
+        flags,                                                                \
+        InstructionSizeInCodeUnitsByOpcode((c), (format)),                    \
+    };
+    DEX_INSTRUCTION_LIST(INSTRUCTION_DESCR)
+#undef INSTRUCTION_DESCR
+    return result;
+  }();
 
   DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction);
 };
diff --git a/libdexfile/dex/dex_instruction_list.h b/libdexfile/dex/dex_instruction_list.h
index 9a01bfe..0fd2a6b 100644
--- a/libdexfile/dex/dex_instruction_list.h
+++ b/libdexfile/dex/dex_instruction_list.h
@@ -305,4 +305,3 @@
   V(k51l)
 
 #endif  // ART_LIBDEXFILE_DEX_DEX_INSTRUCTION_LIST_H_
-#undef ART_LIBDEXFILE_DEX_DEX_INSTRUCTION_LIST_H_  // the guard in this file is just for cpplint
