Changeset 247523 in webkit
- Timestamp:
- Jul 17, 2019 11:12:56 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSScript.mm
r247505 r247523 131 131 bool success = false; 132 132 String systemPath = filePathURL.fileSystemPath(); 133 FileSystem::MappedFileData fileData(systemPath, FileSystem::MappedFileMode::Shared,success);133 FileSystem::MappedFileData fileData(systemPath, success); 134 134 if (!success) 135 135 return createError([NSString stringWithFormat:@"File at path %@ could not be mapped.", static_cast<NSString *>(systemPath)], error); … … 154 154 return; 155 155 156 auto fd = FileSystem::openAndLockFile([m_cachePath path].UTF8String, FileSystem::FileOpenMode::Read, {FileSystem::FileLockMode::Exclusive, FileSystem::FileLockMode::Nonblocking});157 if ( !FileSystem::isHandleValid(fd))156 int fd = open([m_cachePath path].UTF8String, O_RDONLY | O_EXLOCK | O_NONBLOCK, 0666); 157 if (fd == -1) 158 158 return; 159 159 auto closeFD = makeScopeExit([&] { 160 FileSystem::unlockAndCloseFile(fd);160 close(fd); 161 161 }); 162 162 163 bool success; 164 FileSystem::MappedFileData mappedFile(fd, FileSystem::MappedFileMode::Private, success); 165 if (!success) 163 struct stat sb; 164 int res = fstat(fd, &sb); 165 size_t size = static_cast<size_t>(sb.st_size); 166 if (res || !size) 166 167 return; 167 168 168 Ref<JSC::CachedBytecode> cachedBytecode = JSC::CachedBytecode::create(WTFMove(mappedFile)); 169 void* buffer = mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0); 170 171 Ref<JSC::CachedBytecode> cachedBytecode = JSC::CachedBytecode::create(buffer, size); 169 172 170 173 JSC::VM& vm = [m_virtualMachine vm]; … … 289 292 if (cacheError.isValid()) { 290 293 m_cachedBytecode = JSC::CachedBytecode::create(); 291 FileSystem::truncateFile(fd, 0);294 ftruncate(fd, 0); 292 295 error = makeString("Unable to generate bytecode for this JSScript because: ", cacheError.message()); 293 296 return NO; -
trunk/Source/JavaScriptCore/CMakeLists.txt
r247505 r247523 224 224 execute_process(COMMAND bash -c "date +'%s'" OUTPUT_VARIABLE BUILD_TIME OUTPUT_STRIP_TRAILING_WHITESPACE) 225 225 else () 226 s tring(TIMESTAMP BUILD_TIME "%s")226 set(BUILD_TIME 0) 227 227 endif () 228 228 -
trunk/Source/JavaScriptCore/ChangeLog
r247505 r247523 1 2019-07-17 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r247505. 4 https://bugs.webkit.org/show_bug.cgi?id=199871 5 6 "Caused failed ASSERT in stress test" (Requested by creid on 7 #webkit). 8 9 Reverted changeset: 10 11 "Bytecode cache should use FileSystem" 12 https://bugs.webkit.org/show_bug.cgi?id=199759 13 https://trac.webkit.org/changeset/247505 14 1 15 2019-07-16 Christopher Reid <chris.reid@sony.com> 2 16 -
trunk/Source/JavaScriptCore/jsc.cpp
r247505 r247523 86 86 #include <wtf/Box.h> 87 87 #include <wtf/CommaPrinter.h> 88 #include <wtf/FileSystem.h>89 88 #include <wtf/MainThread.h> 90 89 #include <wtf/MemoryPressureHandler.h> … … 1005 1004 void commitCachedBytecode() const override 1006 1005 { 1006 #if OS(DARWIN) 1007 1007 if (!cacheEnabled() || !m_cachedBytecode || !m_cachedBytecode->hasUpdates()) 1008 1008 return; … … 1013 1013 1014 1014 String filename = cachePath(); 1015 auto fd = FileSystem::openAndLockFile(filename, FileSystem::FileOpenMode::Write, {FileSystem::FileLockMode::Exclusive, FileSystem::FileLockMode::Nonblocking});1016 if ( !FileSystem::isHandleValid(fd))1015 int fd = open(filename.utf8().data(), O_CREAT | O_WRONLY | O_TRUNC | O_EXLOCK | O_NONBLOCK, 0666); 1016 if (fd == -1) 1017 1017 return; 1018 1018 1019 1019 auto closeFD = makeScopeExit([&] { 1020 FileSystem::unlockAndCloseFile(fd);1020 close(fd); 1021 1021 }); 1022 1022 1023 long long fileSize; 1024 if (!FileSystem::getFileSize(fd, fileSize)) 1025 return; 1026 1027 size_t cacheFileSize; 1028 if (!WTF::convertSafely(fileSize, cacheFileSize) || cacheFileSize != m_cachedBytecode->size()) { 1023 struct stat sb; 1024 int res = fstat(fd, &sb); 1025 size_t size = static_cast<size_t>(sb.st_size); 1026 if (res || size != m_cachedBytecode->size()) { 1029 1027 // The bytecode cache has already been updated 1030 1028 return; 1031 1029 } 1032 1030 1033 if ( !FileSystem::truncateFile(fd, m_cachedBytecode->sizeForUpdate()))1031 if (ftruncate(fd, m_cachedBytecode->sizeForUpdate())) 1034 1032 return; 1035 1033 1036 1034 m_cachedBytecode->commitUpdates([&] (off_t offset, const void* data, size_t size) { 1037 long long result = FileSystem::seekFile(fd, offset, FileSystem::FileSeekOrigin::Beginning);1035 off_t result = lseek(fd, offset, SEEK_SET); 1038 1036 ASSERT_UNUSED(result, result != -1); 1039 size_t bytesWritten = static_cast<size_t>( FileSystem::writeToFile(fd, static_cast<const char*>(data), size));1037 size_t bytesWritten = static_cast<size_t>(write(fd, data, size)); 1040 1038 ASSERT_UNUSED(bytesWritten, bytesWritten == size); 1041 1039 }); 1040 #endif 1042 1041 } 1043 1042 … … 1048 1047 return static_cast<const char*>(nullptr); 1049 1048 const char* cachePath = Options::diskCachePath(); 1050 String filename = FileSystem::encodeForFileName(sourceOrigin().string()); 1051 return FileSystem::pathByAppendingComponent(cachePath, makeString(source().toString().hash(), '-', filename, ".bytecode-cache")); 1049 String filename = sourceOrigin().string(); 1050 filename.replace('/', '_'); 1051 return makeString(cachePath, '/', source().toString().hash(), '-', filename, ".bytecode-cache"); 1052 1052 } 1053 1053 1054 1054 void loadBytecode() const 1055 1055 { 1056 #if OS(DARWIN) 1056 1057 if (!cacheEnabled()) 1057 1058 return; … … 1061 1062 return; 1062 1063 1063 auto fd = FileSystem::openAndLockFile(filename, FileSystem::FileOpenMode::Read, {FileSystem::FileLockMode::Shared, FileSystem::FileLockMode::Nonblocking});1064 if ( !FileSystem::isHandleValid(fd))1064 int fd = open(filename.utf8().data(), O_RDONLY | O_SHLOCK | O_NONBLOCK); 1065 if (fd == -1) 1065 1066 return; 1066 1067 1067 1068 auto closeFD = makeScopeExit([&] { 1068 FileSystem::unlockAndCloseFile(fd);1069 close(fd); 1069 1070 }); 1070 1071 1071 bool success;1072 FileSystem::MappedFileData mappedFileData(fd, FileSystem::MappedFileMode::Private, success);1073 1074 if ( !success)1072 struct stat sb; 1073 int res = fstat(fd, &sb); 1074 size_t size = static_cast<size_t>(sb.st_size); 1075 if (res || !size) 1075 1076 return; 1076 1077 1077 m_cachedBytecode = CachedBytecode::create(WTFMove(mappedFileData)); 1078 void* buffer = mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0); 1079 if (buffer == MAP_FAILED) 1080 return; 1081 m_cachedBytecode = CachedBytecode::create(buffer, size); 1082 #endif 1078 1083 } 1079 1084 -
trunk/Source/JavaScriptCore/runtime/CachePayload.cpp
r247505 r247523 33 33 namespace JSC { 34 34 35 CachePayload CachePayload::makeMappedPayload(FileSystem::MappedFileData&& data) 35 #if !OS(WINDOWS) 36 CachePayload CachePayload::makeMappedPayload(void* data, size_t size) 36 37 { 37 return CachePayload(true, data .leakHandle(), data.size());38 return CachePayload(true, data, size); 38 39 } 40 #endif 39 41 40 42 CachePayload CachePayload::makeMallocPayload(MallocPtr<uint8_t>&& data, size_t size) … … 75 77 return; 76 78 if (m_mapped) { 77 FileSystem::unmapViewOfFile(m_data, m_size); 79 #if !OS(WINDOWS) 80 munmap(m_data, m_size); 81 #else 82 RELEASE_ASSERT_NOT_REACHED(); 83 #endif 78 84 } else 79 85 fastFree(m_data); -
trunk/Source/JavaScriptCore/runtime/CachePayload.h
r247505 r247523 26 26 #pragma once 27 27 28 #include <wtf/FileSystem.h>29 28 #include <wtf/MallocPtr.h> 30 29 … … 33 32 class CachePayload { 34 33 public: 35 JS_EXPORT_PRIVATE static CachePayload makeMappedPayload(FileSystem::MappedFileData&&); 34 #if !OS(WINDOWS) 35 JS_EXPORT_PRIVATE static CachePayload makeMappedPayload(void*, size_t); 36 #endif 36 37 JS_EXPORT_PRIVATE static CachePayload makeMallocPayload(MallocPtr<uint8_t>&&, size_t); 37 38 JS_EXPORT_PRIVATE static CachePayload makeEmptyPayload(); -
trunk/Source/JavaScriptCore/runtime/CachedBytecode.h
r247505 r247523 47 47 } 48 48 49 static Ref<CachedBytecode> create(FileSystem::MappedFileData&& data, LeafExecutableMap&& leafExecutables = { }) 49 #if !OS(WINDOWS) 50 static Ref<CachedBytecode> create(void* data, size_t size, LeafExecutableMap&& leafExecutables = { }) 50 51 { 51 return adoptRef(*new CachedBytecode(CachePayload::makeMappedPayload( WTFMove(data)), WTFMove(leafExecutables)));52 return adoptRef(*new CachedBytecode(CachePayload::makeMappedPayload(data, size), WTFMove(leafExecutables))); 52 53 } 54 #endif 53 55 54 56 static Ref<CachedBytecode> create(MallocPtr<uint8_t>&& data, size_t size, LeafExecutableMap&& leafExecutables) -
trunk/Source/JavaScriptCore/runtime/CachedTypes.cpp
r247505 r247523 89 89 }; 90 90 91 Encoder(VM& vm, FileSystem::PlatformFileHandle fd = FileSystem::invalidPlatformFileHandle)91 Encoder(VM& vm, int fd = -1) 92 92 : m_vm(vm) 93 93 , m_fd(fd) … … 153 153 m_currentPage->alignEnd(); 154 154 155 if (FileSystem::isHandleValid(m_fd)) { 155 if (m_fd != -1) { 156 #if !OS(WINDOWS) 156 157 return releaseMapped(error); 158 #else 159 RELEASE_ASSERT_NOT_REACHED(); 160 #endif 157 161 } 158 162 … … 169 173 170 174 private: 175 #if !OS(WINDOWS) 171 176 RefPtr<CachedBytecode> releaseMapped(BytecodeCacheError& error) 172 177 { 173 178 size_t size = m_baseOffset + m_currentPage->size(); 174 if ( !FileSystem::truncateFile(m_fd, size)) {179 if (ftruncate(m_fd, size)) { 175 180 error = BytecodeCacheError::StandardError(errno); 176 181 return nullptr; … … 178 183 179 184 for (const auto& page : m_pages) { 180 int bytesWritten = FileSystem::writeToFile(m_fd, reinterpret_cast<char*>(page.buffer()), page.size());185 ssize_t bytesWritten = write(m_fd, page.buffer(), page.size()); 181 186 if (bytesWritten == -1) { 182 187 error = BytecodeCacheError::StandardError(errno); … … 190 195 } 191 196 192 bool success; 193 FileSystem::MappedFileData mappedFileData(m_fd, FileSystem::MappedFileMode::Private, success); 194 if (!success) { 197 void* buffer = mmap(nullptr, size, PROT_READ, MAP_PRIVATE, m_fd, 0); 198 if (buffer == MAP_FAILED) { 195 199 error = BytecodeCacheError::StandardError(errno); 196 200 return nullptr; 197 201 } 198 202 199 return CachedBytecode::create(WTFMove(mappedFileData), WTFMove(m_leafExecutables)); 200 } 203 return CachedBytecode::create(buffer, size, WTFMove(m_leafExecutables)); 204 } 205 #endif 201 206 202 207 class Page { … … 266 271 267 272 VM& m_vm; 268 FileSystem::PlatformFileHandlem_fd;273 int m_fd; 269 274 ptrdiff_t m_baseOffset; 270 275 Page* m_currentPage; … … 2372 2377 } 2373 2378 2374 RefPtr<CachedBytecode> encodeCodeBlock(VM& vm, const SourceCodeKey& key, const UnlinkedCodeBlock* codeBlock, FileSystem::PlatformFileHandlefd, BytecodeCacheError& error)2379 RefPtr<CachedBytecode> encodeCodeBlock(VM& vm, const SourceCodeKey& key, const UnlinkedCodeBlock* codeBlock, int fd, BytecodeCacheError& error) 2375 2380 { 2376 2381 const ClassInfo* classInfo = codeBlock->classInfo(vm); … … 2390 2395 { 2391 2396 BytecodeCacheError error; 2392 return encodeCodeBlock(vm, key, codeBlock, FileSystem::invalidPlatformFileHandle, error);2397 return encodeCodeBlock(vm, key, codeBlock, -1, error); 2393 2398 } 2394 2399 -
trunk/Source/JavaScriptCore/runtime/CachedTypes.h
r247505 r247523 110 110 111 111 JS_EXPORT_PRIVATE RefPtr<CachedBytecode> encodeCodeBlock(VM&, const SourceCodeKey&, const UnlinkedCodeBlock*); 112 JS_EXPORT_PRIVATE RefPtr<CachedBytecode> encodeCodeBlock(VM&, const SourceCodeKey&, const UnlinkedCodeBlock*, FileSystem::PlatformFileHandlefd, BytecodeCacheError&);112 JS_EXPORT_PRIVATE RefPtr<CachedBytecode> encodeCodeBlock(VM&, const SourceCodeKey&, const UnlinkedCodeBlock*, int fd, BytecodeCacheError&); 113 113 114 114 UnlinkedCodeBlock* decodeCodeBlockImpl(VM&, const SourceCodeKey&, Ref<CachedBytecode>); -
trunk/Source/JavaScriptCore/runtime/CodeCache.cpp
r247505 r247523 226 226 } 227 227 228 RefPtr<CachedBytecode> serializeBytecode(VM& vm, UnlinkedCodeBlock* codeBlock, const SourceCode& source, SourceCodeType codeType, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, FileSystem::PlatformFileHandlefd, BytecodeCacheError& error, OptionSet<CodeGenerationMode> codeGenerationMode)228 RefPtr<CachedBytecode> serializeBytecode(VM& vm, UnlinkedCodeBlock* codeBlock, const SourceCode& source, SourceCodeType codeType, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, int fd, BytecodeCacheError& error, OptionSet<CodeGenerationMode> codeGenerationMode) 229 229 { 230 230 return encodeCodeBlock(vm, -
trunk/Source/JavaScriptCore/runtime/CodeCache.h
r247505 r247523 319 319 320 320 void writeCodeBlock(VM&, const SourceCodeKey&, const SourceCodeValue&); 321 RefPtr<CachedBytecode> serializeBytecode(VM&, UnlinkedCodeBlock*, const SourceCode&, SourceCodeType, JSParserStrictMode, JSParserScriptMode, FileSystem::PlatformFileHandlefd, BytecodeCacheError&, OptionSet<CodeGenerationMode>);321 RefPtr<CachedBytecode> serializeBytecode(VM&, UnlinkedCodeBlock*, const SourceCode&, SourceCodeType, JSParserStrictMode, JSParserScriptMode, int fd, BytecodeCacheError&, OptionSet<CodeGenerationMode>); 322 322 SourceCodeKey sourceCodeKeyForSerializedProgram(VM&, const SourceCode&); 323 323 SourceCodeKey sourceCodeKeyForSerializedModule(VM&, const SourceCode&); -
trunk/Source/JavaScriptCore/runtime/Completion.cpp
r247505 r247523 93 93 } 94 94 95 RefPtr<CachedBytecode> generateProgramBytecode(VM& vm, const SourceCode& source, FileSystem::PlatformFileHandlefd, BytecodeCacheError& error)95 RefPtr<CachedBytecode> generateProgramBytecode(VM& vm, const SourceCode& source, int fd, BytecodeCacheError& error) 96 96 { 97 97 JSLockHolder lock(vm); … … 113 113 } 114 114 115 RefPtr<CachedBytecode> generateModuleBytecode(VM& vm, const SourceCode& source, FileSystem::PlatformFileHandlefd, BytecodeCacheError& error)115 RefPtr<CachedBytecode> generateModuleBytecode(VM& vm, const SourceCode& source, int fd, BytecodeCacheError& error) 116 116 { 117 117 JSLockHolder lock(vm); -
trunk/Source/JavaScriptCore/runtime/Completion.h
r247505 r247523 25 25 #include "CallData.h" 26 26 #include "JSCJSValue.h" 27 #include <wtf/FileSystem.h>28 27 #include <wtf/NakedPtr.h> 29 28 … … 45 44 JS_EXPORT_PRIVATE bool checkModuleSyntax(ExecState*, const SourceCode&, ParserError&); 46 45 47 JS_EXPORT_PRIVATE RefPtr<CachedBytecode> generateProgramBytecode(VM&, const SourceCode&, FileSystem::PlatformFileHandlefd, BytecodeCacheError&);48 JS_EXPORT_PRIVATE RefPtr<CachedBytecode> generateModuleBytecode(VM&, const SourceCode&, FileSystem::PlatformFileHandlefd, BytecodeCacheError&);46 JS_EXPORT_PRIVATE RefPtr<CachedBytecode> generateProgramBytecode(VM&, const SourceCode&, int fd, BytecodeCacheError&); 47 JS_EXPORT_PRIVATE RefPtr<CachedBytecode> generateModuleBytecode(VM&, const SourceCode&, int fd, BytecodeCacheError&); 49 48 50 49 JS_EXPORT_PRIVATE JSValue evaluate(ExecState*, const SourceCode&, JSValue thisValue, NakedPtr<Exception>& returnedException); -
trunk/Source/WTF/ChangeLog
r247505 r247523 1 2019-07-17 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r247505. 4 https://bugs.webkit.org/show_bug.cgi?id=199871 5 6 "Caused failed ASSERT in stress test" (Requested by creid on 7 #webkit). 8 9 Reverted changeset: 10 11 "Bytecode cache should use FileSystem" 12 https://bugs.webkit.org/show_bug.cgi?id=199759 13 https://trac.webkit.org/changeset/247505 14 1 15 2019-07-16 Christopher Reid <chris.reid@sony.com> 2 16 -
trunk/Source/WTF/wtf/FileSystem.cpp
r247505 r247523 41 41 #endif 42 42 43 #if USE(GLIB)44 #include <gio/gfiledescriptorbased.h>45 #include <gio/gio.h>46 #endif47 48 43 namespace WTF { 49 44 … … 280 275 #endif 281 276 277 #if HAVE(MMAP) 278 282 279 MappedFileData::~MappedFileData() 283 280 { 284 281 if (!m_fileData) 285 282 return; 286 unmapViewOfFile(m_fileData, m_fileSize); 287 } 288 289 #if HAVE(MMAP) 290 291 MappedFileData::MappedFileData(const String& filePath, MappedFileMode mode, bool& success) 292 { 293 auto fd = openFile(filePath, FileOpenMode::Read); 294 295 success = mapFileHandle(fd, mode); 296 closeFile(fd); 297 } 298 299 bool MappedFileData::mapFileHandle(PlatformFileHandle handle, MappedFileMode mode) 300 { 301 if (!isHandleValid(handle)) 302 return false; 303 304 int fd; 305 #if USE(GLIB) 306 auto* inputStream = g_io_stream_get_input_stream(G_IO_STREAM(handle)); 307 fd = g_file_descriptor_based_get_fd(G_FILE_DESCRIPTOR_BASED(inputStream)); 308 #else 309 fd = handle; 310 #endif 283 munmap(m_fileData, m_fileSize); 284 } 285 286 MappedFileData::MappedFileData(const String& filePath, bool& success) 287 { 288 CString fsRep = fileSystemRepresentation(filePath); 289 int fd = !fsRep.isNull() ? open(fsRep.data(), O_RDONLY) : -1; 290 if (fd < 0) { 291 success = false; 292 return; 293 } 311 294 312 295 struct stat fileStat; 313 296 if (fstat(fd, &fileStat)) { 314 return false; 297 close(fd); 298 success = false; 299 return; 315 300 } 316 301 317 302 unsigned size; 318 303 if (!WTF::convertSafely(fileStat.st_size, size)) { 319 return false; 304 close(fd); 305 success = false; 306 return; 320 307 } 321 308 322 309 if (!size) { 323 return true; 324 } 325 326 void* data = mmap(0, size, PROT_READ, MAP_FILE | (mode == MappedFileMode::Shared ? MAP_SHARED : MAP_PRIVATE), fd, 0); 310 close(fd); 311 success = true; 312 return; 313 } 314 315 void* data = mmap(0, size, PROT_READ, MAP_FILE | MAP_SHARED, fd, 0); 316 close(fd); 327 317 328 318 if (data == MAP_FAILED) { 329 return false; 330 } 331 319 success = false; 320 return; 321 } 322 323 success = true; 332 324 m_fileData = data; 333 325 m_fileSize = size; 334 return true;335 }336 337 bool unmapViewOfFile(void* buffer, size_t size)338 {339 return !munmap(buffer, size);340 326 } 341 327 -
trunk/Source/WTF/wtf/FileSystem.h
r247505 r247523 97 97 }; 98 98 99 enum class MappedFileMode {100 Shared,101 Private,102 };103 104 99 enum class ShouldFollowSymbolicLinks { No, Yes }; 105 100 … … 144 139 // Returns the resulting offset from the beginning of the file if successful, -1 otherwise. 145 140 WTF_EXPORT_PRIVATE long long seekFile(PlatformFileHandle, long long offset, FileSeekOrigin); 146 WTF_EXPORT_PRIVATEbool truncateFile(PlatformFileHandle, long long offset);141 bool truncateFile(PlatformFileHandle, long long offset); 147 142 // Returns number of bytes actually read if successful, -1 otherwise. 148 143 WTF_EXPORT_PRIVATE int writeToFile(PlatformFileHandle, const char* data, int length); … … 197 192 WTF_EXPORT_PRIVATE void makeSafeToUseMemoryMapForPath(const String&); 198 193 199 WTF_EXPORT_PRIVATE bool unmapViewOfFile(void* buffer, size_t);200 201 194 class MappedFileData { 202 195 public: 203 196 MappedFileData() { } 204 197 MappedFileData(MappedFileData&&); 205 WTF_EXPORT_PRIVATE MappedFileData(const String& filePath, MappedFileMode, bool& success); 206 WTF_EXPORT_PRIVATE MappedFileData(PlatformFileHandle, MappedFileMode, bool& success); 198 WTF_EXPORT_PRIVATE MappedFileData(const String& filePath, bool& success); 207 199 WTF_EXPORT_PRIVATE ~MappedFileData(); 208 200 MappedFileData& operator=(MappedFileData&&); … … 212 204 unsigned size() const { return m_fileSize; } 213 205 214 void* leakHandle() { return std::exchange(m_fileData, nullptr); }215 216 206 private: 217 WTF_EXPORT_PRIVATE bool mapFileHandle(PlatformFileHandle, MappedFileMode);218 219 207 void* m_fileData { nullptr }; 220 208 unsigned m_fileSize { 0 }; 221 209 }; 222 223 inline MappedFileData::MappedFileData(PlatformFileHandle handle, MappedFileMode mode, bool& success)224 {225 success = mapFileHandle(handle, mode);226 }227 210 228 211 inline MappedFileData::MappedFileData(MappedFileData&& other) -
trunk/Source/WTF/wtf/UUID.cpp
r247505 r247523 67 67 String bootSessionUUIDString() 68 68 { 69 static LazyNeverDestroyed<String> bootSessionUUID; 69 70 #if OS(DARWIN) 70 static LazyNeverDestroyed<String> bootSessionUUID;71 71 static std::once_flag onceKey; 72 72 std::call_once(onceKey, [] { … … 77 77 bootSessionUUID.construct(static_cast<const char*>(uuid), uuidLength - 1); 78 78 }); 79 #endif 79 80 return bootSessionUUID; 80 #else81 return String();82 #endif83 81 } 84 82 -
trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp
r247505 r247523 391 391 } 392 392 393 bool truncateFile(PlatformFileHandle handle, long long offset)394 {395 return g_seekable_truncate(G_SEEKABLE(g_io_stream_get_output_stream(G_IO_STREAM(handle))), offset, nullptr, nullptr);396 }397 398 393 int writeToFile(PlatformFileHandle handle, const char* data, int length) 399 394 { -
trunk/Source/WTF/wtf/win/FileSystemWin.cpp
r247505 r247523 471 471 } 472 472 473 bool truncateFile(PlatformFileHandle handle, long long offset)474 {475 FILE_END_OF_FILE_INFO eofInfo;476 eofInfo.EndOfFile.QuadPart = offset;477 478 return SetFileInformationByHandle(handle, FileEndOfFileInfo, &eofInfo, sizeof(FILE_END_OF_FILE_INFO));479 }480 481 473 int writeToFile(PlatformFileHandle handle, const char* data, int length) 482 474 { … … 597 589 } 598 590 599 bool unmapViewOfFile(void* buffer, size_t) 600 { 601 return UnmapViewOfFile(buffer); 602 } 603 604 MappedFileData::MappedFileData(const String& filePath, MappedFileMode mode, bool& success) 605 { 591 MappedFileData::~MappedFileData() 592 { 593 if (!m_fileData) 594 return; 595 UnmapViewOfFile(m_fileData); 596 } 597 598 MappedFileData::MappedFileData(const String& filePath, bool& success) 599 { 600 success = false; 606 601 auto file = CreateFile(filePath.wideCharacters().data(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); 607 608 success = mapFileHandle(file, mode); 609 closeFile(file); 610 } 611 612 bool MappedFileData::mapFileHandle(PlatformFileHandle handle, MappedFileMode) 613 { 614 if (!isHandleValid(handle)) 615 return false; 602 if (file == INVALID_HANDLE_VALUE) 603 return; 616 604 617 605 long long size; 618 if (!getFileSize(handle, size) || size > std::numeric_limits<size_t>::max() || size > std::numeric_limits<decltype(m_fileSize)>::max()) { 619 return false; 606 if (!getFileSize(file, size) || size > std::numeric_limits<size_t>::max() || size > std::numeric_limits<decltype(m_fileSize)>::max()) { 607 CloseHandle(file); 608 return; 620 609 } 621 610 622 611 if (!size) { 623 return true; 624 } 625 626 auto mapping = CreateFileMapping(handle, nullptr, PAGE_READONLY, 0, 0, nullptr); 612 CloseHandle(file); 613 success = true; 614 return; 615 } 616 617 auto mapping = CreateFileMapping(file, nullptr, PAGE_READONLY, 0, 0, nullptr); 618 CloseHandle(file); 627 619 if (!mapping) 628 return false;620 return; 629 621 630 622 m_fileData = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, size); 631 623 CloseHandle(mapping); 632 624 if (!m_fileData) 633 return false;625 return; 634 626 m_fileSize = size; 635 returntrue;627 success = true; 636 628 } 637 629 -
trunk/Source/WebCore/ChangeLog
r247522 r247523 1 2019-07-17 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r247505. 4 https://bugs.webkit.org/show_bug.cgi?id=199871 5 6 "Caused failed ASSERT in stress test" (Requested by creid on 7 #webkit). 8 9 Reverted changeset: 10 11 "Bytecode cache should use FileSystem" 12 https://bugs.webkit.org/show_bug.cgi?id=199759 13 https://trac.webkit.org/changeset/247505 14 1 15 2019-07-17 Youenn Fablet <youenn@apple.com> 2 16 -
trunk/Source/WebCore/platform/SharedBuffer.cpp
r247505 r247523 72 72 { 73 73 bool mappingSuccess; 74 FileSystem::MappedFileData mappedFileData(filePath, FileSystem::MappedFileMode::Shared,mappingSuccess);74 FileSystem::MappedFileData mappedFileData(filePath, mappingSuccess); 75 75 76 76 if (!mappingSuccess) -
trunk/Tools/ChangeLog
r247516 r247523 1 2019-07-17 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r247505. 4 https://bugs.webkit.org/show_bug.cgi?id=199871 5 6 "Caused failed ASSERT in stress test" (Requested by creid on 7 #webkit). 8 9 Reverted changeset: 10 11 "Bytecode cache should use FileSystem" 12 https://bugs.webkit.org/show_bug.cgi?id=199759 13 https://trac.webkit.org/changeset/247505 14 1 15 2019-07-17 Russell Epstein <russell_e@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp
r247505 r247523 95 95 { 96 96 bool success; 97 FileSystem::MappedFileData mappedFileData(String("not_existing_file"), FileSystem::MappedFileMode::Shared,success);97 FileSystem::MappedFileData mappedFileData(String("not_existing_file"), success); 98 98 EXPECT_FALSE(success); 99 99 EXPECT_TRUE(!mappedFileData); … … 103 103 { 104 104 bool success; 105 FileSystem::MappedFileData mappedFileData(tempFilePath(), FileSystem::MappedFileMode::Shared,success);105 FileSystem::MappedFileData mappedFileData(tempFilePath(), success); 106 106 EXPECT_TRUE(success); 107 107 EXPECT_TRUE(!!mappedFileData); … … 113 113 { 114 114 bool success; 115 FileSystem::MappedFileData mappedFileData(tempEmptyFilePath(), FileSystem::MappedFileMode::Shared,success);115 FileSystem::MappedFileData mappedFileData(tempEmptyFilePath(), success); 116 116 EXPECT_TRUE(success); 117 117 EXPECT_TRUE(!mappedFileData);
Note: See TracChangeset
for help on using the changeset viewer.