[JSC] Remove BytecodeCacheVersion.h
authortzagallo@apple.com <tzagallo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Dec 2019 22:45:25 +0000 (22:45 +0000)
committertzagallo@apple.com <tzagallo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Dec 2019 22:45:25 +0000 (22:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=204760

Reviewed by Mark Lam.

Having that as a phony make target causes a lot of unnecessary rebuilds. That was a workaround
the fact that we only need a new cache version when we rebuild CachedTypes.cpp, but there was
no straightforward way to get the current timestamp as an integer at that point. Instead, we now
just use a constexpr function that hashes __TIMESTAMP__.

* CMakeLists.txt:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* runtime/CachedTypes.cpp:
(JSC::jscBytecodeCacheVersion):
(JSC::GenericCacheEntry::isUpToDate const):

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

Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/DerivedSources-output.xcfilelist
Source/JavaScriptCore/DerivedSources.make
Source/JavaScriptCore/runtime/CachedTypes.cpp

index c8fec94..4219e23 100644 (file)
@@ -225,10 +225,7 @@ else ()
     string(TIMESTAMP BUILD_TIME "%s")
 endif ()
 
-file(WRITE ${JavaScriptCore_DERIVED_SOURCES_DIR}/BytecodeCacheVersion.h "#define JSC_BYTECODE_CACHE_VERSION ${BUILD_TIME}\n")
-
 list(APPEND JavaScriptCore_HEADERS
-    ${JavaScriptCore_DERIVED_SOURCES_DIR}/BytecodeCacheVersion.h
     ${JavaScriptCore_DERIVED_SOURCES_DIR}/BytecodeStructs.h
     ${JavaScriptCore_DERIVED_SOURCES_DIR}/Bytecodes.h
 )
index 3c540a7..bb01271 100644 (file)
@@ -1,3 +1,22 @@
+2019-12-02  Tadeu Zagallo  <tzagallo@apple.com>
+
+        [JSC] Remove BytecodeCacheVersion.h
+        https://bugs.webkit.org/show_bug.cgi?id=204760
+
+        Reviewed by Mark Lam.
+
+        Having that as a phony make target causes a lot of unnecessary rebuilds. That was a workaround
+        the fact that we only need a new cache version when we rebuild CachedTypes.cpp, but there was
+        no straightforward way to get the current timestamp as an integer at that point. Instead, we now
+        just use a constexpr function that hashes __TIMESTAMP__.
+
+        * CMakeLists.txt:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * runtime/CachedTypes.cpp:
+        (JSC::jscBytecodeCacheVersion):
+        (JSC::GenericCacheEntry::isUpToDate const):
+
 2019-12-02  Mark Lam  <mark.lam@apple.com>
 
         mozilla-tests.yaml/js1_5/Array/regress-101964.js is frequently failing on JSC EWS bots.
index 14aa420..8059a86 100644 (file)
@@ -8,7 +8,6 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/AsyncGeneratorPrototype.lut.
 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/BigIntConstructor.lut.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/BigIntPrototype.lut.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/BooleanPrototype.lut.h
-$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/BytecodeCacheVersion.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/BytecodeIndices.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/BytecodeStructs.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/Bytecodes.h
index f59212f..9987464 100644 (file)
@@ -363,10 +363,3 @@ WasmB3IRGeneratorInlines.h: $(JavaScriptCore)/wasm/generateWasmB3IRGeneratorInli
 all : \
     $(OBJECT_LUT_HEADERS) \
 #
-
-.PHONY : BytecodeCacheVersion.h
-
-BytecodeCacheVersion.h:
-       echo "#define JSC_BYTECODE_CACHE_VERSION $(shell date '+%s')" > BytecodeCacheVersion.h
-
-all : BytecodeCacheVersion.h
index eb9d993..f8d9799 100644 (file)
@@ -27,7 +27,6 @@
 #include "CachedTypes.h"
 
 #include "BytecodeCacheError.h"
-#include "BytecodeCacheVersion.h"
 #include "BytecodeLivenessAnalysis.h"
 #include "JSCInlines.h"
 #include "JSImmutableButterfly.h"
@@ -65,6 +64,11 @@ struct SourceTypeImpl<T, std::enable_if_t<!std::is_fundamental<T>::value && !std
 template<typename T>
 using SourceType = typename SourceTypeImpl<T>::type;
 
+static constexpr unsigned jscBytecodeCacheVersion()
+{
+    return StringHasher::computeHash(__TIMESTAMP__);
+}
+
 class Encoder {
     WTF_MAKE_NONCOPYABLE(Encoder);
     WTF_FORBID_HEAP_ALLOCATION;
@@ -2265,7 +2269,7 @@ protected:
 
     bool isUpToDate(Decoder& decoder) const
     {
-        if (m_cacheVersion != JSC_BYTECODE_CACHE_VERSION)
+        if (m_cacheVersion != jscBytecodeCacheVersion())
             return false;
         if (m_bootSessionUUID.decode(decoder) != bootSessionUUIDString())
             return false;
@@ -2273,7 +2277,7 @@ protected:
     }
 
 private:
-    uint32_t m_cacheVersion { JSC_BYTECODE_CACHE_VERSION };
+    uint32_t m_cacheVersion { jscBytecodeCacheVersion() };
     CachedString m_bootSessionUUID;
     CachedCodeBlockTag m_tag;
 };