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

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

Issue 7608020: Use immediates when possible for HBoundsCheck and HLoadKeyedFastElement (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: refactored as suggested Created 9 years, 4 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/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 } 2298 }
2299 DeoptimizeIf(below_equal, instr->environment()); 2299 DeoptimizeIf(below_equal, instr->environment());
2300 2300
2301 // There are two words between the frame pointer and the last argument. 2301 // There are two words between the frame pointer and the last argument.
2302 // Subtracting from length accounts for one of them add one more. 2302 // Subtracting from length accounts for one of them add one more.
2303 __ movq(result, Operand(arguments, length, times_pointer_size, kPointerSize)); 2303 __ movq(result, Operand(arguments, length, times_pointer_size, kPointerSize));
2304 } 2304 }
2305 2305
2306 2306
2307 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { 2307 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
2308 Register elements = ToRegister(instr->elements());
2309 Register key = ToRegister(instr->key());
2310 Register result = ToRegister(instr->result()); 2308 Register result = ToRegister(instr->result());
2311 ASSERT(result.is(elements));
2312 2309
2313 // Load the result. 2310 // Load the result.
2314 __ movq(result, FieldOperand(elements, 2311 __ movq(result,
2315 key, 2312 BuildFastArrayOperand(instr->elements(), instr->key(),
2316 times_pointer_size, 2313 JSObject::FAST_ELEMENTS,
2317 FixedArray::kHeaderSize)); 2314 FixedArray::kHeaderSize - kHeapObjectTag));
2318 2315
2319 // Check for the hole value. 2316 // Check for the hole value.
2320 if (instr->hydrogen()->RequiresHoleCheck()) { 2317 if (instr->hydrogen()->RequiresHoleCheck()) {
2321 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); 2318 __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
2322 DeoptimizeIf(equal, instr->environment()); 2319 DeoptimizeIf(equal, instr->environment());
2323 } 2320 }
2324 } 2321 }
2325 2322
2326 2323
2327 void LCodeGen::DoLoadKeyedFastDoubleElement( 2324 void LCodeGen::DoLoadKeyedFastDoubleElement(
(...skipping 13 matching lines...) Expand all
2341 } 2338 }
2342 2339
2343 Operand double_load_operand = BuildFastArrayOperand( 2340 Operand double_load_operand = BuildFastArrayOperand(
2344 instr->elements(), instr->key(), JSObject::FAST_DOUBLE_ELEMENTS, 2341 instr->elements(), instr->key(), JSObject::FAST_DOUBLE_ELEMENTS,
2345 FixedDoubleArray::kHeaderSize - kHeapObjectTag); 2342 FixedDoubleArray::kHeaderSize - kHeapObjectTag);
2346 __ movsd(result, double_load_operand); 2343 __ movsd(result, double_load_operand);
2347 } 2344 }
2348 2345
2349 2346
2350 Operand LCodeGen::BuildFastArrayOperand( 2347 Operand LCodeGen::BuildFastArrayOperand(
2351 LOperand* external_pointer, 2348 LOperand* elements_pointer,
2352 LOperand* key, 2349 LOperand* key,
2353 JSObject::ElementsKind elements_kind, 2350 JSObject::ElementsKind elements_kind,
2354 uint32_t offset) { 2351 uint32_t offset) {
2355 Register external_pointer_reg = ToRegister(external_pointer); 2352 Register elements_pointer_reg = ToRegister(elements_pointer);
2356 int shift_size = ElementsKindToShiftSize(elements_kind); 2353 int shift_size = ElementsKindToShiftSize(elements_kind);
2357 if (key->IsConstantOperand()) { 2354 if (key->IsConstantOperand()) {
2358 int constant_value = ToInteger32(LConstantOperand::cast(key)); 2355 int constant_value = ToInteger32(LConstantOperand::cast(key));
2359 if (constant_value & 0xF0000000) { 2356 if (constant_value & 0xF0000000) {
2360 Abort("array index constant value too big"); 2357 Abort("array index constant value too big");
2361 } 2358 }
2362 return Operand(external_pointer_reg, 2359 return Operand(elements_pointer_reg,
2363 constant_value * (1 << shift_size) + offset); 2360 constant_value * (1 << shift_size) + offset);
2364 } else { 2361 } else {
2365 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size); 2362 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size);
2366 return Operand(external_pointer_reg, ToRegister(key), 2363 return Operand(elements_pointer_reg, ToRegister(key),
2367 scale_factor, offset); 2364 scale_factor, offset);
2368 } 2365 }
2369 } 2366 }
2370 2367
2371 2368
2372 void LCodeGen::DoLoadKeyedSpecializedArrayElement( 2369 void LCodeGen::DoLoadKeyedSpecializedArrayElement(
2373 LLoadKeyedSpecializedArrayElement* instr) { 2370 LLoadKeyedSpecializedArrayElement* instr) {
2374 JSObject::ElementsKind elements_kind = instr->elements_kind(); 2371 JSObject::ElementsKind elements_kind = instr->elements_kind();
2375 Operand operand(BuildFastArrayOperand(instr->external_pointer(), 2372 Operand operand(BuildFastArrayOperand(instr->external_pointer(),
2376 instr->key(), elements_kind, 0)); 2373 instr->key(), elements_kind, 0));
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
3130 case JSObject::DICTIONARY_ELEMENTS: 3127 case JSObject::DICTIONARY_ELEMENTS:
3131 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: 3128 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS:
3132 UNREACHABLE(); 3129 UNREACHABLE();
3133 break; 3130 break;
3134 } 3131 }
3135 } 3132 }
3136 } 3133 }
3137 3134
3138 3135
3139 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { 3136 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
3140 if (instr->length()->IsRegister()) { 3137 if (instr->index()->IsConstantOperand()) {
3141 __ cmpq(ToRegister(instr->index()), ToRegister(instr->length())); 3138 if (instr->length()->IsRegister()) {
3139 __ cmpq(ToRegister(instr->length()),
3140 Immediate(ToInteger32(LConstantOperand::cast(instr->index()))));
3141 } else {
3142 __ cmpq(ToOperand(instr->length()),
3143 Immediate(ToInteger32(LConstantOperand::cast(instr->index()))));
3144 }
3142 } else { 3145 } else {
3143 __ cmpq(ToRegister(instr->index()), ToOperand(instr->length())); 3146 if (instr->length()->IsRegister()) {
3147 __ cmpq(ToRegister(instr->length()), ToRegister(instr->index()));
3148 } else {
3149 __ cmpq(ToOperand(instr->length()), ToRegister(instr->index()));
3150 }
3144 } 3151 }
3145 DeoptimizeIf(above_equal, instr->environment()); 3152 DeoptimizeIf(below_equal, instr->environment());
3146 } 3153 }
3147 3154
3148 3155
3149 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { 3156 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) {
3150 Register value = ToRegister(instr->value()); 3157 Register value = ToRegister(instr->value());
3151 Register elements = ToRegister(instr->object()); 3158 Register elements = ToRegister(instr->object());
3152 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; 3159 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg;
3153 3160
3154 // Do the store. 3161 // Do the store.
3155 if (instr->key()->IsConstantOperand()) { 3162 if (instr->key()->IsConstantOperand()) {
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
4184 RegisterEnvironmentForDeoptimization(environment); 4191 RegisterEnvironmentForDeoptimization(environment);
4185 ASSERT(osr_pc_offset_ == -1); 4192 ASSERT(osr_pc_offset_ == -1);
4186 osr_pc_offset_ = masm()->pc_offset(); 4193 osr_pc_offset_ = masm()->pc_offset();
4187 } 4194 }
4188 4195
4189 #undef __ 4196 #undef __
4190 4197
4191 } } // namespace v8::internal 4198 } } // namespace v8::internal
4192 4199
4193 #endif // V8_TARGET_ARCH_X64 4200 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698