| 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 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1523 } | 1523 } |
| 1524 | 1524 |
| 1525 | 1525 |
| 1526 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1526 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
| 1527 Comment cmnt(masm_, "[ ObjectLiteral"); | 1527 Comment cmnt(masm_, "[ ObjectLiteral"); |
| 1528 Handle<FixedArray> constant_properties = expr->constant_properties(); | 1528 Handle<FixedArray> constant_properties = expr->constant_properties(); |
| 1529 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1529 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1530 __ push(FieldOperand(edi, JSFunction::kLiteralsOffset)); | 1530 __ push(FieldOperand(edi, JSFunction::kLiteralsOffset)); |
| 1531 __ push(Immediate(Smi::FromInt(expr->literal_index()))); | 1531 __ push(Immediate(Smi::FromInt(expr->literal_index()))); |
| 1532 __ push(Immediate(constant_properties)); | 1532 __ push(Immediate(constant_properties)); |
| 1533 |
| 1533 int flags = expr->fast_elements() | 1534 int flags = expr->fast_elements() |
| 1534 ? ObjectLiteral::kFastElements | 1535 ? ObjectLiteral::kFastElements |
| 1535 : ObjectLiteral::kNoFlags; | 1536 : ObjectLiteral::kNoFlags; |
| 1536 flags |= expr->has_function() | 1537 flags |= expr->has_function() |
| 1537 ? ObjectLiteral::kHasFunction | 1538 ? ObjectLiteral::kHasFunction |
| 1538 : ObjectLiteral::kNoFlags; | 1539 : ObjectLiteral::kNoFlags; |
| 1540 |
| 1541 if (FLAG_track_allocation_sites && |
| 1542 (loop_depth() != 0 || !scope()->is_global_scope())) { |
| 1543 // Don't track global arrays that are never re-created |
| 1544 flags |= ObjectLiteral::kAllocationSiteInfoAllowed; |
| 1545 } |
| 1546 |
| 1539 __ push(Immediate(Smi::FromInt(flags))); | 1547 __ push(Immediate(Smi::FromInt(flags))); |
| 1540 int properties_count = constant_properties->length() / 2; | 1548 int properties_count = constant_properties->length() / 2; |
| 1541 if (expr->depth() > 1) { | 1549 if (expr->depth() > 1) { |
| 1542 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); | 1550 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
| 1543 } else if (flags != ObjectLiteral::kFastElements || | 1551 } else if (flags != ObjectLiteral::kFastElements || |
| 1544 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { | 1552 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { |
| 1545 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4); | 1553 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4); |
| 1546 } else { | 1554 } else { |
| 1547 FastCloneShallowObjectStub stub(properties_count); | 1555 FastCloneShallowObjectStub stub(properties_count); |
| 1548 __ CallStub(&stub); | 1556 __ CallStub(&stub); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1645 int length = subexprs->length(); | 1653 int length = subexprs->length(); |
| 1646 Handle<FixedArray> constant_elements = expr->constant_elements(); | 1654 Handle<FixedArray> constant_elements = expr->constant_elements(); |
| 1647 ASSERT_EQ(2, constant_elements->length()); | 1655 ASSERT_EQ(2, constant_elements->length()); |
| 1648 ElementsKind constant_elements_kind = | 1656 ElementsKind constant_elements_kind = |
| 1649 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | 1657 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); |
| 1650 bool has_constant_fast_elements = | 1658 bool has_constant_fast_elements = |
| 1651 IsFastObjectElementsKind(constant_elements_kind); | 1659 IsFastObjectElementsKind(constant_elements_kind); |
| 1652 Handle<FixedArrayBase> constant_elements_values( | 1660 Handle<FixedArrayBase> constant_elements_values( |
| 1653 FixedArrayBase::cast(constant_elements->get(1))); | 1661 FixedArrayBase::cast(constant_elements->get(1))); |
| 1654 | 1662 |
| 1663 AllocationSiteMode allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
| 1664 int flags = ArrayLiteral::kNoFlags; |
| 1665 if (FLAG_track_allocation_sites && |
| 1666 (loop_depth() != 0 || !scope()->is_global_scope())) { |
| 1667 // Don't track global arrays that are never re-created |
| 1668 flags |= ArrayLiteral::kAllocationSiteInfoAllowed; |
| 1669 allocation_site_mode = TRACK_ALLOCATION_SITE; |
| 1670 } |
| 1671 |
| 1655 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1672 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1656 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); | 1673 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); |
| 1657 __ push(Immediate(Smi::FromInt(expr->literal_index()))); | 1674 __ push(Immediate(Smi::FromInt(expr->literal_index()))); |
| 1658 __ push(Immediate(constant_elements)); | 1675 __ push(Immediate(constant_elements)); |
| 1676 |
| 1677 ASSERT(((flags & ArrayLiteral::kAllocationSiteInfoAllowed) && |
| 1678 (allocation_site_mode == TRACK_ALLOCATION_SITE)) || |
| 1679 (((flags & ArrayLiteral::kAllocationSiteInfoAllowed) == 0) && |
| 1680 (allocation_site_mode == DONT_TRACK_ALLOCATION_SITE))); |
| 1681 __ push(Immediate(Smi::FromInt(flags))); |
| 1659 Heap* heap = isolate()->heap(); | 1682 Heap* heap = isolate()->heap(); |
| 1660 if (has_constant_fast_elements && | 1683 if (has_constant_fast_elements && |
| 1661 constant_elements_values->map() == heap->fixed_cow_array_map()) { | 1684 constant_elements_values->map() == heap->fixed_cow_array_map()) { |
| 1662 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | 1685 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot |
| 1663 // change, so it's possible to specialize the stub in advance. | 1686 // change, so it's possible to specialize the stub in advance. |
| 1664 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); | 1687 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); |
| 1665 FastCloneShallowArrayStub stub( | 1688 FastCloneShallowArrayStub stub( |
| 1666 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, | 1689 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, |
| 1667 DONT_TRACK_ALLOCATION_SITE, | 1690 DONT_TRACK_ALLOCATION_SITE, |
| 1668 length); | 1691 length); |
| 1669 __ CallStub(&stub); | 1692 __ CallStub(&stub); |
| 1670 } else if (expr->depth() > 1) { | 1693 } else if (expr->depth() > 1) { |
| 1671 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); | 1694 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); |
| 1672 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { | 1695 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
| 1673 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); | 1696 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 4); |
| 1674 } else { | 1697 } else { |
| 1675 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || | 1698 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || |
| 1676 FLAG_smi_only_arrays); | 1699 FLAG_smi_only_arrays); |
| 1677 FastCloneShallowArrayStub::Mode mode = | 1700 FastCloneShallowArrayStub::Mode mode = |
| 1678 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | 1701 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; |
| 1679 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites | |
| 1680 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; | |
| 1681 | 1702 |
| 1682 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | 1703 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot |
| 1683 // change, so it's possible to specialize the stub in advance. | 1704 // change, so it's possible to specialize the stub in advance. |
| 1684 if (has_constant_fast_elements) { | 1705 if (has_constant_fast_elements) { |
| 1685 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; | 1706 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; |
| 1686 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | 1707 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
| 1687 } | 1708 } |
| 1688 | 1709 |
| 1689 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); | 1710 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); |
| 1690 __ CallStub(&stub); | 1711 __ CallStub(&stub); |
| (...skipping 2835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4526 *stack_depth = 0; | 4547 *stack_depth = 0; |
| 4527 *context_length = 0; | 4548 *context_length = 0; |
| 4528 return previous_; | 4549 return previous_; |
| 4529 } | 4550 } |
| 4530 | 4551 |
| 4531 #undef __ | 4552 #undef __ |
| 4532 | 4553 |
| 4533 } } // namespace v8::internal | 4554 } } // namespace v8::internal |
| 4534 | 4555 |
| 4535 #endif // V8_TARGET_ARCH_IA32 | 4556 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |