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