WebAssembly: Module::getOrCreateCodeBlock is wrong
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Apr 2017 19:42:37 +0000 (19:42 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Apr 2017 19:42:37 +0000 (19:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170612

Reviewed by Keith Miller.

When we were getting a module's CodeBlock, we were checking if !runnable(),
and if !runnable(), we were re-creating the CodeBlock. This is wrong, since
!runnable() is true while the CodeBlock is compiling. Instead, we should check
if we've finished compiling, and if so, if that compilation failed.

* wasm/WasmModule.cpp:
(JSC::Wasm::Module::getOrCreateCodeBlock):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/wasm/WasmModule.cpp

index a1032ec..d43dba8 100644 (file)
@@ -1,5 +1,20 @@
 2017-04-07  Saam Barati  <sbarati@apple.com>
 
+        WebAssembly: Module::getOrCreateCodeBlock is wrong
+        https://bugs.webkit.org/show_bug.cgi?id=170612
+
+        Reviewed by Keith Miller.
+
+        When we were getting a module's CodeBlock, we were checking if !runnable(),
+        and if !runnable(), we were re-creating the CodeBlock. This is wrong, since
+        !runnable() is true while the CodeBlock is compiling. Instead, we should check
+        if we've finished compiling, and if so, if that compilation failed.
+
+        * wasm/WasmModule.cpp:
+        (JSC::Wasm::Module::getOrCreateCodeBlock):
+
+2017-04-07  Saam Barati  <sbarati@apple.com>
+
         WebAssembly: Make to a compilation API that allows for multi-VM concurrent compilations of Wasm Modules
         https://bugs.webkit.org/show_bug.cgi?id=170488
 
index 4873da9..d9dd8b7 100644 (file)
@@ -61,7 +61,7 @@ Ref<CodeBlock> Module::getOrCreateCodeBlock(VM& vm, MemoryMode mode)
     // It's worth retrying.
     // FIXME: We might want to back off retrying at some point:
     // https://bugs.webkit.org/show_bug.cgi?id=170607
-    if (!codeBlock || !codeBlock->runnable()) {
+    if (!codeBlock || (codeBlock->compilationFinished() && !codeBlock->runnable())) {
         codeBlock = CodeBlock::create(vm, mode, const_cast<ModuleInformation&>(moduleInformation()));
         m_codeBlocks[static_cast<uint8_t>(mode)] = codeBlock;
     }