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

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

Powered by Google App Engine
This is Rietveld 408576698