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