summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/bytecompiler
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/bytecompiler')
-rw-r--r--JavaScriptCore/bytecompiler/BytecodeGenerator.cpp10
-rw-r--r--JavaScriptCore/bytecompiler/BytecodeGenerator.h23
2 files changed, 13 insertions, 20 deletions
diff --git a/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
index 26de0a1..3a99957 100644
--- a/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
+++ b/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
@@ -218,7 +218,7 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const ScopeChain&
#ifndef NDEBUG
, m_lastOpcodePosition(0)
#endif
- , m_emitNodeDepth(0)
+ , m_stack(m_globalData->stack())
, m_usesExceptions(false)
, m_regeneratingForExceptionInfo(false)
, m_codeBlockBeingRegeneratedFrom(0)
@@ -312,7 +312,7 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const Scope
#ifndef NDEBUG
, m_lastOpcodePosition(0)
#endif
- , m_emitNodeDepth(0)
+ , m_stack(m_globalData->stack())
, m_usesExceptions(false)
, m_regeneratingForExceptionInfo(false)
, m_codeBlockBeingRegeneratedFrom(0)
@@ -477,7 +477,7 @@ BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, const ScopeChain& scope
#ifndef NDEBUG
, m_lastOpcodePosition(0)
#endif
- , m_emitNodeDepth(0)
+ , m_stack(m_globalData->stack())
, m_usesExceptions(false)
, m_regeneratingForExceptionInfo(false)
, m_codeBlockBeingRegeneratedFrom(0)
@@ -1599,7 +1599,9 @@ void BytecodeGenerator::createArgumentsIfNecessary()
{
if (m_codeType != FunctionCode)
return;
- ASSERT(m_codeBlock->usesArguments());
+
+ if (!m_codeBlock->usesArguments())
+ return;
// If we're in strict mode we tear off the arguments on function
// entry, so there's no need to check if we need to create them
diff --git a/JavaScriptCore/bytecompiler/BytecodeGenerator.h b/JavaScriptCore/bytecompiler/BytecodeGenerator.h
index a90f756..37756fa 100644
--- a/JavaScriptCore/bytecompiler/BytecodeGenerator.h
+++ b/JavaScriptCore/bytecompiler/BytecodeGenerator.h
@@ -208,13 +208,9 @@ namespace JSC {
// Node::emitCode assumes that dst, if provided, is either a local or a referenced temporary.
ASSERT(!dst || dst == ignoredResult() || !dst->isTemporary() || dst->refCount());
addLineInfo(n->lineNo());
-
- if (m_emitNodeDepth >= s_maxEmitNodeDepth)
- return emitThrowExpressionTooDeepException();
- ++m_emitNodeDepth;
- RegisterID* r = n->emitBytecode(*this, dst);
- --m_emitNodeDepth;
- return r;
+ return m_stack.recursionCheck()
+ ? n->emitBytecode(*this, dst)
+ : emitThrowExpressionTooDeepException();
}
RegisterID* emitNode(Node* n)
@@ -225,13 +221,10 @@ namespace JSC {
void emitNodeInConditionContext(ExpressionNode* n, Label* trueTarget, Label* falseTarget, bool fallThroughMeansTrue)
{
addLineInfo(n->lineNo());
- if (m_emitNodeDepth >= s_maxEmitNodeDepth) {
+ if (m_stack.recursionCheck())
+ n->emitBytecodeInConditionContext(*this, trueTarget, falseTarget, fallThroughMeansTrue);
+ else
emitThrowExpressionTooDeepException();
- return;
- }
- ++m_emitNodeDepth;
- n->emitBytecodeInConditionContext(*this, trueTarget, falseTarget, fallThroughMeansTrue);
- --m_emitNodeDepth;
}
void emitExpressionInfo(unsigned divot, unsigned startOffset, unsigned endOffset)
@@ -583,13 +576,11 @@ namespace JSC {
size_t m_lastOpcodePosition;
#endif
- unsigned m_emitNodeDepth;
+ StackBounds m_stack;
bool m_usesExceptions;
bool m_regeneratingForExceptionInfo;
CodeBlock* m_codeBlockBeingRegeneratedFrom;
-
- static const unsigned s_maxEmitNodeDepth = 5000;
};
}