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

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: final version 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
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/ast.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 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 Register input = ToRegister(instr->InputAt(0)); 2376 Register input = ToRegister(instr->InputAt(0));
2377 Register scratch = scratch0(); 2377 Register scratch = scratch0();
2378 2378
2379 __ ldr(result, FieldMemOperand(input, JSObject::kElementsOffset)); 2379 __ ldr(result, FieldMemOperand(input, JSObject::kElementsOffset));
2380 if (FLAG_debug_code) { 2380 if (FLAG_debug_code) {
2381 Label done; 2381 Label done;
2382 __ ldr(scratch, FieldMemOperand(result, HeapObject::kMapOffset)); 2382 __ ldr(scratch, FieldMemOperand(result, HeapObject::kMapOffset));
2383 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex); 2383 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex);
2384 __ cmp(scratch, ip); 2384 __ cmp(scratch, ip);
2385 __ b(eq, &done); 2385 __ b(eq, &done);
2386 __ LoadRoot(ip, Heap::kExternalPixelArrayMapRootIndex);
2387 __ cmp(scratch, ip);
2388 __ b(eq, &done);
2389 __ LoadRoot(ip, Heap::kFixedCOWArrayMapRootIndex); 2386 __ LoadRoot(ip, Heap::kFixedCOWArrayMapRootIndex);
2390 __ cmp(scratch, ip); 2387 __ cmp(scratch, ip);
2391 __ Check(eq, "Check for fast elements failed."); 2388 __ ldr(scratch, FieldMemOperand(result, HeapObject::kMapOffset));
2389 __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
2390 __ sub(scratch, scratch, Operand(FIRST_EXTERNAL_ARRAY_TYPE));
2391 __ cmp(scratch, Operand(kExternalArrayTypeCount));
2392 __ Check(cc, "Check for fast elements failed.");
2392 __ bind(&done); 2393 __ bind(&done);
2393 } 2394 }
2394 } 2395 }
2395 2396
2396 2397
2397 void LCodeGen::DoLoadExternalArrayPointer( 2398 void LCodeGen::DoLoadExternalArrayPointer(
2398 LLoadExternalArrayPointer* instr) { 2399 LLoadExternalArrayPointer* instr) {
2399 Register to_reg = ToRegister(instr->result()); 2400 Register to_reg = ToRegister(instr->result());
2400 Register from_reg = ToRegister(instr->InputAt(0)); 2401 Register from_reg = ToRegister(instr->InputAt(0));
2401 __ ldr(to_reg, FieldMemOperand(from_reg, 2402 __ ldr(to_reg, FieldMemOperand(from_reg,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 2435
2435 // Check for the hole value. 2436 // Check for the hole value.
2436 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex); 2437 __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex);
2437 __ cmp(result, scratch); 2438 __ cmp(result, scratch);
2438 DeoptimizeIf(eq, instr->environment()); 2439 DeoptimizeIf(eq, instr->environment());
2439 } 2440 }
2440 2441
2441 2442
2442 void LCodeGen::DoLoadKeyedSpecializedArrayElement( 2443 void LCodeGen::DoLoadKeyedSpecializedArrayElement(
2443 LLoadKeyedSpecializedArrayElement* instr) { 2444 LLoadKeyedSpecializedArrayElement* instr) {
2444 ASSERT(instr->array_type() == kExternalPixelArray);
2445
2446 Register external_pointer = ToRegister(instr->external_pointer()); 2445 Register external_pointer = ToRegister(instr->external_pointer());
2447 Register key = ToRegister(instr->key()); 2446 Register key = ToRegister(instr->key());
2448 Register result = ToRegister(instr->result()); 2447 ExternalArrayType array_type = instr->array_type();
2449 2448 if (array_type == kExternalFloatArray) {
2450 // Load the result. 2449 if (CpuFeatures::IsSupported(VFP3)) {
2451 __ ldrb(result, MemOperand(external_pointer, key)); 2450 CpuFeatures::Scope scope(VFP3);
2451 DwVfpRegister result(ToDoubleRegister(instr->result()));
2452 __ add(scratch0(), external_pointer, Operand(key, LSL, 2));
2453 __ vldr(result, scratch0(), 0);
2454 } else {
2455 Register result(ToRegister(instr->result()));
2456 __ ldr(result, MemOperand(external_pointer, key, LSL, 2));
2457 }
2458 } else {
2459 Register result(ToRegister(instr->result()));
2460 switch (array_type) {
2461 case kExternalByteArray:
2462 __ ldrsb(result, MemOperand(external_pointer, key));
2463 break;
2464 case kExternalUnsignedByteArray:
2465 case kExternalPixelArray:
2466 __ ldrb(result, MemOperand(external_pointer, key));
2467 break;
2468 case kExternalShortArray:
2469 __ ldrsh(result, MemOperand(external_pointer, key, LSL, 1));
2470 break;
2471 case kExternalUnsignedShortArray:
2472 __ ldrh(result, MemOperand(external_pointer, key, LSL, 1));
2473 break;
2474 case kExternalIntArray:
2475 __ ldr(result, MemOperand(external_pointer, key, LSL, 2));
2476 break;
2477 case kExternalUnsignedIntArray:
2478 __ ldr(result, MemOperand(external_pointer, key, LSL, 2));
2479 __ cmp(result, Operand(0x80000000));
2480 // TODO(danno): we could be more clever here, perhaps having a special
2481 // version of the stub that detects if the overflow case actually
2482 // happens, and generate code that returns a double rather than int.
2483 DeoptimizeIf(cs, instr->environment());
2484 break;
2485 case kExternalFloatArray:
2486 UNREACHABLE();
2487 break;
2488 }
2489 }
2452 } 2490 }
2453 2491
2454 2492
2455 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { 2493 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
2456 ASSERT(ToRegister(instr->object()).is(r1)); 2494 ASSERT(ToRegister(instr->object()).is(r1));
2457 ASSERT(ToRegister(instr->key()).is(r0)); 2495 ASSERT(ToRegister(instr->key()).is(r0));
2458 2496
2459 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); 2497 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
2460 CallCode(ic, RelocInfo::CODE_TARGET, instr); 2498 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2461 } 2499 }
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
3105 if (instr->hydrogen()->NeedsWriteBarrier()) { 3143 if (instr->hydrogen()->NeedsWriteBarrier()) {
3106 // Compute address of modified element and store it into key register. 3144 // Compute address of modified element and store it into key register.
3107 __ add(key, scratch, Operand(FixedArray::kHeaderSize)); 3145 __ add(key, scratch, Operand(FixedArray::kHeaderSize));
3108 __ RecordWrite(elements, key, value); 3146 __ RecordWrite(elements, key, value);
3109 } 3147 }
3110 } 3148 }
3111 3149
3112 3150
3113 void LCodeGen::DoStoreKeyedSpecializedArrayElement( 3151 void LCodeGen::DoStoreKeyedSpecializedArrayElement(
3114 LStoreKeyedSpecializedArrayElement* instr) { 3152 LStoreKeyedSpecializedArrayElement* instr) {
3115 ASSERT(instr->array_type() == kExternalPixelArray);
3116 3153
3117 Register external_pointer = ToRegister(instr->external_pointer()); 3154 Register external_pointer = ToRegister(instr->external_pointer());
3118 Register key = ToRegister(instr->key()); 3155 Register key = ToRegister(instr->key());
3119 Register value = ToRegister(instr->value()); 3156 ExternalArrayType array_type = instr->array_type();
3120 3157 if (array_type == kExternalFloatArray) {
3121 // Clamp the value to [0..255]. 3158 if (CpuFeatures::IsSupported(VFP3)) {
3122 __ Usat(value, 8, Operand(value)); 3159 CpuFeatures::Scope scope(VFP3);
3123 __ strb(value, MemOperand(external_pointer, key, LSL, 0)); 3160 DwVfpRegister value(ToDoubleRegister(instr->value()));
3161 __ add(scratch0(), external_pointer, Operand(key, LSL, 2));
3162 __ vstr(value, scratch0(), 0);
3163 } else {
3164 Register value(ToRegister(instr->value()));
3165 __ str(value, MemOperand(external_pointer, key, LSL, 2));
3166 }
3167 } else {
3168 Register value(ToRegister(instr->value()));
3169 switch (array_type) {
3170 case kExternalPixelArray:
3171 // Clamp the value to [0..255].
3172 __ Usat(value, 8, Operand(value));
3173 __ strb(value, MemOperand(external_pointer, key));
3174 break;
3175 case kExternalByteArray:
3176 case kExternalUnsignedByteArray:
3177 __ strb(value, MemOperand(external_pointer, key));
3178 break;
3179 case kExternalShortArray:
3180 case kExternalUnsignedShortArray:
3181 __ strh(value, MemOperand(external_pointer, key, LSL, 1));
3182 break;
3183 case kExternalIntArray:
3184 case kExternalUnsignedIntArray:
3185 __ str(value, MemOperand(external_pointer, key, LSL, 2));
3186 break;
3187 case kExternalFloatArray:
3188 UNREACHABLE();
3189 break;
3190 }
3191 }
3124 } 3192 }
3125 3193
3126 3194
3127 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { 3195 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) {
3128 ASSERT(ToRegister(instr->object()).is(r2)); 3196 ASSERT(ToRegister(instr->object()).is(r2));
3129 ASSERT(ToRegister(instr->key()).is(r1)); 3197 ASSERT(ToRegister(instr->key()).is(r1));
3130 ASSERT(ToRegister(instr->value()).is(r0)); 3198 ASSERT(ToRegister(instr->value()).is(r0));
3131 3199
3132 Handle<Code> ic = info_->is_strict_mode() 3200 Handle<Code> ic = info_->is_strict_mode()
3133 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() 3201 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
4123 ASSERT(!environment->HasBeenRegistered()); 4191 ASSERT(!environment->HasBeenRegistered());
4124 RegisterEnvironmentForDeoptimization(environment); 4192 RegisterEnvironmentForDeoptimization(environment);
4125 ASSERT(osr_pc_offset_ == -1); 4193 ASSERT(osr_pc_offset_ == -1);
4126 osr_pc_offset_ = masm()->pc_offset(); 4194 osr_pc_offset_ = masm()->pc_offset();
4127 } 4195 }
4128 4196
4129 4197
4130 #undef __ 4198 #undef __
4131 4199
4132 } } // namespace v8::internal 4200 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/ast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698