Skip to content

Only create exception objects if we're going to throw them#66

Draft
raneashay wants to merge 1 commit intomicrosoft:mainfrom
raneashay:ashay/localized-exception-creation
Draft

Only create exception objects if we're going to throw them#66
raneashay wants to merge 1 commit intomicrosoft:mainfrom
raneashay:ashay/localized-exception-creation

Conversation

@raneashay
Copy link
Copy Markdown

As I understand, every time an exception object is created, the
constructor calls fillInStackTrace(), which has to walk the call stack
to record every frame. This is expensive, but it's also unnecessary if
the exception is never thrown. There are a few instances in various
parts of the JDK libraries where we create an exception in the dominator
block but don't always throw it. This patch fixes those cases so that
if the exception is not going to be thrown, it is never created in the
first place.

As I understand, every time an exception object is created, the
constructor calls `fillInStackTrace()`, which has to walk the call stack
to record every frame.  This is expensive, but it's also unnecessary if
the exception is never thrown.  There are a few instances in various
parts of the JDK libraries where we create an exception in the dominator
block but don't always throw it.  This patch fixes those cases so that
if the exception is not going to be thrown, it is never created in the
first place.
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.

1 participant