| OLD | NEW |
| 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 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 __ LoadRoot(r1, Heap::kNullValueRootIndex); | 1627 __ LoadRoot(r1, Heap::kNullValueRootIndex); |
| 1628 __ push(r1); | 1628 __ push(r1); |
| 1629 } else { | 1629 } else { |
| 1630 VisitForStackValue(expression); | 1630 VisitForStackValue(expression); |
| 1631 } | 1631 } |
| 1632 } | 1632 } |
| 1633 | 1633 |
| 1634 | 1634 |
| 1635 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1635 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
| 1636 Comment cmnt(masm_, "[ ObjectLiteral"); | 1636 Comment cmnt(masm_, "[ ObjectLiteral"); |
| 1637 |
| 1638 int depth = 1; |
| 1639 expr->BuildConstantProperties(isolate(), &depth); |
| 1637 Handle<FixedArray> constant_properties = expr->constant_properties(); | 1640 Handle<FixedArray> constant_properties = expr->constant_properties(); |
| 1638 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1641 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1639 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); | 1642 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); |
| 1640 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); | 1643 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); |
| 1641 __ mov(r1, Operand(constant_properties)); | 1644 __ mov(r1, Operand(constant_properties)); |
| 1642 int flags = expr->fast_elements() | 1645 int flags = expr->fast_elements() |
| 1643 ? ObjectLiteral::kFastElements | 1646 ? ObjectLiteral::kFastElements |
| 1644 : ObjectLiteral::kNoFlags; | 1647 : ObjectLiteral::kNoFlags; |
| 1645 flags |= expr->has_function() | 1648 flags |= expr->has_function() |
| 1646 ? ObjectLiteral::kHasFunction | 1649 ? ObjectLiteral::kHasFunction |
| 1647 : ObjectLiteral::kNoFlags; | 1650 : ObjectLiteral::kNoFlags; |
| 1648 __ mov(r0, Operand(Smi::FromInt(flags))); | 1651 __ mov(r0, Operand(Smi::FromInt(flags))); |
| 1649 int properties_count = constant_properties->length() / 2; | 1652 int properties_count = constant_properties->length() / 2; |
| 1650 if ((FLAG_track_double_fields && expr->may_store_doubles()) || | 1653 if ((FLAG_track_double_fields && expr->may_store_doubles()) || |
| 1651 expr->depth() > 1 || Serializer::enabled() || | 1654 depth > 1 || Serializer::enabled() || |
| 1652 flags != ObjectLiteral::kFastElements || | 1655 flags != ObjectLiteral::kFastElements || |
| 1653 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { | 1656 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { |
| 1654 __ Push(r3, r2, r1, r0); | 1657 __ Push(r3, r2, r1, r0); |
| 1655 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); | 1658 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
| 1656 } else { | 1659 } else { |
| 1657 FastCloneShallowObjectStub stub(properties_count); | 1660 FastCloneShallowObjectStub stub(properties_count); |
| 1658 __ CallStub(&stub); | 1661 __ CallStub(&stub); |
| 1659 } | 1662 } |
| 1660 | 1663 |
| 1661 // If result_saved is true the result is on top of the stack. If | 1664 // If result_saved is true the result is on top of the stack. If |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1760 context()->PlugTOS(); | 1763 context()->PlugTOS(); |
| 1761 } else { | 1764 } else { |
| 1762 context()->Plug(r0); | 1765 context()->Plug(r0); |
| 1763 } | 1766 } |
| 1764 } | 1767 } |
| 1765 | 1768 |
| 1766 | 1769 |
| 1767 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { | 1770 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
| 1768 Comment cmnt(masm_, "[ ArrayLiteral"); | 1771 Comment cmnt(masm_, "[ ArrayLiteral"); |
| 1769 | 1772 |
| 1773 int depth = 1; |
| 1774 expr->BuildConstantElements(isolate(), &depth); |
| 1770 ZoneList<Expression*>* subexprs = expr->values(); | 1775 ZoneList<Expression*>* subexprs = expr->values(); |
| 1771 int length = subexprs->length(); | 1776 int length = subexprs->length(); |
| 1772 Handle<FixedArray> constant_elements = expr->constant_elements(); | 1777 Handle<FixedArray> constant_elements = expr->constant_elements(); |
| 1773 ASSERT_EQ(2, constant_elements->length()); | 1778 ASSERT_EQ(2, constant_elements->length()); |
| 1774 ElementsKind constant_elements_kind = | 1779 ElementsKind constant_elements_kind = |
| 1775 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | 1780 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); |
| 1776 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind); | 1781 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind); |
| 1777 Handle<FixedArrayBase> constant_elements_values( | 1782 Handle<FixedArrayBase> constant_elements_values( |
| 1778 FixedArrayBase::cast(constant_elements->get(1))); | 1783 FixedArrayBase::cast(constant_elements->get(1))); |
| 1779 | 1784 |
| 1780 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1785 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1781 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); | 1786 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); |
| 1782 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); | 1787 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); |
| 1783 __ mov(r1, Operand(constant_elements)); | 1788 __ mov(r1, Operand(constant_elements)); |
| 1784 if (has_fast_elements && constant_elements_values->map() == | 1789 if (has_fast_elements && constant_elements_values->map() == |
| 1785 isolate()->heap()->fixed_cow_array_map()) { | 1790 isolate()->heap()->fixed_cow_array_map()) { |
| 1786 FastCloneShallowArrayStub stub( | 1791 FastCloneShallowArrayStub stub( |
| 1787 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, | 1792 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, |
| 1788 DONT_TRACK_ALLOCATION_SITE, | 1793 DONT_TRACK_ALLOCATION_SITE, |
| 1789 length); | 1794 length); |
| 1790 __ CallStub(&stub); | 1795 __ CallStub(&stub); |
| 1791 __ IncrementCounter( | 1796 __ IncrementCounter( |
| 1792 isolate()->counters()->cow_arrays_created_stub(), 1, r1, r2); | 1797 isolate()->counters()->cow_arrays_created_stub(), 1, r1, r2); |
| 1793 } else if (expr->depth() > 1 || | 1798 } else if (depth > 1 || Serializer::enabled() || |
| 1794 Serializer::enabled() || | |
| 1795 length > FastCloneShallowArrayStub::kMaximumClonedLength) { | 1799 length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
| 1796 __ Push(r3, r2, r1); | 1800 __ Push(r3, r2, r1); |
| 1797 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); | 1801 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); |
| 1798 } else { | 1802 } else { |
| 1799 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || | 1803 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || |
| 1800 FLAG_smi_only_arrays); | 1804 FLAG_smi_only_arrays); |
| 1801 FastCloneShallowArrayStub::Mode mode = | 1805 FastCloneShallowArrayStub::Mode mode = |
| 1802 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | 1806 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; |
| 1803 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites | 1807 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites |
| 1804 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; | 1808 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; |
| (...skipping 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3694 generator.GenerateSlow(masm_, call_helper); | 3698 generator.GenerateSlow(masm_, call_helper); |
| 3695 | 3699 |
| 3696 __ bind(&done); | 3700 __ bind(&done); |
| 3697 context()->Plug(result); | 3701 context()->Plug(result); |
| 3698 } | 3702 } |
| 3699 | 3703 |
| 3700 | 3704 |
| 3701 void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { | 3705 void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { |
| 3702 ZoneList<Expression*>* args = expr->arguments(); | 3706 ZoneList<Expression*>* args = expr->arguments(); |
| 3703 ASSERT_EQ(2, args->length()); | 3707 ASSERT_EQ(2, args->length()); |
| 3704 VisitForStackValue(args->at(0)); | |
| 3705 VisitForStackValue(args->at(1)); | |
| 3706 | 3708 |
| 3707 StringAddStub stub(STRING_ADD_CHECK_BOTH); | 3709 if (FLAG_new_string_add) { |
| 3708 __ CallStub(&stub); | 3710 VisitForStackValue(args->at(0)); |
| 3711 VisitForAccumulatorValue(args->at(1)); |
| 3712 |
| 3713 __ pop(r1); |
| 3714 NewStringAddStub stub(STRING_ADD_CHECK_BOTH, NOT_TENURED); |
| 3715 __ CallStub(&stub); |
| 3716 } else { |
| 3717 VisitForStackValue(args->at(0)); |
| 3718 VisitForStackValue(args->at(1)); |
| 3719 |
| 3720 StringAddStub stub(STRING_ADD_CHECK_BOTH); |
| 3721 __ CallStub(&stub); |
| 3722 } |
| 3709 context()->Plug(r0); | 3723 context()->Plug(r0); |
| 3710 } | 3724 } |
| 3711 | 3725 |
| 3712 | 3726 |
| 3713 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { | 3727 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { |
| 3714 ZoneList<Expression*>* args = expr->arguments(); | 3728 ZoneList<Expression*>* args = expr->arguments(); |
| 3715 ASSERT_EQ(2, args->length()); | 3729 ASSERT_EQ(2, args->length()); |
| 3716 VisitForStackValue(args->at(0)); | 3730 VisitForStackValue(args->at(0)); |
| 3717 VisitForStackValue(args->at(1)); | 3731 VisitForStackValue(args->at(1)); |
| 3718 | 3732 |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4387 } | 4401 } |
| 4388 | 4402 |
| 4389 // We need a second deoptimization point after loading the value | 4403 // We need a second deoptimization point after loading the value |
| 4390 // in case evaluating the property load my have a side effect. | 4404 // in case evaluating the property load my have a side effect. |
| 4391 if (assign_type == VARIABLE) { | 4405 if (assign_type == VARIABLE) { |
| 4392 PrepareForBailout(expr->expression(), TOS_REG); | 4406 PrepareForBailout(expr->expression(), TOS_REG); |
| 4393 } else { | 4407 } else { |
| 4394 PrepareForBailoutForId(prop->LoadId(), TOS_REG); | 4408 PrepareForBailoutForId(prop->LoadId(), TOS_REG); |
| 4395 } | 4409 } |
| 4396 | 4410 |
| 4397 // Call ToNumber only if operand is not a smi. | 4411 // Inline smi case if we are in a loop. |
| 4398 Label no_conversion; | 4412 Label stub_call, done; |
| 4413 JumpPatchSite patch_site(masm_); |
| 4414 |
| 4415 int count_value = expr->op() == Token::INC ? 1 : -1; |
| 4399 if (ShouldInlineSmiCase(expr->op())) { | 4416 if (ShouldInlineSmiCase(expr->op())) { |
| 4400 __ JumpIfSmi(r0, &no_conversion); | 4417 Label slow; |
| 4418 patch_site.EmitJumpIfNotSmi(r0, &slow); |
| 4419 |
| 4420 // Save result for postfix expressions. |
| 4421 if (expr->is_postfix()) { |
| 4422 if (!context()->IsEffect()) { |
| 4423 // Save the result on the stack. If we have a named or keyed property |
| 4424 // we store the result under the receiver that is currently on top |
| 4425 // of the stack. |
| 4426 switch (assign_type) { |
| 4427 case VARIABLE: |
| 4428 __ push(r0); |
| 4429 break; |
| 4430 case NAMED_PROPERTY: |
| 4431 __ str(r0, MemOperand(sp, kPointerSize)); |
| 4432 break; |
| 4433 case KEYED_PROPERTY: |
| 4434 __ str(r0, MemOperand(sp, 2 * kPointerSize)); |
| 4435 break; |
| 4436 } |
| 4437 } |
| 4438 } |
| 4439 |
| 4440 __ add(r0, r0, Operand(Smi::FromInt(count_value)), SetCC); |
| 4441 __ b(vc, &done); |
| 4442 // Call stub. Undo operation first. |
| 4443 __ sub(r0, r0, Operand(Smi::FromInt(count_value))); |
| 4444 __ jmp(&stub_call); |
| 4445 __ bind(&slow); |
| 4401 } | 4446 } |
| 4402 ToNumberStub convert_stub; | 4447 ToNumberStub convert_stub; |
| 4403 __ CallStub(&convert_stub); | 4448 __ CallStub(&convert_stub); |
| 4404 __ bind(&no_conversion); | |
| 4405 | 4449 |
| 4406 // Save result for postfix expressions. | 4450 // Save result for postfix expressions. |
| 4407 if (expr->is_postfix()) { | 4451 if (expr->is_postfix()) { |
| 4408 if (!context()->IsEffect()) { | 4452 if (!context()->IsEffect()) { |
| 4409 // Save the result on the stack. If we have a named or keyed property | 4453 // 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 | 4454 // we store the result under the receiver that is currently on top |
| 4411 // of the stack. | 4455 // of the stack. |
| 4412 switch (assign_type) { | 4456 switch (assign_type) { |
| 4413 case VARIABLE: | 4457 case VARIABLE: |
| 4414 __ push(r0); | 4458 __ push(r0); |
| 4415 break; | 4459 break; |
| 4416 case NAMED_PROPERTY: | 4460 case NAMED_PROPERTY: |
| 4417 __ str(r0, MemOperand(sp, kPointerSize)); | 4461 __ str(r0, MemOperand(sp, kPointerSize)); |
| 4418 break; | 4462 break; |
| 4419 case KEYED_PROPERTY: | 4463 case KEYED_PROPERTY: |
| 4420 __ str(r0, MemOperand(sp, 2 * kPointerSize)); | 4464 __ str(r0, MemOperand(sp, 2 * kPointerSize)); |
| 4421 break; | 4465 break; |
| 4422 } | 4466 } |
| 4423 } | 4467 } |
| 4424 } | 4468 } |
| 4425 | 4469 |
| 4426 | 4470 |
| 4427 // Inline smi case if we are in a loop. | 4471 __ bind(&stub_call); |
| 4428 Label stub_call, done; | |
| 4429 JumpPatchSite patch_site(masm_); | |
| 4430 | |
| 4431 int count_value = expr->op() == Token::INC ? 1 : -1; | |
| 4432 if (ShouldInlineSmiCase(expr->op())) { | |
| 4433 __ add(r0, r0, Operand(Smi::FromInt(count_value)), SetCC); | |
| 4434 __ b(vs, &stub_call); | |
| 4435 // We could eliminate this smi check if we split the code at | |
| 4436 // the first smi check before calling ToNumber. | |
| 4437 patch_site.EmitJumpIfSmi(r0, &done); | |
| 4438 | |
| 4439 __ bind(&stub_call); | |
| 4440 // Call stub. Undo operation first. | |
| 4441 __ sub(r0, r0, Operand(Smi::FromInt(count_value))); | |
| 4442 } | |
| 4443 __ mov(r1, r0); | 4472 __ mov(r1, r0); |
| 4444 __ mov(r0, Operand(Smi::FromInt(count_value))); | 4473 __ mov(r0, Operand(Smi::FromInt(count_value))); |
| 4445 | 4474 |
| 4446 // Record position before stub call. | 4475 // Record position before stub call. |
| 4447 SetSourcePosition(expr->position()); | 4476 SetSourcePosition(expr->position()); |
| 4448 | 4477 |
| 4449 BinaryOpStub stub(Token::ADD, NO_OVERWRITE); | 4478 BinaryOpStub stub(Token::ADD, NO_OVERWRITE); |
| 4450 CallIC(stub.GetCode(isolate()), | 4479 CallIC(stub.GetCode(isolate()), |
| 4451 RelocInfo::CODE_TARGET, | 4480 RelocInfo::CODE_TARGET, |
| 4452 expr->CountBinOpFeedbackId()); | 4481 expr->CountBinOpFeedbackId()); |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4959 ASSERT(Memory::uint32_at(interrupt_address_pointer) == | 4988 ASSERT(Memory::uint32_at(interrupt_address_pointer) == |
| 4960 reinterpret_cast<uint32_t>( | 4989 reinterpret_cast<uint32_t>( |
| 4961 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4990 isolate->builtins()->OsrAfterStackCheck()->entry())); |
| 4962 return OSR_AFTER_STACK_CHECK; | 4991 return OSR_AFTER_STACK_CHECK; |
| 4963 } | 4992 } |
| 4964 | 4993 |
| 4965 | 4994 |
| 4966 } } // namespace v8::internal | 4995 } } // namespace v8::internal |
| 4967 | 4996 |
| 4968 #endif // V8_TARGET_ARCH_ARM | 4997 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |