Title: [244241] trunk
Revision
244241
Author
[email protected]
Date
2019-04-13 01:54:19 -0700 (Sat, 13 Apr 2019)

Log Message

CodeCache should check that the UnlinkedCodeBlock was successfully created before caching it
https://bugs.webkit.org/show_bug.cgi?id=196880

Reviewed by Yusuke Suzuki.

JSTests:

* stress/bytecode-cache-syntax-error.js: Added.
(catch):

Source/_javascript_Core:

CodeCache should not tell the SourceProvider to cache the bytecode if it failed
to create the UnlinkedCodeBlock.

* runtime/CodeCache.cpp:
(JSC::CodeCache::getUnlinkedGlobalCodeBlock):

Tools:

Add a new function for bytecode cache tests that does not forceDiskCache
for the second run: runBytecodeCacheNoAssetion. This is necessary for the
test added in this patch, since the code is invalid and therefore won't be
cached. It should also be useful for tests that evaluate dynamically
generated code.

* Scripts/jsc-stress-test-helpers/bytecode-cache-test-helper.sh:
* Scripts/run-jsc-stress-tests:

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (244240 => 244241)


--- trunk/JSTests/ChangeLog	2019-04-13 08:00:44 UTC (rev 244240)
+++ trunk/JSTests/ChangeLog	2019-04-13 08:54:19 UTC (rev 244241)
@@ -1,3 +1,13 @@
+2019-04-13  Tadeu Zagallo  <[email protected]>
+
+        CodeCache should check that the UnlinkedCodeBlock was successfully created before caching it
+        https://bugs.webkit.org/show_bug.cgi?id=196880
+
+        Reviewed by Yusuke Suzuki.
+
+        * stress/bytecode-cache-syntax-error.js: Added.
+        (catch):
+
 2019-04-12  Saam barati  <[email protected]>
 
         r244079 logically broke shouldSpeculateInt52

Added: trunk/JSTests/stress/bytecode-cache-syntax-error.js (0 => 244241)


--- trunk/JSTests/stress/bytecode-cache-syntax-error.js	                        (rev 0)
+++ trunk/JSTests/stress/bytecode-cache-syntax-error.js	2019-04-13 08:54:19 UTC (rev 244241)
@@ -0,0 +1,9 @@
+//@ runBytecodeCacheNoAssertion
+
+try {
+    loadString('function(){}');
+    throw new Error('loadString should have thrown');
+} catch (err) {
+    if (err.message != 'Function statements must have a name.')
+        throw new Error('Unexpected exception');
+}

Modified: trunk/Source/_javascript_Core/ChangeLog (244240 => 244241)


--- trunk/Source/_javascript_Core/ChangeLog	2019-04-13 08:00:44 UTC (rev 244240)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-04-13 08:54:19 UTC (rev 244241)
@@ -1,3 +1,16 @@
+2019-04-13  Tadeu Zagallo  <[email protected]>
+
+        CodeCache should check that the UnlinkedCodeBlock was successfully created before caching it
+        https://bugs.webkit.org/show_bug.cgi?id=196880
+
+        Reviewed by Yusuke Suzuki.
+
+        CodeCache should not tell the SourceProvider to cache the bytecode if it failed
+        to create the UnlinkedCodeBlock.
+
+        * runtime/CodeCache.cpp:
+        (JSC::CodeCache::getUnlinkedGlobalCodeBlock):
+
 2019-04-12  Saam barati  <[email protected]>
 
         r244079 logically broke shouldSpeculateInt52

Modified: trunk/Source/_javascript_Core/runtime/CodeCache.cpp (244240 => 244241)


--- trunk/Source/_javascript_Core/runtime/CodeCache.cpp	2019-04-13 08:00:44 UTC (rev 244240)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.cpp	2019-04-13 08:54:19 UTC (rev 244241)
@@ -80,12 +80,13 @@
     VariableEnvironment variablesUnderTDZ;
     unlinkedCodeBlock = generateUnlinkedCodeBlock<UnlinkedCodeBlockType, ExecutableType>(vm, executable, source, strictMode, scriptMode, debuggerMode, error, evalContextType, &variablesUnderTDZ);
 
-    if (unlinkedCodeBlock && Options::useCodeCache())
+    if (unlinkedCodeBlock && Options::useCodeCache()) {
         m_sourceCode.addCache(key, SourceCodeValue(vm, unlinkedCodeBlock, m_sourceCode.age()));
 
-    key.source().provider().cacheBytecode([&] {
-        return encodeCodeBlock(vm, key, unlinkedCodeBlock);
-    });
+        key.source().provider().cacheBytecode([&] {
+            return encodeCodeBlock(vm, key, unlinkedCodeBlock);
+        });
+    }
 
     return unlinkedCodeBlock;
 }

Modified: trunk/Tools/ChangeLog (244240 => 244241)


--- trunk/Tools/ChangeLog	2019-04-13 08:00:44 UTC (rev 244240)
+++ trunk/Tools/ChangeLog	2019-04-13 08:54:19 UTC (rev 244241)
@@ -1,3 +1,19 @@
+2019-04-13  Tadeu Zagallo  <[email protected]>
+
+        CodeCache should check that the UnlinkedCodeBlock was successfully created before caching it
+        https://bugs.webkit.org/show_bug.cgi?id=196880
+
+        Reviewed by Yusuke Suzuki.
+
+        Add a new function for bytecode cache tests that does not forceDiskCache
+        for the second run: runBytecodeCacheNoAssetion. This is necessary for the
+        test added in this patch, since the code is invalid and therefore won't be
+        cached. It should also be useful for tests that evaluate dynamically
+        generated code.
+
+        * Scripts/jsc-stress-test-helpers/bytecode-cache-test-helper.sh:
+        * Scripts/run-jsc-stress-tests:
+
 2019-04-12  Eric Carlson  <[email protected]>
 
         Update AudioSession route sharing policy

Modified: trunk/Tools/Scripts/jsc-stress-test-helpers/bytecode-cache-test-helper.sh (244240 => 244241)


--- trunk/Tools/Scripts/jsc-stress-test-helpers/bytecode-cache-test-helper.sh	2019-04-13 08:00:44 UTC (rev 244240)
+++ trunk/Tools/Scripts/jsc-stress-test-helpers/bytecode-cache-test-helper.sh	2019-04-13 08:54:19 UTC (rev 244241)
@@ -45,6 +45,8 @@
 
 export JSC_diskCachePath=$diskCachePath
 mysys "$pathToVM" "$inputFile" "${extraOptions[@]}"
-export JSC_forceDiskCache=true
+
+if [ -z "$JSC_forceDiskCache" ]; then
+    export JSC_forceDiskCache=true
+fi
 mysys "$pathToVM" "$inputFile" "${extraOptions[@]}"
-

Modified: trunk/Tools/Scripts/run-jsc-stress-tests (244240 => 244241)


--- trunk/Tools/Scripts/run-jsc-stress-tests	2019-04-13 08:00:44 UTC (rev 244240)
+++ trunk/Tools/Scripts/run-jsc-stress-tests	2019-04-13 08:54:19 UTC (rev 244241)
@@ -656,15 +656,23 @@
     run("default", *(FTL_OPTIONS + optionalTestSpecificOptions))
 end
 
-def runBytecodeCache(*optionalTestSpecificOptions)
+def runBytecodeCacheImpl(optionalTestSpecificOptions, *additionalEnv)
     unless $hostOS == "darwin"
         skip
         return
     end
     options = BASE_OPTIONS + $testSpecificRequiredOptions + FTL_OPTIONS + optionalTestSpecificOptions
-    addRunCommand("bytecode-cache", ["sh", (pathToHelpers + "bytecode-cache-test-helper.sh").to_s, pathToVM.to_s, $benchmark.to_s] + options, silentOutputHandler, simpleErrorHandler)
+    addRunCommand("bytecode-cache", ["sh", (pathToHelpers + "bytecode-cache-test-helper.sh").to_s, pathToVM.to_s, $benchmark.to_s] + options, silentOutputHandler, simpleErrorHandler, *additionalEnv)
 end
 
+def runBytecodeCache(*optionalTestSpecificOptions)
+    runBytecodeCacheImpl(optionalTestSpecificOptions)
+end
+
+def runBytecodeCacheNoAssertion(*optionalTestSpecificOptions)
+    runBytecodeCacheImpl(optionalTestSpecificOptions, "JSC_forceDiskCache=false")
+end
+
 def runBigIntEnabled(*optionalTestSpecificOptions)
     # FIXME: <rdar://problem/40331121>
     if $remote or ($architecture !~ /x86/i and $hostOS == "darwin")
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to