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

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

Powered by Google App Engine
This is Rietveld 408576698