Changeset 247523 in webkit


Ignore:
Timestamp:
Jul 17, 2019 11:12:56 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r247505.
https://bugs.webkit.org/show_bug.cgi?id=199871

"Caused failed ASSERT in stress test" (Requested by creid on
#webkit).

Reverted changeset:

"Bytecode cache should use FileSystem"
https://bugs.webkit.org/show_bug.cgi?id=199759
https://trac.webkit.org/changeset/247505

Location:
trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSScript.mm

    r247505 r247523  
    131131    bool success = false;
    132132    String systemPath = filePathURL.fileSystemPath();
    133     FileSystem::MappedFileData fileData(systemPath, FileSystem::MappedFileMode::Shared, success);
     133    FileSystem::MappedFileData fileData(systemPath, success);
    134134    if (!success)
    135135        return createError([NSString stringWithFormat:@"File at path %@ could not be mapped.", static_cast<NSString *>(systemPath)], error);
     
    154154        return;
    155155
    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)
    158158        return;
    159159    auto closeFD = makeScopeExit([&] {
    160         FileSystem::unlockAndCloseFile(fd);
     160        close(fd);
    161161    });
    162162
    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)
    166167        return;
    167168
    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);
    169172
    170173    JSC::VM& vm = [m_virtualMachine vm];
     
    289292    if (cacheError.isValid()) {
    290293        m_cachedBytecode = JSC::CachedBytecode::create();
    291         FileSystem::truncateFile(fd, 0);
     294        ftruncate(fd, 0);
    292295        error = makeString("Unable to generate bytecode for this JSScript because: ", cacheError.message());
    293296        return NO;
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r247505 r247523  
    224224    execute_process(COMMAND bash -c "date +'%s'" OUTPUT_VARIABLE BUILD_TIME OUTPUT_STRIP_TRAILING_WHITESPACE)
    225225else ()
    226     string(TIMESTAMP BUILD_TIME "%s")
     226    set(BUILD_TIME 0)
    227227endif ()
    228228
  • trunk/Source/JavaScriptCore/ChangeLog

    r247505 r247523  
     12019-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
    1152019-07-16  Christopher Reid  <chris.reid@sony.com>
    216
  • trunk/Source/JavaScriptCore/jsc.cpp

    r247505 r247523  
    8686#include <wtf/Box.h>
    8787#include <wtf/CommaPrinter.h>
    88 #include <wtf/FileSystem.h>
    8988#include <wtf/MainThread.h>
    9089#include <wtf/MemoryPressureHandler.h>
     
    10051004    void commitCachedBytecode() const override
    10061005    {
     1006#if OS(DARWIN)
    10071007        if (!cacheEnabled() || !m_cachedBytecode || !m_cachedBytecode->hasUpdates())
    10081008            return;
     
    10131013
    10141014        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)
    10171017            return;
    10181018
    10191019        auto closeFD = makeScopeExit([&] {
    1020             FileSystem::unlockAndCloseFile(fd);
     1020            close(fd);
    10211021        });
    10221022
    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()) {
    10291027            // The bytecode cache has already been updated
    10301028            return;
    10311029        }
    10321030
    1033         if (!FileSystem::truncateFile(fd, m_cachedBytecode->sizeForUpdate()))
     1031        if (ftruncate(fd, m_cachedBytecode->sizeForUpdate()))
    10341032            return;
    10351033
    10361034        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);
    10381036            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));
    10401038            ASSERT_UNUSED(bytesWritten, bytesWritten == size);
    10411039        });
     1040#endif
    10421041    }
    10431042
     
    10481047            return static_cast<const char*>(nullptr);
    10491048        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");
    10521052    }
    10531053
    10541054    void loadBytecode() const
    10551055    {
     1056#if OS(DARWIN)
    10561057        if (!cacheEnabled())
    10571058            return;
     
    10611062            return;
    10621063
    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)
    10651066            return;
    10661067
    10671068        auto closeFD = makeScopeExit([&] {
    1068             FileSystem::unlockAndCloseFile(fd);
     1069            close(fd);
    10691070        });
    10701071
    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)
    10751076            return;
    10761077
    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
    10781083    }
    10791084
  • trunk/Source/JavaScriptCore/runtime/CachePayload.cpp

    r247505 r247523  
    3333namespace JSC {
    3434
    35 CachePayload CachePayload::makeMappedPayload(FileSystem::MappedFileData&& data)
     35#if !OS(WINDOWS)
     36CachePayload CachePayload::makeMappedPayload(void* data, size_t size)
    3637{
    37     return CachePayload(true, data.leakHandle(), data.size());
     38    return CachePayload(true, data, size);
    3839}
     40#endif
    3941
    4042CachePayload CachePayload::makeMallocPayload(MallocPtr<uint8_t>&& data, size_t size)
     
    7577        return;
    7678    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
    7884    } else
    7985        fastFree(m_data);
  • trunk/Source/JavaScriptCore/runtime/CachePayload.h

    r247505 r247523  
    2626#pragma once
    2727
    28 #include <wtf/FileSystem.h>
    2928#include <wtf/MallocPtr.h>
    3029
     
    3332class CachePayload {
    3433public:
    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
    3637    JS_EXPORT_PRIVATE static CachePayload makeMallocPayload(MallocPtr<uint8_t>&&, size_t);
    3738    JS_EXPORT_PRIVATE static CachePayload makeEmptyPayload();
  • trunk/Source/JavaScriptCore/runtime/CachedBytecode.h

    r247505 r247523  
    4747    }
    4848
    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 = { })
    5051    {
    51         return adoptRef(*new CachedBytecode(CachePayload::makeMappedPayload(WTFMove(data)), WTFMove(leafExecutables)));
     52        return adoptRef(*new CachedBytecode(CachePayload::makeMappedPayload(data, size), WTFMove(leafExecutables)));
    5253    }
     54#endif
    5355
    5456    static Ref<CachedBytecode> create(MallocPtr<uint8_t>&& data, size_t size, LeafExecutableMap&& leafExecutables)
  • trunk/Source/JavaScriptCore/runtime/CachedTypes.cpp

    r247505 r247523  
    8989    };
    9090
    91     Encoder(VM& vm, FileSystem::PlatformFileHandle fd = FileSystem::invalidPlatformFileHandle)
     91    Encoder(VM& vm, int fd = -1)
    9292        : m_vm(vm)
    9393        , m_fd(fd)
     
    153153        m_currentPage->alignEnd();
    154154
    155         if (FileSystem::isHandleValid(m_fd)) {
     155        if (m_fd != -1) {
     156#if !OS(WINDOWS)
    156157            return releaseMapped(error);
     158#else
     159            RELEASE_ASSERT_NOT_REACHED();
     160#endif
    157161        }
    158162
     
    169173
    170174private:
     175#if !OS(WINDOWS)
    171176    RefPtr<CachedBytecode> releaseMapped(BytecodeCacheError& error)
    172177    {
    173178        size_t size = m_baseOffset + m_currentPage->size();
    174         if (!FileSystem::truncateFile(m_fd, size)) {
     179        if (ftruncate(m_fd, size)) {
    175180            error = BytecodeCacheError::StandardError(errno);
    176181            return nullptr;
     
    178183
    179184        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());
    181186            if (bytesWritten == -1) {
    182187                error = BytecodeCacheError::StandardError(errno);
     
    190195        }
    191196
    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) {
    195199            error = BytecodeCacheError::StandardError(errno);
    196200            return nullptr;
    197201        }
    198202
    199         return CachedBytecode::create(WTFMove(mappedFileData), WTFMove(m_leafExecutables));
    200     }
     203        return CachedBytecode::create(buffer, size, WTFMove(m_leafExecutables));
     204    }
     205#endif
    201206
    202207    class Page {
     
    266271
    267272    VM& m_vm;
    268     FileSystem::PlatformFileHandle m_fd;
     273    int m_fd;
    269274    ptrdiff_t m_baseOffset;
    270275    Page* m_currentPage;
     
    23722377}
    23732378
    2374 RefPtr<CachedBytecode> encodeCodeBlock(VM& vm, const SourceCodeKey& key, const UnlinkedCodeBlock* codeBlock, FileSystem::PlatformFileHandle fd, BytecodeCacheError& error)
     2379RefPtr<CachedBytecode> encodeCodeBlock(VM& vm, const SourceCodeKey& key, const UnlinkedCodeBlock* codeBlock, int fd, BytecodeCacheError& error)
    23752380{
    23762381    const ClassInfo* classInfo = codeBlock->classInfo(vm);
     
    23902395{
    23912396    BytecodeCacheError error;
    2392     return encodeCodeBlock(vm, key, codeBlock, FileSystem::invalidPlatformFileHandle, error);
     2397    return encodeCodeBlock(vm, key, codeBlock, -1, error);
    23932398}
    23942399
  • trunk/Source/JavaScriptCore/runtime/CachedTypes.h

    r247505 r247523  
    110110
    111111JS_EXPORT_PRIVATE RefPtr<CachedBytecode> encodeCodeBlock(VM&, const SourceCodeKey&, const UnlinkedCodeBlock*);
    112 JS_EXPORT_PRIVATE RefPtr<CachedBytecode> encodeCodeBlock(VM&, const SourceCodeKey&, const UnlinkedCodeBlock*, FileSystem::PlatformFileHandle fd, BytecodeCacheError&);
     112JS_EXPORT_PRIVATE RefPtr<CachedBytecode> encodeCodeBlock(VM&, const SourceCodeKey&, const UnlinkedCodeBlock*, int fd, BytecodeCacheError&);
    113113
    114114UnlinkedCodeBlock* decodeCodeBlockImpl(VM&, const SourceCodeKey&, Ref<CachedBytecode>);
  • trunk/Source/JavaScriptCore/runtime/CodeCache.cpp

    r247505 r247523  
    226226}
    227227
    228 RefPtr<CachedBytecode> serializeBytecode(VM& vm, UnlinkedCodeBlock* codeBlock, const SourceCode& source, SourceCodeType codeType, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, FileSystem::PlatformFileHandle fd, BytecodeCacheError& error, OptionSet<CodeGenerationMode> codeGenerationMode)
     228RefPtr<CachedBytecode> serializeBytecode(VM& vm, UnlinkedCodeBlock* codeBlock, const SourceCode& source, SourceCodeType codeType, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, int fd, BytecodeCacheError& error, OptionSet<CodeGenerationMode> codeGenerationMode)
    229229{
    230230    return encodeCodeBlock(vm,
  • trunk/Source/JavaScriptCore/runtime/CodeCache.h

    r247505 r247523  
    319319
    320320void writeCodeBlock(VM&, const SourceCodeKey&, const SourceCodeValue&);
    321 RefPtr<CachedBytecode> serializeBytecode(VM&, UnlinkedCodeBlock*, const SourceCode&, SourceCodeType, JSParserStrictMode, JSParserScriptMode, FileSystem::PlatformFileHandle fd, BytecodeCacheError&, OptionSet<CodeGenerationMode>);
     321RefPtr<CachedBytecode> serializeBytecode(VM&, UnlinkedCodeBlock*, const SourceCode&, SourceCodeType, JSParserStrictMode, JSParserScriptMode, int fd, BytecodeCacheError&, OptionSet<CodeGenerationMode>);
    322322SourceCodeKey sourceCodeKeyForSerializedProgram(VM&, const SourceCode&);
    323323SourceCodeKey sourceCodeKeyForSerializedModule(VM&, const SourceCode&);
  • trunk/Source/JavaScriptCore/runtime/Completion.cpp

    r247505 r247523  
    9393}
    9494
    95 RefPtr<CachedBytecode> generateProgramBytecode(VM& vm, const SourceCode& source, FileSystem::PlatformFileHandle fd, BytecodeCacheError& error)
     95RefPtr<CachedBytecode> generateProgramBytecode(VM& vm, const SourceCode& source, int fd, BytecodeCacheError& error)
    9696{
    9797    JSLockHolder lock(vm);
     
    113113}
    114114
    115 RefPtr<CachedBytecode> generateModuleBytecode(VM& vm, const SourceCode& source, FileSystem::PlatformFileHandle fd, BytecodeCacheError& error)
     115RefPtr<CachedBytecode> generateModuleBytecode(VM& vm, const SourceCode& source, int fd, BytecodeCacheError& error)
    116116{
    117117    JSLockHolder lock(vm);
  • trunk/Source/JavaScriptCore/runtime/Completion.h

    r247505 r247523  
    2525#include "CallData.h"
    2626#include "JSCJSValue.h"
    27 #include <wtf/FileSystem.h>
    2827#include <wtf/NakedPtr.h>
    2928
     
    4544JS_EXPORT_PRIVATE bool checkModuleSyntax(ExecState*, const SourceCode&, ParserError&);
    4645
    47 JS_EXPORT_PRIVATE RefPtr<CachedBytecode> generateProgramBytecode(VM&, const SourceCode&, FileSystem::PlatformFileHandle fd, BytecodeCacheError&);
    48 JS_EXPORT_PRIVATE RefPtr<CachedBytecode> generateModuleBytecode(VM&, const SourceCode&, FileSystem::PlatformFileHandle fd, BytecodeCacheError&);
     46JS_EXPORT_PRIVATE RefPtr<CachedBytecode> generateProgramBytecode(VM&, const SourceCode&, int fd, BytecodeCacheError&);
     47JS_EXPORT_PRIVATE RefPtr<CachedBytecode> generateModuleBytecode(VM&, const SourceCode&, int fd, BytecodeCacheError&);
    4948
    5049JS_EXPORT_PRIVATE JSValue evaluate(ExecState*, const SourceCode&, JSValue thisValue, NakedPtr<Exception>& returnedException);
  • trunk/Source/WTF/ChangeLog

    r247505 r247523  
     12019-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
    1152019-07-16  Christopher Reid  <chris.reid@sony.com>
    216
  • trunk/Source/WTF/wtf/FileSystem.cpp

    r247505 r247523  
    4141#endif
    4242
    43 #if USE(GLIB)
    44 #include <gio/gfiledescriptorbased.h>
    45 #include <gio/gio.h>
    46 #endif
    47 
    4843namespace WTF {
    4944
     
    280275#endif
    281276
     277#if HAVE(MMAP)
     278
    282279MappedFileData::~MappedFileData()
    283280{
    284281    if (!m_fileData)
    285282        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
     286MappedFileData::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    }
    311294
    312295    struct stat fileStat;
    313296    if (fstat(fd, &fileStat)) {
    314         return false;
     297        close(fd);
     298        success = false;
     299        return;
    315300    }
    316301
    317302    unsigned size;
    318303    if (!WTF::convertSafely(fileStat.st_size, size)) {
    319         return false;
     304        close(fd);
     305        success = false;
     306        return;
    320307    }
    321308
    322309    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);
    327317
    328318    if (data == MAP_FAILED) {
    329         return false;
    330     }
    331 
     319        success = false;
     320        return;
     321    }
     322
     323    success = true;
    332324    m_fileData = data;
    333325    m_fileSize = size;
    334     return true;
    335 }
    336 
    337 bool unmapViewOfFile(void* buffer, size_t size)
    338 {
    339     return !munmap(buffer, size);
    340326}
    341327
  • trunk/Source/WTF/wtf/FileSystem.h

    r247505 r247523  
    9797};
    9898
    99 enum class MappedFileMode {
    100     Shared,
    101     Private,
    102 };
    103 
    10499enum class ShouldFollowSymbolicLinks { No, Yes };
    105100
     
    144139// Returns the resulting offset from the beginning of the file if successful, -1 otherwise.
    145140WTF_EXPORT_PRIVATE long long seekFile(PlatformFileHandle, long long offset, FileSeekOrigin);
    146 WTF_EXPORT_PRIVATE bool truncateFile(PlatformFileHandle, long long offset);
     141bool truncateFile(PlatformFileHandle, long long offset);
    147142// Returns number of bytes actually read if successful, -1 otherwise.
    148143WTF_EXPORT_PRIVATE int writeToFile(PlatformFileHandle, const char* data, int length);
     
    197192WTF_EXPORT_PRIVATE void makeSafeToUseMemoryMapForPath(const String&);
    198193
    199 WTF_EXPORT_PRIVATE bool unmapViewOfFile(void* buffer, size_t);
    200 
    201194class MappedFileData {
    202195public:
    203196    MappedFileData() { }
    204197    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);
    207199    WTF_EXPORT_PRIVATE ~MappedFileData();
    208200    MappedFileData& operator=(MappedFileData&&);
     
    212204    unsigned size() const { return m_fileSize; }
    213205
    214     void* leakHandle() { return std::exchange(m_fileData, nullptr); }
    215 
    216206private:
    217     WTF_EXPORT_PRIVATE bool mapFileHandle(PlatformFileHandle, MappedFileMode);
    218 
    219207    void* m_fileData { nullptr };
    220208    unsigned m_fileSize { 0 };
    221209};
    222 
    223 inline MappedFileData::MappedFileData(PlatformFileHandle handle, MappedFileMode mode, bool& success)
    224 {
    225     success = mapFileHandle(handle, mode);
    226 }
    227210
    228211inline MappedFileData::MappedFileData(MappedFileData&& other)
  • trunk/Source/WTF/wtf/UUID.cpp

    r247505 r247523  
    6767String bootSessionUUIDString()
    6868{
     69    static LazyNeverDestroyed<String> bootSessionUUID;
    6970#if OS(DARWIN)
    70     static LazyNeverDestroyed<String> bootSessionUUID;
    7171    static std::once_flag onceKey;
    7272    std::call_once(onceKey, [] {
     
    7777        bootSessionUUID.construct(static_cast<const char*>(uuid), uuidLength - 1);
    7878    });
     79#endif
    7980    return bootSessionUUID;
    80 #else
    81     return String();
    82 #endif
    8381}
    8482
  • trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp

    r247505 r247523  
    391391}
    392392
    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 
    398393int writeToFile(PlatformFileHandle handle, const char* data, int length)
    399394{
  • trunk/Source/WTF/wtf/win/FileSystemWin.cpp

    r247505 r247523  
    471471}
    472472
    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 
    481473int writeToFile(PlatformFileHandle handle, const char* data, int length)
    482474{
     
    597589}
    598590
    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 {
     591MappedFileData::~MappedFileData()
     592{
     593    if (!m_fileData)
     594        return;
     595    UnmapViewOfFile(m_fileData);
     596}
     597
     598MappedFileData::MappedFileData(const String& filePath, bool& success)
     599{
     600    success = false;
    606601    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;
    616604
    617605    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;
    620609    }
    621610
    622611    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);
    627619    if (!mapping)
    628         return false;
     620        return;
    629621
    630622    m_fileData = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, size);
    631623    CloseHandle(mapping);
    632624    if (!m_fileData)
    633         return false;
     625        return;
    634626    m_fileSize = size;
    635     return true;
     627    success = true;
    636628}
    637629
  • trunk/Source/WebCore/ChangeLog

    r247522 r247523  
     12019-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
    1152019-07-17  Youenn Fablet  <youenn@apple.com>
    216
  • trunk/Source/WebCore/platform/SharedBuffer.cpp

    r247505 r247523  
    7272{
    7373    bool mappingSuccess;
    74     FileSystem::MappedFileData mappedFileData(filePath, FileSystem::MappedFileMode::Shared, mappingSuccess);
     74    FileSystem::MappedFileData mappedFileData(filePath, mappingSuccess);
    7575
    7676    if (!mappingSuccess)
  • trunk/Tools/ChangeLog

    r247516 r247523  
     12019-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
    1152019-07-17  Russell Epstein  <russell_e@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp

    r247505 r247523  
    9595{
    9696    bool success;
    97     FileSystem::MappedFileData mappedFileData(String("not_existing_file"), FileSystem::MappedFileMode::Shared, success);
     97    FileSystem::MappedFileData mappedFileData(String("not_existing_file"), success);
    9898    EXPECT_FALSE(success);
    9999    EXPECT_TRUE(!mappedFileData);
     
    103103{
    104104    bool success;
    105     FileSystem::MappedFileData mappedFileData(tempFilePath(), FileSystem::MappedFileMode::Shared, success);
     105    FileSystem::MappedFileData mappedFileData(tempFilePath(), success);
    106106    EXPECT_TRUE(success);
    107107    EXPECT_TRUE(!!mappedFileData);
     
    113113{
    114114    bool success;
    115     FileSystem::MappedFileData mappedFileData(tempEmptyFilePath(), FileSystem::MappedFileMode::Shared, success);
     115    FileSystem::MappedFileData mappedFileData(tempEmptyFilePath(), success);
    116116    EXPECT_TRUE(success);
    117117    EXPECT_TRUE(!mappedFileData);
Note: See TracChangeset for help on using the changeset viewer.