Commit 0721118d authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[snapshot] Allow an empty v8_extra_library_files

... and do not artificially add at least one dummy.js file.

Until this CL we used to ensure the existence of at least one 'extra
native' by appending a short dummy.js file if v8_extra_library_files
was empty. This file is uselessly compiled and run at startup.

This CL removes that mechanism along with a minor tweak to handle an
empty natives blob.

Bug: v8:9736
Change-Id: I05bf7c54380e77a9105d5c1a1a76983c692faf60
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1809372
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63868}
parent 31f44eea
......@@ -61,9 +61,10 @@ class NativesStore {
// We expect the libraries in the following format:
// int: # of sources.
// 2N blobs: N pairs of source name + actual source.
int library_count = source->GetInt();
for (int i = 0; i < library_count; ++i)
int library_count = source->GetIntSlow();
for (int i = 0; i < library_count; ++i) {
store->ReadNameAndContentPair(source);
}
return store;
}
......
......@@ -63,6 +63,24 @@ class SnapshotByteSource final {
return answer;
}
int GetIntSlow() {
// Unlike GetInt, this reads only up to the end of the blob, even if less
// than 4 bytes are remaining.
// TODO(jgruber): Remove once the use in MakeFromScriptsSource is gone.
DCHECK(position_ < length_);
uint32_t answer = data_[position_];
if (position_ + 1 < length_) answer |= data_[position_ + 1] << 8;
if (position_ + 2 < length_) answer |= data_[position_ + 2] << 16;
if (position_ + 3 < length_) answer |= data_[position_ + 3] << 24;
int bytes = (answer & 3) + 1;
Advance(bytes);
uint32_t mask = 0xffffffffu;
mask >>= 32 - (bytes << 3);
answer &= mask;
answer >>= 2;
return answer;
}
// Returns length.
int GetBlob(const byte** data);
......
......@@ -202,19 +202,11 @@ def PrepareSources(source_files, native_type, emit_js):
Returns:
An instance of Sources.
"""
result = Sources()
filters = BuildFilterChain()
source_files_and_contents = [(f, ReadFile(f)) for f in source_files]
# Have a single not-quite-empty source file if there are none present;
# otherwise you get errors trying to compile an empty C++ array.
# It cannot be empty (or whitespace, which gets trimmed to empty), as
# the deserialization code assumes each file is nonempty.
if not source_files_and_contents:
source_files_and_contents = [("dummy.js", "(function() {})")]
result = Sources()
for (source, contents) in source_files_and_contents:
try:
lines = filters(contents)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment