OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 __ Push(Smi::FromInt(expr->literal_index())); | 1682 __ Push(Smi::FromInt(expr->literal_index())); |
1683 __ Push(constant_elements); | 1683 __ Push(constant_elements); |
1684 Heap* heap = isolate()->heap(); | 1684 Heap* heap = isolate()->heap(); |
1685 if (has_constant_fast_elements && | 1685 if (has_constant_fast_elements && |
1686 constant_elements_values->map() == heap->fixed_cow_array_map()) { | 1686 constant_elements_values->map() == heap->fixed_cow_array_map()) { |
1687 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | 1687 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot |
1688 // change, so it's possible to specialize the stub in advance. | 1688 // change, so it's possible to specialize the stub in advance. |
1689 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); | 1689 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); |
1690 FastCloneShallowArrayStub stub( | 1690 FastCloneShallowArrayStub stub( |
1691 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, | 1691 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, |
| 1692 DONT_TRACK_ALLOCATION_SITE, |
1692 length); | 1693 length); |
1693 __ CallStub(&stub); | 1694 __ CallStub(&stub); |
1694 } else if (expr->depth() > 1) { | 1695 } else if (expr->depth() > 1) { |
1695 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); | 1696 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); |
1696 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { | 1697 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
1697 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); | 1698 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); |
1698 } else { | 1699 } else { |
1699 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || | 1700 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || |
1700 FLAG_smi_only_arrays); | 1701 FLAG_smi_only_arrays); |
| 1702 FastCloneShallowArrayStub::Mode mode = |
| 1703 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; |
| 1704 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites |
| 1705 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; |
| 1706 |
1701 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | 1707 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot |
1702 // change, so it's possible to specialize the stub in advance. | 1708 // change, so it's possible to specialize the stub in advance. |
1703 FastCloneShallowArrayStub::Mode mode = has_constant_fast_elements | 1709 if (has_constant_fast_elements) { |
1704 ? FastCloneShallowArrayStub::CLONE_ELEMENTS | 1710 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; |
1705 : FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | 1711 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
1706 | |
1707 // Tracking allocation info allows us to pre-transition later if it makes | |
1708 // sense. | |
1709 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS && | |
1710 FLAG_track_allocation_sites) { | |
1711 mode = FastCloneShallowArrayStub:: | |
1712 CLONE_ANY_ELEMENTS_WITH_ALLOCATION_SITE_INFO; | |
1713 } | 1712 } |
1714 | 1713 |
1715 FastCloneShallowArrayStub stub(mode, length); | 1714 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); |
1716 __ CallStub(&stub); | 1715 __ CallStub(&stub); |
1717 } | 1716 } |
1718 | 1717 |
1719 bool result_saved = false; // Is the result saved to the stack? | 1718 bool result_saved = false; // Is the result saved to the stack? |
1720 | 1719 |
1721 // Emit code to evaluate all the non-constant subexpressions and to store | 1720 // Emit code to evaluate all the non-constant subexpressions and to store |
1722 // them into the newly cloned array. | 1721 // them into the newly cloned array. |
1723 for (int i = 0; i < length; i++) { | 1722 for (int i = 0; i < length; i++) { |
1724 Expression* subexpr = subexprs->at(i); | 1723 Expression* subexpr = subexprs->at(i); |
1725 // If the subexpression is a literal or a simple materialized literal it | 1724 // If the subexpression is a literal or a simple materialized literal it |
(...skipping 2801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4527 *context_length = 0; | 4526 *context_length = 0; |
4528 return previous_; | 4527 return previous_; |
4529 } | 4528 } |
4530 | 4529 |
4531 | 4530 |
4532 #undef __ | 4531 #undef __ |
4533 | 4532 |
4534 } } // namespace v8::internal | 4533 } } // namespace v8::internal |
4535 | 4534 |
4536 #endif // V8_TARGET_ARCH_X64 | 4535 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |