WebKit Bugzilla
Attachment 362264 Details for
Bug 194768
: Add version number to cached bytecode
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194768-20190218081857.patch (text/plain), 7.06 KB, created by
Tadeu Zagallo
on 2019-02-17 23:19:33 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tadeu Zagallo
Created:
2019-02-17 23:19:33 PST
Size:
7.06 KB
patch
obsolete
>Subversion Revision: 241658 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 13f1d17d290f781a0f252eb496b6448f177f474e..f3446e80b3a882bd1684ffa66fa838aeff0a385d 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,25 @@ >+2019-02-17 Tadeu Zagallo <tzagallo@apple.com> >+ >+ Add version number to cached bytecode >+ https://bugs.webkit.org/show_bug.cgi?id=194768 >+ <rdar://problem/48147968> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a version number to the bytecode cache that should be unique per build. >+ >+ * DerivedSources-output.xcfilelist: >+ * DerivedSources.make: >+ * runtime/CachedTypes.cpp: >+ (JSC::Encoder::malloc): >+ (JSC::CacheEntry::decode const): >+ (JSC::GenericCacheEntry::decode const): >+ (JSC::decodeCodeBlockImpl): >+ (JSC::CacheEntry:: const): Deleted. >+ (JSC:: const): Deleted. >+ * runtime/CodeCache.h: >+ (JSC::CodeCacheMap::fetchFromDiskImpl): >+ > 2019-02-17 Saam Barati <sbarati@apple.com> > > WasmB3IRGenerator models some effects incorrectly >diff --git a/Source/JavaScriptCore/DerivedSources-output.xcfilelist b/Source/JavaScriptCore/DerivedSources-output.xcfilelist >index 9d6b64e92be7d465a6e7134416362f15ba35a382..d2dee4242337789e74bc4c4dff54bf6177a98134 100644 >--- a/Source/JavaScriptCore/DerivedSources-output.xcfilelist >+++ b/Source/JavaScriptCore/DerivedSources-output.xcfilelist >@@ -9,6 +9,7 @@ $(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 >diff --git a/Source/JavaScriptCore/DerivedSources.make b/Source/JavaScriptCore/DerivedSources.make >index 4d3e429074c12ef54dca25512ac203c593299013..3b5e10540bbbdb22c3bbd704e17bbe49b2866e40 100644 >--- a/Source/JavaScriptCore/DerivedSources.make >+++ b/Source/JavaScriptCore/DerivedSources.make >@@ -356,3 +356,10 @@ 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 >diff --git a/Source/JavaScriptCore/runtime/CachedTypes.cpp b/Source/JavaScriptCore/runtime/CachedTypes.cpp >index 8a1dde3130eb552843e8c19bfa0a1b7119da7020..9b1c1e40de80a7af1c5baa164001a8a1ce703ec6 100644 >--- a/Source/JavaScriptCore/runtime/CachedTypes.cpp >+++ b/Source/JavaScriptCore/runtime/CachedTypes.cpp >@@ -26,6 +26,7 @@ > #include "config.h" > #include "CachedTypes.h" > >+#include "BytecodeCacheVersion.h" > #include "BytecodeLivenessAnalysis.h" > #include "JSCast.h" > #include "JSImmutableButterfly.h" >@@ -104,7 +105,7 @@ public: > template<typename T> > T* malloc() > { >- return reinterpret_cast<T*>(malloc(sizeof(T)).buffer()); >+ return new (malloc(sizeof(T)).buffer()) T(); > } > > ptrdiff_t offsetOf(const void* address) >@@ -1720,6 +1721,7 @@ enum CachedCodeBlockTag { > CachedProgramCodeBlockTag, > CachedModuleCodeBlockTag, > CachedEvalCodeBlockTag, >+ InvalidCodeBlockTag, > }; > > template<> >@@ -1986,10 +1988,11 @@ private: > > class GenericCacheEntry { > public: >- std::pair<SourceCodeKey, UnlinkedCodeBlock*> decode(Decoder&) const; >+ bool decode(Decoder&, std::pair<SourceCodeKey, UnlinkedCodeBlock*>&) const; > > protected: >- CachedCodeBlockTag m_tag; >+ uint32_t m_cacheVersion { JSC_BYTECODE_CACHE_VERSION }; >+ CachedCodeBlockTag m_tag { InvalidCodeBlockTag }; > }; > > template<typename UnlinkedCodeBlockType> >@@ -2005,33 +2008,38 @@ public: > private: > friend GenericCacheEntry; > >- std::pair<SourceCodeKey, UnlinkedCodeBlockType*> decode(Decoder& decoder) const >+ bool decode(Decoder& decoder, std::pair<SourceCodeKey, UnlinkedCodeBlockType*>& result) const > { >+ if (m_cacheVersion != JSC_BYTECODE_CACHE_VERSION) >+ return false; > ASSERT(m_tag == CachedCodeBlockTypeImpl<UnlinkedCodeBlockType>::tag); >+ if (m_tag != CachedCodeBlockTypeImpl<UnlinkedCodeBlockType>::tag) >+ return false; > SourceCodeKey decodedKey; > m_key.decode(decoder, decodedKey); >- return { WTFMove(decodedKey), m_codeBlock.decode(decoder) }; >+ result = { WTFMove(decodedKey), m_codeBlock.decode(decoder) }; >+ return true; > } > > CachedSourceCodeKey m_key; > CachedPtr<CachedCodeBlockType<UnlinkedCodeBlockType>> m_codeBlock; > }; > >-std::pair<SourceCodeKey, UnlinkedCodeBlock*> GenericCacheEntry::decode(Decoder& decoder) const >+bool GenericCacheEntry::decode(Decoder& decoder, std::pair<SourceCodeKey, UnlinkedCodeBlock*>& result) const > { > switch (m_tag) { > case CachedProgramCodeBlockTag: >- return reinterpret_cast<const CacheEntry<UnlinkedProgramCodeBlock>*>(this)->decode(decoder); >+ return reinterpret_cast<const CacheEntry<UnlinkedProgramCodeBlock>*>(this)->decode(decoder, reinterpret_cast<std::pair<SourceCodeKey, UnlinkedProgramCodeBlock*>&>(result)); > case CachedModuleCodeBlockTag: >- return reinterpret_cast<const CacheEntry<UnlinkedModuleProgramCodeBlock>*>(this)->decode(decoder); >- case CachedEvalCodeBlockTag: >+ return reinterpret_cast<const CacheEntry<UnlinkedModuleProgramCodeBlock>*>(this)->decode(decoder, reinterpret_cast<std::pair<SourceCodeKey, UnlinkedModuleProgramCodeBlock*>&>(result)); >+ default: > // We do not cache eval code blocks > RELEASE_ASSERT_NOT_REACHED(); > } > RELEASE_ASSERT_NOT_REACHED(); > #if COMPILER(MSVC) > // Without this, MSVC will complain that this path does not return a value. >- return reinterpret_cast<const CacheEntry<UnlinkedEvalCodeBlock>*>(this)->decode(decoder); >+ return false; > #endif > } > >@@ -2064,7 +2072,8 @@ UnlinkedCodeBlock* decodeCodeBlockImpl(VM& vm, const SourceCodeKey& key, const v > std::pair<SourceCodeKey, UnlinkedCodeBlock*> entry; > { > DeferGC deferGC(vm.heap); >- entry = cachedEntry->decode(decoder); >+ if (!cachedEntry->decode(decoder, entry)) >+ return nullptr; > } > > if (entry.first != key) >diff --git a/Source/JavaScriptCore/runtime/CodeCache.h b/Source/JavaScriptCore/runtime/CodeCache.h >index 7ab80fe201abd8bfd92e95f460fc367bb3848b78..41be9772b6dd887adfa3274ecb498410829ec4b6 100644 >--- a/Source/JavaScriptCore/runtime/CodeCache.h >+++ b/Source/JavaScriptCore/runtime/CodeCache.h >@@ -149,6 +149,7 @@ public: > } > > void* buffer = mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0); >+ close(fd); > UnlinkedCodeBlockType* unlinkedCodeBlock = decodeCodeBlock<UnlinkedCodeBlockType>(vm, key, buffer, size); > munmap(buffer, size); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194768
:
362264
|
362266