title: Do processors have actual circuitry to aid exception handling?
body: <p>My question here is pretty simple: I want to know if processors try to help exception handling somehow. Would it be possible to completely remove overhead from exception handling and throwing if enough effort is put in designing a processor "exception-ready"?</p>
  
  <p>Because as far as I know, all exception handling is done via software, and that always adds some overhead. Am I wrong?</p>
  
  <p>-- edit</p>
  
  <p>So, thanks for all the answers below. I appreciate. You have answered my question.</p>
  
  <p>But just to clarify why I asked this: generally, people don't go too deep into optimizing exceptions because they all think "exceptions are for exceptional circumstances", and therefore they are no bottleneck.</p>
  
  <p>I don't think exceptions should only be thrown under dramatic circumstances. What I think is, basically, that an exception should be thrown anytime a function cannot comply to what it promised to do.</p>
  
  <p>If I say:</p>
  
  <pre><code>doSomethingImportant();
  </code></pre>
  
  <p>And if for <em>whatever</em> reason "something important" can't be done, this should throw an exception.</p>
  
  <p>Of course, doSomethingImportant() might not be able to comply because the system ran out of memory (a dramatic problem), but I think we should be able to model simpler "I can't do that now/this time, sorry" into our software, embedded into our designs. I'd like to say that I think exceptions can be exceptional, yes, but they <em>are to be expected</em> like normal software flow, not as a "fatal error" from which the system has to "recover", nomsain?</p>
  
  <p>And while big applications backed by nice data centers will hardly ever bottleneck because of exception handling, please don't forget there's market for embedded devices where resources are counted, and exception handling <em>does</em> have an impact (which is what I'm aiming for).</p>
  
  <p>I personally find exceptions quite expressive, and I'd like to use them in embedded devices with as much "overhead" as I would get by returning "-1" and checking that with an "if".</p>