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 = IsFastObjectElementsKind(constant_elements_kind); | 1704 bool has_fast_elements = constant_elements_kind == FAST_ELEMENTS; |
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(IsFastSmiOrObjectElementsKind(constant_elements_kind) || | 1725 ASSERT(constant_elements_kind == FAST_ELEMENTS || |
| 1726 constant_elements_kind == FAST_SMI_ONLY_ELEMENTS || |
1726 FLAG_smi_only_arrays); | 1727 FLAG_smi_only_arrays); |
1727 FastCloneShallowArrayStub::Mode mode = has_fast_elements | 1728 FastCloneShallowArrayStub::Mode mode = has_fast_elements |
1728 ? FastCloneShallowArrayStub::CLONE_ELEMENTS | 1729 ? FastCloneShallowArrayStub::CLONE_ELEMENTS |
1729 : FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | 1730 : FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; |
1730 FastCloneShallowArrayStub stub(mode, length); | 1731 FastCloneShallowArrayStub stub(mode, length); |
1731 __ CallStub(&stub); | 1732 __ CallStub(&stub); |
1732 } | 1733 } |
1733 | 1734 |
1734 bool result_saved = false; // Is the result saved to the stack? | 1735 bool result_saved = false; // Is the result saved to the stack? |
1735 | 1736 |
1736 // Emit code to evaluate all the non-constant subexpressions and to store | 1737 // Emit code to evaluate all the non-constant subexpressions and to store |
1737 // them into the newly cloned array. | 1738 // them into the newly cloned array. |
1738 for (int i = 0; i < length; i++) { | 1739 for (int i = 0; i < length; i++) { |
1739 Expression* subexpr = subexprs->at(i); | 1740 Expression* subexpr = subexprs->at(i); |
1740 // If the subexpression is a literal or a simple materialized literal it | 1741 // If the subexpression is a literal or a simple materialized literal it |
1741 // is already set in the cloned array. | 1742 // is already set in the cloned array. |
1742 if (subexpr->AsLiteral() != NULL || | 1743 if (subexpr->AsLiteral() != NULL || |
1743 CompileTimeValue::IsCompileTimeValue(subexpr)) { | 1744 CompileTimeValue::IsCompileTimeValue(subexpr)) { |
1744 continue; | 1745 continue; |
1745 } | 1746 } |
1746 | 1747 |
1747 if (!result_saved) { | 1748 if (!result_saved) { |
1748 __ push(r0); | 1749 __ push(r0); |
1749 result_saved = true; | 1750 result_saved = true; |
1750 } | 1751 } |
1751 VisitForAccumulatorValue(subexpr); | 1752 VisitForAccumulatorValue(subexpr); |
1752 | 1753 |
1753 if (IsFastObjectElementsKind(constant_elements_kind)) { | 1754 if (constant_elements_kind == FAST_ELEMENTS) { |
1754 int offset = FixedArray::kHeaderSize + (i * kPointerSize); | 1755 int offset = FixedArray::kHeaderSize + (i * kPointerSize); |
1755 __ ldr(r6, MemOperand(sp)); // Copy of array literal. | 1756 __ ldr(r6, MemOperand(sp)); // Copy of array literal. |
1756 __ ldr(r1, FieldMemOperand(r6, JSObject::kElementsOffset)); | 1757 __ ldr(r1, FieldMemOperand(r6, JSObject::kElementsOffset)); |
1757 __ str(result_register(), FieldMemOperand(r1, offset)); | 1758 __ str(result_register(), FieldMemOperand(r1, offset)); |
1758 // Update the write barrier for the array store. | 1759 // Update the write barrier for the array store. |
1759 __ RecordWriteField(r1, offset, result_register(), r2, | 1760 __ RecordWriteField(r1, offset, result_register(), r2, |
1760 kLRHasBeenSaved, kDontSaveFPRegs, | 1761 kLRHasBeenSaved, kDontSaveFPRegs, |
1761 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); | 1762 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); |
1762 } else { | 1763 } else { |
1763 __ ldr(r1, MemOperand(sp)); // Copy of array literal. | 1764 __ ldr(r1, MemOperand(sp)); // Copy of array literal. |
(...skipping 2770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4534 *context_length = 0; | 4535 *context_length = 0; |
4535 return previous_; | 4536 return previous_; |
4536 } | 4537 } |
4537 | 4538 |
4538 | 4539 |
4539 #undef __ | 4540 #undef __ |
4540 | 4541 |
4541 } } // namespace v8::internal | 4542 } } // namespace v8::internal |
4542 | 4543 |
4543 #endif // V8_TARGET_ARCH_ARM | 4544 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |