| 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 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 | 1694 |
| 1695 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { | 1695 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
| 1696 Comment cmnt(masm_, "[ ArrayLiteral"); | 1696 Comment cmnt(masm_, "[ ArrayLiteral"); |
| 1697 | 1697 |
| 1698 ZoneList<Expression*>* subexprs = expr->values(); | 1698 ZoneList<Expression*>* subexprs = expr->values(); |
| 1699 int length = subexprs->length(); | 1699 int length = subexprs->length(); |
| 1700 Handle<FixedArray> constant_elements = expr->constant_elements(); | 1700 Handle<FixedArray> constant_elements = expr->constant_elements(); |
| 1701 ASSERT_EQ(2, constant_elements->length()); | 1701 ASSERT_EQ(2, constant_elements->length()); |
| 1702 ElementsKind constant_elements_kind = | 1702 ElementsKind constant_elements_kind = |
| 1703 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | 1703 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); |
| 1704 bool has_fast_elements = constant_elements_kind == FAST_ELEMENTS; | 1704 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind); |
| 1705 Handle<FixedArrayBase> constant_elements_values( | 1705 Handle<FixedArrayBase> constant_elements_values( |
| 1706 FixedArrayBase::cast(constant_elements->get(1))); | 1706 FixedArrayBase::cast(constant_elements->get(1))); |
| 1707 | 1707 |
| 1708 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1708 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1709 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); | 1709 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); |
| 1710 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); | 1710 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); |
| 1711 __ mov(r1, Operand(constant_elements)); | 1711 __ mov(r1, Operand(constant_elements)); |
| 1712 __ Push(r3, r2, r1); | 1712 __ Push(r3, r2, r1); |
| 1713 if (has_fast_elements && constant_elements_values->map() == | 1713 if (has_fast_elements && constant_elements_values->map() == |
| 1714 isolate()->heap()->fixed_cow_array_map()) { | 1714 isolate()->heap()->fixed_cow_array_map()) { |
| 1715 FastCloneShallowArrayStub stub( | 1715 FastCloneShallowArrayStub stub( |
| 1716 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, length); | 1716 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, length); |
| 1717 __ CallStub(&stub); | 1717 __ CallStub(&stub); |
| 1718 __ IncrementCounter( | 1718 __ IncrementCounter( |
| 1719 isolate()->counters()->cow_arrays_created_stub(), 1, r1, r2); | 1719 isolate()->counters()->cow_arrays_created_stub(), 1, r1, r2); |
| 1720 } else if (expr->depth() > 1) { | 1720 } else if (expr->depth() > 1) { |
| 1721 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); | 1721 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); |
| 1722 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { | 1722 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
| 1723 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); | 1723 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); |
| 1724 } else { | 1724 } else { |
| 1725 ASSERT(constant_elements_kind == FAST_ELEMENTS || | 1725 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || |
| 1726 constant_elements_kind == FAST_SMI_ONLY_ELEMENTS || | |
| 1727 FLAG_smi_only_arrays); | 1726 FLAG_smi_only_arrays); |
| 1728 FastCloneShallowArrayStub::Mode mode = has_fast_elements | 1727 FastCloneShallowArrayStub::Mode mode = has_fast_elements |
| 1729 ? FastCloneShallowArrayStub::CLONE_ELEMENTS | 1728 ? FastCloneShallowArrayStub::CLONE_ELEMENTS |
| 1730 : FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | 1729 : FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; |
| 1731 FastCloneShallowArrayStub stub(mode, length); | 1730 FastCloneShallowArrayStub stub(mode, length); |
| 1732 __ CallStub(&stub); | 1731 __ CallStub(&stub); |
| 1733 } | 1732 } |
| 1734 | 1733 |
| 1735 bool result_saved = false; // Is the result saved to the stack? | 1734 bool result_saved = false; // Is the result saved to the stack? |
| 1736 | 1735 |
| 1737 // Emit code to evaluate all the non-constant subexpressions and to store | 1736 // Emit code to evaluate all the non-constant subexpressions and to store |
| 1738 // them into the newly cloned array. | 1737 // them into the newly cloned array. |
| 1739 for (int i = 0; i < length; i++) { | 1738 for (int i = 0; i < length; i++) { |
| 1740 Expression* subexpr = subexprs->at(i); | 1739 Expression* subexpr = subexprs->at(i); |
| 1741 // If the subexpression is a literal or a simple materialized literal it | 1740 // If the subexpression is a literal or a simple materialized literal it |
| 1742 // is already set in the cloned array. | 1741 // is already set in the cloned array. |
| 1743 if (subexpr->AsLiteral() != NULL || | 1742 if (subexpr->AsLiteral() != NULL || |
| 1744 CompileTimeValue::IsCompileTimeValue(subexpr)) { | 1743 CompileTimeValue::IsCompileTimeValue(subexpr)) { |
| 1745 continue; | 1744 continue; |
| 1746 } | 1745 } |
| 1747 | 1746 |
| 1748 if (!result_saved) { | 1747 if (!result_saved) { |
| 1749 __ push(r0); | 1748 __ push(r0); |
| 1750 result_saved = true; | 1749 result_saved = true; |
| 1751 } | 1750 } |
| 1752 VisitForAccumulatorValue(subexpr); | 1751 VisitForAccumulatorValue(subexpr); |
| 1753 | 1752 |
| 1754 if (constant_elements_kind == FAST_ELEMENTS) { | 1753 if (IsFastObjectElementsKind(constant_elements_kind)) { |
| 1755 int offset = FixedArray::kHeaderSize + (i * kPointerSize); | 1754 int offset = FixedArray::kHeaderSize + (i * kPointerSize); |
| 1756 __ ldr(r6, MemOperand(sp)); // Copy of array literal. | 1755 __ ldr(r6, MemOperand(sp)); // Copy of array literal. |
| 1757 __ ldr(r1, FieldMemOperand(r6, JSObject::kElementsOffset)); | 1756 __ ldr(r1, FieldMemOperand(r6, JSObject::kElementsOffset)); |
| 1758 __ str(result_register(), FieldMemOperand(r1, offset)); | 1757 __ str(result_register(), FieldMemOperand(r1, offset)); |
| 1759 // Update the write barrier for the array store. | 1758 // Update the write barrier for the array store. |
| 1760 __ RecordWriteField(r1, offset, result_register(), r2, | 1759 __ RecordWriteField(r1, offset, result_register(), r2, |
| 1761 kLRHasBeenSaved, kDontSaveFPRegs, | 1760 kLRHasBeenSaved, kDontSaveFPRegs, |
| 1762 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); | 1761 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); |
| 1763 } else { | 1762 } else { |
| 1764 __ ldr(r1, MemOperand(sp)); // Copy of array literal. | 1763 __ ldr(r1, MemOperand(sp)); // Copy of array literal. |
| (...skipping 2868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4633 *context_length = 0; | 4632 *context_length = 0; |
| 4634 return previous_; | 4633 return previous_; |
| 4635 } | 4634 } |
| 4636 | 4635 |
| 4637 | 4636 |
| 4638 #undef __ | 4637 #undef __ |
| 4639 | 4638 |
| 4640 } } // namespace v8::internal | 4639 } } // namespace v8::internal |
| 4641 | 4640 |
| 4642 #endif // V8_TARGET_ARCH_ARM | 4641 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |