| 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 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 int length = subexprs->length(); | 1663 int length = subexprs->length(); |
| 1664 Handle<FixedArray> constant_elements = expr->constant_elements(); | 1664 Handle<FixedArray> constant_elements = expr->constant_elements(); |
| 1665 ASSERT_EQ(2, constant_elements->length()); | 1665 ASSERT_EQ(2, constant_elements->length()); |
| 1666 ElementsKind constant_elements_kind = | 1666 ElementsKind constant_elements_kind = |
| 1667 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | 1667 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); |
| 1668 bool has_constant_fast_elements = | 1668 bool has_constant_fast_elements = |
| 1669 IsFastObjectElementsKind(constant_elements_kind); | 1669 IsFastObjectElementsKind(constant_elements_kind); |
| 1670 Handle<FixedArrayBase> constant_elements_values( | 1670 Handle<FixedArrayBase> constant_elements_values( |
| 1671 FixedArrayBase::cast(constant_elements->get(1))); | 1671 FixedArrayBase::cast(constant_elements->get(1))); |
| 1672 | 1672 |
| 1673 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | |
| 1674 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); | |
| 1675 __ push(Immediate(Smi::FromInt(expr->literal_index()))); | |
| 1676 __ push(Immediate(constant_elements)); | |
| 1677 Heap* heap = isolate()->heap(); | 1673 Heap* heap = isolate()->heap(); |
| 1678 if (has_constant_fast_elements && | 1674 if (has_constant_fast_elements && |
| 1679 constant_elements_values->map() == heap->fixed_cow_array_map()) { | 1675 constant_elements_values->map() == heap->fixed_cow_array_map()) { |
| 1680 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | 1676 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot |
| 1681 // change, so it's possible to specialize the stub in advance. | 1677 // change, so it's possible to specialize the stub in advance. |
| 1682 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); | 1678 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); |
| 1679 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1680 __ mov(eax, FieldOperand(ebx, JSFunction::kLiteralsOffset)); |
| 1681 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); |
| 1682 __ mov(ecx, Immediate(constant_elements)); |
| 1683 FastCloneShallowArrayStub stub( | 1683 FastCloneShallowArrayStub stub( |
| 1684 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, | 1684 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, |
| 1685 DONT_TRACK_ALLOCATION_SITE, | 1685 DONT_TRACK_ALLOCATION_SITE, |
| 1686 length); | 1686 length); |
| 1687 __ CallStub(&stub); | 1687 __ CallStub(&stub); |
| 1688 } else if (expr->depth() > 1) { | 1688 } else if (expr->depth() > 1) { |
| 1689 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1690 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); |
| 1691 __ push(Immediate(Smi::FromInt(expr->literal_index()))); |
| 1692 __ push(Immediate(constant_elements)); |
| 1689 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); | 1693 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); |
| 1690 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { | 1694 } else if (Serializer::enabled() || |
| 1695 length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
| 1696 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1697 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); |
| 1698 __ push(Immediate(Smi::FromInt(expr->literal_index()))); |
| 1699 __ push(Immediate(constant_elements)); |
| 1691 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); | 1700 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); |
| 1692 } else { | 1701 } else { |
| 1693 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || | 1702 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || |
| 1694 FLAG_smi_only_arrays); | 1703 FLAG_smi_only_arrays); |
| 1695 FastCloneShallowArrayStub::Mode mode = | 1704 FastCloneShallowArrayStub::Mode mode = |
| 1696 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | 1705 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; |
| 1697 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites | 1706 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites |
| 1698 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; | 1707 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; |
| 1699 | 1708 |
| 1700 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | 1709 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot |
| 1701 // change, so it's possible to specialize the stub in advance. | 1710 // change, so it's possible to specialize the stub in advance. |
| 1702 if (has_constant_fast_elements) { | 1711 if (has_constant_fast_elements) { |
| 1703 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; | 1712 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; |
| 1704 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | 1713 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
| 1705 } | 1714 } |
| 1706 | 1715 |
| 1716 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1717 __ mov(eax, FieldOperand(ebx, JSFunction::kLiteralsOffset)); |
| 1718 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); |
| 1719 __ mov(ecx, Immediate(constant_elements)); |
| 1707 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); | 1720 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); |
| 1708 __ CallStub(&stub); | 1721 __ CallStub(&stub); |
| 1709 } | 1722 } |
| 1710 | 1723 |
| 1711 bool result_saved = false; // Is the result saved to the stack? | 1724 bool result_saved = false; // Is the result saved to the stack? |
| 1712 | 1725 |
| 1713 // Emit code to evaluate all the non-constant subexpressions and to store | 1726 // Emit code to evaluate all the non-constant subexpressions and to store |
| 1714 // them into the newly cloned array. | 1727 // them into the newly cloned array. |
| 1715 for (int i = 0; i < length; i++) { | 1728 for (int i = 0; i < length; i++) { |
| 1716 Expression* subexpr = subexprs->at(i); | 1729 Expression* subexpr = subexprs->at(i); |
| (...skipping 2833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4550 *stack_depth = 0; | 4563 *stack_depth = 0; |
| 4551 *context_length = 0; | 4564 *context_length = 0; |
| 4552 return previous_; | 4565 return previous_; |
| 4553 } | 4566 } |
| 4554 | 4567 |
| 4555 #undef __ | 4568 #undef __ |
| 4556 | 4569 |
| 4557 } } // namespace v8::internal | 4570 } } // namespace v8::internal |
| 4558 | 4571 |
| 4559 #endif // V8_TARGET_ARCH_IA32 | 4572 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |