Skip to content

Commit

Permalink
feat: @W-12147195 don't Object.freeze from proxy handlers (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton authored Dec 1, 2022
1 parent 59def82 commit 3a4af4f
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions packages/near-membrane-base/src/membrane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2534,9 +2534,6 @@ export function createMembraneMarshall(
this.setPrototypeOf = BoundaryProxyHandler.defaultSetPrototypeOfTrap;
this.set = BoundaryProxyHandler.defaultSetTrap;
if (foreignTargetTraits & TargetTraits.Revoked) {
// Future optimization: Hoping proxies with frozen handlers
// can be faster.
ObjectFreeze(this);
this.revoke();
} else if (IS_IN_SHADOW_REALM) {
if (
Expand Down Expand Up @@ -2573,11 +2570,6 @@ export function createMembraneMarshall(
},
]);
}
// Future optimization: Hoping proxies with frozen handlers
// can be faster. If local mutations are not trapped, then
// freezing the handler is ok because it is not expecting to
// change in the future.
ObjectFreeze(this);
}
}

Expand All @@ -2591,9 +2583,6 @@ export function createMembraneMarshall(
this.preventExtensions = BoundaryProxyHandler.passthruPreventExtensionsTrap;
this.set = BoundaryProxyHandler.passthruSetTrap;
this.setPrototypeOf = BoundaryProxyHandler.passthruSetPrototypeOfTrap;
// Future optimization: Hoping proxies with frozen handlers can
// be faster.
ObjectFreeze(this);
}

private makeProxyStatic() {
Expand Down Expand Up @@ -2622,9 +2611,6 @@ export function createMembraneMarshall(
const targetIntegrityTraits =
foreignCallableGetTargetIntegrityTraits(foreignTargetPointer);
if (targetIntegrityTraits & TargetIntegrityTraits.Revoked) {
// Future optimization: Hoping proxies with frozen
// handlers can be faster.
ObjectFreeze(this);
// the target is a revoked proxy, in which case we revoke
// this proxy as well.
this.revoke();
Expand All @@ -2641,9 +2627,6 @@ export function createMembraneMarshall(
// We don't wrap `foreignCallableIsTargetRevoked()` in a
// try-catch because it cannot throw.
if (foreignCallableIsTargetRevoked(foreignTargetPointer)) {
// Future optimization: Hoping proxies with frozen
// handlers can be faster.
ObjectFreeze(this);
this.revoke();
return;
}
Expand Down Expand Up @@ -2679,9 +2662,6 @@ export function createMembraneMarshall(
);
}
}
// Future optimization: Hoping proxies with frozen handlers can
// be faster.
ObjectFreeze(this);
}

// Logic implementation of all traps.
Expand Down Expand Up @@ -4851,8 +4831,6 @@ export function createMembraneMarshall(
BoundaryProxyHandlerProto.color = color;
}
ReflectSetPrototypeOf(BoundaryProxyHandlerProto, null);
// Future optimization: Hoping proxies with frozen handlers can be faster.
ObjectFreeze(BoundaryProxyHandlerProto);
};
};
/* eslint-enable prefer-object-spread */
Expand Down

0 comments on commit 3a4af4f

Please sign in to comment.