OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 7029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7040 UNREACHABLE(); | 7040 UNREACHABLE(); |
7041 break; | 7041 break; |
7042 } | 7042 } |
7043 frame_->Push(&value); | 7043 frame_->Push(&value); |
7044 } else { | 7044 } else { |
7045 Load(node->expression()); | 7045 Load(node->expression()); |
7046 bool overwrite = | 7046 bool overwrite = |
7047 (node->expression()->AsBinaryOperation() != NULL && | 7047 (node->expression()->AsBinaryOperation() != NULL && |
7048 node->expression()->AsBinaryOperation()->ResultOverwriteAllowed()); | 7048 node->expression()->AsBinaryOperation()->ResultOverwriteAllowed()); |
7049 switch (op) { | 7049 switch (op) { |
| 7050 case Token::NOT: |
| 7051 case Token::DELETE: |
| 7052 case Token::TYPEOF: |
| 7053 UNREACHABLE(); // handled above |
| 7054 break; |
| 7055 |
7050 case Token::SUB: { | 7056 case Token::SUB: { |
7051 GenericUnaryOpStub stub(Token::SUB, overwrite); | 7057 GenericUnaryOpStub stub(Token::SUB, overwrite); |
7052 Result operand = frame_->Pop(); | 7058 Result operand = frame_->Pop(); |
7053 Result answer = frame_->CallStub(&stub, &operand); | 7059 Result answer = frame_->CallStub(&stub, &operand); |
7054 answer.set_type_info(TypeInfo::Number()); | 7060 answer.set_type_info(TypeInfo::Number()); |
7055 frame_->Push(&answer); | 7061 frame_->Push(&answer); |
7056 break; | 7062 break; |
7057 } | 7063 } |
7058 case Token::BIT_NOT: { | 7064 case Token::BIT_NOT: { |
7059 // Smi check. | 7065 // Smi check. |
(...skipping 20 matching lines...) Expand all Loading... |
7080 continue_label.Jump(&answer); | 7086 continue_label.Jump(&answer); |
7081 | 7087 |
7082 smi_label.Bind(&answer); | 7088 smi_label.Bind(&answer); |
7083 answer.ToRegister(); | 7089 answer.ToRegister(); |
7084 frame_->Spill(answer.reg()); | 7090 frame_->Spill(answer.reg()); |
7085 // Set smi tag bit. It will be reset by the not operation. | 7091 // Set smi tag bit. It will be reset by the not operation. |
7086 __ lea(answer.reg(), Operand(answer.reg(), kSmiTagMask)); | 7092 __ lea(answer.reg(), Operand(answer.reg(), kSmiTagMask)); |
7087 __ not_(answer.reg()); | 7093 __ not_(answer.reg()); |
7088 | 7094 |
7089 continue_label.Bind(&answer); | 7095 continue_label.Bind(&answer); |
7090 if (operand_info.IsInteger32()) { | 7096 answer.set_type_info(TypeInfo::Integer32()); |
7091 answer.set_type_info(TypeInfo::Integer32()); | |
7092 } else { | |
7093 answer.set_type_info(TypeInfo::Number()); | |
7094 } | |
7095 frame_->Push(&answer); | 7097 frame_->Push(&answer); |
7096 } | 7098 } |
7097 break; | 7099 break; |
7098 } | 7100 } |
7099 case Token::ADD: { | 7101 case Token::ADD: { |
7100 // Smi check. | 7102 // Smi check. |
7101 JumpTarget continue_label; | 7103 JumpTarget continue_label; |
7102 Result operand = frame_->Pop(); | 7104 Result operand = frame_->Pop(); |
7103 TypeInfo operand_info = operand.type_info(); | 7105 TypeInfo operand_info = operand.type_info(); |
7104 operand.ToRegister(); | 7106 operand.ToRegister(); |
7105 __ test(operand.reg(), Immediate(kSmiTagMask)); | 7107 __ test(operand.reg(), Immediate(kSmiTagMask)); |
7106 continue_label.Branch(zero, &operand, taken); | 7108 continue_label.Branch(zero, &operand, taken); |
7107 | 7109 |
7108 frame_->Push(&operand); | 7110 frame_->Push(&operand); |
7109 Result answer = frame_->InvokeBuiltin(Builtins::TO_NUMBER, | 7111 Result answer = frame_->InvokeBuiltin(Builtins::TO_NUMBER, |
7110 CALL_FUNCTION, 1); | 7112 CALL_FUNCTION, 1); |
7111 | 7113 |
7112 continue_label.Bind(&answer); | 7114 continue_label.Bind(&answer); |
7113 if (operand_info.IsSmi()) { | 7115 if (operand_info.IsSmi()) { |
7114 answer.set_type_info(TypeInfo::Smi()); | 7116 answer.set_type_info(TypeInfo::Smi()); |
7115 } else if (operand_info.IsInteger32()) { | 7117 } else if (operand_info.IsInteger32()) { |
7116 answer.set_type_info(TypeInfo::Integer32()); | 7118 answer.set_type_info(TypeInfo::Integer32()); |
7117 } else { | 7119 } else { |
7118 answer.set_type_info(TypeInfo::Number()); | 7120 answer.set_type_info(TypeInfo::Number()); |
7119 } | 7121 } |
7120 frame_->Push(&answer); | 7122 frame_->Push(&answer); |
7121 break; | 7123 break; |
7122 } | 7124 } |
7123 default: | 7125 default: |
7124 // NOT, DELETE, TYPEOF, and VOID are handled outside the | |
7125 // switch. | |
7126 UNREACHABLE(); | 7126 UNREACHABLE(); |
7127 } | 7127 } |
7128 } | 7128 } |
7129 } | 7129 } |
7130 } | 7130 } |
7131 | 7131 |
7132 | 7132 |
7133 // The value in dst was optimistically incremented or decremented. The | 7133 // The value in dst was optimistically incremented or decremented. The |
7134 // result overflowed or was not smi tagged. Undo the operation, call | 7134 // result overflowed or was not smi tagged. Undo the operation, call |
7135 // into the runtime to convert the argument to a number, and call the | 7135 // into the runtime to convert the argument to a number, and call the |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7326 } else { | 7326 } else { |
7327 // If the count operation didn't overflow and the result is a valid | 7327 // If the count operation didn't overflow and the result is a valid |
7328 // smi, we're done. Otherwise, we jump to the deferred slow-case | 7328 // smi, we're done. Otherwise, we jump to the deferred slow-case |
7329 // code. | 7329 // code. |
7330 // We combine the overflow and the smi tag check if we could | 7330 // We combine the overflow and the smi tag check if we could |
7331 // successfully allocate a temporary byte register. | 7331 // successfully allocate a temporary byte register. |
7332 if (tmp.is_valid()) { | 7332 if (tmp.is_valid()) { |
7333 __ setcc(overflow, tmp.reg()); | 7333 __ setcc(overflow, tmp.reg()); |
7334 __ or_(Operand(tmp.reg()), new_value.reg()); | 7334 __ or_(Operand(tmp.reg()), new_value.reg()); |
7335 __ test(tmp.reg(), Immediate(kSmiTagMask)); | 7335 __ test(tmp.reg(), Immediate(kSmiTagMask)); |
7336 tmp.Unuse(); | 7336 tmp.Unusec(); |
7337 deferred->Branch(not_zero); | 7337 deferred->Branch(not_zero); |
7338 } else { | 7338 } else { |
7339 // Otherwise we test separately for overflow and smi tag. | 7339 // Otherwise we test separately for overflow and smi tag. |
7340 deferred->Branch(overflow); | 7340 deferred->Branch(overflow); |
7341 __ test(new_value.reg(), Immediate(kSmiTagMask)); | 7341 __ test(new_value.reg(), Immediate(kSmiTagMask)); |
7342 deferred->Branch(not_zero); | 7342 deferred->Branch(not_zero); |
7343 } | 7343 } |
7344 } | 7344 } |
7345 deferred->BindExit(); | 7345 deferred->BindExit(); |
7346 | 7346 |
(...skipping 5574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12921 | 12921 |
12922 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 12922 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
12923 // tagged as a small integer. | 12923 // tagged as a small integer. |
12924 __ bind(&runtime); | 12924 __ bind(&runtime); |
12925 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 12925 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
12926 } | 12926 } |
12927 | 12927 |
12928 #undef __ | 12928 #undef __ |
12929 | 12929 |
12930 } } // namespace v8::internal | 12930 } } // namespace v8::internal |
OLD | NEW |