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