CodeBlocks read from disk should not be re-written
authortzagallo@apple.com <tzagallo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 18:50:20 +0000 (18:50 +0000)
committertzagallo@apple.com <tzagallo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 18:50:20 +0000 (18:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194535

Reviewed by Michael Saboff.

Keep track of which CodeBlocks have been read from disk or have already
been serialized in CodeCache.

* runtime/CodeCache.cpp:
(JSC::CodeCache::write):
* runtime/CodeCache.h:
(JSC::SourceCodeValue::SourceCodeValue):
(JSC::CodeCacheMap::fetchFromDiskImpl):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/CodeCache.cpp
Source/JavaScriptCore/runtime/CodeCache.h

index f6cecf2..2d9c0f0 100644 (file)
@@ -1,5 +1,21 @@
 2019-02-13  Tadeu Zagallo  <tzagallo@apple.com>
 
+        CodeBlocks read from disk should not be re-written
+        https://bugs.webkit.org/show_bug.cgi?id=194535
+
+        Reviewed by Michael Saboff.
+
+        Keep track of which CodeBlocks have been read from disk or have already
+        been serialized in CodeCache.
+
+        * runtime/CodeCache.cpp:
+        (JSC::CodeCache::write):
+        * runtime/CodeCache.h:
+        (JSC::SourceCodeValue::SourceCodeValue):
+        (JSC::CodeCacheMap::fetchFromDiskImpl):
+
+2019-02-13  Tadeu Zagallo  <tzagallo@apple.com>
+
         SourceCode should be copied when generating bytecode for functions
         https://bugs.webkit.org/show_bug.cgi?id=194536
 
index 9b6070b..c1ecedb 100644 (file)
@@ -159,8 +159,12 @@ UnlinkedFunctionExecutable* CodeCache::getUnlinkedGlobalFunctionExecutable(VM& v
 
 void CodeCache::write(VM& vm)
 {
-    for (const auto& it : m_sourceCode)
+    for (auto& it : m_sourceCode) {
+        if (it.value.written)
+            continue;
+        it.value.written = true;
         writeCodeBlock(vm, it.key, it.value);
+    }
 }
 
 void generateUnlinkedCodeBlockForFunctions(VM& vm, UnlinkedCodeBlock* unlinkedCodeBlock, const SourceCode& parentSource, DebuggerMode debuggerMode, ParserError& error)
index 80c0d95..be44bdd 100644 (file)
@@ -75,14 +75,16 @@ struct SourceCodeValue {
     {
     }
 
-    SourceCodeValue(VM& vm, JSCell* cell, int64_t age)
+    SourceCodeValue(VM& vm, JSCell* cell, int64_t age, bool written = false)
         : cell(vm, cell)
         , age(age)
+        , written(written)
     {
     }
 
     Strong<JSCell> cell;
     int64_t age;
+    bool written;
 };
 
 class CodeCacheMap {
@@ -154,7 +156,7 @@ public:
             return nullptr;
 
         VERBOSE_LOG("Found cached CodeBlock on disk");
-        addCache(key, SourceCodeValue(vm, unlinkedCodeBlock, m_age));
+        addCache(key, SourceCodeValue(vm, unlinkedCodeBlock, m_age, true));
         return unlinkedCodeBlock;
 #else
         UNUSED_PARAM(vm);