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

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

Issue 132373011: A64: Synchronize with r17635. (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/ia32/code-stubs-ia32.cc ('k') | src/ia32/lithium-codegen-ia32.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 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 1917 matching lines...) Expand 10 before | Expand all | Expand 10 after
3660 3664
3661 __ bind(&done); 3665 __ bind(&done);
3662 context()->Plug(result); 3666 context()->Plug(result);
3663 } 3667 }
3664 3668
3665 3669
3666 void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { 3670 void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) {
3667 ZoneList<Expression*>* args = expr->arguments(); 3671 ZoneList<Expression*>* args = expr->arguments();
3668 ASSERT_EQ(2, args->length()); 3672 ASSERT_EQ(2, args->length());
3669 3673
3670 VisitForStackValue(args->at(0)); 3674 if (FLAG_new_string_add) {
3671 VisitForStackValue(args->at(1)); 3675 VisitForStackValue(args->at(0));
3676 VisitForAccumulatorValue(args->at(1));
3672 3677
3673 StringAddStub stub(STRING_ADD_CHECK_BOTH); 3678 __ pop(edx);
3674 __ CallStub(&stub); 3679 NewStringAddStub stub(STRING_ADD_CHECK_BOTH, NOT_TENURED);
3680 __ CallStub(&stub);
3681 } else {
3682 VisitForStackValue(args->at(0));
3683 VisitForStackValue(args->at(1));
3684
3685 StringAddStub stub(STRING_ADD_CHECK_BOTH);
3686 __ CallStub(&stub);
3687 }
3675 context()->Plug(eax); 3688 context()->Plug(eax);
3676 } 3689 }
3677 3690
3678 3691
3679 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { 3692 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) {
3680 ZoneList<Expression*>* args = expr->arguments(); 3693 ZoneList<Expression*>* args = expr->arguments();
3681 ASSERT_EQ(2, args->length()); 3694 ASSERT_EQ(2, args->length());
3682 3695
3683 VisitForStackValue(args->at(0)); 3696 VisitForStackValue(args->at(0));
3684 VisitForStackValue(args->at(1)); 3697 VisitForStackValue(args->at(1));
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
4387 } 4400 }
4388 4401
4389 // We need a second deoptimization point after loading the value 4402 // We need a second deoptimization point after loading the value
4390 // in case evaluating the property load my have a side effect. 4403 // in case evaluating the property load my have a side effect.
4391 if (assign_type == VARIABLE) { 4404 if (assign_type == VARIABLE) {
4392 PrepareForBailout(expr->expression(), TOS_REG); 4405 PrepareForBailout(expr->expression(), TOS_REG);
4393 } else { 4406 } else {
4394 PrepareForBailoutForId(prop->LoadId(), TOS_REG); 4407 PrepareForBailoutForId(prop->LoadId(), TOS_REG);
4395 } 4408 }
4396 4409
4397 // Call ToNumber only if operand is not a smi. 4410 // Inline smi case if we are in a loop.
4398 Label no_conversion; 4411 Label done, stub_call;
4412 JumpPatchSite patch_site(masm_);
4399 if (ShouldInlineSmiCase(expr->op())) { 4413 if (ShouldInlineSmiCase(expr->op())) {
4400 __ JumpIfSmi(eax, &no_conversion, Label::kNear); 4414 Label slow;
4415 patch_site.EmitJumpIfNotSmi(eax, &slow, Label::kNear);
4416
4417 // Save result for postfix expressions.
4418 if (expr->is_postfix()) {
4419 if (!context()->IsEffect()) {
4420 // Save the result on the stack. If we have a named or keyed property
4421 // we store the result under the receiver that is currently on top
4422 // of the stack.
4423 switch (assign_type) {
4424 case VARIABLE:
4425 __ push(eax);
4426 break;
4427 case NAMED_PROPERTY:
4428 __ mov(Operand(esp, kPointerSize), eax);
4429 break;
4430 case KEYED_PROPERTY:
4431 __ mov(Operand(esp, 2 * kPointerSize), eax);
4432 break;
4433 }
4434 }
4435 }
4436
4437 if (expr->op() == Token::INC) {
4438 __ add(eax, Immediate(Smi::FromInt(1)));
4439 } else {
4440 __ sub(eax, Immediate(Smi::FromInt(1)));
4441 }
4442 __ j(no_overflow, &done, Label::kNear);
4443 // Call stub. Undo operation first.
4444 if (expr->op() == Token::INC) {
4445 __ sub(eax, Immediate(Smi::FromInt(1)));
4446 } else {
4447 __ add(eax, Immediate(Smi::FromInt(1)));
4448 }
4449 __ jmp(&stub_call, Label::kNear);
4450 __ bind(&slow);
4401 } 4451 }
4402 ToNumberStub convert_stub; 4452 ToNumberStub convert_stub;
4403 __ CallStub(&convert_stub); 4453 __ CallStub(&convert_stub);
4404 __ bind(&no_conversion);
4405 4454
4406 // Save result for postfix expressions. 4455 // Save result for postfix expressions.
4407 if (expr->is_postfix()) { 4456 if (expr->is_postfix()) {
4408 if (!context()->IsEffect()) { 4457 if (!context()->IsEffect()) {
4409 // Save the result on the stack. If we have a named or keyed property 4458 // Save the result on the stack. If we have a named or keyed property
4410 // we store the result under the receiver that is currently on top 4459 // we store the result under the receiver that is currently on top
4411 // of the stack. 4460 // of the stack.
4412 switch (assign_type) { 4461 switch (assign_type) {
4413 case VARIABLE: 4462 case VARIABLE:
4414 __ push(eax); 4463 __ push(eax);
4415 break; 4464 break;
4416 case NAMED_PROPERTY: 4465 case NAMED_PROPERTY:
4417 __ mov(Operand(esp, kPointerSize), eax); 4466 __ mov(Operand(esp, kPointerSize), eax);
4418 break; 4467 break;
4419 case KEYED_PROPERTY: 4468 case KEYED_PROPERTY:
4420 __ mov(Operand(esp, 2 * kPointerSize), eax); 4469 __ mov(Operand(esp, 2 * kPointerSize), eax);
4421 break; 4470 break;
4422 } 4471 }
4423 } 4472 }
4424 } 4473 }
4425 4474
4426 // Inline smi case if we are in a loop.
4427 Label done, stub_call;
4428 JumpPatchSite patch_site(masm_);
4429
4430 if (ShouldInlineSmiCase(expr->op())) {
4431 if (expr->op() == Token::INC) {
4432 __ add(eax, Immediate(Smi::FromInt(1)));
4433 } else {
4434 __ sub(eax, Immediate(Smi::FromInt(1)));
4435 }
4436 __ j(overflow, &stub_call, Label::kNear);
4437 // We could eliminate this smi check if we split the code at
4438 // the first smi check before calling ToNumber.
4439 patch_site.EmitJumpIfSmi(eax, &done, Label::kNear);
4440
4441 __ bind(&stub_call);
4442 // Call stub. Undo operation first.
4443 if (expr->op() == Token::INC) {
4444 __ sub(eax, Immediate(Smi::FromInt(1)));
4445 } else {
4446 __ add(eax, Immediate(Smi::FromInt(1)));
4447 }
4448 }
4449
4450 // Record position before stub call. 4475 // Record position before stub call.
4451 SetSourcePosition(expr->position()); 4476 SetSourcePosition(expr->position());
4452 4477
4453 // Call stub for +1/-1. 4478 // Call stub for +1/-1.
4479 __ bind(&stub_call);
4454 __ mov(edx, eax); 4480 __ mov(edx, eax);
4455 __ mov(eax, Immediate(Smi::FromInt(1))); 4481 __ mov(eax, Immediate(Smi::FromInt(1)));
4456 BinaryOpStub stub(expr->binary_op(), NO_OVERWRITE); 4482 BinaryOpStub stub(expr->binary_op(), NO_OVERWRITE);
4457 CallIC(stub.GetCode(isolate()), 4483 CallIC(stub.GetCode(isolate()),
4458 RelocInfo::CODE_TARGET, 4484 RelocInfo::CODE_TARGET,
4459 expr->CountBinOpFeedbackId()); 4485 expr->CountBinOpFeedbackId());
4460 patch_site.EmitPatchInfo(); 4486 patch_site.EmitPatchInfo();
4461 __ bind(&done); 4487 __ bind(&done);
4462 4488
4463 // Store the value returned in eax. 4489 // Store the value returned in eax.
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
4952 4978
4953 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4979 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4954 Assembler::target_address_at(call_target_address)); 4980 Assembler::target_address_at(call_target_address));
4955 return OSR_AFTER_STACK_CHECK; 4981 return OSR_AFTER_STACK_CHECK;
4956 } 4982 }
4957 4983
4958 4984
4959 } } // namespace v8::internal 4985 } } // namespace v8::internal
4960 4986
4961 #endif // V8_TARGET_ARCH_IA32 4987 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/lithium-codegen-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698