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

Side by Side Diff: test/cctest/wasm/test-managed.cc

Issue 2676513008: [wasm] Managed<T> ensures T's lifetime does not leak past Isolate's (Closed)
Patch Set: renamed to ManagedObjectFinalizer, and using "finalizer"` Created 3 years, 10 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/test-managed.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | 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 "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 }
OLDNEW
« no previous file with comments | « test/cctest/test-managed.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698