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

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

Issue 11411351: Implement basic array prefetching hints in Hydrogen. Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 11 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/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 3079 matching lines...) Expand 10 before | Expand all | Expand 10 after
3090 case FAST_DOUBLE_ELEMENTS: 3090 case FAST_DOUBLE_ELEMENTS:
3091 case FAST_HOLEY_SMI_ELEMENTS: 3091 case FAST_HOLEY_SMI_ELEMENTS:
3092 case FAST_HOLEY_ELEMENTS: 3092 case FAST_HOLEY_ELEMENTS:
3093 case FAST_HOLEY_DOUBLE_ELEMENTS: 3093 case FAST_HOLEY_DOUBLE_ELEMENTS:
3094 case DICTIONARY_ELEMENTS: 3094 case DICTIONARY_ELEMENTS:
3095 case NON_STRICT_ARGUMENTS_ELEMENTS: 3095 case NON_STRICT_ARGUMENTS_ELEMENTS:
3096 UNREACHABLE(); 3096 UNREACHABLE();
3097 break; 3097 break;
3098 } 3098 }
3099 } 3099 }
3100
3101 if (instr->prefetch_distance() != NULL) {
3102 InsertArrayPrefetch(
3103 operand,
3104 instr->prefetch_distance(),
3105 elements_kind,
3106 ToRegister(instr->temp()));
3107 }
3100 } 3108 }
3101 3109
3102 3110
3103 void LCodeGen::HandleX87FPReturnValue(LInstruction* instr) { 3111 void LCodeGen::HandleX87FPReturnValue(LInstruction* instr) {
3104 if (IsX87TopOfStack(instr->result())) { 3112 if (IsX87TopOfStack(instr->result())) {
3105 // Return value is already on stack. If the value has no uses, then 3113 // Return value is already on stack. If the value has no uses, then
3106 // pop it off the FP stack. Otherwise, make sure that there are enough 3114 // pop it off the FP stack. Otherwise, make sure that there are enough
3107 // copies of the value on the stack to feed all of the usages, e.g. 3115 // copies of the value on the stack to feed all of the usages, e.g.
3108 // when the following instruction uses the return value in multiple 3116 // when the following instruction uses the return value in multiple
3109 // inputs. 3117 // inputs.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3145 FixedDoubleArray::kHeaderSize - kHeapObjectTag, 3153 FixedDoubleArray::kHeaderSize - kHeapObjectTag,
3146 instr->additional_index()); 3154 instr->additional_index());
3147 if (CpuFeatures::IsSupported(SSE2)) { 3155 if (CpuFeatures::IsSupported(SSE2)) {
3148 CpuFeatures::Scope scope(SSE2); 3156 CpuFeatures::Scope scope(SSE2);
3149 XMMRegister result = ToDoubleRegister(instr->result()); 3157 XMMRegister result = ToDoubleRegister(instr->result());
3150 __ movdbl(result, double_load_operand); 3158 __ movdbl(result, double_load_operand);
3151 } else { 3159 } else {
3152 __ fld_d(double_load_operand); 3160 __ fld_d(double_load_operand);
3153 HandleX87FPReturnValue(instr); 3161 HandleX87FPReturnValue(instr);
3154 } 3162 }
3163
3164 if (instr->prefetch_distance() != NULL) {
3165 InsertArrayPrefetch(
3166 double_load_operand,
3167 instr->prefetch_distance(),
3168 FAST_DOUBLE_ELEMENTS,
3169 ToRegister(instr->temp()));
3170 }
3155 } 3171 }
3156 3172
3157 3173
3158 void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) { 3174 void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) {
3159 Register result = ToRegister(instr->result()); 3175 Register result = ToRegister(instr->result());
3160 3176
3177 Operand load_operand = BuildFastArrayOperand(
3178 instr->elements(),
3179 instr->key(),
3180 instr->hydrogen()->key()->representation(),
3181 FAST_ELEMENTS,
3182 FixedArray::kHeaderSize - kHeapObjectTag,
3183 instr->additional_index());
3184
3161 // Load the result. 3185 // Load the result.
3162 __ mov(result, 3186 __ mov(result, load_operand);
3163 BuildFastArrayOperand(instr->elements(),
3164 instr->key(),
3165 instr->hydrogen()->key()->representation(),
3166 FAST_ELEMENTS,
3167 FixedArray::kHeaderSize - kHeapObjectTag,
3168 instr->additional_index()));
3169 3187
3170 // Check for the hole value. 3188 // Check for the hole value.
3171 if (instr->hydrogen()->RequiresHoleCheck()) { 3189 if (instr->hydrogen()->RequiresHoleCheck()) {
3172 if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) { 3190 if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) {
3173 __ test(result, Immediate(kSmiTagMask)); 3191 __ test(result, Immediate(kSmiTagMask));
3174 DeoptimizeIf(not_equal, instr->environment()); 3192 DeoptimizeIf(not_equal, instr->environment());
3175 } else { 3193 } else {
3176 __ cmp(result, factory()->the_hole_value()); 3194 __ cmp(result, factory()->the_hole_value());
3177 DeoptimizeIf(equal, instr->environment()); 3195 DeoptimizeIf(equal, instr->environment());
3178 } 3196 }
3179 } 3197 }
3198
3199 if (instr->prefetch_distance() != NULL) {
3200 InsertArrayPrefetch(
3201 load_operand,
3202 instr->prefetch_distance(),
3203 FAST_ELEMENTS,
3204 ToRegister(instr->temp()));
3205 }
3180 } 3206 }
3181 3207
3182 3208
3183 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) { 3209 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) {
3184 if (instr->is_external()) { 3210 if (instr->is_external()) {
3185 DoLoadKeyedExternalArray(instr); 3211 DoLoadKeyedExternalArray(instr);
3186 } else if (instr->hydrogen()->representation().IsDouble()) { 3212 } else if (instr->hydrogen()->representation().IsDouble()) {
3187 DoLoadKeyedFixedDoubleArray(instr); 3213 DoLoadKeyedFixedDoubleArray(instr);
3188 } else { 3214 } else {
3189 DoLoadKeyedFixedArray(instr); 3215 DoLoadKeyedFixedArray(instr);
3190 } 3216 }
3191 } 3217 }
3192 3218
3193 3219
3220 void LCodeGen::InsertArrayPrefetch(
3221 const Operand& operand,
3222 LOperand* prefetch_distance,
3223 ElementsKind elements_kind,
3224 Register scratch) {
3225 __ lea(scratch, operand);
3226 int shift_size = ElementsKindToShiftSize(elements_kind);
3227 if (prefetch_distance->IsConstantOperand()) {
3228 __ prefetch(Operand(scratch,
3229 ToInteger32(LConstantOperand::cast(prefetch_distance)) << shift_size),
3230 1);
3231 } else {
3232 ASSERT(prefetch_distance->IsRegister());
3233 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size);
3234 __ prefetch(
3235 Operand(scratch, ToRegister(prefetch_distance), scale_factor, 0), 1);
3236 }
3237 }
3238
3239
3194 Operand LCodeGen::BuildFastArrayOperand( 3240 Operand LCodeGen::BuildFastArrayOperand(
3195 LOperand* elements_pointer, 3241 LOperand* elements_pointer,
3196 LOperand* key, 3242 LOperand* key,
3197 Representation key_representation, 3243 Representation key_representation,
3198 ElementsKind elements_kind, 3244 ElementsKind elements_kind,
3199 uint32_t offset, 3245 uint32_t offset,
3200 uint32_t additional_index) { 3246 uint32_t additional_index) {
3201 Register elements_pointer_reg = ToRegister(elements_pointer); 3247 Register elements_pointer_reg = ToRegister(elements_pointer);
3202 int shift_size = ElementsKindToShiftSize(elements_kind); 3248 int shift_size = ElementsKindToShiftSize(elements_kind);
3203 // Even though the HLoad/StoreKeyed instructions force the input 3249 // Even though the HLoad/StoreKeyed instructions force the input
(...skipping 2751 matching lines...) Expand 10 before | Expand all | Expand 10 after
5955 FixedArray::kHeaderSize - kPointerSize)); 6001 FixedArray::kHeaderSize - kPointerSize));
5956 __ bind(&done); 6002 __ bind(&done);
5957 } 6003 }
5958 6004
5959 6005
5960 #undef __ 6006 #undef __
5961 6007
5962 } } // namespace v8::internal 6008 } } // namespace v8::internal
5963 6009
5964 #endif // V8_TARGET_ARCH_IA32 6010 #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