OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 } | 1567 } |
1568 | 1568 |
1569 | 1569 |
1570 void LCodeGen::DoMapEnumLength(LMapEnumLength* instr) { | 1570 void LCodeGen::DoMapEnumLength(LMapEnumLength* instr) { |
1571 Register result = ToRegister(instr->result()); | 1571 Register result = ToRegister(instr->result()); |
1572 Register map = ToRegister(instr->value()); | 1572 Register map = ToRegister(instr->value()); |
1573 __ EnumLength(result, map); | 1573 __ EnumLength(result, map); |
1574 } | 1574 } |
1575 | 1575 |
1576 | 1576 |
1577 void LCodeGen::DoElementsKind(LElementsKind* instr) { | |
1578 Register result = ToRegister(instr->result()); | |
1579 Register input = ToRegister(instr->value()); | |
1580 | |
1581 // Load map into |result|. | |
1582 __ movp(result, FieldOperand(input, HeapObject::kMapOffset)); | |
1583 // Load the map's "bit field 2" into |result|. We only need the first byte. | |
1584 __ movzxbq(result, FieldOperand(result, Map::kBitField2Offset)); | |
1585 // Retrieve elements_kind from bit field 2. | |
1586 __ and_(result, Immediate(Map::kElementsKindMask)); | |
1587 __ shr(result, Immediate(Map::kElementsKindShift)); | |
1588 } | |
1589 | |
1590 | |
1591 void LCodeGen::DoValueOf(LValueOf* instr) { | |
1592 Register input = ToRegister(instr->value()); | |
1593 Register result = ToRegister(instr->result()); | |
1594 ASSERT(input.is(result)); | |
1595 Label done; | |
1596 | |
1597 if (!instr->hydrogen()->value()->IsHeapObject()) { | |
1598 // If the object is a smi return the object. | |
1599 __ JumpIfSmi(input, &done, Label::kNear); | |
1600 } | |
1601 | |
1602 // If the object is not a value type, return the object. | |
1603 __ CmpObjectType(input, JS_VALUE_TYPE, kScratchRegister); | |
1604 __ j(not_equal, &done, Label::kNear); | |
1605 __ movp(result, FieldOperand(input, JSValue::kValueOffset)); | |
1606 | |
1607 __ bind(&done); | |
1608 } | |
1609 | |
1610 | |
1611 void LCodeGen::DoDateField(LDateField* instr) { | 1577 void LCodeGen::DoDateField(LDateField* instr) { |
1612 Register object = ToRegister(instr->date()); | 1578 Register object = ToRegister(instr->date()); |
1613 Register result = ToRegister(instr->result()); | 1579 Register result = ToRegister(instr->result()); |
1614 Smi* index = instr->index(); | 1580 Smi* index = instr->index(); |
1615 Label runtime, done, not_date_object; | 1581 Label runtime, done, not_date_object; |
1616 ASSERT(object.is(result)); | 1582 ASSERT(object.is(result)); |
1617 ASSERT(object.is(rax)); | 1583 ASSERT(object.is(rax)); |
1618 | 1584 |
1619 Condition cc = masm()->CheckSmi(object); | 1585 Condition cc = masm()->CheckSmi(object); |
1620 DeoptimizeIf(cc, instr->environment()); | 1586 DeoptimizeIf(cc, instr->environment()); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1721 Register value = ToRegister(instr->value()); | 1687 Register value = ToRegister(instr->value()); |
1722 if (encoding == String::ONE_BYTE_ENCODING) { | 1688 if (encoding == String::ONE_BYTE_ENCODING) { |
1723 __ movb(operand, value); | 1689 __ movb(operand, value); |
1724 } else { | 1690 } else { |
1725 __ movw(operand, value); | 1691 __ movw(operand, value); |
1726 } | 1692 } |
1727 } | 1693 } |
1728 } | 1694 } |
1729 | 1695 |
1730 | 1696 |
1731 void LCodeGen::DoThrow(LThrow* instr) { | |
1732 __ push(ToRegister(instr->value())); | |
1733 ASSERT(ToRegister(instr->context()).is(rsi)); | |
1734 CallRuntime(Runtime::kThrow, 1, instr); | |
1735 | |
1736 if (FLAG_debug_code) { | |
1737 Comment("Unreachable code."); | |
1738 __ int3(); | |
1739 } | |
1740 } | |
1741 | |
1742 | |
1743 void LCodeGen::DoAddI(LAddI* instr) { | 1697 void LCodeGen::DoAddI(LAddI* instr) { |
1744 LOperand* left = instr->left(); | 1698 LOperand* left = instr->left(); |
1745 LOperand* right = instr->right(); | 1699 LOperand* right = instr->right(); |
1746 | 1700 |
1747 Representation target_rep = instr->hydrogen()->representation(); | 1701 Representation target_rep = instr->hydrogen()->representation(); |
1748 bool is_q = target_rep.IsSmi() || target_rep.IsExternal(); | 1702 bool is_q = target_rep.IsSmi() || target_rep.IsExternal(); |
1749 | 1703 |
1750 if (LAddI::UseLea(instr->hydrogen()) && !left->Equals(instr->result())) { | 1704 if (LAddI::UseLea(instr->hydrogen()) && !left->Equals(instr->result())) { |
1751 if (right->IsConstantOperand()) { | 1705 if (right->IsConstantOperand()) { |
1752 int32_t offset = ToInteger32(LConstantOperand::cast(right)); | 1706 int32_t offset = ToInteger32(LConstantOperand::cast(right)); |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2803 ASSERT(result.is(rax)); | 2757 ASSERT(result.is(rax)); |
2804 __ load_rax(ToExternalReference(LConstantOperand::cast(instr->object()))); | 2758 __ load_rax(ToExternalReference(LConstantOperand::cast(instr->object()))); |
2805 } else { | 2759 } else { |
2806 Register object = ToRegister(instr->object()); | 2760 Register object = ToRegister(instr->object()); |
2807 __ Load(result, MemOperand(object, offset), access.representation()); | 2761 __ Load(result, MemOperand(object, offset), access.representation()); |
2808 } | 2762 } |
2809 return; | 2763 return; |
2810 } | 2764 } |
2811 | 2765 |
2812 Register object = ToRegister(instr->object()); | 2766 Register object = ToRegister(instr->object()); |
2813 if (FLAG_track_double_fields && | 2767 if (instr->hydrogen()->representation().IsDouble()) { |
2814 instr->hydrogen()->representation().IsDouble()) { | |
2815 XMMRegister result = ToDoubleRegister(instr->result()); | 2768 XMMRegister result = ToDoubleRegister(instr->result()); |
2816 __ movsd(result, FieldOperand(object, offset)); | 2769 __ movsd(result, FieldOperand(object, offset)); |
2817 return; | 2770 return; |
2818 } | 2771 } |
2819 | 2772 |
2820 Register result = ToRegister(instr->result()); | 2773 Register result = ToRegister(instr->result()); |
2821 if (!access.IsInobject()) { | 2774 if (!access.IsInobject()) { |
2822 __ movp(result, FieldOperand(object, JSObject::kPropertiesOffset)); | 2775 __ movp(result, FieldOperand(object, JSObject::kPropertiesOffset)); |
2823 object = result; | 2776 object = result; |
2824 } | 2777 } |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3201 void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { | 3154 void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { |
3202 Register receiver = ToRegister(instr->receiver()); | 3155 Register receiver = ToRegister(instr->receiver()); |
3203 Register function = ToRegister(instr->function()); | 3156 Register function = ToRegister(instr->function()); |
3204 | 3157 |
3205 // If the receiver is null or undefined, we have to pass the global | 3158 // If the receiver is null or undefined, we have to pass the global |
3206 // object as a receiver to normal functions. Values have to be | 3159 // object as a receiver to normal functions. Values have to be |
3207 // passed unchanged to builtins and strict-mode functions. | 3160 // passed unchanged to builtins and strict-mode functions. |
3208 Label global_object, receiver_ok; | 3161 Label global_object, receiver_ok; |
3209 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; | 3162 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; |
3210 | 3163 |
3211 // Do not transform the receiver to object for strict mode | 3164 if (!instr->hydrogen()->known_function()) { |
3212 // functions. | 3165 // Do not transform the receiver to object for strict mode |
3213 __ movp(kScratchRegister, | 3166 // functions. |
3214 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); | 3167 __ movp(kScratchRegister, |
3215 __ testb(FieldOperand(kScratchRegister, | 3168 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); |
3216 SharedFunctionInfo::kStrictModeByteOffset), | 3169 __ testb(FieldOperand(kScratchRegister, |
3217 Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte)); | 3170 SharedFunctionInfo::kStrictModeByteOffset), |
3218 __ j(not_equal, &receiver_ok, dist); | 3171 Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte)); |
| 3172 __ j(not_equal, &receiver_ok, dist); |
3219 | 3173 |
3220 // Do not transform the receiver to object for builtins. | 3174 // Do not transform the receiver to object for builtins. |
3221 __ testb(FieldOperand(kScratchRegister, | 3175 __ testb(FieldOperand(kScratchRegister, |
3222 SharedFunctionInfo::kNativeByteOffset), | 3176 SharedFunctionInfo::kNativeByteOffset), |
3223 Immediate(1 << SharedFunctionInfo::kNativeBitWithinByte)); | 3177 Immediate(1 << SharedFunctionInfo::kNativeBitWithinByte)); |
3224 __ j(not_equal, &receiver_ok, dist); | 3178 __ j(not_equal, &receiver_ok, dist); |
| 3179 } |
3225 | 3180 |
3226 // Normal function. Replace undefined or null with global receiver. | 3181 // Normal function. Replace undefined or null with global receiver. |
3227 __ CompareRoot(receiver, Heap::kNullValueRootIndex); | 3182 __ CompareRoot(receiver, Heap::kNullValueRootIndex); |
3228 __ j(equal, &global_object, Label::kNear); | 3183 __ j(equal, &global_object, Label::kNear); |
3229 __ CompareRoot(receiver, Heap::kUndefinedValueRootIndex); | 3184 __ CompareRoot(receiver, Heap::kUndefinedValueRootIndex); |
3230 __ j(equal, &global_object, Label::kNear); | 3185 __ j(equal, &global_object, Label::kNear); |
3231 | 3186 |
3232 // The receiver should be a JS object. | 3187 // The receiver should be a JS object. |
3233 Condition is_smi = __ CheckSmi(receiver); | 3188 Condition is_smi = __ CheckSmi(receiver); |
3234 DeoptimizeIf(is_smi, instr->environment()); | 3189 DeoptimizeIf(is_smi, instr->environment()); |
3235 __ CmpObjectType(receiver, FIRST_SPEC_OBJECT_TYPE, kScratchRegister); | 3190 __ CmpObjectType(receiver, FIRST_SPEC_OBJECT_TYPE, kScratchRegister); |
3236 DeoptimizeIf(below, instr->environment()); | 3191 DeoptimizeIf(below, instr->environment()); |
| 3192 |
3237 __ jmp(&receiver_ok, Label::kNear); | 3193 __ jmp(&receiver_ok, Label::kNear); |
3238 | |
3239 __ bind(&global_object); | 3194 __ bind(&global_object); |
3240 __ movp(receiver, FieldOperand(function, JSFunction::kContextOffset)); | 3195 __ movp(receiver, FieldOperand(function, JSFunction::kContextOffset)); |
3241 __ movp(receiver, | 3196 __ movp(receiver, |
3242 Operand(receiver, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 3197 Operand(receiver, |
| 3198 Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
3243 __ movp(receiver, | 3199 __ movp(receiver, |
3244 FieldOperand(receiver, GlobalObject::kGlobalReceiverOffset)); | 3200 FieldOperand(receiver, GlobalObject::kGlobalReceiverOffset)); |
| 3201 |
3245 __ bind(&receiver_ok); | 3202 __ bind(&receiver_ok); |
3246 } | 3203 } |
3247 | 3204 |
3248 | 3205 |
3249 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { | 3206 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { |
3250 Register receiver = ToRegister(instr->receiver()); | 3207 Register receiver = ToRegister(instr->receiver()); |
3251 Register function = ToRegister(instr->function()); | 3208 Register function = ToRegister(instr->function()); |
3252 Register length = ToRegister(instr->length()); | 3209 Register length = ToRegister(instr->length()); |
3253 Register elements = ToRegister(instr->elements()); | 3210 Register elements = ToRegister(instr->elements()); |
3254 ASSERT(receiver.is(rax)); // Used for parameter count. | 3211 ASSERT(receiver.is(rax)); // Used for parameter count. |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3790 } | 3747 } |
3791 } | 3748 } |
3792 | 3749 |
3793 | 3750 |
3794 void LCodeGen::DoCallFunction(LCallFunction* instr) { | 3751 void LCodeGen::DoCallFunction(LCallFunction* instr) { |
3795 ASSERT(ToRegister(instr->context()).is(rsi)); | 3752 ASSERT(ToRegister(instr->context()).is(rsi)); |
3796 ASSERT(ToRegister(instr->function()).is(rdi)); | 3753 ASSERT(ToRegister(instr->function()).is(rdi)); |
3797 ASSERT(ToRegister(instr->result()).is(rax)); | 3754 ASSERT(ToRegister(instr->result()).is(rax)); |
3798 | 3755 |
3799 int arity = instr->arity(); | 3756 int arity = instr->arity(); |
3800 CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS); | 3757 CallFunctionStub stub(arity, instr->hydrogen()->function_flags()); |
3801 if (instr->hydrogen()->IsTailCall()) { | 3758 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
3802 if (NeedsEagerFrame()) __ leave(); | |
3803 __ jmp(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); | |
3804 } else { | |
3805 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | |
3806 } | |
3807 } | 3759 } |
3808 | 3760 |
3809 | 3761 |
3810 void LCodeGen::DoCallNew(LCallNew* instr) { | 3762 void LCodeGen::DoCallNew(LCallNew* instr) { |
3811 ASSERT(ToRegister(instr->context()).is(rsi)); | 3763 ASSERT(ToRegister(instr->context()).is(rsi)); |
3812 ASSERT(ToRegister(instr->constructor()).is(rdi)); | 3764 ASSERT(ToRegister(instr->constructor()).is(rdi)); |
3813 ASSERT(ToRegister(instr->result()).is(rax)); | 3765 ASSERT(ToRegister(instr->result()).is(rax)); |
3814 | 3766 |
3815 __ Set(rax, instr->arity()); | 3767 __ Set(rax, instr->arity()); |
3816 // No cell in ebx for construct type feedback in optimized code | 3768 // No cell in ebx for construct type feedback in optimized code |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3930 if (IsInteger32Constant(operand_value)) { | 3882 if (IsInteger32Constant(operand_value)) { |
3931 DeoptimizeIf(no_condition, instr->environment()); | 3883 DeoptimizeIf(no_condition, instr->environment()); |
3932 } | 3884 } |
3933 } else { | 3885 } else { |
3934 if (!hinstr->value()->type().IsHeapObject()) { | 3886 if (!hinstr->value()->type().IsHeapObject()) { |
3935 Register value = ToRegister(instr->value()); | 3887 Register value = ToRegister(instr->value()); |
3936 Condition cc = masm()->CheckSmi(value); | 3888 Condition cc = masm()->CheckSmi(value); |
3937 DeoptimizeIf(cc, instr->environment()); | 3889 DeoptimizeIf(cc, instr->environment()); |
3938 } | 3890 } |
3939 } | 3891 } |
3940 } else if (FLAG_track_double_fields && representation.IsDouble()) { | 3892 } else if (representation.IsDouble()) { |
3941 ASSERT(transition.is_null()); | 3893 ASSERT(transition.is_null()); |
3942 ASSERT(access.IsInobject()); | 3894 ASSERT(access.IsInobject()); |
3943 ASSERT(!hinstr->NeedsWriteBarrier()); | 3895 ASSERT(!hinstr->NeedsWriteBarrier()); |
3944 XMMRegister value = ToDoubleRegister(instr->value()); | 3896 XMMRegister value = ToDoubleRegister(instr->value()); |
3945 __ movsd(FieldOperand(object, offset), value); | 3897 __ movsd(FieldOperand(object, offset), value); |
3946 return; | 3898 return; |
3947 } | 3899 } |
3948 | 3900 |
3949 if (!transition.is_null()) { | 3901 if (!transition.is_null()) { |
3950 if (!hinstr->NeedsWriteBarrierForMap()) { | 3902 if (!hinstr->NeedsWriteBarrierForMap()) { |
(...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5593 FixedArray::kHeaderSize - kPointerSize)); | 5545 FixedArray::kHeaderSize - kPointerSize)); |
5594 __ bind(&done); | 5546 __ bind(&done); |
5595 } | 5547 } |
5596 | 5548 |
5597 | 5549 |
5598 #undef __ | 5550 #undef __ |
5599 | 5551 |
5600 } } // namespace v8::internal | 5552 } } // namespace v8::internal |
5601 | 5553 |
5602 #endif // V8_TARGET_ARCH_X64 | 5554 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |