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

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 6478027: Implement specialized IC code stubs for pixel array stores. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: merge with latest Created 9 years, 10 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/code-stubs-ia32.h ('k') | src/ia32/ic-ia32.cc » ('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 6541 matching lines...) Expand 10 before | Expand all | Expand 10 after
6552 if (key_not_smi != NULL) { 6552 if (key_not_smi != NULL) {
6553 __ JumpIfNotSmi(key, key_not_smi); 6553 __ JumpIfNotSmi(key, key_not_smi);
6554 } else { 6554 } else {
6555 if (FLAG_debug_code) { 6555 if (FLAG_debug_code) {
6556 __ AbortIfNotSmi(key); 6556 __ AbortIfNotSmi(key);
6557 } 6557 }
6558 } 6558 }
6559 __ mov(untagged_key, key); 6559 __ mov(untagged_key, key);
6560 __ SmiUntag(untagged_key); 6560 __ SmiUntag(untagged_key);
6561 6561
6562 // Verify that the receiver has pixel array elements.
6563 __ mov(elements, FieldOperand(receiver, JSObject::kElementsOffset)); 6562 __ mov(elements, FieldOperand(receiver, JSObject::kElementsOffset));
6564 __ CheckMap(elements, Factory::pixel_array_map(), not_pixel_array, true); 6563 // By passing NULL as not_pixel_array, callers signal that they have already
6564 // verified that the receiver has pixel array elements.
6565 if (not_pixel_array != NULL) {
6566 __ CheckMap(elements, Factory::pixel_array_map(), not_pixel_array, true);
6567 } else {
6568 if (FLAG_debug_code) {
6569 // Map check should have already made sure that elements is a pixel array.
6570 __ cmp(FieldOperand(elements, HeapObject::kMapOffset),
6571 Immediate(Factory::pixel_array_map()));
6572 __ Assert(equal, "Elements isn't a pixel array");
6573 }
6574 }
6565 6575
6566 // Key must be in range. 6576 // Key must be in range.
6567 __ cmp(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset)); 6577 __ cmp(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset));
6568 __ j(above_equal, out_of_range); // unsigned check handles negative keys. 6578 __ j(above_equal, out_of_range); // unsigned check handles negative keys.
6569 6579
6570 // Perform the indexed load and tag the result as a smi. 6580 // Perform the indexed load and tag the result as a smi.
6571 __ mov(elements, FieldOperand(elements, PixelArray::kExternalPointerOffset)); 6581 __ mov(elements, FieldOperand(elements, PixelArray::kExternalPointerOffset));
6572 __ movzx_b(result, Operand(elements, untagged_key, times_1, 0)); 6582 __ movzx_b(result, Operand(elements, untagged_key, times_1, 0));
6573 __ SmiTag(result); 6583 __ SmiTag(result);
6574 __ ret(0); 6584 __ ret(0);
6575 } 6585 }
6576 6586
6577 6587
6588 // Stores an indexed element into a pixel array, clamping the stored value.
6589 void GenerateFastPixelArrayStore(MacroAssembler* masm,
6590 Register receiver,
6591 Register key,
6592 Register value,
6593 Register elements,
6594 Register scratch1,
6595 bool load_elements_from_receiver,
6596 Label* key_not_smi,
6597 Label* value_not_smi,
6598 Label* not_pixel_array,
6599 Label* out_of_range) {
6600 // Register use:
6601 // receiver - holds the receiver and is unchanged unless the
6602 // store succeeds.
6603 // key - holds the key (must be a smi) and is unchanged.
6604 // value - holds the value (must be a smi) and is unchanged.
6605 // elements - holds the element object of the receiver on entry if
6606 // load_elements_from_receiver is false, otherwise used
6607 // internally to store the pixel arrays elements and
6608 // external array pointer.
6609 //
6610 // receiver, key and value remain unmodified until it's guaranteed that the
6611 // store will succeed.
6612 Register external_pointer = elements;
6613 Register untagged_key = scratch1;
6614 Register untagged_value = receiver; // Only set once success guaranteed.
6615
6616 // Fetch the receiver's elements if the caller hasn't already done so.
6617 if (load_elements_from_receiver) {
6618 __ mov(elements, FieldOperand(receiver, JSObject::kElementsOffset));
6619 }
6620
6621 // By passing NULL as not_pixel_array, callers signal that they have already
6622 // verified that the receiver has pixel array elements.
6623 if (not_pixel_array != NULL) {
6624 __ CheckMap(elements, Factory::pixel_array_map(), not_pixel_array, true);
6625 } else {
6626 if (FLAG_debug_code) {
6627 // Map check should have already made sure that elements is a pixel array.
6628 __ cmp(FieldOperand(elements, HeapObject::kMapOffset),
6629 Immediate(Factory::pixel_array_map()));
6630 __ Assert(equal, "Elements isn't a pixel array");
6631 }
6632 }
6633
6634 // Some callers already have verified that the key is a smi. key_not_smi is
6635 // set to NULL as a sentinel for that case. Otherwise, add an explicit check
6636 // to ensure the key is a smi must be added.
6637 if (key_not_smi != NULL) {
6638 __ JumpIfNotSmi(key, key_not_smi);
6639 } else {
6640 if (FLAG_debug_code) {
6641 __ AbortIfNotSmi(key);
6642 }
6643 }
6644
6645 // Key must be a smi and it must be in range.
6646 __ mov(untagged_key, key);
6647 __ SmiUntag(untagged_key);
6648 __ cmp(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset));
6649 __ j(above_equal, out_of_range); // unsigned check handles negative keys.
6650
6651 // Value must be a smi.
6652 __ JumpIfNotSmi(value, value_not_smi);
6653 __ mov(untagged_value, value);
6654 __ SmiUntag(untagged_value);
6655
6656 { // Clamp the value to [0..255].
6657 NearLabel done;
6658 __ test(untagged_value, Immediate(0xFFFFFF00));
6659 __ j(zero, &done);
6660 __ setcc(negative, untagged_value); // 1 if negative, 0 if positive.
6661 __ dec_b(untagged_value); // 0 if negative, 255 if positive.
6662 __ bind(&done);
6663 }
6664
6665 __ mov(external_pointer,
6666 FieldOperand(elements, PixelArray::kExternalPointerOffset));
6667 __ mov_b(Operand(external_pointer, untagged_key, times_1, 0), untagged_value);
6668 __ ret(0); // Return value in eax.
6669 }
6670
6671
6578 #undef __ 6672 #undef __
6579 6673
6580 } } // namespace v8::internal 6674 } } // namespace v8::internal
6581 6675
6582 #endif // V8_TARGET_ARCH_IA32 6676 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.h ('k') | src/ia32/ic-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698