dart-sdk/runtime
Ryan Macnak 31a1fd4b6b [vm, gc] Fix a bug handling WeakProperties under the combination of concurrent marking and write-barrier elimination.
The compiler will in certain cases eliminate write barriers and the runtime will compensate by adding certain objects to a deferred marking stack. These objects will be revisited when marking is finalized. There is no header bit indicating an object has already been added to the deferred marking stack. The same object may be seen by markers multiple times: once as part of ordinary marking and several times as part of deferred marking.

When visiting a WeakProperty, if the fate of its key is not yet known, it is placed in a (worker-local) delayed weak properties list, which is a linked list threaded through the WeakProperties themselves. If more than one worker adds the same WeakProperty to its list, or a single worker does so multiple times, the lists will be corrupted. A previous fix (40cd5fc5f6) attempted to avoid this by ensuring only the worker which marked the WeakProperty would add it to a delayed weak properties list, but this can result in no worker adding the WeakProperty if the WeakProperty is allocated marked and added to the deferred marking stack.

This CL changes the processing of the deferred marking stack to treat WeakProperties as strong references. This ensures a WeakProperty will only be added to a delayed weak properties list by the single worker that encounters it during ordinary marking. This is also very similar to what would happen if the write barrier had not been eliminated: the writes into the marked WeakProperty would cause the new key and value to also become marked.

This CL also fixes another bug where when processing the delayed weak properties lists, the worker would try to ask whether a new-space object was marked.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47128
Change-Id: Id9abaeb4dd52538ebc22ac58e48abcb7ed760854
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212612
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-09-08 17:40:19 +00:00
..
bin [vm] Remove support for dart-ext: imports 2021-09-02 14:14:35 +00:00
docs [vm] Migrate away from native 'name' syntax. 2021-09-08 13:39:34 +00:00
include [vm] Remove support for dart-ext: imports 2021-09-02 14:14:35 +00:00
lib [vm] If isolate group spawning fails, we need to enter the IG in order to delete the api state 2021-09-07 14:08:32 +00:00
observatory [gardening] Skip complex_reload_test 2021-09-07 20:05:14 +00:00
observatory_2 [gardening] Skip complex_reload_test 2021-09-07 20:05:14 +00:00
platform [vm] Remove support for dart-ext: imports 2021-09-02 14:14:35 +00:00
tests [vm, gc] Fix a bug handling WeakProperties under the combination of concurrent marking and write-barrier elimination. 2021-09-08 17:40:19 +00:00
third_party [tools] Update all iteritems -> items 2021-05-20 11:36:52 +00:00
tools [dartfuzz] Avoid more compile-time errors. 2021-08-31 23:11:26 +00:00
vm [vm, gc] Fix a bug handling WeakProperties under the combination of concurrent marking and write-barrier elimination. 2021-09-08 17:40:19 +00:00
.clang-tidy
.gitignore
BUILD.gn Allow deprecated copy on fuchsia 2021-08-11 01:14:22 +00:00
codereview.settings
configs.gni Reland "[vm] Build dart2native dependencies with the normal "create_sdk" target" 2020-06-17 16:12:26 +00:00
CPPLINT.cfg
PRESUBMIT.py [python3] Migrate PRESUBMIT.py files 2021-08-16 08:29:54 +00:00
runtime_args.gni [wasm] Remove deprecated dart_enable_wasm flag. 2021-04-01 22:45:07 +00:00