OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 // stack. Right operand is in eax. | 1655 // stack. Right operand is in eax. |
1656 Label smi_case, done, stub_call; | 1656 Label smi_case, done, stub_call; |
1657 __ pop(edx); | 1657 __ pop(edx); |
1658 __ mov(ecx, eax); | 1658 __ mov(ecx, eax); |
1659 __ or_(eax, Operand(edx)); | 1659 __ or_(eax, Operand(edx)); |
1660 JumpPatchSite patch_site(masm_); | 1660 JumpPatchSite patch_site(masm_); |
1661 patch_site.EmitJumpIfSmi(eax, &smi_case, Label::kNear); | 1661 patch_site.EmitJumpIfSmi(eax, &smi_case, Label::kNear); |
1662 | 1662 |
1663 __ bind(&stub_call); | 1663 __ bind(&stub_call); |
1664 __ mov(eax, ecx); | 1664 __ mov(eax, ecx); |
1665 TypeRecordingBinaryOpStub stub(op, mode); | 1665 BinaryOpStub stub(op, mode); |
1666 EmitCallIC(stub.GetCode(), &patch_site, expr->id()); | 1666 EmitCallIC(stub.GetCode(), &patch_site, expr->id()); |
1667 __ jmp(&done, Label::kNear); | 1667 __ jmp(&done, Label::kNear); |
1668 | 1668 |
1669 // Smi case. | 1669 // Smi case. |
1670 __ bind(&smi_case); | 1670 __ bind(&smi_case); |
1671 __ mov(eax, edx); // Copy left operand in case of a stub call. | 1671 __ mov(eax, edx); // Copy left operand in case of a stub call. |
1672 | 1672 |
1673 switch (op) { | 1673 switch (op) { |
1674 case Token::SAR: | 1674 case Token::SAR: |
1675 __ SmiUntag(eax); | 1675 __ SmiUntag(eax); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1738 | 1738 |
1739 __ bind(&done); | 1739 __ bind(&done); |
1740 context()->Plug(eax); | 1740 context()->Plug(eax); |
1741 } | 1741 } |
1742 | 1742 |
1743 | 1743 |
1744 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, | 1744 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, |
1745 Token::Value op, | 1745 Token::Value op, |
1746 OverwriteMode mode) { | 1746 OverwriteMode mode) { |
1747 __ pop(edx); | 1747 __ pop(edx); |
1748 TypeRecordingBinaryOpStub stub(op, mode); | 1748 BinaryOpStub stub(op, mode); |
1749 // NULL signals no inlined smi code. | 1749 // NULL signals no inlined smi code. |
1750 EmitCallIC(stub.GetCode(), NULL, expr->id()); | 1750 EmitCallIC(stub.GetCode(), NULL, expr->id()); |
1751 context()->Plug(eax); | 1751 context()->Plug(eax); |
1752 } | 1752 } |
1753 | 1753 |
1754 | 1754 |
1755 void FullCodeGenerator::EmitAssignment(Expression* expr, int bailout_ast_id) { | 1755 void FullCodeGenerator::EmitAssignment(Expression* expr, int bailout_ast_id) { |
1756 // Invalid left-hand sides are rewritten to have a 'throw | 1756 // Invalid left-hand sides are rewritten to have a 'throw |
1757 // ReferenceError' on the left-hand side. | 1757 // ReferenceError' on the left-hand side. |
1758 if (!expr->IsValidLeftHandSide()) { | 1758 if (!expr->IsValidLeftHandSide()) { |
(...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3744 } | 3744 } |
3745 | 3745 |
3746 | 3746 |
3747 void FullCodeGenerator::EmitUnaryOperation(UnaryOperation* expr, | 3747 void FullCodeGenerator::EmitUnaryOperation(UnaryOperation* expr, |
3748 const char* comment) { | 3748 const char* comment) { |
3749 // TODO(svenpanne): Allowing format strings in Comment would be nice here... | 3749 // TODO(svenpanne): Allowing format strings in Comment would be nice here... |
3750 Comment cmt(masm_, comment); | 3750 Comment cmt(masm_, comment); |
3751 bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); | 3751 bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); |
3752 UnaryOverwriteMode overwrite = | 3752 UnaryOverwriteMode overwrite = |
3753 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; | 3753 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; |
3754 TypeRecordingUnaryOpStub stub(expr->op(), overwrite); | 3754 UnaryOpStub stub(expr->op(), overwrite); |
3755 // TypeRecordingUnaryOpStub expects the argument to be in the | 3755 // UnaryOpStub expects the argument to be in the |
3756 // accumulator register eax. | 3756 // accumulator register eax. |
3757 VisitForAccumulatorValue(expr->expression()); | 3757 VisitForAccumulatorValue(expr->expression()); |
3758 SetSourcePosition(expr->position()); | 3758 SetSourcePosition(expr->position()); |
3759 EmitCallIC(stub.GetCode(), NULL, expr->id()); | 3759 EmitCallIC(stub.GetCode(), NULL, expr->id()); |
3760 context()->Plug(eax); | 3760 context()->Plug(eax); |
3761 } | 3761 } |
3762 | 3762 |
3763 | 3763 |
3764 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { | 3764 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
3765 Comment cmnt(masm_, "[ CountOperation"); | 3765 Comment cmnt(masm_, "[ CountOperation"); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3877 __ add(Operand(eax), Immediate(Smi::FromInt(1))); | 3877 __ add(Operand(eax), Immediate(Smi::FromInt(1))); |
3878 } | 3878 } |
3879 } | 3879 } |
3880 | 3880 |
3881 // Record position before stub call. | 3881 // Record position before stub call. |
3882 SetSourcePosition(expr->position()); | 3882 SetSourcePosition(expr->position()); |
3883 | 3883 |
3884 // Call stub for +1/-1. | 3884 // Call stub for +1/-1. |
3885 __ mov(edx, eax); | 3885 __ mov(edx, eax); |
3886 __ mov(eax, Immediate(Smi::FromInt(1))); | 3886 __ mov(eax, Immediate(Smi::FromInt(1))); |
3887 TypeRecordingBinaryOpStub stub(expr->binary_op(), NO_OVERWRITE); | 3887 BinaryOpStub stub(expr->binary_op(), NO_OVERWRITE); |
3888 EmitCallIC(stub.GetCode(), &patch_site, expr->CountId()); | 3888 EmitCallIC(stub.GetCode(), &patch_site, expr->CountId()); |
3889 __ bind(&done); | 3889 __ bind(&done); |
3890 | 3890 |
3891 // Store the value returned in eax. | 3891 // Store the value returned in eax. |
3892 switch (assign_type) { | 3892 switch (assign_type) { |
3893 case VARIABLE: | 3893 case VARIABLE: |
3894 if (expr->is_postfix()) { | 3894 if (expr->is_postfix()) { |
3895 // Perform the assignment as if via '='. | 3895 // Perform the assignment as if via '='. |
3896 { EffectContext context(this); | 3896 { EffectContext context(this); |
3897 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3897 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4314 // And return. | 4314 // And return. |
4315 __ ret(0); | 4315 __ ret(0); |
4316 } | 4316 } |
4317 | 4317 |
4318 | 4318 |
4319 #undef __ | 4319 #undef __ |
4320 | 4320 |
4321 } } // namespace v8::internal | 4321 } } // namespace v8::internal |
4322 | 4322 |
4323 #endif // V8_TARGET_ARCH_IA32 | 4323 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |