OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2279 expr->BinaryOperationFeedbackId()); | 2279 expr->BinaryOperationFeedbackId()); |
2280 patch_site.EmitPatchInfo(); | 2280 patch_site.EmitPatchInfo(); |
2281 __ jmp(&done, Label::kNear); | 2281 __ jmp(&done, Label::kNear); |
2282 | 2282 |
2283 __ bind(&smi_case); | 2283 __ bind(&smi_case); |
2284 switch (op) { | 2284 switch (op) { |
2285 case Token::SAR: | 2285 case Token::SAR: |
2286 __ SmiShiftArithmeticRight(rax, rdx, rcx); | 2286 __ SmiShiftArithmeticRight(rax, rdx, rcx); |
2287 break; | 2287 break; |
2288 case Token::SHL: | 2288 case Token::SHL: |
2289 __ SmiShiftLeft(rax, rdx, rcx); | 2289 __ SmiShiftLeft(rax, rdx, rcx, &stub_call); |
2290 break; | 2290 break; |
2291 case Token::SHR: | 2291 case Token::SHR: |
2292 __ SmiShiftLogicalRight(rax, rdx, rcx, &stub_call); | 2292 __ SmiShiftLogicalRight(rax, rdx, rcx, &stub_call); |
2293 break; | 2293 break; |
2294 case Token::ADD: | 2294 case Token::ADD: |
2295 __ SmiAdd(rax, rdx, rcx, &stub_call); | 2295 __ SmiAdd(rax, rdx, rcx, &stub_call); |
2296 break; | 2296 break; |
2297 case Token::SUB: | 2297 case Token::SUB: |
2298 __ SmiSub(rax, rdx, rcx, &stub_call); | 2298 __ SmiSub(rax, rdx, rcx, &stub_call); |
2299 break; | 2299 break; |
(...skipping 2144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4444 } | 4444 } |
4445 } | 4445 } |
4446 | 4446 |
4447 // Inline smi case if we are in a loop. | 4447 // Inline smi case if we are in a loop. |
4448 Label done, stub_call; | 4448 Label done, stub_call; |
4449 JumpPatchSite patch_site(masm_); | 4449 JumpPatchSite patch_site(masm_); |
4450 | 4450 |
4451 if (ShouldInlineSmiCase(expr->op())) { | 4451 if (ShouldInlineSmiCase(expr->op())) { |
4452 if (expr->op() == Token::INC) { | 4452 if (expr->op() == Token::INC) { |
4453 __ SmiAddConstant(rax, rax, Smi::FromInt(1)); | 4453 __ SmiAddConstant(rax, rax, Smi::FromInt(1)); |
| 4454 if (kSmiValueSize == 31) { |
| 4455 // positive overflow |
| 4456 __ testl(rax, Immediate(0x80000000)); |
| 4457 __ j(not_zero, &stub_call, Label::kNear); |
| 4458 } |
4454 } else { | 4459 } else { |
4455 __ SmiSubConstant(rax, rax, Smi::FromInt(1)); | 4460 __ SmiSubConstant(rax, rax, Smi::FromInt(1)); |
| 4461 if (kSmiValueSize == 31) { |
| 4462 // negative overflow |
| 4463 __ testl(rax, Immediate(0x80000000)); |
| 4464 __ j(zero, &stub_call, Label::kNear); |
| 4465 } |
4456 } | 4466 } |
4457 __ j(overflow, &stub_call, Label::kNear); | 4467 if (kSmiValueSize == 32) { |
| 4468 __ j(overflow, &stub_call, Label::kNear); |
| 4469 } |
4458 // We could eliminate this smi check if we split the code at | 4470 // We could eliminate this smi check if we split the code at |
4459 // the first smi check before calling ToNumber. | 4471 // the first smi check before calling ToNumber. |
4460 patch_site.EmitJumpIfSmi(rax, &done, Label::kNear); | 4472 patch_site.EmitJumpIfSmi(rax, &done, Label::kNear); |
4461 | 4473 |
4462 __ bind(&stub_call); | 4474 __ bind(&stub_call); |
4463 // Call stub. Undo operation first. | 4475 // Call stub. Undo operation first. |
4464 if (expr->op() == Token::INC) { | 4476 if (expr->op() == Token::INC) { |
4465 __ SmiSubConstant(rax, rax, Smi::FromInt(1)); | 4477 __ SmiSubConstant(rax, rax, Smi::FromInt(1)); |
4466 } else { | 4478 } else { |
4467 __ SmiAddConstant(rax, rax, Smi::FromInt(1)); | 4479 __ SmiAddConstant(rax, rax, Smi::FromInt(1)); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4902 *context_length = 0; | 4914 *context_length = 0; |
4903 return previous_; | 4915 return previous_; |
4904 } | 4916 } |
4905 | 4917 |
4906 | 4918 |
4907 #undef __ | 4919 #undef __ |
4908 | 4920 |
4909 } } // namespace v8::internal | 4921 } } // namespace v8::internal |
4910 | 4922 |
4911 #endif // V8_TARGET_ARCH_X64 | 4923 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |