Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 12114054: Supporting AllocationSiteInfo for Nested arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some updates Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 && !IsOneTimeCode()) {
1542 // Don't track global arrays that are never re-created
1543 flags |= ObjectLiteral::kAllocationSiteInfoAllowed;
1544 }
1545
1539 __ push(Immediate(Smi::FromInt(flags))); 1546 __ push(Immediate(Smi::FromInt(flags)));
1540 int properties_count = constant_properties->length() / 2; 1547 int properties_count = constant_properties->length() / 2;
1541 if (expr->depth() > 1) { 1548 if (expr->depth() > 1) {
1542 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); 1549 __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
1543 } else if (flags != ObjectLiteral::kFastElements || 1550 } else if (flags != ObjectLiteral::kFastElements ||
1544 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { 1551 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) {
1545 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4); 1552 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4);
1546 } else { 1553 } else {
1547 FastCloneShallowObjectStub stub(properties_count); 1554 FastCloneShallowObjectStub stub(properties_count);
1548 __ CallStub(&stub); 1555 __ CallStub(&stub);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 int length = subexprs->length(); 1652 int length = subexprs->length();
1646 Handle<FixedArray> constant_elements = expr->constant_elements(); 1653 Handle<FixedArray> constant_elements = expr->constant_elements();
1647 ASSERT_EQ(2, constant_elements->length()); 1654 ASSERT_EQ(2, constant_elements->length());
1648 ElementsKind constant_elements_kind = 1655 ElementsKind constant_elements_kind =
1649 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); 1656 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1650 bool has_constant_fast_elements = 1657 bool has_constant_fast_elements =
1651 IsFastObjectElementsKind(constant_elements_kind); 1658 IsFastObjectElementsKind(constant_elements_kind);
1652 Handle<FixedArrayBase> constant_elements_values( 1659 Handle<FixedArrayBase> constant_elements_values(
1653 FixedArrayBase::cast(constant_elements->get(1))); 1660 FixedArrayBase::cast(constant_elements->get(1)));
1654 1661
1662 AllocationSiteMode allocation_site_mode = DONT_TRACK_ALLOCATION_SITE;
1663 int flags = ArrayLiteral::kNoFlags;
1664 if (FLAG_track_allocation_sites && !IsOneTimeCode()) {
1665 // Don't track global arrays that are never re-created
1666 flags |= ArrayLiteral::kAllocationSiteInfoAllowed;
1667 allocation_site_mode = TRACK_ALLOCATION_SITE;
1668 }
1669
1670 ASSERT(((flags & ArrayLiteral::kAllocationSiteInfoAllowed) &&
1671 (allocation_site_mode == TRACK_ALLOCATION_SITE)) ||
1672 (((flags & ArrayLiteral::kAllocationSiteInfoAllowed) == 0) &&
1673 (allocation_site_mode == DONT_TRACK_ALLOCATION_SITE)));
1674
1655 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 1675 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1656 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); 1676 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset));
1657 __ push(Immediate(Smi::FromInt(expr->literal_index()))); 1677 __ push(Immediate(Smi::FromInt(expr->literal_index())));
1658 __ push(Immediate(constant_elements)); 1678 __ push(Immediate(constant_elements));
1659 Heap* heap = isolate()->heap(); 1679 Heap* heap = isolate()->heap();
1660 if (has_constant_fast_elements && 1680 if (has_constant_fast_elements &&
1661 constant_elements_values->map() == heap->fixed_cow_array_map()) { 1681 constant_elements_values->map() == heap->fixed_cow_array_map()) {
1662 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot 1682 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot
1663 // change, so it's possible to specialize the stub in advance. 1683 // change, so it's possible to specialize the stub in advance.
1664 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); 1684 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1);
1665 FastCloneShallowArrayStub stub( 1685 FastCloneShallowArrayStub stub(
1666 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, 1686 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS,
1667 DONT_TRACK_ALLOCATION_SITE, 1687 DONT_TRACK_ALLOCATION_SITE,
1668 length); 1688 length);
1669 __ CallStub(&stub); 1689 __ CallStub(&stub);
1670 } else if (expr->depth() > 1) { 1690 } else if (expr->depth() > 1) {
1671 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); 1691 __ push(Immediate(Smi::FromInt(flags)));
1692 __ CallRuntime(Runtime::kCreateArrayLiteral, 4);
1672 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { 1693 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1673 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); 1694 __ push(Immediate(Smi::FromInt(flags)));
1695 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 4);
1674 } else { 1696 } else {
1675 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || 1697 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) ||
1676 FLAG_smi_only_arrays); 1698 FLAG_smi_only_arrays);
1677 FastCloneShallowArrayStub::Mode mode = 1699 FastCloneShallowArrayStub::Mode mode =
1678 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; 1700 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS;
1679 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites
1680 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE;
1681 1701
1682 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot 1702 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot
1683 // change, so it's possible to specialize the stub in advance. 1703 // change, so it's possible to specialize the stub in advance.
1684 if (has_constant_fast_elements) { 1704 if (has_constant_fast_elements) {
1685 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; 1705 mode = FastCloneShallowArrayStub::CLONE_ELEMENTS;
1686 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; 1706 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE;
1687 } 1707 }
1688 1708
1689 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); 1709 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length);
1690 __ CallStub(&stub); 1710 __ CallStub(&stub);
(...skipping 2835 matching lines...) Expand 10 before | Expand all | Expand 10 after
4526 *stack_depth = 0; 4546 *stack_depth = 0;
4527 *context_length = 0; 4547 *context_length = 0;
4528 return previous_; 4548 return previous_;
4529 } 4549 }
4530 4550
4531 #undef __ 4551 #undef __
4532 4552
4533 } } // namespace v8::internal 4553 } } // namespace v8::internal
4534 4554
4535 #endif // V8_TARGET_ARCH_IA32 4555 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698