GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: stop copying code cache · nodejs/node@a11507e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node.h
    • node_builtins.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node.h‎

Copy file name to clipboardExpand all lines: src/node.h
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@ struct IsolateSettings {
505505
// feature during the build step by passing the --disable-shared-readonly-heap
506506
// flag to the configure script.
507507
//
508+
// The snapshot *must* be kept alive during the execution of the Isolate
509+
// that was created using it.
510+
//
508511
// Snapshots are an *experimental* feature. In particular, the embedder API
509512
// exposed through this class is subject to change or removal between Node.js
510513
// versions, including possible API and ABI breakage.
Collapse file

‎src/node_builtins.cc‎

Copy file name to clipboardExpand all lines: src/node_builtins.cc
+10-6Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,17 @@ void BuiltinLoader::CopyCodeCache(std::vector<CodeCacheInfo>* out) const {
501501

502502
void BuiltinLoader::RefreshCodeCache(const std::vector<CodeCacheInfo>& in) {
503503
RwLock::ScopedLock lock(code_cache_->mutex);
504+
code_cache_->map.reserve(in.size());
505+
DCHECK(code_cache_->map.empty());
504506
for (auto const& item : in) {
505-
size_t length = item.data.size();
506-
uint8_t* buffer = new uint8_t[length];
507-
memcpy(buffer, item.data.data(), length);
508-
auto new_cache = std::make_unique<v8::ScriptCompiler::CachedData>(
509-
buffer, length, v8::ScriptCompiler::CachedData::BufferOwned);
510-
code_cache_->map[item.id] = std::move(new_cache);
507+
auto result = code_cache_->map.emplace(
508+
item.id,
509+
std::make_unique<v8::ScriptCompiler::CachedData>(
510+
item.data.data(),
511+
item.data.size(),
512+
v8::ScriptCompiler::CachedData::BufferNotOwned));
513+
USE(result.second);
514+
DCHECK(result.second);
511515
}
512516
code_cache_->has_code_cache = true;
513517
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.