OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <stdint.h> |
| 6 #include <stdlib.h> |
| 7 #include <string.h> |
| 8 |
| 9 #include "src/wasm/managed.h" |
| 10 |
| 11 #include "test/cctest/cctest.h" |
| 12 #include "test/common/wasm/test-signatures.h" |
| 13 |
| 14 using namespace v8::base; |
| 15 using namespace v8::internal; |
| 16 |
| 17 class DeleteRecorder { |
| 18 public: |
| 19 explicit DeleteRecorder(bool* deleted) : deleted_(deleted) { |
| 20 *deleted_ = false; |
| 21 } |
| 22 ~DeleteRecorder() { *deleted_ = true; } |
| 23 |
| 24 private: |
| 25 bool* deleted_; |
| 26 }; |
| 27 |
| 28 TEST(ManagedCollect) { |
| 29 Isolate* isolate = CcTest::InitIsolateOnce(); |
| 30 bool deleted = false; |
| 31 DeleteRecorder* d = new DeleteRecorder(&deleted); |
| 32 |
| 33 { |
| 34 HandleScope scope(isolate); |
| 35 auto handle = Managed<DeleteRecorder>::New(isolate, d); |
| 36 USE(handle); |
| 37 } |
| 38 |
| 39 CcTest::CollectAllAvailableGarbage(); |
| 40 |
| 41 CHECK(deleted); |
| 42 } |
| 43 |
| 44 TEST(ManagedCollectNoDelete) { |
| 45 Isolate* isolate = CcTest::InitIsolateOnce(); |
| 46 bool deleted = false; |
| 47 DeleteRecorder* d = new DeleteRecorder(&deleted); |
| 48 |
| 49 { |
| 50 HandleScope scope(isolate); |
| 51 auto handle = Managed<DeleteRecorder>::New(isolate, d, false); |
| 52 USE(handle); |
| 53 } |
| 54 |
| 55 CcTest::CollectAllAvailableGarbage(); |
| 56 |
| 57 CHECK(!deleted); |
| 58 delete d; |
| 59 } |
OLD | NEW |