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

Side by Side 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 unified diff | Download patch
« include/v8.h ('K') | « src/api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "src/objects-inl.h" 8 #include "src/objects-inl.h"
9 #include "src/snapshot/code-serializer.h" 9 #include "src/snapshot/code-serializer.h"
10 #include "src/version.h" 10 #include "src/version.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 { 430 {
431 HandleScope scope(test.current_isolate()); 431 HandleScope scope(test.current_isolate());
432 test.InvalidateVersion(); 432 test.InvalidateVersion();
433 test.InvalidateWireBytes(); 433 test.InvalidateWireBytes();
434 test.Deserialize(); 434 test.Deserialize();
435 } 435 }
436 Cleanup(test.current_isolate()); 436 Cleanup(test.current_isolate());
437 Cleanup(); 437 Cleanup();
438 } 438 }
439 439
440 std::unique_ptr<const uint8_t[]> CreatePayload(const uint8_t* start,
441 size_t size) {
442 uint8_t* ret = new uint8_t[size];
443 memcpy(ret, start, size);
444 return std::unique_ptr<const uint8_t[]>(const_cast<const uint8_t*>(ret));
445 }
446
447 TEST(ModuleBuilder) {
448 v8::internal::AccountingAllocator allocator;
449 Zone zone(&allocator, ZONE_NAME);
450 ZoneBuffer buffer(&zone);
451 WasmSerializationTest::BuildWireBytes(&zone, &buffer);
452 CHECK_GT(buffer.size(), 0);
453 size_t third = buffer.size() / 3;
454 size_t first_mark = third - 2;
455 size_t second_mark = buffer.size() - 2 - third;
456 CHECK(0 < first_mark);
457 CHECK(first_mark < second_mark);
458 CHECK(second_mark < buffer.size());
459 Isolate* i_isolate = CcTest::InitIsolateOnce();
460 v8::WasmModuleObjectBuilder builder(CcTest::isolate());
461 std::unique_ptr<const uint8_t[]> first_part =
462 CreatePayload(buffer.begin(), first_mark);
463 std::unique_ptr<const uint8_t[]> second_part =
464 CreatePayload(buffer.begin() + first_mark, second_mark - first_mark);
465 std::unique_ptr<const uint8_t[]> third_part =
466 CreatePayload(buffer.begin() + second_mark, buffer.size() - second_mark);
467 builder.OnBytesReceived(std::move(first_part), first_mark);
468 builder.OnBytesReceived(std::move(second_part), second_mark - first_mark);
469 builder.OnBytesReceived(std::move(third_part), buffer.size() - second_mark);
470 {
471 HandleScope scope(i_isolate);
472 v8::MaybeLocal<v8::WasmCompiledModule> maybe_module = builder.Finish();
473 CHECK(!maybe_module.IsEmpty());
474 }
475 }
476
477 TEST(FailingModuleBuilder) {
478 v8::internal::AccountingAllocator allocator;
479 Zone zone(&allocator, ZONE_NAME);
480 ZoneBuffer buffer(&zone);
481 WasmSerializationTest::BuildWireBytes(&zone, &buffer);
482 CHECK_GT(buffer.size(), 0);
483 size_t third = buffer.size() / 3;
484 size_t first_mark = third - 2;
485 size_t second_mark = buffer.size() - 2 - third;
486 CHECK(0 < first_mark);
487 CHECK(first_mark < second_mark);
488 CHECK(second_mark < buffer.size());
489 Isolate* i_isolate = CcTest::InitIsolateOnce();
490 v8::WasmModuleObjectBuilder builder(CcTest::isolate());
491 std::unique_ptr<const uint8_t[]> first_part =
492 CreatePayload(buffer.begin(), first_mark);
493 builder.OnBytesReceived(std::move(first_part), first_mark);
494 {
495 HandleScope scope(i_isolate);
496 v8::MaybeLocal<v8::WasmCompiledModule> maybe_module = builder.Finish();
497 CHECK(maybe_module.IsEmpty());
498 }
499 }
500
440 bool False(v8::Local<v8::Context> context) { return false; } 501 bool False(v8::Local<v8::Context> context) { return false; }
441 502
442 TEST(BlockWasmCodeGen) { 503 TEST(BlockWasmCodeGen) {
443 v8::internal::AccountingAllocator allocator; 504 v8::internal::AccountingAllocator allocator;
444 Zone zone(&allocator, ZONE_NAME); 505 Zone zone(&allocator, ZONE_NAME);
445 ZoneBuffer buffer(&zone); 506 ZoneBuffer buffer(&zone);
446 WasmSerializationTest::BuildWireBytes(&zone, &buffer); 507 WasmSerializationTest::BuildWireBytes(&zone, &buffer);
447 Isolate* isolate = CcTest::InitIsolateOnce(); 508 Isolate* isolate = CcTest::InitIsolateOnce();
448 HandleScope scope(isolate); 509 HandleScope scope(isolate);
449 testing::SetupIsolateForWasmModule(isolate); 510 testing::SetupIsolateForWasmModule(isolate);
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 ModuleOrigin::kWasmOrigin); 1130 ModuleOrigin::kWasmOrigin);
1070 CHECK_EQ(kExpectedValue, result); 1131 CHECK_EQ(kExpectedValue, result);
1071 // Free the buffer as the tracker does not know about it. 1132 // Free the buffer as the tracker does not know about it.
1072 if (!memory->has_guard_region()) { 1133 if (!memory->has_guard_region()) {
1073 isolate->array_buffer_allocator()->Free( 1134 isolate->array_buffer_allocator()->Free(
1074 memory->backing_store(), NumberToSize(memory->byte_length())); 1135 memory->backing_store(), NumberToSize(memory->byte_length()));
1075 } 1136 }
1076 } 1137 }
1077 Cleanup(); 1138 Cleanup();
1078 } 1139 }
OLDNEW
« 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