Bug 1253681 - BaldrMonkey: Update to the current official opcode encodings. r=luke
authorDan Gohman <sunfish@mozilla.com>
Fri, 04 Mar 2016 11:55:59 -0800
changeset 323178 77a522bb407ea1e7f96357467c96b25aa429f9d4
parent 323177 3f727688f71fd533436fb1dfb0c4184ada04ae50
child 323179 1ea5c28a280f8c56b2b437dbb161bf9e64f1d1bb
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1253681
milestone47.0a1
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
Bug 1253681 - BaldrMonkey: Update to the current official opcode encodings. r=luke
js/src/asmjs/Wasm.cpp
js/src/asmjs/WasmBinary.h
js/src/asmjs/WasmIonCompile.cpp
--- a/js/src/asmjs/Wasm.cpp
+++ b/js/src/asmjs/Wasm.cpp
@@ -1416,17 +1416,17 @@ static bool
 wasm_toSource(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     args.rval().setString(cx->names().Wasm);
     return true;
 }
 #endif
 
-static JSFunctionSpec wasm_static_methods[] = {
+static const JSFunctionSpec wasm_static_methods[] = {
 #if JS_HAS_TOSOURCE
     JS_FN(js_toSource_str,     wasm_toSource,     0, 0),
 #endif
     JS_FN("instantiateModule", InstantiateModule, 1, 0),
     JS_FS_END
 };
 
 const Class js::WasmClass = {
--- a/js/src/asmjs/WasmBinary.h
+++ b/js/src/asmjs/WasmBinary.h
@@ -44,198 +44,203 @@ static const char FunctionTableId[]     
 static const char MemoryId[]             = "memory";
 static const char ExportTableId[]        = "export_table";
 static const char FunctionBodiesId[]     = "function_bodies";
 static const char DataSegmentsId[]       = "data_segments";
 
 enum class Expr : uint16_t
 {
     // Control opcodes
-    Nop,
-    Block,
-    Loop,
-    If,
-    IfElse,
-    Select,
-    Br,
-    BrIf,
-    BrTable,
-    Return,
-    Unreachable,
+    Nop            = 0x00,
+    Block          = 0x01,
+    Loop           = 0x02,
+    If             = 0x03,
+    IfElse         = 0x04,
+    Select         = 0x05,
+    Br             = 0x06,
+    BrIf           = 0x07,
+    BrTable        = 0x08,
+    Return         = 0x14,
+    Unreachable    = 0x15,
 
     // Calls
-    Call,
-    CallIndirect,
-    CallImport,
+    Call           = 0x12,
+    CallIndirect   = 0x13,
+    CallImport     = 0x09,
 
     // Constants and calls
-    I32Const,
-    I64Const,
-    F64Const,
-    F32Const,
-    GetLocal,
-    SetLocal,
-    LoadGlobal,
-    StoreGlobal,
+    I32Const       = 0x0a,
+    I64Const       = 0x0b,
+    F64Const       = 0x0c,
+    F32Const       = 0x0d,
+    GetLocal       = 0x0e,
+    SetLocal       = 0x0f,
 
     // I32 opcodes
-    I32Add,
-    I32Sub,
-    I32Mul,
-    I32DivS,
-    I32DivU,
-    I32RemS,
-    I32RemU,
-    I32Or,
-    I32And,
-    I32Xor,
-    I32Shl,
-    I32ShrU,
-    I32ShrS,
-    I32Eq,
-    I32Ne,
-    I32LtS,
-    I32LeS,
-    I32LtU,
-    I32LeU,
-    I32GtS,
-    I32GeS,
-    I32GtU,
-    I32GeU,
-    I32Clz,
-    I32Ctz,
-    I32Popcnt,
+    I32Add         = 0x40,
+    I32Sub         = 0x41,
+    I32Mul         = 0x42,
+    I32DivS        = 0x43,
+    I32DivU        = 0x44,
+    I32RemS        = 0x45,
+    I32RemU        = 0x46,
+    I32Or          = 0x48,
+    I32And         = 0x47,
+    I32Xor         = 0x49,
+    I32Shl         = 0x4a,
+    I32ShrU        = 0x4b,
+    I32ShrS        = 0x4c,
+    I32Eq          = 0x4d,
+    I32Ne          = 0x4e,
+    I32LtS         = 0x4f,
+    I32LeS         = 0x50,
+    I32LtU         = 0x51,
+    I32LeU         = 0x52,
+    I32GtS         = 0x53,
+    I32GeS         = 0x54,
+    I32GtU         = 0x55,
+    I32GeU         = 0x56,
+    I32Clz         = 0x57,
+    I32Ctz         = 0x58,
+    I32Popcnt      = 0x59,
 
     // I64 opcodes
-    I64Add,
-    I64Sub,
-    I64Mul,
-    I64DivS,
-    I64DivU,
-    I64RemS,
-    I64RemU,
-    I64Or,
-    I64And,
-    I64Xor,
-    I64Shl,
-    I64ShrU,
-    I64ShrS,
-    I64Eq,
-    I64Ne,
-    I64LtS,
-    I64LeS,
-    I64LtU,
-    I64LeU,
-    I64GtS,
-    I64GeS,
-    I64GtU,
-    I64GeU,
-    I64Clz,
-    I64Ctz,
-    I64Popcnt,
+    I64Add         = 0x5b,
+    I64Sub         = 0x5c,
+    I64Mul         = 0x5d,
+    I64DivS        = 0x5e,
+    I64DivU        = 0x5f,
+    I64RemS        = 0x60,
+    I64RemU        = 0x61,
+    I64Or          = 0x63,
+    I64And         = 0x62,
+    I64Xor         = 0x64,
+    I64Shl         = 0x65,
+    I64ShrU        = 0x66,
+    I64ShrS        = 0x67,
+    I64Eq          = 0x68,
+    I64Ne          = 0x69,
+    I64LtS         = 0x6a,
+    I64LeS         = 0x6b,
+    I64LtU         = 0x6c,
+    I64LeU         = 0x6d,
+    I64GtS         = 0x6e,
+    I64GeS         = 0x6f,
+    I64GtU         = 0x70,
+    I64GeU         = 0x71,
+    I64Clz         = 0x72,
+    I64Ctz         = 0x73,
+    I64Popcnt      = 0x74,
 
     // F32 opcodes
-    F32Add,
-    F32Sub,
-    F32Mul,
-    F32Div,
-    F32Min,
-    F32Max,
-    F32Abs,
-    F32Neg,
-    F32CopySign,
-    F32Ceil,
-    F32Floor,
-    F32Trunc,
-    F32Nearest,
-    F32Sqrt,
-    F32Eq,
-    F32Ne,
-    F32Lt,
-    F32Le,
-    F32Gt,
-    F32Ge,
+    F32Add         = 0x75,
+    F32Sub         = 0x76,
+    F32Mul         = 0x77,
+    F32Div         = 0x78,
+    F32Min         = 0x79,
+    F32Max         = 0x7a,
+    F32Abs         = 0x7b,
+    F32Neg         = 0x7c,
+    F32CopySign    = 0x7d,
+    F32Ceil        = 0x7e,
+    F32Floor       = 0x7f,
+    F32Trunc       = 0x80,
+    F32Nearest     = 0x81,
+    F32Sqrt        = 0x82,
+    F32Eq          = 0x83,
+    F32Ne          = 0x84,
+    F32Lt          = 0x85,
+    F32Le          = 0x86,
+    F32Gt          = 0x87,
+    F32Ge          = 0x88,
 
     // F64 opcodes
-    F64Add,
-    F64Sub,
-    F64Mul,
-    F64Div,
-    F64Min,
-    F64Max,
-    F64Abs,
-    F64Neg,
-    F64CopySign,
-    F64Ceil,
-    F64Floor,
-    F64Trunc,
-    F64Nearest,
-    F64Sqrt,
-    F64Eq,
-    F64Ne,
-    F64Lt,
-    F64Le,
-    F64Gt,
-    F64Ge,
+    F64Add         = 0x89,
+    F64Sub         = 0x8a,
+    F64Mul         = 0x8b,
+    F64Div         = 0x8c,
+    F64Min         = 0x8d,
+    F64Max         = 0x8e,
+    F64Abs         = 0x8f,
+    F64Neg         = 0x90,
+    F64CopySign    = 0x91,
+    F64Ceil        = 0x92,
+    F64Floor       = 0x93,
+    F64Trunc       = 0x94,
+    F64Nearest     = 0x95,
+    F64Sqrt        = 0x96,
+    F64Eq          = 0x97,
+    F64Ne          = 0x98,
+    F64Lt          = 0x99,
+    F64Le          = 0x9a,
+    F64Gt          = 0x9b,
+    F64Ge          = 0x9c,
 
     // Conversions
-    I32WrapI64,
-    I64ExtendSI32,
-    I64ExtendUI32,
-    I32TruncSF32,
-    I32TruncSF64,
-    I32TruncUF32,
-    I32TruncUF64,
-    I64TruncSF32,
-    I64TruncSF64,
-    I64TruncUF32,
-    I64TruncUF64,
-    F32ConvertSI32,
-    F32ConvertUI32,
-    F64ConvertSI32,
-    F64ConvertUI32,
-    F32ConvertSI64,
-    F32ConvertUI64,
-    F64ConvertSI64,
-    F64ConvertUI64,
-    F32DemoteF64,
-    F64PromoteF32,
-    I32ReinterpretF32,
-    F32ReinterpretI32,
-    I64ReinterpretF64,
-    F64ReinterpretI64,
+    I32WrapI64     = 0xa1,
+    I64ExtendSI32  = 0xa6,
+    I64ExtendUI32  = 0xa7,
+    I32TruncSF32   = 0x9d,
+    I32TruncSF64   = 0x9e,
+    I32TruncUF32   = 0x9f,
+    I32TruncUF64   = 0xa0,
+    I64TruncSF32   = 0xa2,
+    I64TruncSF64   = 0xa3,
+    I64TruncUF32   = 0xa4,
+    I64TruncUF64   = 0xa5,
+    F32ConvertSI32 = 0xa8,
+    F32ConvertUI32 = 0xa9,
+    F64ConvertSI32 = 0xae,
+    F64ConvertUI32 = 0xaf,
+    F32ConvertSI64 = 0xaa,
+    F32ConvertUI64 = 0xab,
+    F64ConvertSI64 = 0xb0,
+    F64ConvertUI64 = 0xb1,
+    F32DemoteF64   = 0xac,
+    F64PromoteF32  = 0xb2,
+    I32ReinterpretF32 = 0xb4,
+    F32ReinterpretI32 = 0xad,
+    I64ReinterpretF64 = 0xb5,
+    F64ReinterpretI64 = 0xb3,
 
     // Load/store operations
-    I32LoadMem8S,
-    I32LoadMem8U,
-    I32LoadMem16S,
-    I32LoadMem16U,
-    I32LoadMem,
-    I64LoadMem8S,
-    I64LoadMem8U,
-    I64LoadMem16S,
-    I64LoadMem16U,
-    I64LoadMem32S,
-    I64LoadMem32U,
-    I64LoadMem,
-    F32LoadMem,
-    F64LoadMem,
+    I32LoadMem8S   = 0x20,
+    I32LoadMem8U   = 0x21,
+    I32LoadMem16S  = 0x22,
+    I32LoadMem16U  = 0x23,
+    I32LoadMem     = 0x2a,
+    I64LoadMem8S   = 0x24,
+    I64LoadMem8U   = 0x25,
+    I64LoadMem16S  = 0x26,
+    I64LoadMem16U  = 0x27,
+    I64LoadMem32S  = 0x28,
+    I64LoadMem32U  = 0x29,
+    I64LoadMem     = 0x2b,
+    F32LoadMem     = 0x2c,
+    F64LoadMem     = 0x2d,
 
-    I32StoreMem8,
-    I32StoreMem16,
-    I64StoreMem8,
-    I64StoreMem16,
-    I64StoreMem32,
-    I32StoreMem,
-    I64StoreMem,
-    F32StoreMem,
-    F64StoreMem,
+    I32StoreMem8   = 0x2e,
+    I32StoreMem16  = 0x2f,
+    I64StoreMem8   = 0x30,
+    I64StoreMem16  = 0x31,
+    I64StoreMem32  = 0x32,
+    I32StoreMem    = 0x33,
+    I64StoreMem    = 0x34,
+    F32StoreMem    = 0x35,
+    F64StoreMem    = 0x36,
+
+    // Special operators
+    MemorySize     = 0x3b,
+    GrowMemory     = 0x39,
 
     // asm.js specific
-    Id,
+    Id             = 0xc0, // Encodings from here down are specific to baldr.
+
+    LoadGlobal,
+    StoreGlobal,
 
     I32Min,
     I32Max,
 
     // Atomics
     AtomicsFence,
     I32AtomicsCompareExchange,
     I32AtomicsExchange,
--- a/js/src/asmjs/WasmIonCompile.cpp
+++ b/js/src/asmjs/WasmIonCompile.cpp
@@ -2978,16 +2978,18 @@ EmitExpr(FunctionCompiler& f, ExprType t
       case Expr::I64LoadMem:
       case Expr::I64StoreMem8:
       case Expr::I64StoreMem16:
       case Expr::I64StoreMem32:
       case Expr::I64StoreMem:
       case Expr::I64Clz:
       case Expr::I64Ctz:
       case Expr::I64Popcnt:
+      case Expr::MemorySize:
+      case Expr::GrowMemory:
         MOZ_CRASH("NYI");
       case Expr::Unreachable:
         break;
       case Expr::Limit:
         MOZ_CRASH("Limit");
     }
 
     MOZ_CRASH("unexpected wasm opcode");