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

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

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

Powered by Google App Engine
This is Rietveld 408576698