Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1052)

Unified Diff: test/cctest/wasm/test-run-wasm-module.cc

Issue 2763413003: [wasm] Skeleton WasmModuleObjectBuilder for streamed compilation (Closed)
Patch Set: [wasm] Skeleton WasmModuleObjectBuilder for streamed compilation Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« include/v8.h ('K') | « src/api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/test-run-wasm-module.cc
diff --git a/test/cctest/wasm/test-run-wasm-module.cc b/test/cctest/wasm/test-run-wasm-module.cc
index 70c0eb012960087362c399a737089a714a5943b7..2abc515780d655e0e811162f4c574c918cb161cb 100644
--- a/test/cctest/wasm/test-run-wasm-module.cc
+++ b/test/cctest/wasm/test-run-wasm-module.cc
@@ -437,6 +437,67 @@ TEST(DeserializeWireBytesAndSerializedDataInvalid) {
Cleanup();
}
+std::unique_ptr<const uint8_t[]> CreatePayload(const uint8_t* start,
+ size_t size) {
+ uint8_t* ret = new uint8_t[size];
+ memcpy(ret, start, size);
+ return std::unique_ptr<const uint8_t[]>(const_cast<const uint8_t*>(ret));
+}
+
+TEST(ModuleBuilder) {
+ v8::internal::AccountingAllocator allocator;
+ Zone zone(&allocator, ZONE_NAME);
+ ZoneBuffer buffer(&zone);
+ WasmSerializationTest::BuildWireBytes(&zone, &buffer);
+ CHECK_GT(buffer.size(), 0);
+ size_t third = buffer.size() / 3;
+ size_t first_mark = third - 2;
+ size_t second_mark = buffer.size() - 2 - third;
+ CHECK(0 < first_mark);
+ CHECK(first_mark < second_mark);
+ CHECK(second_mark < buffer.size());
+ Isolate* i_isolate = CcTest::InitIsolateOnce();
+ v8::WasmModuleObjectBuilder builder(CcTest::isolate());
+ std::unique_ptr<const uint8_t[]> first_part =
+ CreatePayload(buffer.begin(), first_mark);
+ std::unique_ptr<const uint8_t[]> second_part =
+ CreatePayload(buffer.begin() + first_mark, second_mark - first_mark);
+ std::unique_ptr<const uint8_t[]> third_part =
+ CreatePayload(buffer.begin() + second_mark, buffer.size() - second_mark);
+ builder.OnBytesReceived(std::move(first_part), first_mark);
+ builder.OnBytesReceived(std::move(second_part), second_mark - first_mark);
+ builder.OnBytesReceived(std::move(third_part), buffer.size() - second_mark);
+ {
+ HandleScope scope(i_isolate);
+ v8::MaybeLocal<v8::WasmCompiledModule> maybe_module = builder.Finish();
+ CHECK(!maybe_module.IsEmpty());
+ }
+}
+
+TEST(FailingModuleBuilder) {
+ v8::internal::AccountingAllocator allocator;
+ Zone zone(&allocator, ZONE_NAME);
+ ZoneBuffer buffer(&zone);
+ WasmSerializationTest::BuildWireBytes(&zone, &buffer);
+ CHECK_GT(buffer.size(), 0);
+ size_t third = buffer.size() / 3;
+ size_t first_mark = third - 2;
+ size_t second_mark = buffer.size() - 2 - third;
+ CHECK(0 < first_mark);
+ CHECK(first_mark < second_mark);
+ CHECK(second_mark < buffer.size());
+ Isolate* i_isolate = CcTest::InitIsolateOnce();
+ v8::WasmModuleObjectBuilder builder(CcTest::isolate());
+ std::unique_ptr<const uint8_t[]> first_part =
+ CreatePayload(buffer.begin(), first_mark);
+ builder.OnBytesReceived(std::move(first_part), first_mark);
+ {
+ HandleScope scope(i_isolate);
+ v8::MaybeLocal<v8::WasmCompiledModule> maybe_module = builder.Finish();
+ CHECK(maybe_module.IsEmpty());
+ }
+}
+
bool False(v8::Local<v8::Context> context) { return false; }
TEST(BlockWasmCodeGen) {
« include/v8.h ('K') | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698