+
+#if OS(DARWIN)
+ const char* cachePath = Options::diskCachePath();
+ if (!cachePath)
+ return nullptr;
+
+ unsigned hash = key.hash();
+ char filename[512];
+ int count = snprintf(filename, 512, "%s/%u.cache", cachePath, hash);
+ if (count < 0 || count > 512)
+ return nullptr;
+
+ int fd = open(filename, O_RDONLY);
+ if (fd == -1)
+ return nullptr;
+
+ int rc = flock(fd, LOCK_SH | LOCK_NB);
+ if (rc) {
+ close(fd);
+ return nullptr;
+ }
+
+ struct stat sb;
+ int res = fstat(fd, &sb);
+ size_t size = static_cast<size_t>(sb.st_size);
+ if (res || !size) {
+ close(fd);
+ return nullptr;
+ }
+
+ void* buffer = mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0);
+ UnlinkedCodeBlockType* unlinkedCodeBlock = decodeCodeBlock<UnlinkedCodeBlockType>(vm, key, buffer, size);
+ munmap(buffer, size);
+
+ if (!unlinkedCodeBlock)
+ return nullptr;
+
+ VERBOSE_LOG("Found cached CodeBlock on disk");
+ addCache(key, SourceCodeValue(vm, unlinkedCodeBlock, m_age, true));
+ return unlinkedCodeBlock;
+#else
+ UNUSED_PARAM(vm);
+ UNUSED_PARAM(key);