Bug 1546138 - Baldr: rename TableKind::TypedFunction to AsmJS (r=lth)
☠☠ backed out by e5562f9f81ca ☠ ☠
authorLuke Wagner <luke@mozilla.com>
Wed, 24 Apr 2019 16:57:07 -0500
changeset 535389 b60f1ed65b1aa52865eac106b6f9838352811d9e
parent 535388 da9544b976b137d7c95d37d8bb695a712abd8af4
child 535390 edf39b4a6ec1260b6fc400bd55df352e5b0b2ebd
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslth
bugs1546138
milestone68.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 1546138 - Baldr: rename TableKind::TypedFunction to AsmJS (r=lth) Differential Revision: https://phabricator.services.mozilla.com/D29299
js/src/wasm/AsmJS.cpp
js/src/wasm/WasmCraneliftCompile.cpp
js/src/wasm/WasmGenerator.cpp
js/src/wasm/WasmTable.cpp
js/src/wasm/WasmTable.h
js/src/wasm/WasmTypes.h
--- a/js/src/wasm/AsmJS.cpp
+++ b/js/src/wasm/AsmJS.cpp
@@ -2014,17 +2014,17 @@ class MOZ_STACK_CLASS JS_HAZ_ROOTED Modu
     }
 
     MOZ_ASSERT(sigIndex >= env_.asmJSSigToTableIndex.length());
     if (!env_.asmJSSigToTableIndex.resize(sigIndex + 1)) {
       return false;
     }
 
     env_.asmJSSigToTableIndex[sigIndex] = env_.tables.length();
