OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 2827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2838 } | 2838 } |
2839 | 2839 |
2840 private: | 2840 private: |
2841 CheckedSmiOpInstr* instruction_; | 2841 CheckedSmiOpInstr* instruction_; |
2842 intptr_t try_index_; | 2842 intptr_t try_index_; |
2843 }; | 2843 }; |
2844 | 2844 |
2845 | 2845 |
2846 LocationSummary* CheckedSmiOpInstr::MakeLocationSummary(Zone* zone, | 2846 LocationSummary* CheckedSmiOpInstr::MakeLocationSummary(Zone* zone, |
2847 bool opt) const { | 2847 bool opt) const { |
| 2848 bool is_shift = (op_kind() == Token::kSHL) || (op_kind() == Token::kSHR); |
2848 const intptr_t kNumInputs = 2; | 2849 const intptr_t kNumInputs = 2; |
2849 const intptr_t kNumTemps = 0; | 2850 const intptr_t kNumTemps = is_shift ? 1 : 0; |
2850 LocationSummary* summary = new (zone) LocationSummary( | 2851 LocationSummary* summary = new (zone) LocationSummary( |
2851 zone, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath); | 2852 zone, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath); |
2852 summary->set_in(0, Location::RequiresRegister()); | 2853 summary->set_in(0, Location::RequiresRegister()); |
2853 summary->set_in(1, Location::RequiresRegister()); | 2854 summary->set_in(1, Location::RequiresRegister()); |
2854 switch (op_kind()) { | 2855 switch (op_kind()) { |
2855 case Token::kADD: | 2856 case Token::kADD: |
2856 case Token::kSUB: | 2857 case Token::kSUB: |
2857 case Token::kMUL: | 2858 case Token::kMUL: |
| 2859 case Token::kSHL: |
| 2860 case Token::kSHR: |
2858 summary->set_out(0, Location::RequiresRegister()); | 2861 summary->set_out(0, Location::RequiresRegister()); |
2859 break; | 2862 break; |
2860 case Token::kBIT_OR: | 2863 case Token::kBIT_OR: |
2861 case Token::kBIT_AND: | 2864 case Token::kBIT_AND: |
2862 case Token::kBIT_XOR: | 2865 case Token::kBIT_XOR: |
2863 summary->set_out(0, Location::SameAsFirstInput()); | 2866 summary->set_out(0, Location::SameAsFirstInput()); |
2864 break; | 2867 break; |
2865 default: | 2868 default: |
2866 UNIMPLEMENTED(); | 2869 UNIMPLEMENTED(); |
2867 } | 2870 } |
| 2871 if (is_shift) { |
| 2872 summary->set_temp(0, Location::RegisterLocation(RCX)); |
| 2873 } |
2868 return summary; | 2874 return summary; |
2869 } | 2875 } |
2870 | 2876 |
2871 | 2877 |
2872 void CheckedSmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2878 void CheckedSmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2873 CheckedSmiSlowPath* slow_path = | 2879 CheckedSmiSlowPath* slow_path = |
2874 new CheckedSmiSlowPath(this, compiler->CurrentTryIndex()); | 2880 new CheckedSmiSlowPath(this, compiler->CurrentTryIndex()); |
2875 compiler->AddSlowPathCode(slow_path); | 2881 compiler->AddSlowPathCode(slow_path); |
2876 // Test operands if necessary. | 2882 // Test operands if necessary. |
2877 | 2883 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2914 __ orq(result, right); | 2920 __ orq(result, right); |
2915 break; | 2921 break; |
2916 case Token::kBIT_AND: | 2922 case Token::kBIT_AND: |
2917 ASSERT(left == result); | 2923 ASSERT(left == result); |
2918 __ andq(result, right); | 2924 __ andq(result, right); |
2919 break; | 2925 break; |
2920 case Token::kBIT_XOR: | 2926 case Token::kBIT_XOR: |
2921 ASSERT(left == result); | 2927 ASSERT(left == result); |
2922 __ xorq(result, right); | 2928 __ xorq(result, right); |
2923 break; | 2929 break; |
| 2930 case Token::kSHL: |
| 2931 ASSERT(result != right); |
| 2932 ASSERT(locs()->temp(0).reg() == RCX); |
| 2933 __ cmpq(right, Immediate(Smi::RawValue(Smi::kBits))); |
| 2934 __ j(ABOVE_EQUAL, slow_path->entry_label()); |
| 2935 |
| 2936 __ movq(RCX, right); |
| 2937 __ SmiUntag(RCX); |
| 2938 __ movq(result, left); |
| 2939 __ shlq(result, RCX); |
| 2940 __ movq(TMP, result); |
| 2941 __ sarq(TMP, RCX); |
| 2942 __ cmpq(TMP, result); |
| 2943 __ j(NOT_EQUAL, slow_path->entry_label()); |
| 2944 break; |
| 2945 case Token::kSHR: { |
| 2946 Label shift_count_ok; |
| 2947 ASSERT(result != right); |
| 2948 ASSERT(locs()->temp(0).reg() == RCX); |
| 2949 __ cmpq(right, Immediate(Smi::RawValue(Smi::kBits))); |
| 2950 __ j(ABOVE_EQUAL, slow_path->entry_label()); |
| 2951 |
| 2952 __ movq(RCX, right); |
| 2953 __ SmiUntag(RCX); |
| 2954 __ movq(result, left); |
| 2955 __ SmiUntag(result); |
| 2956 __ sarq(result, RCX); |
| 2957 __ SmiTag(result); |
| 2958 break; |
| 2959 } |
2924 default: | 2960 default: |
2925 UNIMPLEMENTED(); | 2961 UNIMPLEMENTED(); |
2926 } | 2962 } |
2927 __ Bind(slow_path->exit_label()); | 2963 __ Bind(slow_path->exit_label()); |
2928 } | 2964 } |
2929 | 2965 |
2930 | 2966 |
2931 class CheckedSmiComparisonSlowPath : public SlowPathCode { | 2967 class CheckedSmiComparisonSlowPath : public SlowPathCode { |
2932 public: | 2968 public: |
2933 CheckedSmiComparisonSlowPath(CheckedSmiComparisonInstr* instruction, | 2969 CheckedSmiComparisonSlowPath(CheckedSmiComparisonInstr* instruction, |
(...skipping 3836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6770 __ Drop(1); | 6806 __ Drop(1); |
6771 __ popq(result); | 6807 __ popq(result); |
6772 } | 6808 } |
6773 | 6809 |
6774 | 6810 |
6775 } // namespace dart | 6811 } // namespace dart |
6776 | 6812 |
6777 #undef __ | 6813 #undef __ |
6778 | 6814 |
6779 #endif // defined TARGET_ARCH_X64 | 6815 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |