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

Side by Side Diff: src/ia32/lithium-codegen-ia32.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/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 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 2284 matching lines...) Expand 10 before | Expand all | Expand 10 after
2295 __ sub(length, index); 2295 __ sub(length, index);
2296 DeoptimizeIf(below_equal, instr->environment()); 2296 DeoptimizeIf(below_equal, instr->environment());
2297 2297
2298 // There are two words between the frame pointer and the last argument. 2298 // There are two words between the frame pointer and the last argument.
2299 // Subtracting from length accounts for one of them add one more. 2299 // Subtracting from length accounts for one of them add one more.
2300 __ mov(result, Operand(arguments, length, times_4, kPointerSize)); 2300 __ mov(result, Operand(arguments, length, times_4, kPointerSize));
2301 } 2301 }
2302 2302
2303 2303
2304 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { 2304 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
2305 Register elements = ToRegister(instr->elements());
2306 Register key = ToRegister(instr->key());
2307 Register result = ToRegister(instr->result()); 2305 Register result = ToRegister(instr->result());
2308 ASSERT(result.is(elements));
2309 2306
2310 // Load the result. 2307 // Load the result.
2311 __ mov(result, FieldOperand(elements, 2308 __ mov(result,
2312 key, 2309 BuildFastArrayOperand(instr->elements(), instr->key(),
2313 times_pointer_size, 2310 JSObject::FAST_ELEMENTS,
2314 FixedArray::kHeaderSize)); 2311 FixedArray::kHeaderSize - kHeapObjectTag));
2315 2312
2316 // Check for the hole value. 2313 // Check for the hole value.
2317 if (instr->hydrogen()->RequiresHoleCheck()) { 2314 if (instr->hydrogen()->RequiresHoleCheck()) {
2318 __ cmp(result, factory()->the_hole_value()); 2315 __ cmp(result, factory()->the_hole_value());
2319 DeoptimizeIf(equal, instr->environment()); 2316 DeoptimizeIf(equal, instr->environment());
2320 } 2317 }
2321 } 2318 }
2322 2319
2323 2320
2324 void LCodeGen::DoLoadKeyedFastDoubleElement( 2321 void LCodeGen::DoLoadKeyedFastDoubleElement(
(...skipping 12 matching lines...) Expand all
2337 } 2334 }
2338 2335
2339 Operand double_load_operand = BuildFastArrayOperand( 2336 Operand double_load_operand = BuildFastArrayOperand(
2340 instr->elements(), instr->key(), JSObject::FAST_DOUBLE_ELEMENTS, 2337 instr->elements(), instr->key(), JSObject::FAST_DOUBLE_ELEMENTS,
2341 FixedDoubleArray::kHeaderSize - kHeapObjectTag); 2338 FixedDoubleArray::kHeaderSize - kHeapObjectTag);
2342 __ movdbl(result, double_load_operand); 2339 __ movdbl(result, double_load_operand);
2343 } 2340 }
2344 2341
2345 2342
2346 Operand LCodeGen::BuildFastArrayOperand( 2343 Operand LCodeGen::BuildFastArrayOperand(
2347 LOperand* external_pointer, 2344 LOperand* elements_pointer,
2348 LOperand* key, 2345 LOperand* key,
2349 JSObject::ElementsKind elements_kind, 2346 JSObject::ElementsKind elements_kind,
2350 uint32_t offset) { 2347 uint32_t offset) {
2351 Register external_pointer_reg = ToRegister(external_pointer); 2348 Register elements_pointer_reg = ToRegister(elements_pointer);
2352 int shift_size = ElementsKindToShiftSize(elements_kind); 2349 int shift_size = ElementsKindToShiftSize(elements_kind);
2353 if (key->IsConstantOperand()) { 2350 if (key->IsConstantOperand()) {
2354 int constant_value = ToInteger32(LConstantOperand::cast(key)); 2351 int constant_value = ToInteger32(LConstantOperand::cast(key));
2355 if (constant_value & 0xF0000000) { 2352 if (constant_value & 0xF0000000) {
2356 Abort("array index constant value too big"); 2353 Abort("array index constant value too big");
2357 } 2354 }
2358 return Operand(external_pointer_reg, 2355 return Operand(elements_pointer_reg,
2359 constant_value * (1 << shift_size) + offset); 2356 constant_value * (1 << shift_size) + offset);
2360 } else { 2357 } else {
2361 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size); 2358 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size);
2362 return Operand(external_pointer_reg, ToRegister(key), scale_factor, offset); 2359 return Operand(elements_pointer_reg, ToRegister(key), scale_factor, offset);
2363 } 2360 }
2364 } 2361 }
2365 2362
2366 2363
2367 void LCodeGen::DoLoadKeyedSpecializedArrayElement( 2364 void LCodeGen::DoLoadKeyedSpecializedArrayElement(
2368 LLoadKeyedSpecializedArrayElement* instr) { 2365 LLoadKeyedSpecializedArrayElement* instr) {
2369 JSObject::ElementsKind elements_kind = instr->elements_kind(); 2366 JSObject::ElementsKind elements_kind = instr->elements_kind();
2370 Operand operand(BuildFastArrayOperand(instr->external_pointer(), 2367 Operand operand(BuildFastArrayOperand(instr->external_pointer(),
2371 instr->key(), elements_kind, 0)); 2368 instr->key(), elements_kind, 0));
2372 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { 2369 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) {
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
3101 3098
3102 __ mov(ecx, instr->name()); 3099 __ mov(ecx, instr->name());
3103 Handle<Code> ic = instr->strict_mode() 3100 Handle<Code> ic = instr->strict_mode()
3104 ? isolate()->builtins()->StoreIC_Initialize_Strict() 3101 ? isolate()->builtins()->StoreIC_Initialize_Strict()
3105 : isolate()->builtins()->StoreIC_Initialize(); 3102 : isolate()->builtins()->StoreIC_Initialize();
3106 CallCode(ic, RelocInfo::CODE_TARGET, instr); 3103 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3107 } 3104 }
3108 3105
3109 3106
3110 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { 3107 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
3111 __ cmp(ToRegister(instr->index()), ToOperand(instr->length())); 3108 if (instr->index()->IsConstantOperand()) {
3112 DeoptimizeIf(above_equal, instr->environment()); 3109 __ cmp(ToOperand(instr->length()),
3110 ToImmediate(LConstantOperand::cast(instr->index())));
3111 DeoptimizeIf(below_equal, instr->environment());
3112 } else {
3113 __ cmp(ToRegister(instr->index()), ToOperand(instr->length()));
3114 DeoptimizeIf(above_equal, instr->environment());
3115 }
3113 } 3116 }
3114 3117
3115 3118
3116 void LCodeGen::DoStoreKeyedSpecializedArrayElement( 3119 void LCodeGen::DoStoreKeyedSpecializedArrayElement(
3117 LStoreKeyedSpecializedArrayElement* instr) { 3120 LStoreKeyedSpecializedArrayElement* instr) {
3118 JSObject::ElementsKind elements_kind = instr->elements_kind(); 3121 JSObject::ElementsKind elements_kind = instr->elements_kind();
3119 Operand operand(BuildFastArrayOperand(instr->external_pointer(), 3122 Operand operand(BuildFastArrayOperand(instr->external_pointer(),
3120 instr->key(), elements_kind, 0)); 3123 instr->key(), elements_kind, 0));
3121 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) { 3124 if (elements_kind == JSObject::EXTERNAL_FLOAT_ELEMENTS) {
3122 __ cvtsd2ss(xmm0, ToDoubleRegister(instr->value())); 3125 __ cvtsd2ss(xmm0, ToDoubleRegister(instr->value()));
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after
4399 env->deoptimization_index()); 4402 env->deoptimization_index());
4400 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4403 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4401 } 4404 }
4402 4405
4403 4406
4404 #undef __ 4407 #undef __
4405 4408
4406 } } // namespace v8::internal 4409 } } // namespace v8::internal
4407 4410
4408 #endif // V8_TARGET_ARCH_IA32 4411 #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