2008-12-09 Sam Weinig <sam@webkit.org>
Reviewed by Geoffrey Garen.
Remove unnecessary extra lookup when throwing an exception.
We used to first lookup the target offset using getHandlerForVPC
and then we would lookup the native code stub using
nativeExceptionCodeForHandlerVPC. Instead, we can just pass around
the HandlerInfo.
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::handlerForVPC): Return the HandlerInfo.
* bytecode/CodeBlock.h: Remove nativeExceptionCodeForHandlerVPC.
* interpreter/Interpreter.cpp:
(JSC::Interpreter::throwException): Return a HandlerInfo instead of
and Instruction offset.
(JSC::Interpreter::privateExecute): Get the offset from HandlerInfo.
(JSC::Interpreter::cti_op_throw): Get the native code from the HandleInfo.
(JSC::Interpreter::cti_vm_throw): Ditto.
* interpreter/Interpreter.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@39156 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/bytecode/CodeBlock.cpp b/JavaScriptCore/bytecode/CodeBlock.cpp
index 5125d2f..01d452d 100644
--- a/JavaScriptCore/bytecode/CodeBlock.cpp
+++ b/JavaScriptCore/bytecode/CodeBlock.cpp
@@ -1194,40 +1194,20 @@
}
}
-bool CodeBlock::getHandlerForVPC(const Instruction* vPC, Instruction*& target, int& scopeDepth)
-{
- if (!m_rareData)
- return false;
-
- Vector<HandlerInfo>::iterator ptr = m_rareData->m_exceptionHandlers.begin();
- Vector<HandlerInfo>::iterator end = m_rareData->m_exceptionHandlers.end();
- unsigned addressOffset = vPC - m_instructions.begin();
- ASSERT(addressOffset < m_instructions.size());
-
- for (; ptr != end; ++ptr) {
- // Handlers are ordered innermost first, so the first handler we encounter
- // that contains the source address is the correct handler to use.
- if (ptr->start <= addressOffset && ptr->end >= addressOffset) {
- scopeDepth = ptr->scopeDepth;
- target = m_instructions.begin() + ptr->target;
- return true;
- }
- }
- return false;
-}
-
-void* CodeBlock::nativeExceptionCodeForHandlerVPC(const Instruction* handlerVPC)
+HandlerInfo* CodeBlock::handlerForVPC(const Instruction* vPC)
{
if (!m_rareData)
return 0;
- Vector<HandlerInfo>::iterator ptr = m_rareData->m_exceptionHandlers.begin();
- Vector<HandlerInfo>::iterator end = m_rareData->m_exceptionHandlers.end();
+ unsigned addressOffset = vPC - m_instructions.begin();
+ ASSERT(addressOffset < m_instructions.size());
- for (; ptr != end; ++ptr) {
- Instruction*target = m_instructions.begin() + ptr->target;
- if (handlerVPC == target)
- return ptr->nativeCode;
+ Vector<HandlerInfo>& exceptionHandlers = m_rareData->m_exceptionHandlers;
+ for (size_t i = 0; i < exceptionHandlers.size(); ++i) {
+ // Handlers are ordered innermost first, so the first handler we encounter
+ // that contains the source address is the correct handler to use.
+ if (exceptionHandlers[i].start <= addressOffset && exceptionHandlers[i].end >= addressOffset)
+ return &exceptionHandlers[i];
}
return 0;