OLD | NEW |
---|---|
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1657 primitive.Bind(); | 1657 primitive.Bind(); |
1658 frame_->EmitPush(rax); | 1658 frame_->EmitPush(rax); |
1659 frame_->InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION, 1); | 1659 frame_->InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION, 1); |
1660 // function call returns the value in rax, which is where we want it below | 1660 // function call returns the value in rax, which is where we want it below |
1661 | 1661 |
1662 jsobject.Bind(); | 1662 jsobject.Bind(); |
1663 // Get the set of properties (as a FixedArray or Map). | 1663 // Get the set of properties (as a FixedArray or Map). |
1664 // rax: value to be iterated over | 1664 // rax: value to be iterated over |
1665 frame_->EmitPush(rax); // push the object being iterated over (slot 4) | 1665 frame_->EmitPush(rax); // push the object being iterated over (slot 4) |
1666 | 1666 |
1667 | |
1668 // Check cache validity in generated code. This is a fast case for | |
1669 // the JSObject::IsSimpleEnum cache validity checks. If we cannot | |
1670 // guarantee cache validity, call the runtime system to check cache | |
1671 // validity or get the property names in a fixed array. | |
1672 JumpTarget call_runtime; | |
1673 JumpTarget loop(JumpTarget::BIDIRECTIONAL); | |
1674 JumpTarget check_prototype; | |
1675 JumpTarget use_cache; | |
1676 __ movq(rcx, rax); | |
1677 loop.Bind(); | |
1678 // Check that there are no elements. | |
1679 __ movq(rdx, FieldOperand(rcx, JSObject::kElementsOffset)); | |
1680 __ Cmp(rdx, Factory::empty_fixed_array()); | |
Erik Corry
2009/12/03 08:49:32
We have CompareRoot for this. Same speed but more
Mads Ager (chromium)
2009/12/03 10:15:31
Done.
| |
1681 call_runtime.Branch(not_equal); | |
1682 // Check that instance descriptors are not empty so that we can | |
1683 // check for an enum cache. Leave the map in ebx for the subsequent | |
1684 // prototype load. | |
1685 __ movq(rbx, FieldOperand(rcx, HeapObject::kMapOffset)); | |
1686 __ movq(rdx, FieldOperand(rbx, Map::kInstanceDescriptorsOffset)); | |
1687 __ Cmp(rdx, Factory::empty_descriptor_array()); | |
Erik Corry
2009/12/03 08:49:32
And here
Mads Ager (chromium)
2009/12/03 10:15:31
Done.
| |
1688 call_runtime.Branch(equal); | |
1689 // Check that there in an enum cache in the non-empty instance | |
1690 // descriptors. This is the case if the next enumeration index | |
1691 // field does not contain a smi. | |
1692 __ movq(rdx, FieldOperand(rdx, DescriptorArray::kEnumerationIndexOffset)); | |
1693 is_smi = masm_->CheckSmi(rdx); | |
1694 call_runtime.Branch(is_smi); | |
1695 // For all objects but the receiver, check that the cache is empty. | |
1696 __ cmpq(rcx, rax); | |
1697 check_prototype.Branch(equal); | |
1698 __ movq(rdx, FieldOperand(rdx, DescriptorArray::kEnumCacheBridgeCacheOffset)); | |
1699 __ Cmp(rdx, Factory::empty_fixed_array()); | |
Erik Corry
2009/12/03 08:49:32
And here
Mads Ager (chromium)
2009/12/03 10:15:31
Done.
| |
1700 call_runtime.Branch(not_equal); | |
1701 check_prototype.Bind(); | |
1702 // Load the prototype from the map and loop if non-null. | |
1703 __ movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); | |
1704 __ Cmp(rcx, Factory::null_value()); | |
Mads Ager (chromium)
2009/12/03 10:15:31
And here.
| |
1705 loop.Branch(not_equal); | |
1706 // The enum cache is valid. Load the map of the object being | |
1707 // iterated over and use the cache for the iteration. | |
1708 __ movq(rax, FieldOperand(rax, HeapObject::kMapOffset)); | |
1709 use_cache.Jump(); | |
1710 | |
1711 call_runtime.Bind(); | |
1712 // Call the runtime to get the property names for the object. | |
1667 frame_->EmitPush(rax); // push the Object (slot 4) for the runtime call | 1713 frame_->EmitPush(rax); // push the Object (slot 4) for the runtime call |
1668 frame_->CallRuntime(Runtime::kGetPropertyNamesFast, 1); | 1714 frame_->CallRuntime(Runtime::kGetPropertyNamesFast, 1); |
1669 | 1715 |
1670 // If we got a Map, we can do a fast modification check. | 1716 // If we got a Map, we can do a fast modification check. |
1671 // Otherwise, we got a FixedArray, and we have to do a slow check. | 1717 // Otherwise, we got a FixedArray, and we have to do a slow check. |
1672 // rax: map or fixed array (result from call to | 1718 // rax: map or fixed array (result from call to |
1673 // Runtime::kGetPropertyNamesFast) | 1719 // Runtime::kGetPropertyNamesFast) |
1674 __ movq(rdx, rax); | 1720 __ movq(rdx, rax); |
1675 __ movq(rcx, FieldOperand(rdx, HeapObject::kMapOffset)); | 1721 __ movq(rcx, FieldOperand(rdx, HeapObject::kMapOffset)); |
1676 __ CompareRoot(rcx, Heap::kMetaMapRootIndex); | 1722 __ CompareRoot(rcx, Heap::kMetaMapRootIndex); |
1677 fixed_array.Branch(not_equal); | 1723 fixed_array.Branch(not_equal); |
1678 | 1724 |
1725 use_cache.Bind(); | |
1679 // Get enum cache | 1726 // Get enum cache |
1680 // rax: map (result from call to Runtime::kGetPropertyNamesFast) | 1727 // rax: map (either the result from a call to |
1728 // Runtime::kGetPropertyNamesFast or has been fetched directly from | |
1729 // the object) | |
1681 __ movq(rcx, rax); | 1730 __ movq(rcx, rax); |
1682 __ movq(rcx, FieldOperand(rcx, Map::kInstanceDescriptorsOffset)); | 1731 __ movq(rcx, FieldOperand(rcx, Map::kInstanceDescriptorsOffset)); |
1683 // Get the bridge array held in the enumeration index field. | 1732 // Get the bridge array held in the enumeration index field. |
1684 __ movq(rcx, FieldOperand(rcx, DescriptorArray::kEnumerationIndexOffset)); | 1733 __ movq(rcx, FieldOperand(rcx, DescriptorArray::kEnumerationIndexOffset)); |
1685 // Get the cache from the bridge array. | 1734 // Get the cache from the bridge array. |
1686 __ movq(rdx, FieldOperand(rcx, DescriptorArray::kEnumCacheBridgeCacheOffset)); | 1735 __ movq(rdx, FieldOperand(rcx, DescriptorArray::kEnumCacheBridgeCacheOffset)); |
1687 | 1736 |
1688 frame_->EmitPush(rax); // <- slot 3 | 1737 frame_->EmitPush(rax); // <- slot 3 |
1689 frame_->EmitPush(rdx); // <- slot 2 | 1738 frame_->EmitPush(rdx); // <- slot 2 |
1690 __ movl(rax, FieldOperand(rdx, FixedArray::kLengthOffset)); | 1739 __ movl(rax, FieldOperand(rdx, FixedArray::kLengthOffset)); |
(...skipping 6180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7871 masm.GetCode(&desc); | 7920 masm.GetCode(&desc); |
7872 // Call the function from C++. | 7921 // Call the function from C++. |
7873 return FUNCTION_CAST<ModuloFunction>(buffer); | 7922 return FUNCTION_CAST<ModuloFunction>(buffer); |
7874 } | 7923 } |
7875 | 7924 |
7876 #endif | 7925 #endif |
7877 | 7926 |
7878 #undef __ | 7927 #undef __ |
7879 | 7928 |
7880 } } // namespace v8::internal | 7929 } } // namespace v8::internal |
OLD | NEW |