Commit 33b7578c authored by mjs@apple.com's avatar mjs@apple.com

2008-06-15 Maciej Stachowiak <mjs@apple.com>

        Reviewed by Alexey.
        
        - add emitUnaryOp, emitNullaryOp and emitUnaryOpNoDst; use them
        
        This removes some boilerplate code and also reduces the number of
        places that will need to be changed to do on-demand emit of
        loads (and thus support k operands).

        * VM/CodeGenerator.cpp:
        (KJS::CodeGenerator::emitUnaryOp):
        (KJS::CodeGenerator::emitNullaryOp):
        (KJS::CodeGenerator::emitUnaryOpNoDst):
        (KJS::CodeGenerator::emitPushScope):
        * VM/CodeGenerator.h:
        (KJS::CodeGenerator::emitNewObject):
        (KJS::CodeGenerator::emitNewArray):
        (KJS::CodeGenerator::emitNot):
        (KJS::CodeGenerator::emitBitNot):
        (KJS::CodeGenerator::emitToJSNumber):
        (KJS::CodeGenerator::emitNegate):
        (KJS::CodeGenerator::emitInstanceOf):
        (KJS::CodeGenerator::emitTypeOf):
        (KJS::CodeGenerator::emitIn):
        (KJS::CodeGenerator::emitReturn):
        (KJS::CodeGenerator::emitEnd):
        (KJS::CodeGenerator::emitGetPropertyNames):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fb32d42d
