Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle remotables vs presences in weak collections #3142

Merged
merged 1 commit into from
May 21, 2021

Conversation

FUDCo
Copy link
Contributor

@FUDCo FUDCo commented May 20, 2021

closes #3115

@FUDCo FUDCo added enhancement New feature or request SwingSet package: SwingSet labels May 20, 2021
@FUDCo FUDCo requested a review from warner May 20, 2021 22:39
@FUDCo FUDCo self-assigned this May 20, 2021
@FUDCo FUDCo force-pushed the 3115-weak-collection-enhancements branch from 4af2ae4 to 69c5c61 Compare May 20, 2021 22:39
@FUDCo FUDCo force-pushed the 3115-weak-collection-enhancements branch from 69c5c61 to d033227 Compare May 20, 2021 23:07
@FUDCo FUDCo requested a review from warner May 20, 2021 23:17
@FUDCo FUDCo enabled auto-merge May 20, 2021 23:18
@FUDCo FUDCo force-pushed the 3115-weak-collection-enhancements branch 2 times, most recently from 27ff1b0 to 41ffa2c Compare May 21, 2021 00:05
@@ -253,8 +263,8 @@ export function makeVirtualObjectManager(
function virtualObjectKey(key) {
const vobjID = valToSlot.get(key);
if (vobjID) {
const { type, virtual } = parseVatSlot(vobjID);
if (type === 'object' && virtual) {
const { type, virtual, allocatedByVat } = parseVatSlot(vobjID);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great for addressing #3115: keys which are Presences or Representatives use their vref as the index, keys which are Remotables (or any non-vref-bearing object) use the Object identity.

let memorableExportRemotable;
let memorableExportVirtualObject;
let memorableExportPromise;
let forgetableExportRemotable;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be even more explicit, you could put the forgetable ones inside the scope of prepareWeakMap, so they wouldn't even be in scope during probeWeakMap. Nulling them out is fine belt-and-suspenders. (I can imagine a JS engine following a different code path for "value fell out of scope" vs "value was explicitly overwritten", with conceivably different GC timing).

Copy link
Member

@warner warner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look good, with the proposed addition. I think we should remove the isExternallyHeld unless I've gotten myself confused. Remainder looks great.

@FUDCo FUDCo force-pushed the 3115-weak-collection-enhancements branch from 41ffa2c to e4a32a2 Compare May 21, 2021 06:35
@FUDCo FUDCo requested a review from warner May 21, 2021 06:36
Copy link
Member

@warner warner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New code looks good!

@FUDCo FUDCo merged commit 26ea09e into master May 21, 2021
@FUDCo FUDCo deleted the 3115-weak-collection-enhancements branch May 21, 2021 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request SwingSet package: SwingSet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

replacement WeakMap/WeakSet should not treat Remoteables specially
2 participants