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

feat: perf work #230

Merged
merged 1 commit into from
Oct 27, 2021
Merged

feat: perf work #230

merged 1 commit into from
Oct 27, 2021

Conversation

jdalton
Copy link
Contributor

@jdalton jdalton commented Oct 26, 2021

A perf pass for low hanging things in near-membrane

@@ -134,7 +132,6 @@ export function tameDOM(
env.remap(blueRefs.window, globalDescriptors);
// remapping unforgeable objects
env.remap(blueRefs.EventTargetProto, blueRefs.EventTargetProtoDescriptors);
env.remap(blueRefs.WindowProto, blueRefs.WindowProtoDescriptors);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

☝️ This call to remap is a noop since WindowProtoDescriptors is an empty object and now removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

lol, I forgot that I have a branch with this change and the removal of record.WindowProtoDescriptors = {};. Glad to see it go!

args[i] = getLocalValue(listOfValuesOrPointers[i]);
// Inline `getLocalValue`.
const arg = listOfValuesOrPointers[i];
args[i] = typeof arg === 'function' ? arg() : arg;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

☝️ More inlining of code in apply and construct traps. Just easy reasonable inlining nothing overboard.

@@ -272,7 +274,9 @@ export function createMembraneMarshall() {
key,
callbackWithDescriptor
);
(descriptors as any)[key] = safeDesc!;
if (safeDesc!) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just because there is an own property doesn't mean getOwnPropertyDescriptor will return something. There's that WebKit bug Rick workaround. This is more of that.

Copy link
Contributor

Choose a reason for hiding this comment

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

does this means we can remove the unnecessary condition for undefined descriptors somewhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

does this means we can remove the unnecessary condition for undefined descriptors somewhere else?

No, the above is a guard that is needed for the bug case. Just because a property is an own property doesn't necessarily mean we will get a descriptor (in a perfect world, that made logical sense, we could trust that we would get a descriptor if an own property exists, but in this buggy world it is not guaranteed so the truthy guard is needed)

// Increasing to 20 as a baby step.
Error.stackTraceLimit *= 2;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👆 Moved that higher to avoid just setting it over and over and over.

None = 0,
MagicMarker = 1 << 0,
}
ReflectSetPrototypeOf(MarshallSupportFlagsField, null);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nulled the prototypes of our enums to avoid hasOwnProperty checks on them.

!ReflectApply(SetProtoHas, ESGlobalKeys, [key]) &&
!ReflectApply(ArrayProtoIncludes, ReflectiveIntrinsicObjectNames, [key])
) {
const unsafeDesc = ReflectGetOwnPropertyDescriptor(source, key);
// Safari 14.0.x (macOS) and 14.2 (iOS) have a bug where 'showModalDialog'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Easy inline at the intrinsics level ☝️

@jdalton jdalton force-pushed the perf-work branch 2 times, most recently from efbfd5c to 6e3dc2a Compare October 26, 2021 22:11
combinedArgs[i + combinedOffset] = getTransferableValue(args[i]);
const arg = args[i];
const combinedIndex = i + combinedOffset;
// Inline `getTransferableValue`.
Copy link
Contributor

Choose a reason for hiding this comment

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

If JavaScript were to support Macros 🙊

@jdalton jdalton force-pushed the perf-work branch 4 times, most recently from a7cab18 to cf38319 Compare October 27, 2021 18:53
@jdalton jdalton merged commit 7b7824e into salesforce:master Oct 27, 2021
@jdalton jdalton deleted the perf-work branch October 27, 2021 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants