WebAssembly: NFC s/goto/lambda/g
authorjfbastien@apple.com <jfbastien@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Mar 2017 17:17:49 +0000 (17:17 +0000)
committerjfbastien@apple.com <jfbastien@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Mar 2017 17:17:49 +0000 (17:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170242

Reviewed by Mark Lam.

Lambdas are more in-style than the goto I just used.

* wasm/WasmMemory.cpp:
(JSC::Wasm::tryGetFastMemory):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214541 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/wasm/WasmMemory.cpp

index 130cdae..bf01047 100644 (file)
@@ -1,3 +1,15 @@
+2017-03-29  JF Bastien  <jfbastien@apple.com>
+
+        WebAssembly: NFC s/goto/lambda/g
+        https://bugs.webkit.org/show_bug.cgi?id=170242
+
+        Reviewed by Mark Lam.
+
+        Lambdas are more in-style than the goto I just used.
+
+        * wasm/WasmMemory.cpp:
+        (JSC::Wasm::tryGetFastMemory):
+
 2017-03-28  Saam Barati  <sbarati@apple.com>
 
         AssemblyHelpers should not have a VM field
index 2b65210..6c25389 100644 (file)
@@ -118,15 +118,21 @@ inline bool tryGetFastMemory(VM& vm, void*& memory, size_t& mappedCapacity, Memo
         return false;
     };
 
+    auto fail = [] () -> bool {
+        if (UNLIKELY(Options::crashIfWebAssemblyCantFastMemory()))
+            webAssemblyCouldntGetFastMemory();
+        return false;
+    };
+
     // We might GC here so we should be holding the API lock.
     // FIXME: We should be able to syncronously trigger the GC from another thread.
     ASSERT(vm.currentThreadIsHoldingAPILock());
     if (UNLIKELY(!fastMemoryEnabled()))
-        goto fail;
+        return fail();
 
     // We need to be sure we have a stub prior to running code.
     if (UNLIKELY(!vm.getCTIStub(throwExceptionFromWasmThunkGenerator).size()))
-        goto fail;
+        return fail();
 
     ASSERT(allocatedFastMemories <= maxFastMemories);
     if (dequeFastMemory())
@@ -138,7 +144,7 @@ inline bool tryGetFastMemory(VM& vm, void*& memory, size_t& mappedCapacity, Memo
         vm.heap.collectAllGarbage();
         if (dequeFastMemory())
             return true;
-        goto fail;
+        return fail();
     }
 
     if (mmapBytes(fastMemoryMappedBytes, memory)) {
@@ -152,13 +158,8 @@ inline bool tryGetFastMemory(VM& vm, void*& memory, size_t& mappedCapacity, Memo
 
     if (memory)
         return true;
-    goto fail;
-
-fail:
-    if (UNLIKELY(Options::crashIfWebAssemblyCantFastMemory()))
-        webAssemblyCouldntGetFastMemory();
 
-    return false;
+    return fail();
 }
 
 inline void releaseFastMemory(void*& memory, size_t writableSize, size_t mappedCapacity, MemoryMode mode)