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

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

Issue 11299328: Implement basic array prefetching hints in Hydrogen. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years 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/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.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 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 2831 matching lines...) Expand 10 before | Expand all | Expand 10 after
2842 case FAST_DOUBLE_ELEMENTS: 2842 case FAST_DOUBLE_ELEMENTS:
2843 case FAST_HOLEY_SMI_ELEMENTS: 2843 case FAST_HOLEY_SMI_ELEMENTS:
2844 case FAST_HOLEY_ELEMENTS: 2844 case FAST_HOLEY_ELEMENTS:
2845 case FAST_HOLEY_DOUBLE_ELEMENTS: 2845 case FAST_HOLEY_DOUBLE_ELEMENTS:
2846 case DICTIONARY_ELEMENTS: 2846 case DICTIONARY_ELEMENTS:
2847 case NON_STRICT_ARGUMENTS_ELEMENTS: 2847 case NON_STRICT_ARGUMENTS_ELEMENTS:
2848 UNREACHABLE(); 2848 UNREACHABLE();
2849 break; 2849 break;
2850 } 2850 }
2851 } 2851 }
2852
2853 if (instr->prefetch_distance() != NULL) {
2854 InsertArrayPrefetch(
2855 operand,
2856 instr->prefetch_distance(),
2857 elements_kind,
2858 ToRegister(instr->temp()));
2859 }
2852 } 2860 }
2853 2861
2854 2862
2855 void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) { 2863 void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) {
2856 XMMRegister result = ToDoubleRegister(instr->result()); 2864 XMMRegister result = ToDoubleRegister(instr->result());
2857 2865
2858 if (instr->hydrogen()->RequiresHoleCheck()) { 2866 if (instr->hydrogen()->RequiresHoleCheck()) {
2859 int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + 2867 int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag +
2860 sizeof(kHoleNanLower32); 2868 sizeof(kHoleNanLower32);
2861 Operand hole_check_operand = BuildFastArrayOperand( 2869 Operand hole_check_operand = BuildFastArrayOperand(
2862 instr->elements(), instr->key(), 2870 instr->elements(), instr->key(),
2863 instr->hydrogen()->key()->representation(), 2871 instr->hydrogen()->key()->representation(),
2864 FAST_DOUBLE_ELEMENTS, 2872 FAST_DOUBLE_ELEMENTS,
2865 offset, 2873 offset,
2866 instr->additional_index()); 2874 instr->additional_index());
2867 __ cmp(hole_check_operand, Immediate(kHoleNanUpper32)); 2875 __ cmp(hole_check_operand, Immediate(kHoleNanUpper32));
2868 DeoptimizeIf(equal, instr->environment()); 2876 DeoptimizeIf(equal, instr->environment());
2869 } 2877 }
2870 2878
2871 Operand double_load_operand = BuildFastArrayOperand( 2879 Operand double_load_operand = BuildFastArrayOperand(
2872 instr->elements(), 2880 instr->elements(),
2873 instr->key(), 2881 instr->key(),
2874 instr->hydrogen()->key()->representation(), 2882 instr->hydrogen()->key()->representation(),
2875 FAST_DOUBLE_ELEMENTS, 2883 FAST_DOUBLE_ELEMENTS,
2876 FixedDoubleArray::kHeaderSize - kHeapObjectTag, 2884 FixedDoubleArray::kHeaderSize - kHeapObjectTag,
2877 instr->additional_index()); 2885 instr->additional_index());
2878 __ movdbl(result, double_load_operand); 2886 __ movdbl(result, double_load_operand);
2887
2888 if (instr->prefetch_distance() != NULL) {
2889 InsertArrayPrefetch(
2890 double_load_operand,
2891 instr->prefetch_distance(),
2892 FAST_DOUBLE_ELEMENTS,
2893 ToRegister(instr->temp()));
2894 }
2879 } 2895 }
2880 2896
2881 2897
2882 void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) { 2898 void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) {
2883 Register result = ToRegister(instr->result()); 2899 Register result = ToRegister(instr->result());
2884 2900
2901 Operand load_operand = BuildFastArrayOperand(
2902 instr->elements(),
2903 instr->key(),
2904 instr->hydrogen()->key()->representation(),
2905 FAST_ELEMENTS,
2906 FixedArray::kHeaderSize - kHeapObjectTag,
2907 instr->additional_index());
2908
2885 // Load the result. 2909 // Load the result.
2886 __ mov(result, 2910 __ mov(result, load_operand);
2887 BuildFastArrayOperand(instr->elements(),
2888 instr->key(),
2889 instr->hydrogen()->key()->representation(),
2890 FAST_ELEMENTS,
2891 FixedArray::kHeaderSize - kHeapObjectTag,
2892 instr->additional_index()));
2893 2911
2894 // Check for the hole value. 2912 // Check for the hole value.
2895 if (instr->hydrogen()->RequiresHoleCheck()) { 2913 if (instr->hydrogen()->RequiresHoleCheck()) {
2896 if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) { 2914 if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) {
2897 __ test(result, Immediate(kSmiTagMask)); 2915 __ test(result, Immediate(kSmiTagMask));
2898 DeoptimizeIf(not_equal, instr->environment()); 2916 DeoptimizeIf(not_equal, instr->environment());
2899 } else { 2917 } else {
2900 __ cmp(result, factory()->the_hole_value()); 2918 __ cmp(result, factory()->the_hole_value());
2901 DeoptimizeIf(equal, instr->environment()); 2919 DeoptimizeIf(equal, instr->environment());
2902 } 2920 }
2903 } 2921 }
2922
2923 if (instr->prefetch_distance() != NULL) {
2924 InsertArrayPrefetch(
2925 load_operand,
2926 instr->prefetch_distance(),
2927 FAST_ELEMENTS,
2928 ToRegister(instr->temp()));
2929 }
2904 } 2930 }
2905 2931
2906 2932
2907 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { 2933 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) {
2908 if (instr->is_external()) { 2934 if (instr->is_external()) {
2909 DoLoadKeyedExternalArray(instr); 2935 DoLoadKeyedExternalArray(instr);
2910 } else if (instr->hydrogen()->representation().IsDouble()) { 2936 } else if (instr->hydrogen()->representation().IsDouble()) {
2911 DoLoadKeyedFixedDoubleArray(instr); 2937 DoLoadKeyedFixedDoubleArray(instr);
2912 } else { 2938 } else {
2913 DoLoadKeyedFixedArray(instr); 2939 DoLoadKeyedFixedArray(instr);
2914 } 2940 }
2915 } 2941 }
2916 2942
2917 2943
2944 void LCodeGen::InsertArrayPrefetch(
2945 const Operand& operand,
2946 LOperand* prefetch_distance,
2947 ElementsKind elements_kind,
2948 Register scratch) {
2949 __ lea(scratch, operand);
2950 int shift_size = ElementsKindToShiftSize(elements_kind);
2951 if (prefetch_distance->IsConstantOperand()) {
2952 __ prefetch(Operand(scratch,
2953 ToInteger32(LConstantOperand::cast(prefetch_distance)) << shift_size),
2954 1);
2955 } else {
2956 ASSERT(prefetch_distance->IsRegister());
2957 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size);
2958 __ prefetch(
2959 Operand(scratch, ToRegister(prefetch_distance), scale_factor, 0), 1);
2960 }
2961 }
2962
2963
2918 Operand LCodeGen::BuildFastArrayOperand( 2964 Operand LCodeGen::BuildFastArrayOperand(
2919 LOperand* elements_pointer, 2965 LOperand* elements_pointer,
2920 LOperand* key, 2966 LOperand* key,
2921 Representation key_representation, 2967 Representation key_representation,
2922 ElementsKind elements_kind, 2968 ElementsKind elements_kind,
2923 uint32_t offset, 2969 uint32_t offset,
2924 uint32_t additional_index) { 2970 uint32_t additional_index) {
2925 Register elements_pointer_reg = ToRegister(elements_pointer); 2971 Register elements_pointer_reg = ToRegister(elements_pointer);
2926 int shift_size = ElementsKindToShiftSize(elements_kind); 2972 int shift_size = ElementsKindToShiftSize(elements_kind);
2927 // Even though the HLoad/StoreKeyed instructions force the input 2973 // Even though the HLoad/StoreKeyed instructions force the input
(...skipping 2684 matching lines...) Expand 10 before | Expand all | Expand 10 after
5612 FixedArray::kHeaderSize - kPointerSize)); 5658 FixedArray::kHeaderSize - kPointerSize));
5613 __ bind(&done); 5659 __ bind(&done);
5614 } 5660 }
5615 5661
5616 5662
5617 #undef __ 5663 #undef __
5618 5664
5619 } } // namespace v8::internal 5665 } } // namespace v8::internal
5620 5666
5621 #endif // V8_TARGET_ARCH_IA32 5667 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698