OLD | NEW |
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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 CHECK(first_mark < second_mark); | 457 CHECK(first_mark < second_mark); |
458 CHECK(second_mark < buffer.size()); | 458 CHECK(second_mark < buffer.size()); |
459 Isolate* i_isolate = CcTest::InitIsolateOnce(); | 459 Isolate* i_isolate = CcTest::InitIsolateOnce(); |
460 v8::WasmModuleObjectBuilder builder(CcTest::isolate()); | 460 v8::WasmModuleObjectBuilder builder(CcTest::isolate()); |
461 std::unique_ptr<const uint8_t[]> first_part = | 461 std::unique_ptr<const uint8_t[]> first_part = |
462 CreatePayload(buffer.begin(), first_mark); | 462 CreatePayload(buffer.begin(), first_mark); |
463 std::unique_ptr<const uint8_t[]> second_part = | 463 std::unique_ptr<const uint8_t[]> second_part = |
464 CreatePayload(buffer.begin() + first_mark, second_mark - first_mark); | 464 CreatePayload(buffer.begin() + first_mark, second_mark - first_mark); |
465 std::unique_ptr<const uint8_t[]> third_part = | 465 std::unique_ptr<const uint8_t[]> third_part = |
466 CreatePayload(buffer.begin() + second_mark, buffer.size() - second_mark); | 466 CreatePayload(buffer.begin() + second_mark, buffer.size() - second_mark); |
467 builder.OnBytesReceived(std::move(first_part), first_mark); | 467 builder.OnBytesReceived(first_part.get(), first_mark); |
468 builder.OnBytesReceived(std::move(second_part), second_mark - first_mark); | 468 builder.OnBytesReceived(second_part.get(), second_mark - first_mark); |
469 builder.OnBytesReceived(std::move(third_part), buffer.size() - second_mark); | 469 builder.OnBytesReceived(third_part.get(), buffer.size() - second_mark); |
470 { | 470 { |
471 HandleScope scope(i_isolate); | 471 HandleScope scope(i_isolate); |
472 v8::MaybeLocal<v8::WasmCompiledModule> maybe_module = builder.Finish(); | 472 v8::MaybeLocal<v8::WasmCompiledModule> maybe_module = builder.Finish(); |
473 CHECK(!maybe_module.IsEmpty()); | 473 CHECK(!maybe_module.IsEmpty()); |
474 } | 474 } |
475 } | 475 } |
476 | 476 |
477 TEST(FailingModuleBuilder) { | 477 TEST(FailingModuleBuilder) { |
478 v8::internal::AccountingAllocator allocator; | 478 v8::internal::AccountingAllocator allocator; |
479 Zone zone(&allocator, ZONE_NAME); | 479 Zone zone(&allocator, ZONE_NAME); |
480 ZoneBuffer buffer(&zone); | 480 ZoneBuffer buffer(&zone); |
481 WasmSerializationTest::BuildWireBytes(&zone, &buffer); | 481 WasmSerializationTest::BuildWireBytes(&zone, &buffer); |
482 CHECK_GT(buffer.size(), 0); | 482 CHECK_GT(buffer.size(), 0); |
483 size_t third = buffer.size() / 3; | 483 size_t third = buffer.size() / 3; |
484 size_t first_mark = third - 2; | 484 size_t first_mark = third - 2; |
485 size_t second_mark = buffer.size() - 2 - third; | 485 size_t second_mark = buffer.size() - 2 - third; |
486 CHECK(0 < first_mark); | 486 CHECK(0 < first_mark); |
487 CHECK(first_mark < second_mark); | 487 CHECK(first_mark < second_mark); |
488 CHECK(second_mark < buffer.size()); | 488 CHECK(second_mark < buffer.size()); |
489 Isolate* i_isolate = CcTest::InitIsolateOnce(); | 489 Isolate* i_isolate = CcTest::InitIsolateOnce(); |
490 v8::WasmModuleObjectBuilder builder(CcTest::isolate()); | 490 v8::WasmModuleObjectBuilder builder(CcTest::isolate()); |
491 std::unique_ptr<const uint8_t[]> first_part = | 491 std::unique_ptr<const uint8_t[]> first_part = |
492 CreatePayload(buffer.begin(), first_mark); | 492 CreatePayload(buffer.begin(), first_mark); |
493 builder.OnBytesReceived(std::move(first_part), first_mark); | 493 builder.OnBytesReceived(first_part.get(), first_mark); |
494 { | 494 { |
495 HandleScope scope(i_isolate); | 495 HandleScope scope(i_isolate); |
496 v8::MaybeLocal<v8::WasmCompiledModule> maybe_module = builder.Finish(); | 496 v8::MaybeLocal<v8::WasmCompiledModule> maybe_module = builder.Finish(); |
497 CHECK(maybe_module.IsEmpty()); | 497 CHECK(maybe_module.IsEmpty()); |
498 } | 498 } |
499 } | 499 } |
500 | 500 |
501 bool False(v8::Local<v8::Context> context) { return false; } | 501 bool False(v8::Local<v8::Context> context) { return false; } |
502 | 502 |
503 TEST(BlockWasmCodeGen) { | 503 TEST(BlockWasmCodeGen) { |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 ModuleOrigin::kWasmOrigin); | 1126 ModuleOrigin::kWasmOrigin); |
1127 CHECK_EQ(kExpectedValue, result); | 1127 CHECK_EQ(kExpectedValue, result); |
1128 // Free the buffer as the tracker does not know about it. | 1128 // Free the buffer as the tracker does not know about it. |
1129 if (!memory->has_guard_region()) { | 1129 if (!memory->has_guard_region()) { |
1130 isolate->array_buffer_allocator()->Free( | 1130 isolate->array_buffer_allocator()->Free( |
1131 memory->backing_store(), NumberToSize(memory->byte_length())); | 1131 memory->backing_store(), NumberToSize(memory->byte_length())); |
1132 } | 1132 } |
1133 } | 1133 } |
1134 Cleanup(); | 1134 Cleanup(); |
1135 } | 1135 } |
OLD | NEW |