Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/ia32/codegen-ia32.cc

Issue 3017025: Use static type information when creating the inlined code for comparison ope... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | src/x64/codegen-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 break; 1438 break;
1439 } 1439 }
1440 if (answer_object == Heap::undefined_value()) { 1440 if (answer_object == Heap::undefined_value()) {
1441 return false; 1441 return false;
1442 } 1442 }
1443 frame_->Push(Handle<Object>(answer_object)); 1443 frame_->Push(Handle<Object>(answer_object));
1444 return true; 1444 return true;
1445 } 1445 }
1446 1446
1447 1447
1448 void CodeGenerator::JumpIfBothSmiUsingTypeInfo(Register left,
1449 Register right,
1450 TypeInfo left_info,
1451 TypeInfo right_info,
1452 JumpTarget* both_smi) {
1453 if (left_info.IsDouble() || left_info.IsString() ||
1454 right_info.IsDouble() || right_info.IsString()) {
1455 // We know that left and right are not both smi. Don't do any tests.
1456 return;
1457 }
1458
1459 if (left.is(right)) {
1460 if (!left_info.IsSmi()) {
1461 __ test(left, Immediate(kSmiTagMask));
1462 both_smi->Branch(zero);
1463 } else {
1464 if (FLAG_debug_code) __ AbortIfNotSmi(left);
1465 both_smi->Jump();
1466 }
1467 } else if (!left_info.IsSmi()) {
1468 if (!right_info.IsSmi()) {
1469 Result temp = allocator_->Allocate();
1470 ASSERT(temp.is_valid());
1471 __ mov(temp.reg(), left);
1472 __ or_(temp.reg(), Operand(right));
1473 __ test(temp.reg(), Immediate(kSmiTagMask));
1474 temp.Unuse();
1475 both_smi->Branch(zero);
1476 } else {
1477 __ test(left, Immediate(kSmiTagMask));
1478 both_smi->Branch(zero);
1479 }
1480 } else {
1481 if (FLAG_debug_code) __ AbortIfNotSmi(left);
1482 if (!right_info.IsSmi()) {
1483 __ test(right, Immediate(kSmiTagMask));
1484 both_smi->Branch(zero);
1485 } else {
1486 if (FLAG_debug_code) __ AbortIfNotSmi(right);
1487 both_smi->Jump();
1488 }
1489 }
1490 }
1491
1492
1448 void CodeGenerator::JumpIfNotBothSmiUsingTypeInfo(Register left, 1493 void CodeGenerator::JumpIfNotBothSmiUsingTypeInfo(Register left,
1449 Register right, 1494 Register right,
1450 Register scratch, 1495 Register scratch,
1451 TypeInfo left_info, 1496 TypeInfo left_info,
1452 TypeInfo right_info, 1497 TypeInfo right_info,
1453 DeferredCode* deferred) { 1498 DeferredCode* deferred) {
1454 if (left.is(right)) { 1499 if (left.is(right)) {
1455 if (!left_info.IsSmi()) { 1500 if (!left_info.IsSmi()) {
1456 __ test(left, Immediate(kSmiTagMask)); 1501 __ test(left, Immediate(kSmiTagMask));
1457 deferred->Branch(not_zero); 1502 deferred->Branch(not_zero);
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
2728 // Here we split control flow to the stub call and inlined cases 2773 // Here we split control flow to the stub call and inlined cases
2729 // before finally splitting it to the control destination. We use 2774 // before finally splitting it to the control destination. We use
2730 // a jump target and branching to duplicate the virtual frame at 2775 // a jump target and branching to duplicate the virtual frame at
2731 // the first split. We manually handle the off-frame references 2776 // the first split. We manually handle the off-frame references
2732 // by reconstituting them on the non-fall-through path. 2777 // by reconstituting them on the non-fall-through path.
2733 JumpTarget is_smi; 2778 JumpTarget is_smi;
2734 Register left_reg = left_side.reg(); 2779 Register left_reg = left_side.reg();
2735 Register right_reg = right_side.reg(); 2780 Register right_reg = right_side.reg();
2736 2781
2737 // In-line check for comparing two smis. 2782 // In-line check for comparing two smis.
2738 Result temp = allocator_->Allocate(); 2783 JumpIfBothSmiUsingTypeInfo(left_side.reg(), right_side.reg(),
2739 ASSERT(temp.is_valid()); 2784 left_side.type_info(), right_side.type_info(),
2740 __ mov(temp.reg(), left_side.reg()); 2785 &is_smi);
2741 __ or_(temp.reg(), Operand(right_side.reg()));
2742 __ test(temp.reg(), Immediate(kSmiTagMask));
2743 temp.Unuse();
2744 is_smi.Branch(zero, taken);
2745 2786
2746 // Inline the equality check if both operands can't be a NaN. If both 2787 if (has_valid_frame()) {
2747 // objects are the same they are equal. 2788 // Inline the equality check if both operands can't be a NaN. If both
2748 if (nan_info == kCantBothBeNaN && cc == equal) { 2789 // objects are the same they are equal.
2749 __ cmp(left_side.reg(), Operand(right_side.reg())); 2790 if (nan_info == kCantBothBeNaN && cc == equal) {
2750 dest->true_target()->Branch(equal); 2791 __ cmp(left_side.reg(), Operand(right_side.reg()));
2792 dest->true_target()->Branch(equal);
2793 }
2794
2795 // Inlined number comparison:
2796 if (inline_number_compare) {
2797 GenerateInlineNumberComparison(&left_side, &right_side, cc, dest);
2798 }
2799
2800 // End of in-line compare, call out to the compare stub. Don't include
2801 // number comparison in the stub if it was inlined.
2802 CompareStub stub(cc, strict, nan_info, !inline_number_compare);
2803 Result answer = frame_->CallStub(&stub, &left_side, &right_side);
2804 __ test(answer.reg(), Operand(answer.reg()));
2805 answer.Unuse();
2806 if (is_smi.is_linked()) {
2807 dest->true_target()->Branch(cc);
2808 dest->false_target()->Jump();
2809 } else {
2810 dest->Split(cc);
2811 }
2751 } 2812 }
2752 2813
2753 // Inlined number comparison: 2814 if (is_smi.is_linked()) {
2754 if (inline_number_compare) { 2815 is_smi.Bind();
2755 GenerateInlineNumberComparison(&left_side, &right_side, cc, dest); 2816 left_side = Result(left_reg);
2817 right_side = Result(right_reg);
2818 __ cmp(left_side.reg(), Operand(right_side.reg()));
2819 right_side.Unuse();
2820 left_side.Unuse();
2821 dest->Split(cc);
2756 } 2822 }
2757
2758 // End of in-line compare, call out to the compare stub. Don't include
2759 // number comparison in the stub if it was inlined.
2760 CompareStub stub(cc, strict, nan_info, !inline_number_compare);
2761 Result answer = frame_->CallStub(&stub, &left_side, &right_side);
2762 __ test(answer.reg(), Operand(answer.reg()));
2763 answer.Unuse();
2764 dest->true_target()->Branch(cc);
2765 dest->false_target()->Jump();
2766
2767 is_smi.Bind();
2768 left_side = Result(left_reg);
2769 right_side = Result(right_reg);
2770 __ cmp(left_side.reg(), Operand(right_side.reg()));
2771 right_side.Unuse();
2772 left_side.Unuse();
2773 dest->Split(cc);
2774 } 2823 }
2775 } 2824 }
2776 } 2825 }
2777 2826
2778 2827
2779 void CodeGenerator::ConstantSmiComparison(Condition cc, 2828 void CodeGenerator::ConstantSmiComparison(Condition cc,
2780 bool strict, 2829 bool strict,
2781 ControlDestination* dest, 2830 ControlDestination* dest,
2782 Result* left_side, 2831 Result* left_side,
2783 Result* right_side, 2832 Result* right_side,
(...skipping 11119 matching lines...) Expand 10 before | Expand all | Expand 10 after
13903 masm.GetCode(&desc); 13952 masm.GetCode(&desc);
13904 // Call the function from C++. 13953 // Call the function from C++.
13905 return FUNCTION_CAST<MemCopyFunction>(buffer); 13954 return FUNCTION_CAST<MemCopyFunction>(buffer);
13906 } 13955 }
13907 13956
13908 #undef __ 13957 #undef __
13909 13958
13910 } } // namespace v8::internal 13959 } } // namespace v8::internal
13911 13960
13912 #endif // V8_TARGET_ARCH_IA32 13961 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | src/x64/codegen-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698