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

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

Issue 6805005: Fix opmitized external array access for compound assignments (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: remove unchanged file Created 9 years, 8 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
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 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 Register input = ToRegister(instr->InputAt(0)); 2354 Register input = ToRegister(instr->InputAt(0));
2355 Register scratch = scratch0(); 2355 Register scratch = scratch0();
2356 2356
2357 __ ldr(result, FieldMemOperand(input, JSObject::kElementsOffset)); 2357 __ ldr(result, FieldMemOperand(input, JSObject::kElementsOffset));
2358 if (FLAG_debug_code) { 2358 if (FLAG_debug_code) {
2359 Label done; 2359 Label done;
2360 __ ldr(scratch, FieldMemOperand(result, HeapObject::kMapOffset)); 2360 __ ldr(scratch, FieldMemOperand(result, HeapObject::kMapOffset));
2361 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex); 2361 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex);
2362 __ cmp(scratch, ip); 2362 __ cmp(scratch, ip);
2363 __ b(eq, &done); 2363 __ b(eq, &done);
2364 __ LoadRoot(ip, Heap::kExternalPixelArrayMapRootIndex);
2365 __ cmp(scratch, ip);
2366 __ b(eq, &done);
2367 __ LoadRoot(ip, Heap::kFixedCOWArrayMapRootIndex); 2364 __ LoadRoot(ip, Heap::kFixedCOWArrayMapRootIndex);
2368 __ cmp(scratch, ip); 2365 __ cmp(scratch, ip);
2369 __ Check(eq, "Check for fast elements failed."); 2366 __ ldr(scratch, FieldMemOperand(result, HeapObject::kMapOffset));
2367 __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
2368 __ sub(scratch, scratch, Operand(FIRST_EXTERNAL_ARRAY_TYPE));
2369 __ cmp(scratch, Operand(kExternalArrayTypeCount));
2370 __ Check(cc, "Check for fast elements failed.");
2370 __ bind(&done); 2371 __ bind(&done);
2371 } 2372 }
2372 } 2373 }
2373 2374
2374 2375
2375 void LCodeGen::DoLoadExternalArrayPointer( 2376 void LCodeGen::DoLoadExternalArrayPointer(
2376 LLoadExternalArrayPointer* instr) { 2377 LLoadExternalArrayPointer* instr) {
2377 Register to_reg = ToRegister(instr->result()); 2378 Register to_reg = ToRegister(instr->result());
2378 Register from_reg = ToRegister(instr->InputAt(0)); 2379 Register from_reg = ToRegister(instr->InputAt(0));
2379 __ ldr(to_reg, FieldMemOperand(from_reg, 2380 __ ldr(to_reg, FieldMemOperand(from_reg,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2412 2413
2413 // Check for the hole value. 2414 // Check for the hole value.
2414 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex); 2415 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex);
2415 __ cmp(result, scratch); 2416 __ cmp(result, scratch);
2416 DeoptimizeIf(eq, instr->environment()); 2417 DeoptimizeIf(eq, instr->environment());
2417 } 2418 }
2418 2419
2419 2420
2420 void LCodeGen::DoLoadKeyedSpecializedArrayElement( 2421 void LCodeGen::DoLoadKeyedSpecializedArrayElement(
2421 LLoadKeyedSpecializedArrayElement* instr) { 2422 LLoadKeyedSpecializedArrayElement* instr) {
2422 ASSERT(instr->array_type() == kExternalPixelArray);
2423
2424 Register external_pointer = ToRegister(instr->external_pointer()); 2423 Register external_pointer = ToRegister(instr->external_pointer());
2425 Register key = ToRegister(instr->key()); 2424 Register key = ToRegister(instr->key());
2426 Register result = ToRegister(instr->result()); 2425 ExternalArrayType array_type = instr->array_type();
2427 2426 if (array_type == kExternalFloatArray) {
2428 // Load the result. 2427 if (CpuFeatures::IsSupported(VFP3)) {
2429 __ ldrb(result, MemOperand(external_pointer, key)); 2428 CpuFeatures::Scope scope(VFP3);
2429 DwVfpRegister result(ToDoubleRegister(instr->result()));
2430 __ add(scratch0(), external_pointer, Operand(key, LSL, 2));
2431 __ vldr(result, scratch0(), 0);
2432 } else {
2433 Register result(ToRegister(instr->result()));
2434 __ ldr(result, MemOperand(external_pointer, key, LSL, 2));
2435 }
2436 } else {
2437 Register result(ToRegister(instr->result()));
2438 switch (array_type) {
2439 case kExternalByteArray:
2440 __ ldrsb(result, MemOperand(external_pointer, key));
2441 break;
2442 case kExternalUnsignedByteArray:
2443 case kExternalPixelArray:
2444 __ ldrb(result, MemOperand(external_pointer, key));
2445 break;
2446 case kExternalShortArray:
2447 __ ldrsh(result, MemOperand(external_pointer, key, LSL, 1));
2448 break;
2449 case kExternalUnsignedShortArray:
2450 __ ldrh(result, MemOperand(external_pointer, key, LSL, 1));
2451 break;
2452 case kExternalIntArray:
2453 __ ldr(result, MemOperand(external_pointer, key, LSL, 2));
2454 break;
2455 case kExternalUnsignedIntArray:
2456 __ ldr(result, MemOperand(external_pointer, key, LSL, 2));
2457 __ cmp(result, Operand(0x80000000));
2458 // TODO(danno): we could be more clever here, perhaps having a special
2459 // version of the stub that detects if the overflow case actually
2460 // happens, and generate code that returns a double rather than int.
2461 DeoptimizeIf(cs, instr->environment());
2462 break;
2463 case kExternalFloatArray:
2464 default:
2465 UNREACHABLE();
2466 break;
2467 }
2468 }
2430 } 2469 }
2431 2470
2432 2471
2433 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { 2472 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
2434 ASSERT(ToRegister(instr->object()).is(r1)); 2473 ASSERT(ToRegister(instr->object()).is(r1));
2435 ASSERT(ToRegister(instr->key()).is(r0)); 2474 ASSERT(ToRegister(instr->key()).is(r0));
2436 2475
2437 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); 2476 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
2438 CallCode(ic, RelocInfo::CODE_TARGET, instr); 2477 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2439 } 2478 }
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
3083 if (instr->hydrogen()->NeedsWriteBarrier()) { 3122 if (instr->hydrogen()->NeedsWriteBarrier()) {
3084 // Compute address of modified element and store it into key register. 3123 // Compute address of modified element and store it into key register.
3085 __ add(key, scratch, Operand(FixedArray::kHeaderSize)); 3124 __ add(key, scratch, Operand(FixedArray::kHeaderSize));
3086 __ RecordWrite(elements, key, value); 3125 __ RecordWrite(elements, key, value);
3087 } 3126 }
3088 } 3127 }
3089 3128
3090 3129
3091 void LCodeGen::DoStoreKeyedSpecializedArrayElement( 3130 void LCodeGen::DoStoreKeyedSpecializedArrayElement(
3092 LStoreKeyedSpecializedArrayElement* instr) { 3131 LStoreKeyedSpecializedArrayElement* instr) {
3093 ASSERT(instr->array_type() == kExternalPixelArray);
3094 3132
3095 Register external_pointer = ToRegister(instr->external_pointer()); 3133 Register external_pointer = ToRegister(instr->external_pointer());
3096 Register key = ToRegister(instr->key()); 3134 Register key = ToRegister(instr->key());
3097 Register value = ToRegister(instr->value()); 3135 ExternalArrayType array_type = instr->array_type();
3098 3136 if (array_type == kExternalFloatArray) {
3099 // Clamp the value to [0..255]. 3137 if (CpuFeatures::IsSupported(VFP3)) {
3100 __ Usat(value, 8, Operand(value)); 3138 CpuFeatures::Scope scope(VFP3);
3101 __ strb(value, MemOperand(external_pointer, key, LSL, 0)); 3139 DwVfpRegister value(ToDoubleRegister(instr->value()));
3140 __ add(scratch0(), external_pointer, Operand(key, LSL, 2));
3141 __ vstr(value, scratch0(), 0);
3142 } else {
3143 Register value(ToRegister(instr->value()));
3144 __ str(value, MemOperand(external_pointer, key, LSL, 2));
3145 }
3146 } else {
3147 Register value(ToRegister(instr->value()));
3148 switch (array_type) {
3149 case kExternalPixelArray:
3150 // Clamp the value to [0..255].
3151 __ Usat(value, 8, Operand(value));
3152 __ strb(value, MemOperand(external_pointer, key));
3153 break;
3154 case kExternalByteArray:
3155 case kExternalUnsignedByteArray:
3156 __ strb(value, MemOperand(external_pointer, key));
3157 break;
3158 case kExternalShortArray:
3159 case kExternalUnsignedShortArray:
3160 __ strh(value, MemOperand(external_pointer, key, LSL, 1));
3161 break;
3162 case kExternalIntArray:
3163 case kExternalUnsignedIntArray:
3164 __ str(value, MemOperand(external_pointer, key, LSL, 2));
3165 break;
3166 case kExternalFloatArray:
3167 default:
3168 UNREACHABLE();
3169 break;
3170 }
3171 }
3102 } 3172 }
3103 3173
3104 3174
3105 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { 3175 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) {
3106 ASSERT(ToRegister(instr->object()).is(r2)); 3176 ASSERT(ToRegister(instr->object()).is(r2));
3107 ASSERT(ToRegister(instr->key()).is(r1)); 3177 ASSERT(ToRegister(instr->key()).is(r1));
3108 ASSERT(ToRegister(instr->value()).is(r0)); 3178 ASSERT(ToRegister(instr->value()).is(r0));
3109 3179
3110 Handle<Code> ic = info_->is_strict() 3180 Handle<Code> ic = info_->is_strict()
3111 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() 3181 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
4101 ASSERT(!environment->HasBeenRegistered()); 4171 ASSERT(!environment->HasBeenRegistered());
4102 RegisterEnvironmentForDeoptimization(environment); 4172 RegisterEnvironmentForDeoptimization(environment);
4103 ASSERT(osr_pc_offset_ == -1); 4173 ASSERT(osr_pc_offset_ == -1);
4104 osr_pc_offset_ = masm()->pc_offset(); 4174 osr_pc_offset_ = masm()->pc_offset();
4105 } 4175 }
4106 4176
4107 4177
4108 #undef __ 4178 #undef __
4109 4179
4110 } } // namespace v8::internal 4180 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698