diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-04-08 10:12:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-08 10:12:43 -0400 |
commit | f7fdb90fd51e340ea598c055bb3573d3cdfbdaa8 (patch) | |
tree | 40db117b3a9fd2ac70e3b5551195e21eef464138 /core/libdeno/snapshot_creator.cc | |
parent | cdb72afd8d91978573f0fa897844aee853983b44 (diff) |
core: snapshot improvements (#2052)
* Moves how snapshots are supplied to the Isolate. Previously they were
given by Behavior::startup_data() but it was only called once at
startup. It makes more sense (and simplifies Behavior) to pass it to the
constructor of Isolate.
* Adds new libdeno type deno_snapshot instead of overloading
deno_buf.
* Adds new libdeno method to delete snapshot deno_snapshot_delete().
* Renames deno_get_snapshot() to deno_snapshot_new().
* Makes StartupData hold references to snapshots. This was implicit when
it previously held a deno_buf but is made explicit now. Note that
include_bytes!() returns a &'static [u8] and we want to avoid
copying that.
Diffstat (limited to 'core/libdeno/snapshot_creator.cc')
-rw-r--r-- | core/libdeno/snapshot_creator.cc | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/core/libdeno/snapshot_creator.cc b/core/libdeno/snapshot_creator.cc index 19098392d..081bd1156 100644 --- a/core/libdeno/snapshot_creator.cc +++ b/core/libdeno/snapshot_creator.cc @@ -8,8 +8,6 @@ #include "third_party/v8/include/v8.h" #include "third_party/v8/src/base/logging.h" -namespace deno {} // namespace deno - int main(int argc, char** argv) { const char* snapshot_out_bin = argv[1]; const char* js_fn = argv[2]; @@ -23,7 +21,7 @@ int main(int argc, char** argv) { CHECK(deno::ReadFileToString(js_fn, &js_source)); deno_init(); - deno_config config = {1, deno::empty_buf, deno::empty_buf, nullptr}; + deno_config config = {1, deno::empty_snapshot, deno::empty_buf, nullptr}; Deno* d = deno_new(config); deno_execute(d, nullptr, js_fn, js_source.c_str()); @@ -34,13 +32,13 @@ int main(int argc, char** argv) { return 1; } - auto snapshot = deno_get_snapshot(d); + auto snapshot = deno_snapshot_new(d); std::ofstream file_(snapshot_out_bin, std::ios::binary); file_.write(reinterpret_cast<char*>(snapshot.data_ptr), snapshot.data_len); file_.close(); - delete[] snapshot.data_ptr; + deno_snapshot_delete(snapshot); deno_delete(d); return file_.bad(); |