| 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 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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() || |
| 1737 length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
| 1732 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1738 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1733 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); | 1739 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); |
| 1734 __ push(Immediate(Smi::FromInt(expr->literal_index()))); | 1740 __ push(Immediate(Smi::FromInt(expr->literal_index()))); |
| 1735 __ push(Immediate(constant_elements)); | 1741 __ push(Immediate(constant_elements)); |
| 1736 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); | 1742 __ CallRuntime(Runtime::kCreateArrayLiteral, 3); |
| 1737 } else if (Serializer::enabled() || | |
| 1738 length > FastCloneShallowArrayStub::kMaximumClonedLength) { | |
| 1739 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | |
| 1740 __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset)); | |
| 1741 __ push(Immediate(Smi::FromInt(expr->literal_index()))); | |
| 1742 __ push(Immediate(constant_elements)); | |
| 1743 __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3); | |
| 1744 } else { | 1743 } else { |
| 1745 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || | 1744 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || |
| 1746 FLAG_smi_only_arrays); | 1745 FLAG_smi_only_arrays); |
| 1747 FastCloneShallowArrayStub::Mode mode = | 1746 FastCloneShallowArrayStub::Mode mode = |
| 1748 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; | 1747 FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; |
| 1749 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites | 1748 AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites |
| 1750 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; | 1749 ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; |
| 1751 | 1750 |
| 1752 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot | 1751 // If the elements are already FAST_*_ELEMENTS, the boilerplate cannot |
| 1753 // change, so it's possible to specialize the stub in advance. | 1752 // change, so it's possible to specialize the stub in advance. |
| (...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3046 | 3045 |
| 3047 __ JumpIfSmi(eax, if_false); | 3046 __ JumpIfSmi(eax, if_false); |
| 3048 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); | 3047 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); |
| 3049 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 3048 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
| 3050 Split(equal, if_true, if_false, fall_through); | 3049 Split(equal, if_true, if_false, fall_through); |
| 3051 | 3050 |
| 3052 context()->Plug(if_true, if_false); | 3051 context()->Plug(if_true, if_false); |
| 3053 } | 3052 } |
| 3054 | 3053 |
| 3055 | 3054 |
| 3055 void FullCodeGenerator::EmitIsMinusZero(CallRuntime* expr) { |
| 3056 ZoneList<Expression*>* args = expr->arguments(); |
| 3057 ASSERT(args->length() == 1); |
| 3058 |
| 3059 VisitForAccumulatorValue(args->at(0)); |
| 3060 |
| 3061 Label materialize_true, materialize_false; |
| 3062 Label* if_true = NULL; |
| 3063 Label* if_false = NULL; |
| 3064 Label* fall_through = NULL; |
| 3065 context()->PrepareTest(&materialize_true, &materialize_false, |
| 3066 &if_true, &if_false, &fall_through); |
| 3067 |
| 3068 Handle<Map> map = masm()->isolate()->factory()->heap_number_map(); |
| 3069 __ CheckMap(eax, map, if_false, DO_SMI_CHECK); |
| 3070 __ cmp(FieldOperand(eax, HeapNumber::kExponentOffset), Immediate(0x80000000)); |
| 3071 __ j(not_equal, if_false); |
| 3072 __ cmp(FieldOperand(eax, HeapNumber::kMantissaOffset), Immediate(0x00000000)); |
| 3073 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
| 3074 Split(equal, if_true, if_false, fall_through); |
| 3075 |
| 3076 context()->Plug(if_true, if_false); |
| 3077 } |
| 3078 |
| 3079 |
| 3080 |
| 3056 void FullCodeGenerator::EmitIsArray(CallRuntime* expr) { | 3081 void FullCodeGenerator::EmitIsArray(CallRuntime* expr) { |
| 3057 ZoneList<Expression*>* args = expr->arguments(); | 3082 ZoneList<Expression*>* args = expr->arguments(); |
| 3058 ASSERT(args->length() == 1); | 3083 ASSERT(args->length() == 1); |
| 3059 | 3084 |
| 3060 VisitForAccumulatorValue(args->at(0)); | 3085 VisitForAccumulatorValue(args->at(0)); |
| 3061 | 3086 |
| 3062 Label materialize_true, materialize_false; | 3087 Label materialize_true, materialize_false; |
| 3063 Label* if_true = NULL; | 3088 Label* if_true = NULL; |
| 3064 Label* if_false = NULL; | 3089 Label* if_false = NULL; |
| 3065 Label* fall_through = NULL; | 3090 Label* fall_through = NULL; |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3665 | 3690 |
| 3666 __ bind(&done); | 3691 __ bind(&done); |
| 3667 context()->Plug(result); | 3692 context()->Plug(result); |
| 3668 } | 3693 } |
| 3669 | 3694 |
| 3670 | 3695 |
| 3671 void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { | 3696 void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { |
| 3672 ZoneList<Expression*>* args = expr->arguments(); | 3697 ZoneList<Expression*>* args = expr->arguments(); |
| 3673 ASSERT_EQ(2, args->length()); | 3698 ASSERT_EQ(2, args->length()); |
| 3674 | 3699 |
| 3675 VisitForStackValue(args->at(0)); | 3700 if (FLAG_new_string_add) { |
| 3676 VisitForStackValue(args->at(1)); | 3701 VisitForStackValue(args->at(0)); |
| 3702 VisitForAccumulatorValue(args->at(1)); |
| 3677 | 3703 |
| 3678 StringAddStub stub(STRING_ADD_CHECK_BOTH); | 3704 __ pop(edx); |
| 3679 __ CallStub(&stub); | 3705 NewStringAddStub stub(STRING_ADD_CHECK_BOTH, NOT_TENURED); |
| 3706 __ CallStub(&stub); |
| 3707 } else { |
| 3708 VisitForStackValue(args->at(0)); |
| 3709 VisitForStackValue(args->at(1)); |
| 3710 |
| 3711 StringAddStub stub(STRING_ADD_CHECK_BOTH); |
| 3712 __ CallStub(&stub); |
| 3713 } |
| 3680 context()->Plug(eax); | 3714 context()->Plug(eax); |
| 3681 } | 3715 } |
| 3682 | 3716 |
| 3683 | 3717 |
| 3684 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { | 3718 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { |
| 3685 ZoneList<Expression*>* args = expr->arguments(); | 3719 ZoneList<Expression*>* args = expr->arguments(); |
| 3686 ASSERT_EQ(2, args->length()); | 3720 ASSERT_EQ(2, args->length()); |
| 3687 | 3721 |
| 3688 VisitForStackValue(args->at(0)); | 3722 VisitForStackValue(args->at(0)); |
| 3689 VisitForStackValue(args->at(1)); | 3723 VisitForStackValue(args->at(1)); |
| 3690 | 3724 |
| 3691 StringCompareStub stub; | 3725 StringCompareStub stub; |
| 3692 __ CallStub(&stub); | 3726 __ CallStub(&stub); |
| 3693 context()->Plug(eax); | 3727 context()->Plug(eax); |
| 3694 } | 3728 } |
| 3695 | 3729 |
| 3696 | 3730 |
| 3697 void FullCodeGenerator::EmitMathSin(CallRuntime* expr) { | |
| 3698 // Load the argument on the stack and call the stub. | |
| 3699 TranscendentalCacheStub stub(TranscendentalCache::SIN, | |
| 3700 TranscendentalCacheStub::TAGGED); | |
| 3701 ZoneList<Expression*>* args = expr->arguments(); | |
| 3702 ASSERT(args->length() == 1); | |
| 3703 VisitForStackValue(args->at(0)); | |
| 3704 __ CallStub(&stub); | |
| 3705 context()->Plug(eax); | |
| 3706 } | |
| 3707 | |
| 3708 | |
| 3709 void FullCodeGenerator::EmitMathCos(CallRuntime* expr) { | |
| 3710 // Load the argument on the stack and call the stub. | |
| 3711 TranscendentalCacheStub stub(TranscendentalCache::COS, | |
| 3712 TranscendentalCacheStub::TAGGED); | |
| 3713 ZoneList<Expression*>* args = expr->arguments(); | |
| 3714 ASSERT(args->length() == 1); | |
| 3715 VisitForStackValue(args->at(0)); | |
| 3716 __ CallStub(&stub); | |
| 3717 context()->Plug(eax); | |
| 3718 } | |
| 3719 | |
| 3720 | |
| 3721 void FullCodeGenerator::EmitMathTan(CallRuntime* expr) { | |
| 3722 // Load the argument on the stack and call the stub. | |
| 3723 TranscendentalCacheStub stub(TranscendentalCache::TAN, | |
| 3724 TranscendentalCacheStub::TAGGED); | |
| 3725 ZoneList<Expression*>* args = expr->arguments(); | |
| 3726 ASSERT(args->length() == 1); | |
| 3727 VisitForStackValue(args->at(0)); | |
| 3728 __ CallStub(&stub); | |
| 3729 context()->Plug(eax); | |
| 3730 } | |
| 3731 | |
| 3732 | |
| 3733 void FullCodeGenerator::EmitMathLog(CallRuntime* expr) { | 3731 void FullCodeGenerator::EmitMathLog(CallRuntime* expr) { |
| 3734 // Load the argument on the stack and call the stub. | 3732 // Load the argument on the stack and call the stub. |
| 3735 TranscendentalCacheStub stub(TranscendentalCache::LOG, | 3733 TranscendentalCacheStub stub(TranscendentalCache::LOG, |
| 3736 TranscendentalCacheStub::TAGGED); | 3734 TranscendentalCacheStub::TAGGED); |
| 3737 ZoneList<Expression*>* args = expr->arguments(); | 3735 ZoneList<Expression*>* args = expr->arguments(); |
| 3738 ASSERT(args->length() == 1); | 3736 ASSERT(args->length() == 1); |
| 3739 VisitForStackValue(args->at(0)); | 3737 VisitForStackValue(args->at(0)); |
| 3740 __ CallStub(&stub); | 3738 __ CallStub(&stub); |
| 3741 context()->Plug(eax); | 3739 context()->Plug(eax); |
| 3742 } | 3740 } |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4392 } | 4390 } |
| 4393 | 4391 |
| 4394 // We need a second deoptimization point after loading the value | 4392 // We need a second deoptimization point after loading the value |
| 4395 // in case evaluating the property load my have a side effect. | 4393 // in case evaluating the property load my have a side effect. |
| 4396 if (assign_type == VARIABLE) { | 4394 if (assign_type == VARIABLE) { |
| 4397 PrepareForBailout(expr->expression(), TOS_REG); | 4395 PrepareForBailout(expr->expression(), TOS_REG); |
| 4398 } else { | 4396 } else { |
| 4399 PrepareForBailoutForId(prop->LoadId(), TOS_REG); | 4397 PrepareForBailoutForId(prop->LoadId(), TOS_REG); |
| 4400 } | 4398 } |
| 4401 | 4399 |
| 4402 // Call ToNumber only if operand is not a smi. | 4400 // Inline smi case if we are in a loop. |
| 4403 Label no_conversion; | 4401 Label done, stub_call; |
| 4402 JumpPatchSite patch_site(masm_); |
| 4404 if (ShouldInlineSmiCase(expr->op())) { | 4403 if (ShouldInlineSmiCase(expr->op())) { |
| 4405 __ JumpIfSmi(eax, &no_conversion, Label::kNear); | 4404 Label slow; |
| 4405 patch_site.EmitJumpIfNotSmi(eax, &slow, Label::kNear); |
| 4406 |
| 4407 // Save result for postfix expressions. |
| 4408 if (expr->is_postfix()) { |
| 4409 if (!context()->IsEffect()) { |
| 4410 // Save the result on the stack. If we have a named or keyed property |
| 4411 // we store the result under the receiver that is currently on top |
| 4412 // of the stack. |
| 4413 switch (assign_type) { |
| 4414 case VARIABLE: |
| 4415 __ push(eax); |
| 4416 break; |
| 4417 case NAMED_PROPERTY: |
| 4418 __ mov(Operand(esp, kPointerSize), eax); |
| 4419 break; |
| 4420 case KEYED_PROPERTY: |
| 4421 __ mov(Operand(esp, 2 * kPointerSize), eax); |
| 4422 break; |
| 4423 } |
| 4424 } |
| 4425 } |
| 4426 |
| 4427 if (expr->op() == Token::INC) { |
| 4428 __ add(eax, Immediate(Smi::FromInt(1))); |
| 4429 } else { |
| 4430 __ sub(eax, Immediate(Smi::FromInt(1))); |
| 4431 } |
| 4432 __ j(no_overflow, &done, Label::kNear); |
| 4433 // Call stub. Undo operation first. |
| 4434 if (expr->op() == Token::INC) { |
| 4435 __ sub(eax, Immediate(Smi::FromInt(1))); |
| 4436 } else { |
| 4437 __ add(eax, Immediate(Smi::FromInt(1))); |
| 4438 } |
| 4439 __ jmp(&stub_call, Label::kNear); |
| 4440 __ bind(&slow); |
| 4406 } | 4441 } |
| 4407 ToNumberStub convert_stub; | 4442 ToNumberStub convert_stub; |
| 4408 __ CallStub(&convert_stub); | 4443 __ CallStub(&convert_stub); |
| 4409 __ bind(&no_conversion); | |
| 4410 | 4444 |
| 4411 // Save result for postfix expressions. | 4445 // Save result for postfix expressions. |
| 4412 if (expr->is_postfix()) { | 4446 if (expr->is_postfix()) { |
| 4413 if (!context()->IsEffect()) { | 4447 if (!context()->IsEffect()) { |
| 4414 // Save the result on the stack. If we have a named or keyed property | 4448 // Save the result on the stack. If we have a named or keyed property |
| 4415 // we store the result under the receiver that is currently on top | 4449 // we store the result under the receiver that is currently on top |
| 4416 // of the stack. | 4450 // of the stack. |
| 4417 switch (assign_type) { | 4451 switch (assign_type) { |
| 4418 case VARIABLE: | 4452 case VARIABLE: |
| 4419 __ push(eax); | 4453 __ push(eax); |
| 4420 break; | 4454 break; |
| 4421 case NAMED_PROPERTY: | 4455 case NAMED_PROPERTY: |
| 4422 __ mov(Operand(esp, kPointerSize), eax); | 4456 __ mov(Operand(esp, kPointerSize), eax); |
| 4423 break; | 4457 break; |
| 4424 case KEYED_PROPERTY: | 4458 case KEYED_PROPERTY: |
| 4425 __ mov(Operand(esp, 2 * kPointerSize), eax); | 4459 __ mov(Operand(esp, 2 * kPointerSize), eax); |
| 4426 break; | 4460 break; |
| 4427 } | 4461 } |
| 4428 } | 4462 } |
| 4429 } | 4463 } |
| 4430 | 4464 |
| 4431 // Inline smi case if we are in a loop. | |
| 4432 Label done, stub_call; | |
| 4433 JumpPatchSite patch_site(masm_); | |
| 4434 | |
| 4435 if (ShouldInlineSmiCase(expr->op())) { | |
| 4436 if (expr->op() == Token::INC) { | |
| 4437 __ add(eax, Immediate(Smi::FromInt(1))); | |
| 4438 } else { | |
| 4439 __ sub(eax, Immediate(Smi::FromInt(1))); | |
| 4440 } | |
| 4441 __ j(overflow, &stub_call, Label::kNear); | |
| 4442 // We could eliminate this smi check if we split the code at | |
| 4443 // the first smi check before calling ToNumber. | |
| 4444 patch_site.EmitJumpIfSmi(eax, &done, Label::kNear); | |
| 4445 | |
| 4446 __ bind(&stub_call); | |
| 4447 // Call stub. Undo operation first. | |
| 4448 if (expr->op() == Token::INC) { | |
| 4449 __ sub(eax, Immediate(Smi::FromInt(1))); | |
| 4450 } else { | |
| 4451 __ add(eax, Immediate(Smi::FromInt(1))); | |
| 4452 } | |
| 4453 } | |
| 4454 | |
| 4455 // Record position before stub call. | 4465 // Record position before stub call. |
| 4456 SetSourcePosition(expr->position()); | 4466 SetSourcePosition(expr->position()); |
| 4457 | 4467 |
| 4458 // Call stub for +1/-1. | 4468 // Call stub for +1/-1. |
| 4469 __ bind(&stub_call); |
| 4459 __ mov(edx, eax); | 4470 __ mov(edx, eax); |
| 4460 __ mov(eax, Immediate(Smi::FromInt(1))); | 4471 __ mov(eax, Immediate(Smi::FromInt(1))); |
| 4461 BinaryOpStub stub(expr->binary_op(), NO_OVERWRITE); | 4472 BinaryOpStub stub(expr->binary_op(), NO_OVERWRITE); |
| 4462 CallIC(stub.GetCode(isolate()), | 4473 CallIC(stub.GetCode(isolate()), |
| 4463 RelocInfo::CODE_TARGET, | 4474 RelocInfo::CODE_TARGET, |
| 4464 expr->CountBinOpFeedbackId()); | 4475 expr->CountBinOpFeedbackId()); |
| 4465 patch_site.EmitPatchInfo(); | 4476 patch_site.EmitPatchInfo(); |
| 4466 __ bind(&done); | 4477 __ bind(&done); |
| 4467 | 4478 |
| 4468 // Store the value returned in eax. | 4479 // Store the value returned in eax. |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4957 | 4968 |
| 4958 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4969 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4959 Assembler::target_address_at(call_target_address)); | 4970 Assembler::target_address_at(call_target_address)); |
| 4960 return OSR_AFTER_STACK_CHECK; | 4971 return OSR_AFTER_STACK_CHECK; |
| 4961 } | 4972 } |
| 4962 | 4973 |
| 4963 | 4974 |
| 4964 } } // namespace v8::internal | 4975 } } // namespace v8::internal |
| 4965 | 4976 |
| 4966 #endif // V8_TARGET_ARCH_IA32 | 4977 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |