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