Commit 4fef5618 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Clean up SetCompiledModuleBytes

- Pass base::Vector instead of pointer plus size
- Remove always-true return value
- Remove unused SetCompiledModuleBytes in tests
- Drive-by: Use std::move for std::function callback

R=ahaas@chromium.org

Bug: v8:12425
Change-Id: I698abb64e4c8d8229997f09d6a79ef664fe9c933
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3644952
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80596}
parent 4578a57b
......@@ -91,15 +91,13 @@ class V8_EXPORT_PRIVATE StreamingDecoder {
std::function<void(const std::shared_ptr<NativeModule>&)>;
void SetModuleCompiledCallback(ModuleCompiledCallback callback) {
module_compiled_callback_ = callback;
module_compiled_callback_ = std::move(callback);
}
// Passes previously compiled module bytes from the embedder's cache.
// The content shouldn't be used until Finish(true) is called.
bool SetCompiledModuleBytes(
base::Vector<const uint8_t> compiled_module_bytes) {
compiled_module_bytes_ = compiled_module_bytes;
return true;
void SetCompiledModuleBytes(base::Vector<const uint8_t> bytes) {
compiled_module_bytes_ = bytes;
}
virtual void NotifyNativeModuleCreated(
......
......@@ -82,9 +82,10 @@ class WasmStreaming::WasmStreamingImpl {
Utils::OpenHandle(*exception.ToLocalChecked()));
}
bool SetCompiledModuleBytes(const uint8_t* bytes, size_t size) {
if (!i::wasm::IsSupportedVersion({bytes, size})) return false;
return streaming_decoder_->SetCompiledModuleBytes({bytes, size});
bool SetCompiledModuleBytes(base::Vector<const uint8_t> bytes) {
if (!i::wasm::IsSupportedVersion(bytes)) return false;
streaming_decoder_->SetCompiledModuleBytes(bytes);
return true;
}
void SetClient(std::shared_ptr<Client> client) {
......@@ -132,7 +133,7 @@ void WasmStreaming::Abort(MaybeLocal<Value> exception) {
bool WasmStreaming::SetCompiledModuleBytes(const uint8_t* bytes, size_t size) {
TRACE_EVENT0("v8.wasm", "wasm.SetCompiledModuleBytes");
return impl_->SetCompiledModuleBytes(bytes, size);
return impl_->SetCompiledModuleBytes(base::VectorOf(bytes, size));
}
void WasmStreaming::SetClient(std::shared_ptr<Client> client) {
......
......@@ -63,10 +63,6 @@ class StreamTester {
void FinishStream() { stream_->Finish(); }
void SetCompiledModuleBytes(const uint8_t* start, size_t length) {
stream_->SetCompiledModuleBytes(base::Vector<const uint8_t>(start, length));
}
private:
i::HandleScope internal_scope_;
std::shared_ptr<StreamingDecoder> stream_;
......
......@@ -217,8 +217,8 @@ class StreamTester {
void FinishStream() { stream_->Finish(); }
void SetCompiledModuleBytes(const uint8_t* start, size_t length) {
stream_->SetCompiledModuleBytes(base::Vector<const uint8_t>(start, length));
void SetCompiledModuleBytes(base::Vector<const uint8_t> bytes) {
stream_->SetCompiledModuleBytes(bytes);
}
Zone* zone() { return &zone_; }
......@@ -1231,7 +1231,7 @@ STREAM_TEST(TestDeserializationBypassesCompilation) {
ZoneBuffer wire_bytes = GetValidModuleBytes(tester.zone());
ZoneBuffer module_bytes =
GetValidCompiledModuleBytes(isolate, tester.zone(), wire_bytes);
tester.SetCompiledModuleBytes(module_bytes.begin(), module_bytes.size());
tester.SetCompiledModuleBytes(base::VectorOf(module_bytes));
tester.OnBytesReceived(wire_bytes.begin(), wire_bytes.size());
tester.FinishStream();
......@@ -1250,7 +1250,7 @@ STREAM_TEST(TestDeserializationFails) {
// corrupt header
byte first_byte = *module_bytes.begin();
module_bytes.patch_u8(0, first_byte + 1);
tester.SetCompiledModuleBytes(module_bytes.begin(), module_bytes.size());
tester.SetCompiledModuleBytes(base::VectorOf(module_bytes));
tester.OnBytesReceived(wire_bytes.begin(), wire_bytes.size());
tester.FinishStream();
......
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