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

Side by Side Diff: src/ia32/ic-ia32.cc

Issue 246076: Change clamping 0..255 instruction sequence for pixel array code (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 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/assembler-ia32.cc ('k') | src/x64/assembler-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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 __ cmp(FieldOperand(ecx, HeapObject::kMapOffset), 291 __ cmp(FieldOperand(ecx, HeapObject::kMapOffset),
292 Immediate(Factory::pixel_array_map())); 292 Immediate(Factory::pixel_array_map()));
293 __ j(not_equal, &slow); 293 __ j(not_equal, &slow);
294 __ cmp(eax, FieldOperand(ecx, PixelArray::kLengthOffset)); 294 __ cmp(eax, FieldOperand(ecx, PixelArray::kLengthOffset));
295 __ j(above_equal, &slow); 295 __ j(above_equal, &slow);
296 __ mov(ecx, FieldOperand(ecx, PixelArray::kExternalPointerOffset)); 296 __ mov(ecx, FieldOperand(ecx, PixelArray::kExternalPointerOffset));
297 __ movzx_b(eax, Operand(ecx, eax, times_1, 0)); 297 __ movzx_b(eax, Operand(ecx, eax, times_1, 0));
298 __ shl(eax, kSmiTagSize); 298 __ shl(eax, kSmiTagSize);
299 __ ret(0); 299 __ ret(0);
300 300
301
302 // Slow case: Load name and receiver from stack and jump to runtime. 301 // Slow case: Load name and receiver from stack and jump to runtime.
303 __ bind(&slow); 302 __ bind(&slow);
304 __ IncrementCounter(&Counters::keyed_load_generic_slow, 1); 303 __ IncrementCounter(&Counters::keyed_load_generic_slow, 1);
305 KeyedLoadIC::Generate(masm, ExternalReference(Runtime::kKeyedGetProperty)); 304 KeyedLoadIC::Generate(masm, ExternalReference(Runtime::kKeyedGetProperty));
306 305
307 __ bind(&check_string); 306 __ bind(&check_string);
308 // The key is not a smi. 307 // The key is not a smi.
309 // Is it a string? 308 // Is it a string?
310 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edx); 309 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edx);
311 __ j(above_equal, &slow); 310 __ j(above_equal, &slow);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 // Check that the value is a smi. If a conversion is needed call into the 416 // Check that the value is a smi. If a conversion is needed call into the
418 // runtime to convert and clamp. 417 // runtime to convert and clamp.
419 __ test(eax, Immediate(kSmiTagMask)); 418 __ test(eax, Immediate(kSmiTagMask));
420 __ j(not_zero, &slow); 419 __ j(not_zero, &slow);
421 __ sar(ebx, kSmiTagSize); // Untag the index. 420 __ sar(ebx, kSmiTagSize); // Untag the index.
422 __ cmp(ebx, FieldOperand(ecx, PixelArray::kLengthOffset)); 421 __ cmp(ebx, FieldOperand(ecx, PixelArray::kLengthOffset));
423 __ j(above_equal, &slow); 422 __ j(above_equal, &slow);
424 __ mov(edx, eax); // Save the value. 423 __ mov(edx, eax); // Save the value.
425 __ sar(eax, kSmiTagSize); // Untag the value. 424 __ sar(eax, kSmiTagSize); // Untag the value.
426 { // Clamp the value to [0..255]. 425 { // Clamp the value to [0..255].
427 Label done, is_negative; 426 Label done, is_negative;
Tobias Kaes 2009/10/08 07:42:43 is_negative isn't used anymore, is it?
Søren Thygesen Gjesse 2009/10/08 07:46:14 Absolutely right, I will get rid of it.
428 __ test(eax, Immediate(0xFFFFFF00)); 427 __ test(eax, Immediate(0xFFFFFF00));
429 __ j(zero, &done); 428 __ j(zero, &done);
430 __ j(negative, &is_negative); 429 __ setcc(negative, eax); // 1 if negative, 0 if positive.
431 __ mov(eax, Immediate(255)); 430 __ dec_b(eax); // 0 if negative, 255 if positive.
432 __ jmp(&done);
433 __ bind(&is_negative);
434 __ xor_(eax, Operand(eax)); // Clear eax.
435 __ bind(&done); 431 __ bind(&done);
436 } 432 }
437 __ mov(ecx, FieldOperand(ecx, PixelArray::kExternalPointerOffset)); 433 __ mov(ecx, FieldOperand(ecx, PixelArray::kExternalPointerOffset));
438 __ mov_b(Operand(ecx, ebx, times_1, 0), eax); 434 __ mov_b(Operand(ecx, ebx, times_1, 0), eax);
439 __ mov(eax, edx); // Return the original value. 435 __ mov(eax, edx); // Return the original value.
440 __ ret(0); 436 __ ret(0);
441 437
442 // Extra capacity case: Check if there is extra capacity to 438 // Extra capacity case: Check if there is extra capacity to
443 // perform the store and update the length. Used for adding one 439 // perform the store and update the length. Used for adding one
444 // element to the array by writing to array[array.length]. 440 // element to the array by writing to array[array.length].
445 __ bind(&extra); 441 __ bind(&extra);
446 // eax: value 442 // eax: value
447 // edx: JSArray 443 // edx: JSArray
448 // ecx: FixedArray 444 // ecx: FixedArray
449 // ebx: index (as a smi) 445 // ebx: index (as a smi)
450 // flags: compare (ebx, edx.length()) 446 // flags: compare (ebx, edx.length())
451 __ j(not_equal, &slow, not_taken); // do not leave holes in the array 447 __ j(not_equal, &slow, not_taken); // do not leave holes in the array
452 __ sar(ebx, kSmiTagSize); // untag 448 __ sar(ebx, kSmiTagSize); // untag
453 __ cmp(ebx, FieldOperand(ecx, Array::kLengthOffset)); 449 __ cmp(ebx, FieldOperand(ecx, Array::kLengthOffset));
454 __ j(above_equal, &slow, not_taken); 450 __ j(above_equal, &slow, not_taken);
455 // Restore tag and increment. 451 // Restore tag and increment.
456 __ lea(ebx, Operand(ebx, times_2, 1 << kSmiTagSize)); 452 __ lea(ebx, Operand(ebx, times_2, 1 << kSmiTagSize));
457 __ mov(FieldOperand(edx, JSArray::kLengthOffset), ebx); 453 __ mov(FieldOperand(edx, JSArray::kLengthOffset), ebx);
458 __ sub(Operand(ebx), Immediate(1 << kSmiTagSize)); // decrement ebx again 454 __ sub(Operand(ebx), Immediate(1 << kSmiTagSize)); // decrement ebx again
459 __ jmp(&fast); 455 __ jmp(&fast);
460 456
461
462 // Array case: Get the length and the elements array from the JS 457 // Array case: Get the length and the elements array from the JS
463 // array. Check that the array is in fast mode; if it is the 458 // array. Check that the array is in fast mode; if it is the
464 // length is always a smi. 459 // length is always a smi.
465 __ bind(&array); 460 __ bind(&array);
466 // eax: value 461 // eax: value
467 // edx: JSArray 462 // edx: JSArray
468 // ebx: index (as a smi) 463 // ebx: index (as a smi)
469 __ mov(ecx, FieldOperand(edx, JSObject::kElementsOffset)); 464 __ mov(ecx, FieldOperand(edx, JSObject::kElementsOffset));
470 __ cmp(FieldOperand(ecx, HeapObject::kMapOffset), 465 __ cmp(FieldOperand(ecx, HeapObject::kMapOffset),
471 Immediate(Factory::fixed_array_map())); 466 Immediate(Factory::fixed_array_map()));
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 1028
1034 // Do tail-call to runtime routine. 1029 // Do tail-call to runtime routine.
1035 __ TailCallRuntime( 1030 __ TailCallRuntime(
1036 ExternalReference(IC_Utility(kSharedStoreIC_ExtendStorage)), 3, 1); 1031 ExternalReference(IC_Utility(kSharedStoreIC_ExtendStorage)), 3, 1);
1037 } 1032 }
1038 1033
1039 #undef __ 1034 #undef __
1040 1035
1041 1036
1042 } } // namespace v8::internal 1037 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/assembler-ia32.cc ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698