2008-06-15 Maciej Stachowiak <mjs@apple.com>
Reviewed by Alexey.
- add emitUnaryOp, emitNullaryOp and emitUnaryOpNoDst; use them
This removes some boilerplate code and also reduces the number of
places that will need to be changed to do on-demand emit of
loads (and thus support k operands).
* VM/CodeGenerator.cpp:
(KJS::CodeGenerator::emitUnaryOp):
(KJS::CodeGenerator::emitNullaryOp):
(KJS::CodeGenerator::emitUnaryOpNoDst):
(KJS::CodeGenerator::emitPushScope):
* VM/CodeGenerator.h:
(KJS::CodeGenerator::emitNewObject):
(KJS::CodeGenerator::emitNewArray):
(KJS::CodeGenerator::emitNot):
(KJS::CodeGenerator::emitBitNot):
(KJS::CodeGenerator::emitToJSNumber):
(KJS::CodeGenerator::emitNegate):
(KJS::CodeGenerator::emitInstanceOf):
(KJS::CodeGenerator::emitTypeOf):
(KJS::CodeGenerator::emitIn):
(KJS::CodeGenerator::emitReturn):
(KJS::CodeGenerator::emitEnd):
(KJS::CodeGenerator::emitGetPropertyNames):
2008-06-15 Alp Toker <alp@nuanti.com>
Rubber-stamped by Maciej.
......
......@@ -509,9 +509,9 @@ RegisterID* CodeGenerator::emitMove(RegisterID* dst, RegisterID* src)
return dst;
}
RegisterID* CodeGenerator::emitNot(RegisterID* dst, RegisterID* src)
RegisterID* CodeGenerator::emitUnaryOp(OpcodeID opcode, RegisterID* dst, RegisterID* src)
{
emitOpcode(op_not);
emitOpcode(opcode);
instructions().append(dst->index());
instructions().append(src->index());
return dst;
......@@ -547,30 +547,6 @@ RegisterID* CodeGenerator::emitPostDec(RegisterID* dst, RegisterID* srcDst)
return dst;
}
RegisterID* CodeGenerator::emitToJSNumber(RegisterID* dst, RegisterID* src)
{
emitOpcode(op_to_jsnumber);
instructions().append(dst->index());
instructions().append(src->index());
return dst;
}
RegisterID* CodeGenerator::emitNegate(RegisterID* dst, RegisterID* src)
{
emitOpcode(op_negate);
instructions().append(dst->index());
instructions().append(src->index());
return dst;
}
RegisterID* CodeGenerator::emitBitNot(RegisterID* dst, RegisterID* src)
{
emitOpcode(op_bitnot);
instructions().append(dst->index());
instructions().append(src->index());
return dst;
}
RegisterID* CodeGenerator::emitBinaryOp(OpcodeID opcode, RegisterID* dst, RegisterID* src1, RegisterID* src2)
{
emitOpcode(opcode);
......@@ -580,32 +556,6 @@ RegisterID* CodeGenerator::emitBinaryOp(OpcodeID opcode, RegisterID* dst, Regist
return dst;
}
RegisterID* CodeGenerator::emitInstanceOf(RegisterID* dst, RegisterID* value, RegisterID* base)
{
emitOpcode(op_instanceof);
instructions().append(dst->index());
instructions().append(value->index());
instructions().append(base->index());
return dst;
}
RegisterID* CodeGenerator::emitTypeOf(RegisterID* dst, RegisterID* src)
{
emitOpcode(op_typeof);
instructions().append(dst->index());
instructions().append(src->index());
return dst;
}
RegisterID* CodeGenerator::emitIn(RegisterID* dst, RegisterID* property, RegisterID* base)
{
emitOpcode(op_in);
instructions().append(dst->index());
instructions().append(property->index());
instructions().append(base->index());
return dst;
}
RegisterID* CodeGenerator::emitLoad(RegisterID* dst, bool b)
{
emitOpcode(op_load);
......@@ -630,16 +580,9 @@ RegisterID* CodeGenerator::emitLoad(RegisterID* dst, JSValue* v)
return dst;
}
RegisterID* CodeGenerator::emitNewObject(RegisterID* dst)
{
emitOpcode(op_new_object);
instructions().append(dst->index());
return dst;
}
RegisterID* CodeGenerator::emitNewArray(RegisterID* dst)
RegisterID* CodeGenerator::emitNullaryOp(OpcodeID opcode, RegisterID* dst)
{
emitOpcode(op_new_array);
emitOpcode(opcode);
instructions().append(dst->index());
return dst;
}
......@@ -895,18 +838,11 @@ RegisterID* CodeGenerator::emitCall(OpcodeID opcodeID, RegisterID* dst, Register
return dst;
}
RegisterID* CodeGenerator::emitReturn(RegisterID* r0)
{
emitOpcode(op_ret);
instructions().append(r0->index());
return r0;
}
RegisterID* CodeGenerator::emitEnd(RegisterID* dst)
RegisterID* CodeGenerator::emitUnaryNoDstOp(OpcodeID opcode, RegisterID* src)
{
emitOpcode(op_end);
instructions().append(dst->index());
return dst;
emitOpcode(opcode);
instructions().append(src->index());
return src;
}
RegisterID* CodeGenerator::emitConstruct(RegisterID* dst, RegisterID* func, ArgumentsNode* argumentsNode)
......@@ -935,14 +871,12 @@ RegisterID* CodeGenerator::emitConstruct(RegisterID* dst, RegisterID* func, Argu
RegisterID* CodeGenerator::emitPushScope(RegisterID* scope)
{
m_codeBlock->needsFullScopeChain = true;
emitOpcode(op_push_scope);
instructions().append(scope->index());
ControlFlowContext context;
context.isFinallyBlock = false;
m_scopeContextStack.append(context);
m_dynamicScopeDepth++;
return scope;
return emitUnaryNoDstOp(op_push_scope, scope);
}
void CodeGenerator::emitPopScope()
......@@ -1117,14 +1051,6 @@ RegisterID* CodeGenerator::emitNextPropertyName(RegisterID* dst, RegisterID* ite
return dst;
}
RegisterID* CodeGenerator::emitGetPropertyNames(RegisterID* dst, RegisterID* base)
{
emitOpcode(op_get_pnames);
instructions().append(dst->index());
instructions().append(base->index());
return dst;
}
RegisterID* CodeGenerator::emitCatch(RegisterID* targetRegister, LabelID* start, LabelID* end)
{
HandlerInfo info = { start->offsetFrom(0), end->offsetFrom(0), instructions().size(), m_dynamicScopeDepth };
......@@ -1134,12 +1060,6 @@ RegisterID* CodeGenerator::emitCatch(RegisterID* targetRegister, LabelID* start,
return targetRegister;
}
void CodeGenerator::emitThrow(RegisterID* exception)
{
emitOpcode(op_throw);
instructions().append(exception->index());
}
RegisterID* CodeGenerator::emitNewError(RegisterID* dst, ErrorType type, JSValue* message)
{
emitOpcode(op_new_error);
......
......@@ -192,8 +192,14 @@ namespace KJS {
RegisterID* emitLoad(RegisterID* dst, double);
RegisterID* emitLoad(RegisterID* dst, JSValue*);
RegisterID* emitNewObject(RegisterID* dst);
RegisterID* emitNewArray(RegisterID* dst);
RegisterID* emitNullaryOp(OpcodeID, RegisterID* dst);
RegisterID* emitUnaryOp(OpcodeID, RegisterID* dst, RegisterID* src);
RegisterID* emitBinaryOp(OpcodeID, RegisterID* dst, RegisterID* src1, RegisterID* src2);
RegisterID* emitUnaryNoDstOp(OpcodeID, RegisterID* src);
RegisterID* emitNewObject(RegisterID* dst) { return emitNullaryOp(op_new_object, dst); }
RegisterID* emitNewArray(RegisterID* dst) { return emitNullaryOp(op_new_array, dst); }
RegisterID* emitNewFunction(RegisterID* dst, FuncDeclNode* func);
RegisterID* emitNewFunctionExpression(RegisterID* dst, FuncExprNode* func);
......@@ -201,21 +207,20 @@ namespace KJS {
RegisterID* emitMove(RegisterID* dst, RegisterID* src);
RegisterID* emitNot(RegisterID* dst, RegisterID* src);
RegisterID* emitBitNot(RegisterID* dst, RegisterID* src);
RegisterID* emitToJSNumber(RegisterID* dst, RegisterID* src);
RegisterID* emitNegate(RegisterID* dst, RegisterID* src);
RegisterID* emitNot(RegisterID* dst, RegisterID* src) { return emitUnaryOp(op_not, dst, src); }
RegisterID* emitBitNot(RegisterID* dst, RegisterID* src) { return emitUnaryOp(op_bitnot, dst, src); }
RegisterID* emitToJSNumber(RegisterID* dst, RegisterID* src) { return emitUnaryOp(op_to_jsnumber, dst, src); }
RegisterID* emitNegate(RegisterID* dst, RegisterID* src) { return emitUnaryOp(op_negate, dst, src); }
RegisterID* emitPreInc(RegisterID* srcDst);
RegisterID* emitPreDec(RegisterID* srcDst);
RegisterID* emitPostInc(RegisterID* dst, RegisterID* srcDst);
RegisterID* emitPostDec(RegisterID* dst, RegisterID* srcDst);
RegisterID* emitBinaryOp(OpcodeID opcode, RegisterID* dst, RegisterID* src1, RegisterID* src2);
RegisterID* emitInstanceOf(RegisterID* dst, RegisterID* value, RegisterID* base);
RegisterID* emitTypeOf(RegisterID* dst, RegisterID* src);
RegisterID* emitIn(RegisterID* dst, RegisterID* property, RegisterID* base);
RegisterID* emitInstanceOf(RegisterID* dst, RegisterID* value, RegisterID* base) { return emitBinaryOp(op_instanceof, dst, value, base); }
RegisterID* emitTypeOf(RegisterID* dst, RegisterID* src) { return emitUnaryOp(op_typeof, dst, src); }
RegisterID* emitIn(RegisterID* dst, RegisterID* property, RegisterID* base) { return emitBinaryOp(op_in, dst, property, base); }
RegisterID* emitResolve(RegisterID* dst, const Identifier& property);
RegisterID* emitGetScopedVar(RegisterID* dst, size_t skip, int index);
......@@ -237,8 +242,9 @@ namespace KJS {
RegisterID* emitCall(RegisterID* dst, RegisterID* func, RegisterID* base, ArgumentsNode*);
RegisterID* emitCallEval(RegisterID* dst, RegisterID* func, RegisterID* base, ArgumentsNode*);
RegisterID* emitReturn(RegisterID*);
RegisterID* emitEnd(RegisterID* dst);
RegisterID* emitReturn(RegisterID* src) { return emitUnaryNoDstOp(op_ret, src); }
RegisterID* emitEnd(RegisterID* src) { return emitUnaryNoDstOp(op_end, src); }
RegisterID* emitConstruct(RegisterID* dst, RegisterID* func, ArgumentsNode*);
......@@ -252,11 +258,11 @@ namespace KJS {
PassRefPtr<LabelID> emitJumpSubroutine(RegisterID* retAddrDst, LabelID*);
void emitSubroutineReturn(RegisterID* retAddrSrc);
RegisterID* emitGetPropertyNames(RegisterID* dst, RegisterID* base);
RegisterID* emitGetPropertyNames(RegisterID* dst, RegisterID* base) { return emitUnaryOp(op_get_pnames, dst, base); }
RegisterID* emitNextPropertyName(RegisterID* dst, RegisterID* iter, LabelID* target);
RegisterID* emitCatch(RegisterID*, LabelID* start, LabelID* end);
void emitThrow(RegisterID*);
void emitThrow(RegisterID* exc) { emitUnaryNoDstOp(op_throw, exc); }
RegisterID* emitNewError(RegisterID* dst, ErrorType type, JSValue* message);
RegisterID* emitPushScope(RegisterID* scope);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment