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

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

Issue 6546036: Combine typed and pixel arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix wrong external element call 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
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 6458 matching lines...) Expand 10 before | Expand all | Expand 10 after
6469 __ pop(ecx); 6469 __ pop(ecx);
6470 __ pop(eax); 6470 __ pop(eax);
6471 __ pop(edx); 6471 __ pop(edx);
6472 __ push(ecx); 6472 __ push(ecx);
6473 6473
6474 // Do a tail call to the rewritten stub. 6474 // Do a tail call to the rewritten stub.
6475 __ jmp(Operand(edi)); 6475 __ jmp(Operand(edi));
6476 } 6476 }
6477 6477
6478 6478
6479 // Loads a indexed element from a pixel array.
6480 void GenerateFastPixelArrayLoad(MacroAssembler* masm,
6481 Register receiver,
6482 Register key,
6483 Register elements,
6484 Register untagged_key,
6485 Register result,
6486 Label* not_pixel_array,
6487 Label* key_not_smi,
6488 Label* out_of_range) {
6489 // Register use:
6490 // receiver - holds the receiver and is unchanged.
6491 // key - holds the key and is unchanged (must be a smi).
6492 // elements - is set to the the receiver's element if
6493 // the receiver doesn't have a pixel array or the
6494 // key is not a smi, otherwise it's the elements'
6495 // external pointer.
6496 // untagged_key - is set to the untagged key
6497
6498 // Some callers already have verified that the key is a smi. key_not_smi is
6499 // set to NULL as a sentinel for that case. Otherwise, add an explicit check
6500 // to ensure the key is a smi must be added.
6501 if (key_not_smi != NULL) {
6502 __ JumpIfNotSmi(key, key_not_smi);
6503 } else {
6504 if (FLAG_debug_code) {
6505 __ AbortIfNotSmi(key);
6506 }
6507 }
6508 __ mov(untagged_key, key);
6509 __ SmiUntag(untagged_key);
6510
6511 __ mov(elements, FieldOperand(receiver, JSObject::kElementsOffset));
6512 // By passing NULL as not_pixel_array, callers signal that they have already
6513 // verified that the receiver has pixel array elements.
6514 if (not_pixel_array != NULL) {
6515 __ CheckMap(elements, Factory::pixel_array_map(), not_pixel_array, true);
6516 } else {
6517 if (FLAG_debug_code) {
6518 // Map check should have already made sure that elements is a pixel array.
6519 __ cmp(FieldOperand(elements, HeapObject::kMapOffset),
6520 Immediate(Factory::pixel_array_map()));
6521 __ Assert(equal, "Elements isn't a pixel array");
6522 }
6523 }
6524
6525 // Key must be in range.
6526 __ cmp(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset));
6527 __ j(above_equal, out_of_range); // unsigned check handles negative keys.
6528
6529 // Perform the indexed load and tag the result as a smi.
6530 __ mov(elements, FieldOperand(elements, PixelArray::kExternalPointerOffset));
6531 __ movzx_b(result, Operand(elements, untagged_key, times_1, 0));
6532 __ SmiTag(result);
6533 __ ret(0);
6534 }
6535
6536
6537 // Stores an indexed element into a pixel array, clamping the stored value.
6538 void GenerateFastPixelArrayStore(MacroAssembler* masm,
6539 Register receiver,
6540 Register key,
6541 Register value,
6542 Register elements,
6543 Register scratch1,
6544 bool load_elements_from_receiver,
6545 Label* key_not_smi,
6546 Label* value_not_smi,
6547 Label* not_pixel_array,
6548 Label* out_of_range) {
6549 // Register use:
6550 // receiver - holds the receiver and is unchanged unless the
6551 // store succeeds.
6552 // key - holds the key (must be a smi) and is unchanged.
6553 // value - holds the value (must be a smi) and is unchanged.
6554 // elements - holds the element object of the receiver on entry if
6555 // load_elements_from_receiver is false, otherwise used
6556 // internally to store the pixel arrays elements and
6557 // external array pointer.
6558 //
6559 // receiver, key and value remain unmodified until it's guaranteed that the
6560 // store will succeed.
6561 Register external_pointer = elements;
6562 Register untagged_key = scratch1;
6563 Register untagged_value = receiver; // Only set once success guaranteed.
6564
6565 // Fetch the receiver's elements if the caller hasn't already done so.
6566 if (load_elements_from_receiver) {
6567 __ mov(elements, FieldOperand(receiver, JSObject::kElementsOffset));
6568 }
6569
6570 // By passing NULL as not_pixel_array, callers signal that they have already
6571 // verified that the receiver has pixel array elements.
6572 if (not_pixel_array != NULL) {
6573 __ CheckMap(elements, Factory::pixel_array_map(), not_pixel_array, true);
6574 } else {
6575 if (FLAG_debug_code) {
6576 // Map check should have already made sure that elements is a pixel array.
6577 __ cmp(FieldOperand(elements, HeapObject::kMapOffset),
6578 Immediate(Factory::pixel_array_map()));
6579 __ Assert(equal, "Elements isn't a pixel array");
6580 }
6581 }
6582
6583 // Some callers already have verified that the key is a smi. key_not_smi is
6584 // set to NULL as a sentinel for that case. Otherwise, add an explicit check
6585 // to ensure the key is a smi must be added.
6586 if (key_not_smi != NULL) {
6587 __ JumpIfNotSmi(key, key_not_smi);
6588 } else {
6589 if (FLAG_debug_code) {
6590 __ AbortIfNotSmi(key);
6591 }
6592 }
6593
6594 // Key must be a smi and it must be in range.
6595 __ mov(untagged_key, key);
6596 __ SmiUntag(untagged_key);
6597 __ cmp(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset));
6598 __ j(above_equal, out_of_range); // unsigned check handles negative keys.
6599
6600 // Value must be a smi.
6601 __ JumpIfNotSmi(value, value_not_smi);
6602 __ mov(untagged_value, value);
6603 __ SmiUntag(untagged_value);
6604
6605 { // Clamp the value to [0..255].
6606 NearLabel done;
6607 __ test(untagged_value, Immediate(0xFFFFFF00));
6608 __ j(zero, &done);
6609 __ setcc(negative, untagged_value); // 1 if negative, 0 if positive.
6610 __ dec_b(untagged_value); // 0 if negative, 255 if positive.
6611 __ bind(&done);
6612 }
6613
6614 __ mov(external_pointer,
6615 FieldOperand(elements, PixelArray::kExternalPointerOffset));
6616 __ mov_b(Operand(external_pointer, untagged_key, times_1, 0), untagged_value);
6617 __ ret(0); // Return value in eax.
6618 }
6619
6620
6621 #undef __ 6479 #undef __
6622 6480
6623 } } // namespace v8::internal 6481 } } // namespace v8::internal
6624 6482
6625 #endif // V8_TARGET_ARCH_IA32 6483 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698