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 "src/objects-inl.h" | |
12 #include "test/cctest/cctest.h" | |
13 #include "test/common/wasm/test-signatures.h" | |
14 | |
15 using namespace v8::base; | |
16 using namespace v8::internal; | |
17 | |
18 class DeleteRecorder { | |
19 public: | |
20 explicit DeleteRecorder(bool* deleted) : deleted_(deleted) { | |
21 *deleted_ = false; | |
22 } | |
23 ~DeleteRecorder() { *deleted_ = true; } | |
24 | |
25 private: | |
26 bool* deleted_; | |
27 }; | |
28 | |
29 TEST(ManagedCollect) { | |
30 Isolate* isolate = CcTest::InitIsolateOnce(); | |
31 bool deleted = false; | |
32 DeleteRecorder* d = new DeleteRecorder(&deleted); | |
33 | |
34 { | |
35 HandleScope scope(isolate); | |
36 auto handle = Managed<DeleteRecorder>::New(isolate, d); | |
37 USE(handle); | |
38 } | |
39 | |
40 CcTest::CollectAllAvailableGarbage(); | |
41 | |
42 CHECK(deleted); | |
43 } | |
44 | |
45 TEST(ManagedCollectNoDelete) { | |
46 Isolate* isolate = CcTest::InitIsolateOnce(); | |
47 bool deleted = false; | |
48 DeleteRecorder* d = new DeleteRecorder(&deleted); | |
49 | |
50 { | |
51 HandleScope scope(isolate); | |
52 auto handle = Managed<DeleteRecorder>::New(isolate, d, false); | |
53 USE(handle); | |
54 } | |
55 | |
56 CcTest::CollectAllAvailableGarbage(); | |
57 | |
58 CHECK(!deleted); | |
59 delete d; | |
60 } | |
OLD | NEW |