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

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

Issue 148593004: A64: Synchronize with r18084. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 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
« no previous file with comments | « src/x64/deoptimizer-x64.cc ('k') | src/x64/lithium-codegen-x64.h » ('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 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); 1729 int flags = expr->depth() == 1
1730 ? ArrayLiteral::kShallowElements
1731 : ArrayLiteral::kNoFlags;
1732
1731 ZoneList<Expression*>* subexprs = expr->values(); 1733 ZoneList<Expression*>* subexprs = expr->values();
1732 int length = subexprs->length(); 1734 int length = subexprs->length();
1733 Handle<FixedArray> constant_elements = expr->constant_elements(); 1735 Handle<FixedArray> constant_elements = expr->constant_elements();
1734 ASSERT_EQ(2, constant_elements->length()); 1736 ASSERT_EQ(2, constant_elements->length());
1735 ElementsKind constant_elements_kind = 1737 ElementsKind constant_elements_kind =
1736 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); 1738 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1737 bool has_constant_fast_elements = 1739 bool has_constant_fast_elements =
1738 IsFastObjectElementsKind(constant_elements_kind); 1740 IsFastObjectElementsKind(constant_elements_kind);
1739 Handle<FixedArrayBase> constant_elements_values( 1741 Handle<FixedArrayBase> constant_elements_values(
1740 FixedArrayBase::cast(constant_elements->get(1))); 1742 FixedArrayBase::cast(constant_elements->get(1)));
1741 1743
1742 Heap* heap = isolate()->heap(); 1744 Heap* heap = isolate()->heap();
1743 if (has_constant_fast_elements && 1745 if (has_constant_fast_elements &&
1744 constant_elements_values->map() == heap->fixed_cow_array_map()) { 1746 constant_elements_values->map() == heap->fixed_cow_array_map()) {
1745 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot 1747 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot
1746 // change, so it's possible to specialize the stub in advance. 1748 // change, so it's possible to specialize the stub in advance.
1747 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1); 1749 __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1);
1748 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1750 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1749 __ movq(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset)); 1751 __ movq(rax, FieldOperand(rbx, JSFunction::kLiteralsOffset));
1750 __ Move(rbx, Smi::FromInt(expr->literal_index())); 1752 __ Move(rbx, Smi::FromInt(expr->literal_index()));
1751 __ Move(rcx, constant_elements); 1753 __ Move(rcx, constant_elements);
1752 FastCloneShallowArrayStub stub( 1754 FastCloneShallowArrayStub stub(
1753 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, 1755 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS,
1754 DONT_TRACK_ALLOCATION_SITE, 1756 DONT_TRACK_ALLOCATION_SITE,
1755 length); 1757 length);
1756 __ CallStub(&stub); 1758 __ CallStub(&stub);
1757 } else if (depth > 1 || Serializer::enabled() || 1759 } else if (expr->depth() > 1 || Serializer::enabled() ||
1758 length > FastCloneShallowArrayStub::kMaximumClonedLength) { 1760 length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1759 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 1761 __ movq(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
1760 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); 1762 __ push(FieldOperand(rbx, JSFunction::kLiteralsOffset));
1761 __ Push(Smi::FromInt(expr->literal_index())); 1763 __ Push(Smi::FromInt(expr->literal_index()));
1762 __ Push(constant_elements); 1764 __ Push(constant_elements);
1763 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); 1765 __ Push(Smi::FromInt(flags));
1766 __ CallRuntime(Runtime::kCreateArrayLiteral, 4);
1764 } else { 1767 } else {
1765 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || 1768 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) ||
1766 FLAG_smi_only_arrays); 1769 FLAG_smi_only_arrays);
1767 FastCloneShallowArrayStub::Mode mode = 1770 FastCloneShallowArrayStub::Mode mode =
1768 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; 1771 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS;
1769 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites 1772 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites
1770 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; 1773 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE;
1771 1774
1772 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot 1775 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot
1773 // change, so it's possible to specialize the stub in advance. 1776 // change, so it's possible to specialize the stub in advance.
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
3266 VisitForStackValue(args->at(1)); 3269 VisitForStackValue(args->at(1));
3267 VisitForStackValue(args->at(2)); 3270 VisitForStackValue(args->at(2));
3268 __ CallRuntime(Runtime::kLog, 2); 3271 __ CallRuntime(Runtime::kLog, 2);
3269 } 3272 }
3270 // Finally, we're expected to leave a value on the top of the stack. 3273 // Finally, we're expected to leave a value on the top of the stack.
3271 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); 3274 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
3272 context()->Plug(rax); 3275 context()->Plug(rax);
3273 } 3276 }
3274 3277
3275 3278
3276 void FullCodeGenerator::EmitRandomHeapNumber(CallRuntime* expr) {
3277 ASSERT(expr->arguments()->length() == 0);
3278
3279 Label slow_allocate_heapnumber;
3280 Label heapnumber_allocated;
3281
3282 __ AllocateHeapNumber(rbx, rcx, &slow_allocate_heapnumber);
3283 __ jmp(&heapnumber_allocated);
3284
3285 __ bind(&slow_allocate_heapnumber);
3286 // Allocate a heap number.
3287 __ CallRuntime(Runtime::kNumberAlloc, 0);
3288 __ movq(rbx, rax);
3289
3290 __ bind(&heapnumber_allocated);
3291
3292 // Return a random uint32 number in rax.
3293 // The fresh HeapNumber is in rbx, which is callee-save on both x64 ABIs.
3294 __ PrepareCallCFunction(1);
3295 __ movq(arg_reg_1,
3296 ContextOperand(context_register(), Context::GLOBAL_OBJECT_INDEX));
3297 __ movq(arg_reg_1,
3298 FieldOperand(arg_reg_1, GlobalObject::kNativeContextOffset));
3299 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1);
3300
3301 // Convert 32 random bits in rax to 0.(32 random bits) in a double
3302 // by computing:
3303 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
3304 __ movl(rcx, Immediate(0x49800000)); // 1.0 x 2^20 as single.
3305 __ movd(xmm1, rcx);
3306 __ movd(xmm0, rax);
3307 __ cvtss2sd(xmm1, xmm1);
3308 __ xorps(xmm0, xmm1);
3309 __ subsd(xmm0, xmm1);
3310 __ movsd(FieldOperand(rbx, HeapNumber::kValueOffset), xmm0);
3311
3312 __ movq(rax, rbx);
3313 context()->Plug(rax);
3314 }
3315
3316
3317 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { 3279 void FullCodeGenerator::EmitSubString(CallRuntime* expr) {
3318 // Load the arguments on the stack and call the stub. 3280 // Load the arguments on the stack and call the stub.
3319 SubStringStub stub; 3281 SubStringStub stub;
3320 ZoneList<Expression*>* args = expr->arguments(); 3282 ZoneList<Expression*>* args = expr->arguments();
3321 ASSERT(args->length() == 3); 3283 ASSERT(args->length() == 3);
3322 VisitForStackValue(args->at(0)); 3284 VisitForStackValue(args->at(0));
3323 VisitForStackValue(args->at(1)); 3285 VisitForStackValue(args->at(1));
3324 VisitForStackValue(args->at(2)); 3286 VisitForStackValue(args->at(2));
3325 __ CallStub(&stub); 3287 __ CallStub(&stub);
3326 context()->Plug(rax); 3288 context()->Plug(rax);
(...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after
4939 4901
4940 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4902 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4941 Assembler::target_address_at(call_target_address)); 4903 Assembler::target_address_at(call_target_address));
4942 return OSR_AFTER_STACK_CHECK; 4904 return OSR_AFTER_STACK_CHECK;
4943 } 4905 }
4944 4906
4945 4907
4946 } } // namespace v8::internal 4908 } } // namespace v8::internal
4947 4909
4948 #endif // V8_TARGET_ARCH_X64 4910 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/deoptimizer-x64.cc ('k') | src/x64/lithium-codegen-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698