-    if (!env_.tables.emplaceBack(TableKind::TypedFunction, Limits(mask + 1))) {
+    if (!env_.tables.emplaceBack(TableKind::AsmJS, Limits(mask + 1))) {
       return false;
     }
 
     Global* global = validationLifo_.new_<Global>(Global::Table);
     if (!global) {
       return false;
     }
 
--- a/js/src/wasm/WasmCraneliftCompile.cpp
+++ b/js/src/wasm/WasmCraneliftCompile.cpp
@@ -431,19 +431,19 @@ TypeCode global_type(const GlobalDesc* g
 
 size_t global_tlsOffset(const GlobalDesc* global) {
   return globalToTlsOffset(global->offset());
 }
 
 // TableDesc
 
 size_t table_tlsOffset(const TableDesc* table) {
-  MOZ_RELEASE_ASSERT(table->kind == TableKind::FuncRef ||
-                         table->kind == TableKind::TypedFunction,
-                     "cranelift doesn't support AnyRef tables yet.");
+  MOZ_RELEASE_ASSERT(
+      table->kind == TableKind::FuncRef || table->kind == TableKind::AsmJS,
+      "cranelift doesn't support AnyRef tables yet.");
   return globalToTlsOffset(table->globalDataOffset);
 }
 
 // Sig
 
 size_t funcType_numArgs(const FuncTypeWithId* funcType) {
   return funcType->args().length();
 }
--- a/js/src/wasm/WasmGenerator.cpp
+++ b/js/src/wasm/WasmGenerator.cpp
@@ -373,17 +373,17 @@ bool ModuleGenerator::init(Metadata* may
       case TableKind::FuncRef:
         for (uint32_t funcIndex : seg->elemFuncIndices) {
           if (funcIndex == NullFuncIndex) {
             continue;
           }
           addOrMerge(ExportedFunc(funcIndex, false));
         }
         break;
-      case TableKind::TypedFunction:
+      case TableKind::AsmJS:
         // asm.js functions are not exported.
         break;
       case TableKind::AnyRef:
         break;
     }
   }
 
   auto* newEnd =
--- a/js/src/wasm/WasmTable.cpp
+++ b/js/src/wasm/WasmTable.cpp
@@ -51,17 +51,17 @@ Table::Table(JSContext* cx, const TableD
   MOZ_ASSERT(kind_ == TableKind::AnyRef);
 }
 
 /* static */
 SharedTable Table::create(JSContext* cx, const TableDesc& desc,
                           HandleWasmTableObject maybeObject) {
   switch (desc.kind) {
     case TableKind::FuncRef:
-    case TableKind::TypedFunction: {
+    case TableKind::AsmJS: {
       UniqueFuncRefArray functions(
           cx->pod_calloc<FunctionTableElem>(desc.limits.initial));
       if (!functions) {
         return nullptr;
       }
       return SharedTable(
           cx->new_<Table>(cx, desc, maybeObject, std::move(functions)));
     }
@@ -99,17 +99,17 @@ void Table::tracePrivate(JSTracer* trc) 
         }
       }
       break;
     }
     case TableKind::AnyRef: {
       objects_.trace(trc);
       break;
     }
-    case TableKind::TypedFunction: {
+    case TableKind::AsmJS: {
 #ifdef DEBUG
       for (uint32_t i = 0; i < length_; i++) {
         MOZ_ASSERT(!functions_[i].tls);
       }
 #endif
       break;
     }
   }
@@ -164,17 +164,17 @@ void Table::setFuncRef(uint32_t index, v
 
   switch (kind_) {
     case TableKind::FuncRef:
       elem.code = code;
       elem.tls = instance->tlsData();
       MOZ_ASSERT(elem.tls->instance->objectUnbarriered()->isTenured(),
                  "no writeBarrierPost (Table::set)");
       break;
-    case TableKind::TypedFunction:
+    case TableKind::AsmJS:
       elem.code = code;
       elem.tls = nullptr;
       break;
     case TableKind::AnyRef:
       MOZ_CRASH("Bad table type");
   }
 }
 
@@ -197,17 +197,17 @@ void Table::setNull(uint32_t index) {
       elem.code = nullptr;
       elem.tls = nullptr;
       break;
     }
     case TableKind::AnyRef: {
       setAnyRef(index, AnyRef::null());
       break;
     }
-    case TableKind::TypedFunction: {
+    case TableKind::AsmJS: {
       MOZ_CRASH("Should not happen");
     }
   }
 }
 
 void Table::copy(const Table& srcTable, uint32_t dstIndex, uint32_t srcIndex) {
   switch (kind_) {
     case TableKind::FuncRef: {
@@ -228,17 +228,17 @@ void Table::copy(const Table& srcTable, 
         MOZ_ASSERT(!dst.code);
       }
       break;
     }
     case TableKind::AnyRef: {
       setAnyRef(dstIndex, srcTable.getAnyRef(srcIndex));
       break;
     }
-    case TableKind::TypedFunction: {
+    case TableKind::AsmJS: {
       MOZ_CRASH("Bad table type");
     }
   }
 }
 
 uint32_t Table::grow(uint32_t delta, JSContext* cx) {
   // This isn't just an optimization: movingGrowable() assumes that
   // onMovingGrowTable does not fire when length == maximum.
@@ -280,17 +280,17 @@ uint32_t Table::grow(uint32_t delta, JSC
       break;
     }
     case TableKind::AnyRef: {
       if (!objects_.resize(newLength.value())) {
         return -1;
       }
       break;
     }
-    case TableKind::TypedFunction: {
+    case TableKind::AsmJS: {
       MOZ_CRASH("Bad table type");
     }
   }
 
   length_ = newLength.value();
 
   for (InstanceSet::Range r = observers_.all(); !r.empty(); r.popFront()) {
     r.front()->instance().onMovingGrowTable(this);
--- a/js/src/wasm/WasmTable.h
+++ b/js/src/wasm/WasmTable.h
@@ -65,19 +65,18 @@ class Table : public ShareableBase<Table
   friend class js::WasmTableObject;
 
  public:
   static RefPtr<Table> create(JSContext* cx, const TableDesc& desc,
                               HandleWasmTableObject maybeObject);
   void trace(JSTracer* trc);
 
   TableKind kind() const { return kind_; }
-  bool isTypedFunction() const { return kind_ == TableKind::TypedFunction; }
   bool isFunction() const {
-    return kind_ == TableKind::FuncRef || kind_ == TableKind::TypedFunction;
+    return kind_ == TableKind::FuncRef || kind_ == TableKind::AsmJS;
   }
   uint32_t length() const { return length_; }
   Maybe<uint32_t> maximum() const { return maximum_; }
 
   // Only for function values.  Raw pointer to the table.
   uint8_t* functionBase() const;
 
   // get/setFuncRef is allowed only on table-of-funcref.
--- a/js/src/wasm/WasmTypes.h
+++ b/js/src/wasm/WasmTypes.h
@@ -1948,20 +1948,23 @@ struct Limits {
 
   Limits() = default;
   explicit Limits(uint32_t initial, const Maybe<uint32_t>& maximum = Nothing(),
                   Shareable shared = Shareable::False)
       : initial(initial), maximum(maximum), shared(shared) {}
 };
 
 // TableDesc describes a table as well as the offset of the table's base pointer
-// in global memory. Currently, wasm only has "any function" and asm.js only
-// "typed function".
-
-enum class TableKind { FuncRef, AnyRef, TypedFunction };
+// in global memory. The TableKind determines the representation:
+//  - AnyRef: a wasm anyref word (wasm::AnyRef)
+//  - FuncRef: a two-word FunctionTableElem (wasm indirect call ABI)
+//  - AsmJS: a two-word FunctionTableElem (asm.js ABI)
+// Eventually there should be a single unified AnyRef representation.
+
+enum class TableKind { AnyRef, FuncRef, AsmJS };
 
 struct TableDesc {
   TableKind kind;
   bool importedOrExported;
   uint32_t globalDataOffset;
   Limits limits;
 
   TableDesc() = default;