summaryrefslogtreecommitdiffstats
path: root/Source/JavaScriptCore/bytecompiler
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-13 16:23:25 +0100
committerBen Murdoch <benm@google.com>2011-05-16 11:35:02 +0100
commit65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch)
treef478babb801e720de7bfaee23443ffe029f58731 /Source/JavaScriptCore/bytecompiler
parent47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff)
downloadexternal_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/JavaScriptCore/bytecompiler')
-rw-r--r--Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp18
-rw-r--r--Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h4
-rw-r--r--Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp32
3 files changed, 17 insertions, 37 deletions
diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
index 3a99957..34afb52 100644
--- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
+++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
@@ -137,7 +137,7 @@ bool BytecodeGenerator::dumpsGeneratedCode()
#endif
}
-void BytecodeGenerator::generate()
+JSObject* BytecodeGenerator::generate()
{
m_codeBlock->setThisRegister(m_thisRegister.index());
@@ -154,6 +154,10 @@ void BytecodeGenerator::generate()
symbolTable().clear();
m_codeBlock->shrinkToFit();
+
+ if (m_expressionTooDeep)
+ return createOutOfMemoryError(m_scopeChain->globalObject());
+ return 0;
}
bool BytecodeGenerator::addVar(const Identifier& ident, bool isConstant, RegisterID*& r0)
@@ -222,6 +226,7 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const ScopeChain&
, m_usesExceptions(false)
, m_regeneratingForExceptionInfo(false)
, m_codeBlockBeingRegeneratedFrom(0)
+ , m_expressionTooDeep(false)
{
if (m_shouldEmitDebugHooks)
m_codeBlock->setNeedsFullScopeChain(true);
@@ -316,6 +321,7 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const Scope
, m_usesExceptions(false)
, m_regeneratingForExceptionInfo(false)
, m_codeBlockBeingRegeneratedFrom(0)
+ , m_expressionTooDeep(false)
{
if (m_shouldEmitDebugHooks)
m_codeBlock->setNeedsFullScopeChain(true);
@@ -481,6 +487,7 @@ BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, const ScopeChain& scope
, m_usesExceptions(false)
, m_regeneratingForExceptionInfo(false)
, m_codeBlockBeingRegeneratedFrom(0)
+ , m_expressionTooDeep(false)
{
if (m_shouldEmitDebugHooks || m_baseScopeDepth)
m_codeBlock->setNeedsFullScopeChain(true);
@@ -2053,12 +2060,6 @@ void BytecodeGenerator::emitThrowReferenceError(const UString& message)
instructions().append(addConstantValue(jsString(globalData(), message))->index());
}
-void BytecodeGenerator::emitThrowSyntaxError(const UString& message)
-{
- emitOpcode(op_throw_syntax_error);
- instructions().append(addConstantValue(jsString(globalData(), message))->index());
-}
-
PassRefPtr<Label> BytecodeGenerator::emitJumpSubroutine(RegisterID* retAddrDst, Label* finally)
{
size_t begin = instructions().size();
@@ -2210,8 +2211,7 @@ RegisterID* BytecodeGenerator::emitThrowExpressionTooDeepException()
// And we could make the caller pass the node pointer in, if there was some way of getting
// that from an arbitrary node. However, calling emitExpressionInfo without any useful data
// is still good enough to get us an accurate line number.
- emitExpressionInfo(0, 0, 0);
- emitThrowSyntaxError("Expression too deep");
+ m_expressionTooDeep = true;
return newTemporary();
}
diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
index 37756fa..8b0cc40 100644
--- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
+++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
@@ -102,7 +102,7 @@ namespace JSC {
bool isConstructor() { return m_codeBlock->m_isConstructor; }
- void generate();
+ JSObject* generate();
// Returns the register corresponding to a local variable, or 0 if no
// such register exists. Registers returned by registerFor do not
@@ -364,7 +364,6 @@ namespace JSC {
}
void emitThrowReferenceError(const UString& message);
- void emitThrowSyntaxError(const UString& message);
void emitPushNewScope(RegisterID* dst, const Identifier& property, RegisterID* value);
@@ -581,6 +580,7 @@ namespace JSC {
bool m_usesExceptions;
bool m_regeneratingForExceptionInfo;
CodeBlock* m_codeBlockBeingRegeneratedFrom;
+ bool m_expressionTooDeep;
};
}
diff --git a/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp b/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
index a850c96..2875434 100644
--- a/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
+++ b/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
@@ -83,13 +83,6 @@ RegisterID* ThrowableExpressionData::emitThrowReferenceError(BytecodeGenerator&
return generator.newTemporary();
}
-RegisterID* ThrowableExpressionData::emitThrowSyntaxError(BytecodeGenerator& generator, const UString& message)
-{
- generator.emitExpressionInfo(divot(), startOffset(), endOffset());
- generator.emitThrowSyntaxError(message);
- return generator.newTemporary();
-}
-
// ------------------------------ NullNode -------------------------------------
RegisterID* NullNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
@@ -130,11 +123,10 @@ RegisterID* StringNode::emitBytecode(BytecodeGenerator& generator, RegisterID* d
RegisterID* RegExpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- RefPtr<RegExp> regExp = generator.globalData()->regExpCache()->lookupOrCreate(m_pattern.ustring(), m_flags.ustring());
- if (!regExp->isValid())
- return emitThrowSyntaxError(generator, makeUString("Invalid regular expression: ", regExp->errorMessage()));
if (dst == generator.ignoredResult())
return 0;
+ RefPtr<RegExp> regExp = generator.globalData()->regExpCache()->lookupOrCreate(m_pattern.ustring(), m_flags.ustring());
+ ASSERT(regExp->isValid());
return generator.emitNewRegExp(generator.finalDestination(dst), regExp.get());
}
@@ -1641,12 +1633,7 @@ RegisterID* ContinueNode::emitBytecode(BytecodeGenerator& generator, RegisterID*
generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
LabelScope* scope = generator.continueTarget(m_ident);
-
- if (!scope) {
- if (m_ident.isEmpty())
- return emitThrowSyntaxError(generator, "Invalid continue statement.");
- return emitThrowSyntaxError(generator, makeUString("Undefined label: '", m_ident.ustring(), "'."));
- }
+ ASSERT(scope);
generator.emitJumpScopes(scope->continueTarget(), scope->scopeDepth());
return dst;
@@ -1660,12 +1647,7 @@ RegisterID* BreakNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
LabelScope* scope = generator.breakTarget(m_ident);
-
- if (!scope) {
- if (m_ident.isEmpty())
- return emitThrowSyntaxError(generator, "Invalid break statement.");
- return emitThrowSyntaxError(generator, makeUString("Undefined label: '", m_ident.ustring(), "'."));
- }
+ ASSERT(scope);
generator.emitJumpScopes(scope->breakTarget(), scope->scopeDepth());
return dst;
@@ -1676,8 +1658,7 @@ RegisterID* BreakNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
RegisterID* ReturnNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
- if (generator.codeType() != FunctionCode)
- return emitThrowSyntaxError(generator, "Invalid return statement.");
+ ASSERT(generator.codeType() == FunctionCode);
if (dst == generator.ignoredResult())
dst = 0;
@@ -1882,8 +1863,7 @@ RegisterID* LabelNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
{
generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
- if (generator.breakTarget(m_name))
- return emitThrowSyntaxError(generator, makeUString("Duplicate label: ", m_name.ustring(), "."));
+ ASSERT(!generator.breakTarget(m_name));
RefPtr<LabelScope> scope = generator.newLabelScope(LabelScope::NamedLabel, &m_name);
RegisterID* r0 = generator.emitNode(dst, m_statement);