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

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

Issue 61873003: Defer allocation of constant literal properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 if (expression == NULL) { 1590 if (expression == NULL) {
1591 __ PushRoot(Heap::kNullValueRootIndex); 1591 __ PushRoot(Heap::kNullValueRootIndex);
1592 } else { 1592 } else {
1593 VisitForStackValue(expression); 1593 VisitForStackValue(expression);
1594 } 1594 }
1595 } 1595 }
1596 1596
1597 1597
1598 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1598 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1599 Comment cmnt(masm_, "[ ObjectLiteral"); 1599 Comment cmnt(masm_, "[ ObjectLiteral");
1600
1601 int depth = 1;
1602 expr->BuildConstantProperties(isolate(), &depth);
1600 Handle<FixedArray> constant_properties = expr->constant_properties(); 1603 Handle<FixedArray> constant_properties = expr->constant_properties();
1601 int flags = expr->fast_elements() 1604 int flags = expr->fast_elements()
1602 ? ObjectLiteral::kFastElements 1605 ? ObjectLiteral::kFastElements
1603 : ObjectLiteral::kNoFlags; 1606 : ObjectLiteral::kNoFlags;
1604 flags |= expr->has_function() 1607 flags |= expr->has_function()
1605 ? ObjectLiteral::kHasFunction 1608 ? ObjectLiteral::kHasFunction
1606 : ObjectLiteral::kNoFlags; 1609 : ObjectLiteral::kNoFlags;
1607 int properties_count = constant_properties->length() / 2; 1610 int properties_count = constant_properties->length() / 2;
1608 if ((FLAG_track_double_fields && expr->may_store_doubles()) || 1611 if ((FLAG_track_double_fields && expr->may_store_doubles()) ||
1609 expr->depth() > 1 || Serializer::enabled() || 1612 depth > 1 || Serializer::enabled() ||
1610 flags != ObjectLiteral::kFastElements || 1613 flags != ObjectLiteral::kFastElements ||
1611 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { 1614 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) {
1612 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1615 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1613 __ push(FieldOperand(rdi, JSFunction::kLiteralsOffset)); 1616 __ push(FieldOperand(rdi, JSFunction::kLiteralsOffset));
1614 __ Push(Smi::FromInt(expr->literal_index())); 1617 __ Push(Smi::FromInt(expr->literal_index()));
1615 __ Push(constant_properties); 1618 __ Push(constant_properties);
1616 __ Push(Smi::FromInt(flags)); 1619 __ Push(Smi::FromInt(flags));
1617 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); 1620 __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
1618 } else { 1621 } else {
1619 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1622 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 context()->PlugTOS(); 1721 context()->PlugTOS();
1719 } else { 1722 } else {
1720 context()->Plug(rax); 1723 context()->Plug(rax);
1721 } 1724 }
1722 } 1725 }
1723 1726
1724 1727
1725 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1728 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1726 Comment cmnt(masm_, "[ ArrayLiteral"); 1729 Comment cmnt(masm_, "[ ArrayLiteral");
1727 1730
1731 int depth = 1;
1732 expr->BuildConstantElements(isolate(), &depth);
1728 ZoneList<Expression*>* subexprs = expr->values(); 1733 ZoneList<Expression*>* subexprs = expr->values();
1729 int length = subexprs->length(); 1734 int length = subexprs->length();
1730 Handle<FixedArray> constant_elements = expr->constant_elements(); 1735 Handle<FixedArray> constant_elements = expr->constant_elements();
1731 ASSERT_EQ(2, constant_elements->length()); 1736 ASSERT_EQ(2, constant_elements->length());
1732 ElementsKind constant_elements_kind = 1737 ElementsKind constant_elements_kind =
1733 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); 1738 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1734 bool has_constant_fast_elements = 1739 bool has_constant_fast_elements =
1735 IsFastObjectElementsKind(constant_elements_kind); 1740 IsFastObjectElementsKind(constant_elements_kind);
1736 Handle<FixedArrayBase> constant_elements_values( 1741 Handle<FixedArrayBase> constant_elements_values(
1737 FixedArrayBase::cast(constant_elements->get(1))); 1742 FixedArrayBase::cast(constant_elements->get(1)));
1738 1743
1739 Heap* heap = isolate()->heap(); 1744 Heap* heap = isolate()->heap();
1740 if (has_constant_fast_elements && 1745 if (has_constant_fast_elements &&
1741 constant_elements_values->map() == heap->fixed_cow_array_map()) { 1746 constant_elements_values->map() == heap->fixed_cow_array_map()) {
1742 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot 1747 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot
1743 // change, so it's possible to specialize the stub in advance. 1748 // change, so it's possible to specialize the stub in advance.
1744 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); 1749 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1);
1745 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1750 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1746 __ movq(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset)); 1751 __ movq(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset));
1747 __ Move(rbx, Smi::FromInt(expr->literal_index())); 1752 __ Move(rbx, Smi::FromInt(expr->literal_index()));
1748 __ Move(rcx, constant_elements); 1753 __ Move(rcx, constant_elements);
1749 FastCloneShallowArrayStub stub( 1754 FastCloneShallowArrayStub stub(
1750 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, 1755 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS,
1751 DONT_TRACK_ALLOCATION_SITE, 1756 DONT_TRACK_ALLOCATION_SITE,
1752 length); 1757 length);
1753 __ CallStub(&stub); 1758 __ CallStub(&stub);
1754 } else if (expr->depth() > 1 || 1759 } else if (depth > 1 || Serializer::enabled() ||
1755 Serializer::enabled() ||
1756 length > FastCloneShallowArrayStub::kMaximumClonedLength) { 1760 length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1757 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1761 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1758 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); 1762 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset));
1759 __ Push(Smi::FromInt(expr->literal_index())); 1763 __ Push(Smi::FromInt(expr->literal_index()));
1760 __ Push(constant_elements); 1764 __ Push(constant_elements);
1761 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); 1765 __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
1762 } else { 1766 } else {
1763 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || 1767 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) ||
1764 FLAG_smi_only_arrays); 1768 FLAG_smi_only_arrays);
1765 FastCloneShallowArrayStub::Mode mode = 1769 FastCloneShallowArrayStub::Mode mode =
(...skipping 3173 matching lines...) Expand 10 before | Expand all | Expand 10 after
4939 4943
4940 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4944 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4941 Assembler::target_address_at(call_target_address)); 4945 Assembler::target_address_at(call_target_address));
4942 return OSR_AFTER_STACK_CHECK; 4946 return OSR_AFTER_STACK_CHECK;
4943 } 4947 }
4944 4948
4945 4949
4946 } } // namespace v8::internal 4950 } } // namespace v8::internal
4947 4951
4948 #endif // V8_TARGET_ARCH_X64 4952 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698