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-managed.cc

Issue 2409173005: [wasm] Add a Managed<T> wrapper class for allocating C++ classes that are deleted when the wrapper … (Closed)
Patch Set: [wasm] Add a Managed<T> wrapper class for allocating C++ classes that are garbage collected. Created 4 years, 2 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
« no previous file with comments | « test/cctest/cctest.gyp ('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
(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 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698