| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 | 774 |
| 775 | 775 |
| 776 void CodeGenerator::GenericBinaryOperation(Token::Value op, | 776 void CodeGenerator::GenericBinaryOperation(Token::Value op, |
| 777 StaticType* type, | 777 StaticType* type, |
| 778 OverwriteMode overwrite_mode) { | 778 OverwriteMode overwrite_mode) { |
| 779 Comment cmnt(masm_, "[ BinaryOperation"); | 779 Comment cmnt(masm_, "[ BinaryOperation"); |
| 780 Comment cmnt_token(masm_, Token::String(op)); | 780 Comment cmnt_token(masm_, Token::String(op)); |
| 781 | 781 |
| 782 if (op == Token::COMMA) { | 782 if (op == Token::COMMA) { |
| 783 // Simply discard left value. | 783 // Simply discard left value. |
| 784 frame_->EmitPop(eax); | 784 frame_->Nip(1); |
| 785 frame_->Drop(); | |
| 786 frame_->EmitPush(eax); | |
| 787 return; | 785 return; |
| 788 } | 786 } |
| 789 | 787 |
| 788 VirtualFrame::SpilledScope spilled_scope(this); |
| 790 // Set the flags based on the operation, type and loop nesting level. | 789 // Set the flags based on the operation, type and loop nesting level. |
| 791 GenericBinaryFlags flags; | 790 GenericBinaryFlags flags; |
| 792 switch (op) { | 791 switch (op) { |
| 793 case Token::BIT_OR: | 792 case Token::BIT_OR: |
| 794 case Token::BIT_AND: | 793 case Token::BIT_AND: |
| 795 case Token::BIT_XOR: | 794 case Token::BIT_XOR: |
| 796 case Token::SHL: | 795 case Token::SHL: |
| 797 case Token::SHR: | 796 case Token::SHR: |
| 798 case Token::SAR: | 797 case Token::SAR: |
| 799 // Bit operations always assume they likely operate on Smis. Still only | 798 // Bit operations always assume they likely operate on Smis. Still only |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 OverwriteMode overwrite_mode) { | 1020 OverwriteMode overwrite_mode) { |
| 1022 // NOTE: This is an attempt to inline (a bit) more of the code for | 1021 // NOTE: This is an attempt to inline (a bit) more of the code for |
| 1023 // some possible smi operations (like + and -) when (at least) one | 1022 // some possible smi operations (like + and -) when (at least) one |
| 1024 // of the operands is a literal smi. With this optimization, the | 1023 // of the operands is a literal smi. With this optimization, the |
| 1025 // performance of the system is increased by ~15%, and the generated | 1024 // performance of the system is increased by ~15%, and the generated |
| 1026 // code size is increased by ~1% (measured on a combination of | 1025 // code size is increased by ~1% (measured on a combination of |
| 1027 // different benchmarks). | 1026 // different benchmarks). |
| 1028 | 1027 |
| 1029 // TODO(1217802): Optimize some special cases of operations | 1028 // TODO(1217802): Optimize some special cases of operations |
| 1030 // involving a smi literal (multiply by 2, shift by 0, etc.). | 1029 // involving a smi literal (multiply by 2, shift by 0, etc.). |
| 1030 VirtualFrame::SpilledScope spilled_scope(this); |
| 1031 | 1031 |
| 1032 // Get the literal value. | 1032 // Get the literal value. |
| 1033 int int_value = Smi::cast(*value)->value(); | 1033 int int_value = Smi::cast(*value)->value(); |
| 1034 ASSERT(is_intn(int_value, kMaxSmiInlinedBits)); | 1034 ASSERT(is_intn(int_value, kMaxSmiInlinedBits)); |
| 1035 | 1035 |
| 1036 switch (op) { | 1036 switch (op) { |
| 1037 case Token::ADD: { | 1037 case Token::ADD: { |
| 1038 DeferredCode* deferred = NULL; | 1038 DeferredCode* deferred = NULL; |
| 1039 if (!reversed) { | 1039 if (!reversed) { |
| 1040 deferred = new DeferredInlinedSmiAdd(this, int_value, overwrite_mode); | 1040 deferred = new DeferredInlinedSmiAdd(this, int_value, overwrite_mode); |
| (...skipping 3115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4156 | 4156 |
| 4157 // Evaluate right side expression. | 4157 // Evaluate right side expression. |
| 4158 is_false.Bind(); | 4158 is_false.Bind(); |
| 4159 Load(node->right()); | 4159 Load(node->right()); |
| 4160 | 4160 |
| 4161 // Exit (always with a materialized value). | 4161 // Exit (always with a materialized value). |
| 4162 exit.Bind(); | 4162 exit.Bind(); |
| 4163 } | 4163 } |
| 4164 | 4164 |
| 4165 } else { | 4165 } else { |
| 4166 VirtualFrame::SpilledScope spilled_scope(this); | |
| 4167 // NOTE: The code below assumes that the slow cases (calls to runtime) | 4166 // NOTE: The code below assumes that the slow cases (calls to runtime) |
| 4168 // never return a constant/immutable object. | 4167 // never return a constant/immutable object. |
| 4169 OverwriteMode overwrite_mode = NO_OVERWRITE; | 4168 OverwriteMode overwrite_mode = NO_OVERWRITE; |
| 4170 if (node->left()->AsBinaryOperation() != NULL && | 4169 if (node->left()->AsBinaryOperation() != NULL && |
| 4171 node->left()->AsBinaryOperation()->ResultOverwriteAllowed()) { | 4170 node->left()->AsBinaryOperation()->ResultOverwriteAllowed()) { |
| 4172 overwrite_mode = OVERWRITE_LEFT; | 4171 overwrite_mode = OVERWRITE_LEFT; |
| 4173 } else if (node->right()->AsBinaryOperation() != NULL && | 4172 } else if (node->right()->AsBinaryOperation() != NULL && |
| 4174 node->right()->AsBinaryOperation()->ResultOverwriteAllowed()) { | 4173 node->right()->AsBinaryOperation()->ResultOverwriteAllowed()) { |
| 4175 overwrite_mode = OVERWRITE_RIGHT; | 4174 overwrite_mode = OVERWRITE_RIGHT; |
| 4176 } | 4175 } |
| 4177 | 4176 |
| 4178 // Optimize for the case where (at least) one of the expressions | 4177 // Optimize for the case where (at least) one of the expressions |
| 4179 // is a literal small integer. | 4178 // is a literal small integer. |
| 4180 Literal* lliteral = node->left()->AsLiteral(); | 4179 Literal* lliteral = node->left()->AsLiteral(); |
| 4181 Literal* rliteral = node->right()->AsLiteral(); | 4180 Literal* rliteral = node->right()->AsLiteral(); |
| 4182 | 4181 |
| 4183 if (IsInlineSmi(rliteral)) { | 4182 if (IsInlineSmi(rliteral)) { |
| 4184 LoadAndSpill(node->left()); | 4183 Load(node->left()); |
| 4185 SmiOperation(node->op(), node->type(), rliteral->handle(), false, | 4184 SmiOperation(node->op(), node->type(), rliteral->handle(), false, |
| 4186 overwrite_mode); | 4185 overwrite_mode); |
| 4187 } else if (IsInlineSmi(lliteral)) { | 4186 } else if (IsInlineSmi(lliteral)) { |
| 4188 LoadAndSpill(node->right()); | 4187 Load(node->right()); |
| 4189 SmiOperation(node->op(), node->type(), lliteral->handle(), true, | 4188 SmiOperation(node->op(), node->type(), lliteral->handle(), true, |
| 4190 overwrite_mode); | 4189 overwrite_mode); |
| 4191 } else { | 4190 } else { |
| 4192 LoadAndSpill(node->left()); | 4191 Load(node->left()); |
| 4193 LoadAndSpill(node->right()); | 4192 Load(node->right()); |
| 4194 GenericBinaryOperation(node->op(), node->type(), overwrite_mode); | 4193 GenericBinaryOperation(node->op(), node->type(), overwrite_mode); |
| 4195 } | 4194 } |
| 4196 } | 4195 } |
| 4197 } | 4196 } |
| 4198 | 4197 |
| 4199 | 4198 |
| 4200 void CodeGenerator::VisitThisFunction(ThisFunction* node) { | 4199 void CodeGenerator::VisitThisFunction(ThisFunction* node) { |
| 4201 VirtualFrame::SpilledScope spilled_scope(this); | 4200 VirtualFrame::SpilledScope spilled_scope(this); |
| 4202 frame_->EmitPush(frame_->Function()); | 4201 frame_->EmitPush(frame_->Function()); |
| 4203 } | 4202 } |
| (...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6105 | 6104 |
| 6106 // Slow-case: Go through the JavaScript implementation. | 6105 // Slow-case: Go through the JavaScript implementation. |
| 6107 __ bind(&slow); | 6106 __ bind(&slow); |
| 6108 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 6107 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
| 6109 } | 6108 } |
| 6110 | 6109 |
| 6111 | 6110 |
| 6112 #undef __ | 6111 #undef __ |
| 6113 | 6112 |
| 6114 } } // namespace v8::internal | 6113 } } // namespace v8::internal |
| OLD | NEW |