Commit Graph

82 Commits

Author SHA1 Message Date
Michael Lippautz
86b458396f cppgc: Pass on source location when tracing roots
Bug: chromium:1056170
Change-Id: Ib03a09db010f3ad06701520fc39e7e83055dbb9e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2467855
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70515}
2020-10-14 20:39:02 +00:00
Omer Katz
8ac2d54aa2 cppgc: Add bailout for concurrent marking
Tracing JSMembers uses the bailout mechanism.
The bailout is implemented as a dynamic mechanism named
DeferTraceToMutatorThreadIfConcurrent that is called from
relevant Trace methods.

Bug: chromium:1056170
Change-Id: I90e6feae25c4c832be256693f9e44a963a6794b7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2426613
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70429}
2020-10-09 15:04:32 +00:00
Michael Lippautz
4569ffae0b Migrate CrossThreadPersistent
Adds a cross-thread reference for strongly and weakly retaining
objects on a thread other than the thread that owns the object.

The intended use of the reference is by setting it up on the
originating thread, holding the object alive from another thread, and
ultimately accessing the object again on the originating thread.

The reference has known caveats:
- It's unsafe to use when the heap may terminate;
- It's unsafe to transitively reach through the graph because of
  compaction;

Change-Id: I84fbdde69a099eb54af5b93c34e2169915b17e64
Bug: chromium:1056170
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2436449
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70428}
2020-10-09 14:33:57 +00:00
Michael Lippautz
d3e8c837eb cppgc: Fix compile-time typename for release builds
Bug: chromium:1056170
Change-Id: I3320a0b8c740067ea1e424c37ae8db4e87753c1a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2461738
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70419}
2020-10-09 09:33:02 +00:00
Anton Bikineev
d21c89bb4a cppgc: Support compile-time typename computation
Bug: chromium:1056170
Change-Id: If4d4d08b4a50312b7a3cd1d11bb2cccc2272c96b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2461733
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70414}
2020-10-08 20:58:52 +00:00
Omer Katz
0b96f711cb cppgc: Provide TraceTraitBase that users can inherit from
The TraceTrait for JSMember is currently missing GetTraceDescriptor.
We missed it because we don't have proper tests for JSMember, but it
would fail to build if it was ever actually traced.

Bug: chromium:1056170
Change-Id: I45fd2c7c666e791f866813f762b488958f65f3cf
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2460815
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70413}
2020-10-08 19:22:21 +00:00
Omer Katz
65bec1aa79 cppgc: Use libplatform as default platform
Bug: chromium:1056170
Change-Id: I4214978f31ae754e4940dfca4182ada202d17c01
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2456688
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70412}
2020-10-08 18:16:52 +00:00
Michael Lippautz
f50c64bdfe cppgc: Add naming infrastructure
Adds NameProvider to allow specifying names of objects. The
corresponding internal NameTrait is registered with the GCInfo object.

Use name infrastructure to provide a hint on encountering an unmarked
object in the marking verifier.

Bug: chromium:1056170
Change-Id: I95bb290660f5905500f861bd5cc85148a1b47184
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2454087
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70400}
2020-10-08 12:25:21 +00:00
Omer Katz
4d5ab15dc4 cppgc: Mark custom spaces as compactable
To support compaction of backing stores in blink, we need to distinguish
custom spaces holding backing stores from other custom spaces.
Custom space compactablity is explicitly declared as an enum value and
propagated to BaseSpace as a bool flag.

Note that even if/when general compaction is implemented/enabled for
normal pages we will still need such a marking for supporting
non-compactable custom spaces.

Bug: v8:10990
Change-Id: I165a0268ded121e91399834a4091e88e57f2565c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2449973
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70345}
2020-10-06 14:59:22 +00:00
Michael Lippautz
20e1ba2808 cppgc: Move ProcessWeakness into FinishMarking
For cross-thread handling we require the atomic marking pause to
provide an atomically consistent view of markbits and weak references.
This is ensured by locking the whole atomic pause from entering to
weak processing.

This CL move ProcessWeakness() into FinishMarking() which allows to
nicely scope the upcomming lock from EnterAtomicPause() to
LeaveAtomicPause(). The alternative is requiring the caller to ensure
proper locking which is harder than ensuring that the Marker is
consistent.

Bug: chromium:1056170
Change-Id: Ib6028a0d76fcf9422c4a0d422fec3d568f106bf2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2442620
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70259}
2020-10-01 14:57:31 +00:00
Omer Katz
905318c724 Reland "cppgc: Provide jobs support through DefaultPlatform and TestPlatform"
This reverts commit 2221f0909b.

Reason for revert: fix in patchset 2

Original change's description:
> Revert "cppgc: Provide jobs support through DefaultPlatform and TestPlatform"
>
> This reverts commit 22c0fc8f2e.
>
> Reason for revert: https://ci.chromium.org/p/v8/builders/ci/V8%20Linux%20gcc/8712?
>
> Original change's description:
> > cppgc: Provide jobs support through DefaultPlatform and TestPlatform
> >
> > This CL extends cppgc::DefaultPlatform and TestPlatform to emulate
> > jobs using std::thread and v8::base::Thread respectively.
> > Jobs using these platform do not yield unless the job as been
> > cancelled. Additionally, the job priority is ignored.
> >
> > Bug: chromium:1056170
> > Change-Id: I72db1eef410d2be3d3e5ea7d4ece9e5584a451f2
> > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2416378
> > Commit-Queue: Omer Katz <omerkatz@chromium.org>
> > Reviewed-by: Anton Bikineev <bikineev@chromium.org>
> > Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#70139}
>
> TBR=mlippautz@chromium.org,bikineev@chromium.org,omerkatz@chromium.org
>
> Change-Id: Ic29235e3ab78a1b515a5b14b808e116a1ccffc0f
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:1056170
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2432087
> Reviewed-by: Francis McCabe <fgm@chromium.org>
> Commit-Queue: Francis McCabe <fgm@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#70142}

# Not skipping CQ checks because this is a reland.

Bug: chromium:1056170
Change-Id: Iaa8312da759ab97f646a9fb6144462a115393b5f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2431666
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70150}
2020-09-28 09:07:25 +00:00
Francis McCabe
2221f0909b Revert "cppgc: Provide jobs support through DefaultPlatform and TestPlatform"
This reverts commit 22c0fc8f2e.

Reason for revert: https://ci.chromium.org/p/v8/builders/ci/V8%20Linux%20gcc/8712?

Original change's description:
> cppgc: Provide jobs support through DefaultPlatform and TestPlatform
>
> This CL extends cppgc::DefaultPlatform and TestPlatform to emulate
> jobs using std::thread and v8::base::Thread respectively.
> Jobs using these platform do not yield unless the job as been
> cancelled. Additionally, the job priority is ignored.
>
> Bug: chromium:1056170
> Change-Id: I72db1eef410d2be3d3e5ea7d4ece9e5584a451f2
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2416378
> Commit-Queue: Omer Katz <omerkatz@chromium.org>
> Reviewed-by: Anton Bikineev <bikineev@chromium.org>
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#70139}

TBR=mlippautz@chromium.org,bikineev@chromium.org,omerkatz@chromium.org

Change-Id: Ic29235e3ab78a1b515a5b14b808e116a1ccffc0f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1056170
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2432087
Reviewed-by: Francis McCabe <fgm@chromium.org>
Commit-Queue: Francis McCabe <fgm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70142}
2020-09-25 17:51:10 +00:00
Omer Katz
22c0fc8f2e cppgc: Provide jobs support through DefaultPlatform and TestPlatform
This CL extends cppgc::DefaultPlatform and TestPlatform to emulate
jobs using std::thread and v8::base::Thread respectively.
Jobs using these platform do not yield unless the job as been
cancelled. Additionally, the job priority is ignored.

Bug: chromium:1056170
Change-Id: I72db1eef410d2be3d3e5ea7d4ece9e5584a451f2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2416378
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70139}
2020-09-25 17:47:08 +00:00
Omer Katz
58ca454f51 cppgc: Support incremental marking without non-nested tasks
For the standalone library, some platform implementations might not
support non-nested tasks. We can still offer incremental marking in
such cases using regular tasks and without assuming an empty stack.
(cppgc's default platform e.g. doesn't support non-nested tasks.)

This CL also updates GCInvoker to not trigger an incremental GC if we
won't be able to finalize it. That makes finalizing through an
non-nested incremental task safe.

Bug: chromium:1056170
Change-Id: I85f0c9f2efe643cb87dd65d80417eea0d6ee5d52
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2414217
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69971}
2020-09-17 12:07:17 +00:00
Michael Lippautz
42d2cd757d cppgc: Typo and signature fix
Change-Id: I4e2a0ddbeba68a4cc136bb6d56383b0a7e4f1dff
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2388107
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69661}
2020-09-02 07:34:20 +00:00
Anton Bikineev
c316d0ede4 cppgc: Nullify source Members on move
Explicit nullification aims to simplify migration to Oilpan, in the
case when unique_ptrs are converted to Member and user code relies on
source pointers to be in "empty" state.

Change-Id: Ia54137d53ca03f93932b3c1f2eaba439a416a06e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2379857
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Auto-Submit: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69603}
2020-08-28 10:38:36 +00:00
Omer Katz
1227c465c8 cppgc: Make bikineev and omerkatz owners of include/cppgc
Bug: chromium:1056170
Change-Id: I2e0947c5acfd110f0add7ae5b4e3e54e3c827478
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2379864
Auto-Submit: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69599}
2020-08-28 08:05:30 +00:00
Omer Katz
ed2c70704f cppgc: Use full qualifier in prefinalizer macro.
Pdfium folks can't build pre-finalizers due to the missing qualifier.

Bug: chromium:1056170
Change-Id: Ib90859880e845c714c52f10ee50841ac46bcb0ef
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2339477
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Auto-Submit: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69254}
2020-08-05 15:50:07 +00:00
Anton Bikineev
e68ff8e2ea cppgc: Add DefaultPlatform and standalone sample
Standalone sample doesn't use libplatform for default platform
implementation. This is needed for Oilpan GitHub mirror, which won't
contain libplatform.

Bug: v8:10724
Change-Id: I2e20ad157263a5073d0ba9ae8a2e211b2fcb35ed
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2310362
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69016}
2020-07-23 09:54:32 +00:00
Omer Katz
ab2b18e1be cppgc: Use object start bitmap to trace mixins
This CL removes the GetTraceDescriptor virtual call from garbage
collected mixins and replaces it with querying the object start
bitmap.

The CL also removes the mixin macros which are now no longer needed.

Bug: chromium:1056170
Change-Id: I27ed299f93025d09a3bb3f0d17b14bed3c200565
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2287508
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68787}
2020-07-10 12:00:45 +00:00
Michael Lippautz
3a50eae048 api: Add JSVisitor and JSMember reference
- Adds JSVisitor that is used for unified heap marking.
- Adds JSMember as supported reference type that also encapsulates a
  write barrier in future. JSMember is a replacement for
  TracedReference which can be deprecated with EmbedderHeapTracer once
  the library is used to handle unified heap collections.

The dispatch for v8::JSMember on cppgc::Visitor is provided through a
specialization of TraceTrait.

Bug: chromium:1056170
Change-Id: I60d976ae66db3e5fa2e690a21627bdcb8c6871af
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2284488
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68716}
2020-07-07 13:48:31 +00:00
Michael Lippautz
9c362b0045 cppgc: Various cleanups
- Cleanup includes, fix typo, fix qualifiers.
- Fix getter names of MarkerBase when only exposed for testing.

Bug: chromium:1056170
Change-Id: Ibcb0f62414c9c865fa98e6d2b2c9b150aa2a361f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2281004
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68678}
2020-07-03 20:42:48 +00:00
Michael Lippautz
448907a30b cppgc: Refactor visitation 2/3
Split off ConservativeMarkingVisitor from MarkingVisitor.

After this change, MarkingVisitor and ConservativeMarkingVisitor are
types that are instantiated with Marking and merely forward to
MarkingState accrodingly. The two marking-related visitors can be
passed along as interface types cppgc::Visitor and
ConservativeTracingVisitor, respectively.

Change-Id: Iad103dc3053c61d1a104a8802edd420d21cdf935
Bug: chromium:1056170
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2270538
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68661}
2020-07-02 15:56:09 +00:00
Michael Lippautz
a938481070 cppgc: Remove NOLINT(runtime/references)
Mutable references are allowed by the style guide and the linter has
been adjusted.

Bug: v8:10624, chromium:1056170
Change-Id: I8a7dc06da5758f5c714a5e61d75378c2a13ffb9b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2252192
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68455}
2020-06-22 10:08:55 +00:00
Michael Lippautz
8bdce52713 Reland "cppgc: Properly clear (Weak)Peristent and WeakMember pointers"
This is a reland of e0c1a349ea

The issue was passing SentinelPointer (== +1) through T*.

The fix is disabling cfi unrelated cast diagnostic for the bottlenecks
(Get()). This means that nullptr is treated the same as
kSentinelPointer.

The alternative would be a DCHECK that Get() does not return
kSentinelPointer and adjusting all Member and Persistent logic that
uses Get() to work on void*. This is quite intrusive as it involves
Swap(), heterogeneous assignments, comparisons, etc.

Original change's description:
> cppgc: Properly clear (Weak)Peristent and WeakMember pointers
>
> The CL addresses two issues with (Weak)Persistent and WeakMember:
> 1. (Weak)Persistent pointers are cleared on heap teardown. Before this
>    CL the pointers would contain stale values which could lead to UAF.
> 2. WeakPersistent and WeakMember are cleared using a combination of
>    internal clearing methods and mutable fields which avoids the use
>    of const_cast<>.
>
> Bug: chromium:1056170
> Change-Id: Ibf2b0f0856771b4f6906608cde13a6d43ebf81f3
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2248190
> Reviewed-by: Omer Katz <omerkatz@chromium.org>
> Reviewed-by: Anton Bikineev <bikineev@chromium.org>
> Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#68394}

Bug: chromium:1056170
Change-Id: I3d74b43464c2973df1956f51b1419d755dd9f519
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2250240
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68426}
2020-06-19 08:48:49 +00:00
Zhi An Ng
8a27d9f93e Revert "cppgc: Properly clear (Weak)Peristent and WeakMember pointers"
This reverts commit e0c1a349ea.

Reason for revert: Fails on Linux 64 cfi https://ci.chromium.org/p/v8/builders/ci/V8%20Linux64%20-%20cfi/25283?

TBR=omerkatz@chromium.org,mlippautz@chromium.org,bikineev@chromium.org,bikineev@chromium.org

Change-Id: I2b208c4019979735925bff5e0551291fae6a14d6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2250320
Reviewed-by: Zhi An Ng <zhin@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68396}
2020-06-17 18:20:46 +00:00
Michael Lippautz
e0c1a349ea cppgc: Properly clear (Weak)Peristent and WeakMember pointers
The CL addresses two issues with (Weak)Persistent and WeakMember:
1. (Weak)Persistent pointers are cleared on heap teardown. Before this
   CL the pointers would contain stale values which could lead to UAF.
2. WeakPersistent and WeakMember are cleared using a combination of
   internal clearing methods and mutable fields which avoids the use
   of const_cast<>.

Bug: chromium:1056170
Change-Id: Ibf2b0f0856771b4f6906608cde13a6d43ebf81f3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2248190
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68394}
2020-06-17 17:00:38 +00:00
Anton Bikineev
5785d98b4b cppgc: Add initial implementation of young generation
This adds the following things:
- age table for 4K regions;
- generational barrier for mixed 4K regions;
- unmarking for major collections;
- young generation flags.

Bug: chromium:1029379
Change-Id: Ief1229f0dac5f90c5f06d3168c8ffb4b7d1f1b53
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2246566
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68379}
2020-06-17 06:48:10 +00:00
Anton Bikineev
3a929dfa1c cppgc: Move caged heap into a separate class
This also introduces CagedHeapLocalData.

Bug: chromium:1029379
Change-Id: Ice04fe5ad7daa02f17ad107e78e53bdd32479737
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2246560
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68358}
2020-06-16 09:58:19 +00:00
Michael Lippautz
2f8c30ef69 cppgc: Various trivial fixes
- Document internal namespace
- Various trivial fixes

Bug: chromium:1056170
Change-Id: If527d491a37d7ccd0aa4ff829ccc5dc06c02da38
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2246569
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68349}
2020-06-15 18:25:51 +00:00
Michael Lippautz
154627bff4 cppgc: Rework pre-finalizer registration
Since the registration requires calling into the library, there's no
reason to get the heap through a magic getter on API level.

Bug: chromium:1056170
Change-Id: I8d2b1d0fcee8c855908bd26c71a22826c493ed29
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2238568
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68315}
2020-06-11 20:12:21 +00:00
Michael Lippautz
935d915186 cppgc: Introduce AllocationHandle
Unified heap support in V8 requires having another (at least internal)
heap that implements a unfied garbage collection strategy. This will
not re-use the already existing cppgc::Heap because there should be no
way in creating such a heap externally or scheduling stand-alone
garbage collections.

In order to have a common token, this CL introduces AllocationHandle
which can be passed to MakeGarbageCollected to allocate C++ objects.
V8 (soon) and the stand-alone heap both have methods to retrieve such
a handle.

This works around a problem with creating diamond class hierarchies
when a base class would be exposed on the public API level.

Fast paths for Blink are still possible because allocation handles can
be cached the same way (e.g. global, or TLS) as a heap can be cached.

Tbr: yangguo@chromium.org
Bug: chromium:1056170
Change-Id: I8e9472a2c24ef82d1178953e8429b1fd8a2344bc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2238027
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68310}
2020-06-10 23:11:20 +00:00
Michael Lippautz
a3c0bc572a cppgc: Adds docs to SourceLocation
Bug: chromium:1056170
Change-Id: I89d0fbe6b73bf1b8765bb532fff58b1960fed09a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2235537
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68236}
2020-06-08 18:31:36 +00:00
Michael Lippautz
c9d7b23658 cppgc: Add basic heap growing strategy
Adds allocation-based heap growing strategy that triggers GC based on
some limit. The limit is computed based on previous live memory and a
constant growing factor.

For invoking GC, we support two modes: with and without conservative
stack scanning. Without conservative stack scanning, an invoker makes
sure that we schedule a GC without stack using the existing platform.

Bug: chromium:1056170
Change-Id: I1808aeb5806a6ddd5501b556d6b6b129a85b9cda
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2228887
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68235}
2020-06-08 17:55:53 +00:00
Michael Lippautz
5273aac4c8 cppgc: Another round of docs
Document:
- Visitor

Bug: chromium:1056170
Change-Id: Icc0037befa73f043fcbf14ff4ff89be8b8940ee4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2235696
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68233}
2020-06-08 17:22:48 +00:00
Michael Lippautz
1ea90d478f cppgc: Another round of API docs
Document:
- TraceCallback
- TraceDescriptor
- TraceTrait

Bug: chromium:1056170
Change-Id: I1c57ce215e4f6f83563326924cfc4c6aeef33e41
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2235112
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68225}
2020-06-08 13:06:22 +00:00
Anton Bikineev
ad54f1bb17 cppgc: Add write barrier
This moves from Blink:
1) implementation of the marking write barrier;
2) WriteBarrierWorklist to Marker;
3) incremental/concurrent marking options.

Bug: chromium:1056170
Change-Id: Ia3e31ffd920a99803420b1453695fe2fb8d843b8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2218064
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68108}
2020-06-02 18:03:35 +00:00
Michael Lippautz
3d53d7acad cppgc: Rely on per-heap platform objects
Split platform into a process-global initialization part and per-heap
platform objects.

These platform objects still contain allocators and executors. With
per-heap platforms GetForegroundTaskRunner() returns by definition the
correct runner.

In future, when initialized throuhg V8, an adapter can be used to
translate between the different platforms, avoiding the needed for V8
embedders to provide additional information.

Bug: chromium:1056170
Change-Id: I11bdd15e945687cfbdf38cae4137facb02559e0a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2218030
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68059}
2020-05-28 20:29:55 +00:00
Michael Lippautz
44143cfd14 cppgc: Add some more API documentation
Add docs for:
- cppgc namespace (to have doxygen generate the namespace doc)
- Heap
- LivenessBroker

Bug: chromium:1056170
Change-Id: I5e4664458b7209f4adebb4d5e7b5119c341f59a9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2214834
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68015}
2020-05-27 14:09:11 +00:00
Anton Bikineev
09f082f233 Reland "cppgc: Port concurrent sweeper"
This reverts commit a35d0e8cb5.

The original CL is likely not a culprit for the infra failures.

Bug: chromium:1056170
Change-Id: I8fa85db8a737fb01328021782f0c43626fa52b0d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2215826
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67977}
2020-05-26 15:40:53 +00:00
Maya Lekova
a35d0e8cb5 Revert "cppgc: Port concurrent sweeper"
This reverts commit 9a0e6bd5c0.

Reason for revert: Speculative revert for https://ci.chromium.org/p/v8/builders/ci/V8%20Linux64%20-%20builder/47777

Original change's description:
> cppgc: Port concurrent sweeper
> 
> This moves concurrent and incremental sweeping from Blink. This also
> adds TestPlatform that makes it easier to test concurrent and
> incremental sweeping.
> 
> Drive-by: fix unmarking of large pages.
> 
> Bug: chromium:1056170
> Change-Id: Ifd50ff67b9df17ff117a5f4d4eb5a2937d3023be
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2207132
> Commit-Queue: Anton Bikineev <bikineev@chromium.org>
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Omer Katz <omerkatz@chromium.org>
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#67969}

TBR=ulan@chromium.org,mlippautz@chromium.org,bikineev@chromium.org,omerkatz@chromium.org

Change-Id: I5530f11f7b8560116324bb156ba98e426c0feb35
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1056170
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2215057
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67970}
2020-05-26 14:27:40 +00:00
Anton Bikineev
9a0e6bd5c0 cppgc: Port concurrent sweeper
This moves concurrent and incremental sweeping from Blink. This also
adds TestPlatform that makes it easier to test concurrent and
incremental sweeping.

Drive-by: fix unmarking of large pages.

Bug: chromium:1056170
Change-Id: Ifd50ff67b9df17ff117a5f4d4eb5a2937d3023be
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2207132
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67969}
2020-05-26 14:14:38 +00:00
Michael Lippautz
1d26770085 cppgc: Add composite object tracing to Visitor
This allows embedding objects in each other and recursively trace
through them.

Bug: chromium:1056170
Change-Id: I4e4ae4c1669109c01003cb6b69797cf271a74033
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2198977
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67841}
2020-05-15 21:09:15 +00:00
Omer Katz
288b545ad0 cppgc: Add TraceCallback to GCInfo
This is needed to trace objects found durinbg stack scanning.

Bug: chromium:1056170
Change-Id: I1280d98f2fe69281c514b3a7d4a57f909a2eed96
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2190425
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67788}
2020-05-13 23:53:43 +00:00
Michael Lippautz
81290c4851 cppgc: Use static_assert to force semi colon after macro
Bug: chromium:1056170
Change-Id: I1b6787ecea6ad58173a0bcc8e8d0862a5b19d299
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2199342
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67784}
2020-05-13 21:47:48 +00:00
Omer Katz
fff219bff7 heap,cppgc: Update StackState enum values
This CL adds 2 new values to the EmbedderStackState enum with more
explicit names. The old values are updated as aliases to the new
values and marked as soon to be deprecated. This CL also moves the
enum to v8-platform.h so that it can be reused by cppgc.

Depracating individual values in an enum is supported by GCC only
since version 6. Thus new macros were needed for the deprecation
(which delegate to the existing macros when supported). GCC versions
older than 6 are still used by the CQ bots.

Bug: chromium:1056170
Change-Id: Id1ea73edfbbae282b0d8a3bb103dbbbf8ebd417e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2188971
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67744}
2020-05-12 12:07:27 +00:00
Michael Lippautz
d65ea662c5 cppgc: Allocation cleanups
Bug: chromium:1056170
Change-Id: I99d073e268f5779f0985d6197432c50036060b60
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2192663
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67713}
2020-05-11 15:50:28 +00:00
Michael Lippautz
80a63bd9e5 cppgc: Fix typo in docs
Bug: chromium:1056170
Change-Id: I0854b9b144ad47dc7ea0b16862fea1583aec7402
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2190416
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67676}
2020-05-08 11:11:18 +00:00
Michael Lippautz
611d1bb9a8 cppgc: Implement allocation on custom spaces
This patch provides infrastructure to pin object types to specific
spaces. This allows embedders to create mutual exclusive arenas for
certain (base) types. In future, this will also be used to provide
sliding-window compaction on certain custom spaces.

We mainly preserve the existing infrastructure with the difference
that spaces are now slightly more dynamic than in Blink as they are
kept in a vector instead of a fixed-size array.

The mechanism differs from Blink in that it does not allow the user
object to call allocation methods directly but instead provides a
trait that can be overridden to specify a custom space.

The patch preserves templatization for objects that do not go into
custom spaces to safe a branch in the allocation hot path.

Change-Id: I08aa6932348e2d6258e19c4a32d189865f459f02
Bug: chromium:1056170
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2187611
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67666}
2020-05-08 07:20:49 +00:00
Omer Katz
f197fd2731 Reland "cppgc: Initial marking loop"
This reverts commit dc1af6a219.

Reason for revert: Diff in patchset 2

Original change's description:
> Revert "cppgc: Initial marking loop"
> 
> This reverts commit fb9a19fe0d.
> 
> Reason for revert: https://ci.chromium.org/p/v8/builders/ci/V8%20Linux64%20UBSan/11028
> 
> Original change's description:
> > cppgc: Initial marking loop
> > 
> > This CL introduces:
> > - Worklist
> > - MarkingHandler to manage gc marking phase
> > - Integration into CollectGarbage for atomic pause GC
> > - MarkingVisitor for main thread marking
> > 
> > Still missing from this CL:
> > - Proper handling for stack scanning
> > - Handling of previously not fully constructed objects
> > 
> > Bug: chromium:1056170
> > Change-Id: I70ac8534dfb898777cf3a06e3119cac8072174fd
> > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2170526
> > Commit-Queue: Omer Katz <omerkatz@chromium.org>
> > Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#67642}
> 
> TBR=ulan@chromium.org,mlippautz@chromium.org,bikineev@chromium.org,omerkatz@chromium.org
> 
> Change-Id: I666481f44119771be685bf2555aa0dd5eda83a01
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:1056170
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2187502
> Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
> Commit-Queue: Nico Hartmann <nicohartmann@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#67643}

TBR=ulan@chromium.org,mlippautz@chromium.org,bikineev@chromium.org,omerkatz@chromium.org,nicohartmann@chromium.org

# Not skipping CQ checks because this is a reland.

Bug: chromium:1056170
Change-Id: I54e963e2aeaaf16069bdcdb019c0ac65e28ef6e2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2187733
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67654}
2020-05-07 16:12:24 +00:00