endojs / endo

Endo is a distributed secure JavaScript sandbox, based on SES
Apache License 2.0
762 stars 68 forks source link

refactor(exo): shorten exo-call fastpath #2247

Closed erights closed 2 months ago

erights commented 2 months ago

closes: #XXXX refs: #XXXX

Description

Should be a pure refactor without any[1] observable differences. Shorten the exo-call fastpath for the normal thisful case

By "thisful", I mean the exo objects defined with the normal exo-making, exo-class-making, and exo-class-kit-making APIs, whether directly or via zones. The non-thisful case is only the deprecated virtual and durable kinds, which are not yet gone and so must still be supported. But have only the non-thisful case pay for the arg shifting, rather than making all calls pay for that.

The previous debug experience involved two layers of wrapping function to get from the external call to a method of an exo into the exo's own behavior method. This PR reduces that to one level of wrapper. The effectively step into from the call into the actual behavior method before and after this PR

There is also one less exo infrastructure frame on the call stack. In the debugger, the remaining stack frame is labeled

image

vs

image

Also less noise in verbose error stacks.

Security Considerations

none. The safety checks should be exactly the same.

Scaling Considerations

Probably has a performance advantage for the normal thisful case. But we won't know until we measure. We're putting this into review before measuring though, since the main motivation is the better debugging experience.

Documentation Considerations

none

Testing Considerations

[1] The refactoring did result in an error message changing, requiring a corresponding change in a golden error message test.

The tests in endo only test the normal thisful case. We depend on integration testing with agoric-sdk to test the non-thisful case.

Compatibility Considerations

none, given that the integration test with agoric-sdk confirms we did not break the non-thisful case.

Upgrade Considerations

none.

erights commented 2 months ago

Integration test via pount-endo-branch at https://github.com/Agoric/agoric-sdk/pull/9298

patch for debugging use until then https://github.com/Agoric/agoric-sdk/pull/9297

erights commented 2 months ago

Both agoric-sdk integration test PRs are green.