summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/bytecompiler
diff options
context:
space:
mode:
authorLeon Clarke <leonclarke@google.com>2010-06-03 14:33:32 +0100
committerLeon Clarke <leonclarke@google.com>2010-06-08 12:24:51 +0100
commit5af96e2c7b73ebc627c6894727826a7576d31758 (patch)
treef9d5e6f6175ccd7e3d14de9b290f08937a0d17ba /JavaScriptCore/bytecompiler
parent8cc4fcf4f6adcbc0e0aebfc24fbad9a4cddf2cfb (diff)
downloadexternal_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.zip
external_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.tar.gz
external_webkit-5af96e2c7b73ebc627c6894727826a7576d31758.tar.bz2
Merge webkit.org at r60469 : Initial merge by git.
Change-Id: I66a0047aa2af802f66bb0c7f2a8b02247a596234
Diffstat (limited to 'JavaScriptCore/bytecompiler')
-rw-r--r--JavaScriptCore/bytecompiler/BytecodeGenerator.cpp32
-rw-r--r--JavaScriptCore/bytecompiler/BytecodeGenerator.h4
2 files changed, 20 insertions, 16 deletions
diff --git a/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
index cdf87d2..bebfdbb 100644
--- a/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
+++ b/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
@@ -364,16 +364,29 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const Debug
m_thisRegister.setIndex(m_nextParameterIndex);
++m_nextParameterIndex;
++m_codeBlock->m_numParameters;
-
- if (!isConstructor() && (functionBody->usesThis() || m_shouldEmitDebugHooks)) {
- emitOpcode(op_convert_this);
- instructions().append(m_thisRegister.index());
- }
for (size_t i = 0; i < parameterCount; ++i)
addParameter(parameters[i]);
preserveLastVar();
+
+ if (isConstructor()) {
+ RefPtr<RegisterID> func = newTemporary();
+ RefPtr<RegisterID> funcProto = newTemporary();
+
+ emitOpcode(op_get_callee);
+ instructions().append(func->index());
+ // Load prototype.
+ emitGetByIdExceptionInfo(op_create_this);
+ emitGetById(funcProto.get(), func.get(), globalData()->propertyNames->prototype);
+
+ emitOpcode(op_create_this);
+ instructions().append(m_thisRegister.index());
+ instructions().append(funcProto->index());
+ } else if (functionBody->usesThis() || m_shouldEmitDebugHooks) {
+ emitOpcode(op_convert_this);
+ instructions().append(m_thisRegister.index());
+ }
}
BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, const Debugger* debugger, const ScopeChain& scopeChain, SymbolTable* symbolTable, EvalCodeBlock* codeBlock)
@@ -1581,8 +1594,6 @@ RegisterID* BytecodeGenerator::emitConstruct(RegisterID* dst, RegisterID* func,
}
}
- RefPtr<RegisterID> funcProto = newTemporary();
-
// Generate code for arguments.
Vector<RefPtr<RegisterID>, 16> argv;
argv.append(newTemporary()); // reserve space for "this"
@@ -1598,11 +1609,6 @@ RegisterID* BytecodeGenerator::emitConstruct(RegisterID* dst, RegisterID* func,
instructions().append(func->index());
}
- // Load prototype.
- emitExpressionInfo(divot, startOffset, endOffset);
- emitGetByIdExceptionInfo(op_construct);
- emitGetById(funcProto.get(), func, globalData()->propertyNames->prototype);
-
// Reserve space for call frame.
Vector<RefPtr<RegisterID>, RegisterFile::CallFrameHeaderSize> callFrame;
for (int i = 0; i < RegisterFile::CallFrameHeaderSize; ++i)
@@ -1618,8 +1624,6 @@ RegisterID* BytecodeGenerator::emitConstruct(RegisterID* dst, RegisterID* func,
instructions().append(func->index()); // func
instructions().append(argv.size()); // argCount
instructions().append(argv[0]->index() + argv.size() + RegisterFile::CallFrameHeaderSize); // registerOffset
- instructions().append(funcProto->index()); // proto
- instructions().append(argv[0]->index()); // thisRegister
if (dst != ignoredResult()) {
emitOpcode(op_call_put_result);
instructions().append(dst->index()); // dst
diff --git a/JavaScriptCore/bytecompiler/BytecodeGenerator.h b/JavaScriptCore/bytecompiler/BytecodeGenerator.h
index 7626bf4..398d666 100644
--- a/JavaScriptCore/bytecompiler/BytecodeGenerator.h
+++ b/JavaScriptCore/bytecompiler/BytecodeGenerator.h
@@ -248,10 +248,10 @@ namespace JSC {
{
// Only op_construct and op_instanceof need exception info for
// a preceding op_get_by_id.
- ASSERT(opcodeID == op_construct || opcodeID == op_instanceof);
+ ASSERT(opcodeID == op_create_this || opcodeID == op_instanceof);
GetByIdExceptionInfo info;
info.bytecodeOffset = instructions().size();
- info.isOpConstruct = (opcodeID == op_construct);
+ info.isOpCreateThis = (opcodeID == op_create_this);
m_codeBlock->addGetByIdExceptionInfo(info);
}