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 2454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2465 // the first split. We manually handle the off-frame references | 2465 // the first split. We manually handle the off-frame references |
2466 // by reconstituting them on the non-fall-through path. | 2466 // by reconstituting them on the non-fall-through path. |
2467 | 2467 |
2468 if (left_side.is_smi()) { | 2468 if (left_side.is_smi()) { |
2469 if (FLAG_debug_code) __ AbortIfNotSmi(left_side.reg()); | 2469 if (FLAG_debug_code) __ AbortIfNotSmi(left_side.reg()); |
2470 } else { | 2470 } else { |
2471 JumpTarget is_smi; | 2471 JumpTarget is_smi; |
2472 __ test(left_side.reg(), Immediate(kSmiTagMask)); | 2472 __ test(left_side.reg(), Immediate(kSmiTagMask)); |
2473 is_smi.Branch(zero, taken); | 2473 is_smi.Branch(zero, taken); |
2474 | 2474 |
2475 bool is_for_loop_compare = (node->AsCompareOperation() != NULL) | 2475 bool is_loop_condition = (node->AsExpression() != NULL) && |
fschneider
2010/03/23 13:19:38
I think we should change CodeGenerator::Comparison
| |
2476 && node->AsCompareOperation()->is_for_loop_condition(); | 2476 node->AsExpression()->is_loop_condition(); |
2477 if (!is_for_loop_compare | 2477 if (!is_loop_condition && |
2478 && CpuFeatures::IsSupported(SSE2) | 2478 CpuFeatures::IsSupported(SSE2) && |
2479 && right_val->IsSmi()) { | 2479 right_val->IsSmi()) { |
2480 // Right side is a constant smi and left side has been checked | 2480 // Right side is a constant smi and left side has been checked |
2481 // not to be a smi. | 2481 // not to be a smi. |
2482 CpuFeatures::Scope use_sse2(SSE2); | 2482 CpuFeatures::Scope use_sse2(SSE2); |
2483 JumpTarget not_number; | 2483 JumpTarget not_number; |
2484 __ cmp(FieldOperand(left_reg, HeapObject::kMapOffset), | 2484 __ cmp(FieldOperand(left_reg, HeapObject::kMapOffset), |
2485 Immediate(Factory::heap_number_map())); | 2485 Immediate(Factory::heap_number_map())); |
2486 not_number.Branch(not_equal, &left_side); | 2486 not_number.Branch(not_equal, &left_side); |
2487 __ movdbl(xmm1, | 2487 __ movdbl(xmm1, |
2488 FieldOperand(left_reg, HeapNumber::kValueOffset)); | 2488 FieldOperand(left_reg, HeapNumber::kValueOffset)); |
2489 int value = Smi::cast(*right_val)->value(); | 2489 int value = Smi::cast(*right_val)->value(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2713 | 2713 |
2714 // Inline number comparison handling any combination of smi's and heap | 2714 // Inline number comparison handling any combination of smi's and heap |
2715 // numbers if: | 2715 // numbers if: |
2716 // code is in a loop | 2716 // code is in a loop |
2717 // the compare operation is different from equal | 2717 // the compare operation is different from equal |
2718 // compare is not a for-loop comparison | 2718 // compare is not a for-loop comparison |
2719 // The reason for excluding equal is that it will most likely be done | 2719 // The reason for excluding equal is that it will most likely be done |
2720 // with smi's (not heap numbers) and the code to comparing smi's is inlined | 2720 // with smi's (not heap numbers) and the code to comparing smi's is inlined |
2721 // separately. The same reason applies for for-loop comparison which will | 2721 // separately. The same reason applies for for-loop comparison which will |
2722 // also most likely be smi comparisons. | 2722 // also most likely be smi comparisons. |
2723 bool is_for_loop_compare = (node->AsCompareOperation() != NULL) | 2723 bool is_loop_condition = (node->AsExpression() != NULL) |
2724 && node->AsCompareOperation()->is_for_loop_condition(); | 2724 && node->AsExpression()->is_loop_condition(); |
2725 bool inline_number_compare = loop_nesting() > 0 | 2725 bool inline_number_compare = |
2726 && cc != equal | 2726 loop_nesting() > 0 && cc != equal && !is_loop_condition; |
2727 && !is_for_loop_compare; | |
2728 | 2727 |
2729 // Left and right needed in registers for the following code. | 2728 // Left and right needed in registers for the following code. |
2730 left_side.ToRegister(); | 2729 left_side.ToRegister(); |
2731 right_side.ToRegister(); | 2730 right_side.ToRegister(); |
2732 | 2731 |
2733 if (known_non_smi) { | 2732 if (known_non_smi) { |
2734 // Inline the equality check if both operands can't be a NaN. If both | 2733 // Inline the equality check if both operands can't be a NaN. If both |
2735 // objects are the same they are equal. | 2734 // objects are the same they are equal. |
2736 if (nan_info == kCantBothBeNaN && cc == equal) { | 2735 if (nan_info == kCantBothBeNaN && cc == equal) { |
2737 __ cmp(left_side.reg(), Operand(right_side.reg())); | 2736 __ cmp(left_side.reg(), Operand(right_side.reg())); |
(...skipping 9747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12485 | 12484 |
12486 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 12485 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
12487 // tagged as a small integer. | 12486 // tagged as a small integer. |
12488 __ bind(&runtime); | 12487 __ bind(&runtime); |
12489 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 12488 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
12490 } | 12489 } |
12491 | 12490 |
12492 #undef __ | 12491 #undef __ |
12493 | 12492 |
12494 } } // namespace v8::internal | 12493 } } // namespace v8::internal |
OLD | NEW |