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

Side by Side Diff: src/ia32/full-codegen-ia32.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/ast.cc ('k') | src/mips/full-codegen-mips.cc » ('j') | 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 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 __ push(Immediate(isolate()->factory()->null_value())); 1568 __ push(Immediate(isolate()->factory()->null_value()));
1569 } else { 1569 } else {
1570 VisitForStackValue(expression); 1570 VisitForStackValue(expression);
1571 } 1571 }
1572 } 1572 }
1573 1573
1574 1574
1575 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1575 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1576 Comment cmnt(masm_, "[ ObjectLiteral"); 1576 Comment cmnt(masm_, "[ ObjectLiteral");
1577 1577
1578 int depth = 1; 1578 expr->BuildConstantProperties(isolate());
1579 expr->BuildConstantProperties(isolate(), &depth);
1580 Handle<FixedArray> constant_properties = expr->constant_properties(); 1579 Handle<FixedArray> constant_properties = expr->constant_properties();
1581 int flags = expr->fast_elements() 1580 int flags = expr->fast_elements()
1582 ? ObjectLiteral::kFastElements 1581 ? ObjectLiteral::kFastElements
1583 : ObjectLiteral::kNoFlags; 1582 : ObjectLiteral::kNoFlags;
1584 flags |= expr->has_function() 1583 flags |= expr->has_function()
1585 ? ObjectLiteral::kHasFunction 1584 ? ObjectLiteral::kHasFunction
1586 : ObjectLiteral::kNoFlags; 1585 : ObjectLiteral::kNoFlags;
1587 int properties_count = constant_properties->length() / 2; 1586 int properties_count = constant_properties->length() / 2;
1588 if ((FLAG_track_double_fields && expr->may_store_doubles()) || 1587 if ((FLAG_track_double_fields && expr->may_store_doubles()) ||
1589 depth > 1 || Serializer::enabled() || 1588 expr->depth() > 1 || Serializer::enabled() ||
1590 flags != ObjectLiteral::kFastElements || 1589 flags != ObjectLiteral::kFastElements ||
1591 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { 1590 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) {
1592 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 1591 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1593 __ push(FieldOperand(edi, JSFunction::kLiteralsOffset)); 1592 __ push(FieldOperand(edi, JSFunction::kLiteralsOffset));
1594 __ push(Immediate(Smi::FromInt(expr->literal_index()))); 1593 __ push(Immediate(Smi::FromInt(expr->literal_index())));
1595 __ push(Immediate(constant_properties)); 1594 __ push(Immediate(constant_properties));
1596 __ push(Immediate(Smi::FromInt(flags))); 1595 __ push(Immediate(Smi::FromInt(flags)));
1597 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); 1596 __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
1598 } else { 1597 } else {
1599 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 1598 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 context()->PlugTOS(); 1697 context()->PlugTOS();
1699 } else { 1698 } else {
1700 context()->Plug(eax); 1699 context()->Plug(eax);
1701 } 1700 }
1702 } 1701 }
1703 1702
1704 1703
1705 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1704 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1706 Comment cmnt(masm_, "[ ArrayLiteral"); 1705 Comment cmnt(masm_, "[ ArrayLiteral");
1707 1706
1708 int depth = 1; 1707 expr->BuildConstantElements(isolate());
1709 expr->BuildConstantElements(isolate(), &depth);
1710 ZoneList<Expression*>* subexprs = expr->values(); 1708 ZoneList<Expression*>* subexprs = expr->values();
1711 int length = subexprs->length(); 1709 int length = subexprs->length();
1712 Handle<FixedArray> constant_elements = expr->constant_elements(); 1710 Handle<FixedArray> constant_elements = expr->constant_elements();
1713 ASSERT_EQ(2, constant_elements->length()); 1711 ASSERT_EQ(2, constant_elements->length());
1714 ElementsKind constant_elements_kind = 1712 ElementsKind constant_elements_kind =
1715 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); 1713 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1716 bool has_constant_fast_elements = 1714 bool has_constant_fast_elements =
1717 IsFastObjectElementsKind(constant_elements_kind); 1715 IsFastObjectElementsKind(constant_elements_kind);
1718 Handle<FixedArrayBase> constant_elements_values( 1716 Handle<FixedArrayBase> constant_elements_values(
1719 FixedArrayBase::cast(constant_elements->get(1))); 1717 FixedArrayBase::cast(constant_elements->get(1)));
1720 1718
1721 Heap* heap = isolate()->heap(); 1719 Heap* heap = isolate()->heap();
1722 if (has_constant_fast_elements && 1720 if (has_constant_fast_elements &&
1723 constant_elements_values->map() == heap->fixed_cow_array_map()) { 1721 constant_elements_values->map() == heap->fixed_cow_array_map()) {
1724 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot 1722 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot
1725 // change, so it's possible to specialize the stub in advance. 1723 // change, so it's possible to specialize the stub in advance.
1726 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); 1724 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1);
1727 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 1725 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1728 __ mov(eax, FieldOperand(ebx, JSFunction::kLiteralsOffset)); 1726 __ mov(eax, FieldOperand(ebx, JSFunction::kLiteralsOffset));
1729 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index()))); 1727 __ mov(ebx, Immediate(Smi::FromInt(expr->literal_index())));
1730 __ mov(ecx, Immediate(constant_elements)); 1728 __ mov(ecx, Immediate(constant_elements));
1731 FastCloneShallowArrayStub stub( 1729 FastCloneShallowArrayStub stub(
1732 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, 1730 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS,
1733 DONT_TRACK_ALLOCATION_SITE, 1731 DONT_TRACK_ALLOCATION_SITE,
1734 length); 1732 length);
1735 __ CallStub(&stub); 1733 __ CallStub(&stub);
1736 } else if (depth > 1 || Serializer::enabled() || 1734 } else if (expr->depth() > 1 || Serializer::enabled() ||
1737 length > FastCloneShallowArrayStub::kMaximumClonedLength) { 1735 length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1738 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 1736 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1739 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); 1737 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset));
1740 __ push(Immediate(Smi::FromInt(expr->literal_index()))); 1738 __ push(Immediate(Smi::FromInt(expr->literal_index())));
1741 __ push(Immediate(constant_elements)); 1739 __ push(Immediate(constant_elements));
1742 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); 1740 __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
1743 } else { 1741 } else {
1744 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || 1742 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) ||
1745 FLAG_smi_only_arrays); 1743 FLAG_smi_only_arrays);
1746 FastCloneShallowArrayStub::Mode mode = 1744 FastCloneShallowArrayStub::Mode mode =
(...skipping 3209 matching lines...) Expand 10 before | Expand all | Expand 10 after
4956 4954
4957 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4955 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4958 Assembler::target_address_at(call_target_address)); 4956 Assembler::target_address_at(call_target_address));
4959 return OSR_AFTER_STACK_CHECK; 4957 return OSR_AFTER_STACK_CHECK;
4960 } 4958 }
4961 4959
4962 4960
4963 } } // namespace v8::internal 4961 } } // namespace v8::internal
4964 4962
4965 #endif // V8_TARGET_ARCH_IA32 4963 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698