OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2813 // If the object is not a value type, return the object. | 2813 // If the object is not a value type, return the object. |
2814 __ CmpObjectType(rax, JS_VALUE_TYPE, rbx); | 2814 __ CmpObjectType(rax, JS_VALUE_TYPE, rbx); |
2815 __ j(not_equal, &done); | 2815 __ j(not_equal, &done); |
2816 __ movq(rax, FieldOperand(rax, JSValue::kValueOffset)); | 2816 __ movq(rax, FieldOperand(rax, JSValue::kValueOffset)); |
2817 | 2817 |
2818 __ bind(&done); | 2818 __ bind(&done); |
2819 context()->Plug(rax); | 2819 context()->Plug(rax); |
2820 } | 2820 } |
2821 | 2821 |
2822 | 2822 |
| 2823 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { |
| 2824 ZoneList<Expression*>* args = expr->arguments(); |
| 2825 ASSERT(args->length() == 2); |
| 2826 ASSERT_NE(NULL, args->at(1)->AsLiteral()); |
| 2827 int index = Smi::cast(*(args->at(1)->AsLiteral()->handle()))->value(); |
| 2828 |
| 2829 VisitForAccumulatorValue(args->at(0)); // Load the object. |
| 2830 |
| 2831 #ifdef DEBUG |
| 2832 __ AbortIfSmi(rax); |
| 2833 __ CmpObjectType(rax, JS_DATE_TYPE, rbx); |
| 2834 __ Assert(equal, "Trying to get date field from non-date."); |
| 2835 #endif |
| 2836 |
| 2837 __ movq(rax, FieldOperand(rax, JSDate::kValueOffset + kPointerSize * index)); |
| 2838 context()->Plug(rax); |
| 2839 } |
| 2840 |
| 2841 |
2823 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { | 2842 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { |
2824 // Load the arguments on the stack and call the runtime function. | 2843 // Load the arguments on the stack and call the runtime function. |
2825 ZoneList<Expression*>* args = expr->arguments(); | 2844 ZoneList<Expression*>* args = expr->arguments(); |
2826 ASSERT(args->length() == 2); | 2845 ASSERT(args->length() == 2); |
2827 VisitForStackValue(args->at(0)); | 2846 VisitForStackValue(args->at(0)); |
2828 VisitForStackValue(args->at(1)); | 2847 VisitForStackValue(args->at(1)); |
2829 MathPowStub stub(MathPowStub::ON_STACK); | 2848 MathPowStub stub(MathPowStub::ON_STACK); |
2830 __ CallStub(&stub); | 2849 __ CallStub(&stub); |
2831 context()->Plug(rax); | 2850 context()->Plug(rax); |
2832 } | 2851 } |
(...skipping 20 matching lines...) Expand all Loading... |
2853 // Update the write barrier. Save the value as it will be | 2872 // Update the write barrier. Save the value as it will be |
2854 // overwritten by the write barrier code and is needed afterward. | 2873 // overwritten by the write barrier code and is needed afterward. |
2855 __ movq(rdx, rax); | 2874 __ movq(rdx, rax); |
2856 __ RecordWriteField(rbx, JSValue::kValueOffset, rdx, rcx, kDontSaveFPRegs); | 2875 __ RecordWriteField(rbx, JSValue::kValueOffset, rdx, rcx, kDontSaveFPRegs); |
2857 | 2876 |
2858 __ bind(&done); | 2877 __ bind(&done); |
2859 context()->Plug(rax); | 2878 context()->Plug(rax); |
2860 } | 2879 } |
2861 | 2880 |
2862 | 2881 |
| 2882 void FullCodeGenerator::EmitSetDateField(CallRuntime* expr) { |
| 2883 ZoneList<Expression*>* args = expr->arguments(); |
| 2884 ASSERT(args->length() == 3); |
| 2885 ASSERT_NE(NULL, args->at(1)->AsLiteral()); |
| 2886 int index = Smi::cast(*(args->at(1)->AsLiteral()->handle()))->value(); |
| 2887 |
| 2888 VisitForStackValue(args->at(0)); // Load the object. |
| 2889 VisitForAccumulatorValue(args->at(2)); // Load the value. |
| 2890 __ pop(rbx); // rax = value. rbx = object. |
| 2891 |
| 2892 #ifdef DEBUG |
| 2893 __ AbortIfSmi(rbx); |
| 2894 __ CmpObjectType(rbx, JS_DATE_TYPE, rcx); |
| 2895 __ Assert(equal, "Trying to set date field on non-date."); |
| 2896 #endif |
| 2897 |
| 2898 // Store the value. |
| 2899 __ movq(FieldOperand(rbx, JSDate::kValueOffset + kPointerSize * index), rax); |
| 2900 // Caches can only be smi or NaN, so we can skip the write barrier for them. |
| 2901 if (index < JSDate::kFirstBarrierFree) { |
| 2902 // Update the write barrier. Save the value as it will be |
| 2903 // overwritten by the write barrier code and is needed afterward. |
| 2904 __ movq(rdx, rax); |
| 2905 __ RecordWriteField(rbx, JSDate::kValueOffset + kPointerSize * index, |
| 2906 rdx, rcx, kDontSaveFPRegs); |
| 2907 } |
| 2908 context()->Plug(rax); |
| 2909 } |
| 2910 |
| 2911 |
2863 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { | 2912 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { |
2864 ZoneList<Expression*>* args = expr->arguments(); | 2913 ZoneList<Expression*>* args = expr->arguments(); |
2865 ASSERT_EQ(args->length(), 1); | 2914 ASSERT_EQ(args->length(), 1); |
2866 | 2915 |
2867 // Load the argument on the stack and call the stub. | 2916 // Load the argument on the stack and call the stub. |
2868 VisitForStackValue(args->at(0)); | 2917 VisitForStackValue(args->at(0)); |
2869 | 2918 |
2870 NumberToStringStub stub; | 2919 NumberToStringStub stub; |
2871 __ CallStub(&stub); | 2920 __ CallStub(&stub); |
2872 context()->Plug(rax); | 2921 context()->Plug(rax); |
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4352 *context_length = 0; | 4401 *context_length = 0; |
4353 return previous_; | 4402 return previous_; |
4354 } | 4403 } |
4355 | 4404 |
4356 | 4405 |
4357 #undef __ | 4406 #undef __ |
4358 | 4407 |
4359 } } // namespace v8::internal | 4408 } } // namespace v8::internal |
4360 | 4409 |
4361 #endif // V8_TARGET_ARCH_X64 | 4410 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |