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 2857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2868 // If the object is not a value type, return the object. | 2868 // If the object is not a value type, return the object. |
2869 __ CmpObjectType(eax, JS_VALUE_TYPE, ebx); | 2869 __ CmpObjectType(eax, JS_VALUE_TYPE, ebx); |
2870 __ j(not_equal, &done, Label::kNear); | 2870 __ j(not_equal, &done, Label::kNear); |
2871 __ mov(eax, FieldOperand(eax, JSValue::kValueOffset)); | 2871 __ mov(eax, FieldOperand(eax, JSValue::kValueOffset)); |
2872 | 2872 |
2873 __ bind(&done); | 2873 __ bind(&done); |
2874 context()->Plug(eax); | 2874 context()->Plug(eax); |
2875 } | 2875 } |
2876 | 2876 |
2877 | 2877 |
| 2878 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { |
| 2879 ZoneList<Expression*>* args = expr->arguments(); |
| 2880 ASSERT(args->length() == 2); |
| 2881 ASSERT_NE(NULL, args->at(1)->AsLiteral()); |
| 2882 int index = Smi::cast(*(args->at(1)->AsLiteral()->handle()))->value(); |
| 2883 |
| 2884 VisitForAccumulatorValue(args->at(0)); // Load the object. |
| 2885 |
| 2886 #ifdef DEBUG |
| 2887 __ AbortIfSmi(eax); |
| 2888 __ CmpObjectType(eax, JS_DATE_TYPE, ebx); |
| 2889 __ Assert(equal, "Trying to get date field from non-date."); |
| 2890 #endif |
| 2891 |
| 2892 __ mov(eax, FieldOperand(eax, JSDate::kValueOffset + kPointerSize * index)); |
| 2893 context()->Plug(eax); |
| 2894 } |
| 2895 |
| 2896 |
2878 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { | 2897 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { |
2879 // Load the arguments on the stack and call the runtime function. | 2898 // Load the arguments on the stack and call the runtime function. |
2880 ZoneList<Expression*>* args = expr->arguments(); | 2899 ZoneList<Expression*>* args = expr->arguments(); |
2881 ASSERT(args->length() == 2); | 2900 ASSERT(args->length() == 2); |
2882 VisitForStackValue(args->at(0)); | 2901 VisitForStackValue(args->at(0)); |
2883 VisitForStackValue(args->at(1)); | 2902 VisitForStackValue(args->at(1)); |
2884 | 2903 |
2885 if (CpuFeatures::IsSupported(SSE2)) { | 2904 if (CpuFeatures::IsSupported(SSE2)) { |
2886 MathPowStub stub(MathPowStub::ON_STACK); | 2905 MathPowStub stub(MathPowStub::ON_STACK); |
2887 __ CallStub(&stub); | 2906 __ CallStub(&stub); |
(...skipping 26 matching lines...) Expand all Loading... |
2914 // Update the write barrier. Save the value as it will be | 2933 // Update the write barrier. Save the value as it will be |
2915 // overwritten by the write barrier code and is needed afterward. | 2934 // overwritten by the write barrier code and is needed afterward. |
2916 __ mov(edx, eax); | 2935 __ mov(edx, eax); |
2917 __ RecordWriteField(ebx, JSValue::kValueOffset, edx, ecx, kDontSaveFPRegs); | 2936 __ RecordWriteField(ebx, JSValue::kValueOffset, edx, ecx, kDontSaveFPRegs); |
2918 | 2937 |
2919 __ bind(&done); | 2938 __ bind(&done); |
2920 context()->Plug(eax); | 2939 context()->Plug(eax); |
2921 } | 2940 } |
2922 | 2941 |
2923 | 2942 |
| 2943 void FullCodeGenerator::EmitSetDateField(CallRuntime* expr) { |
| 2944 ZoneList<Expression*>* args = expr->arguments(); |
| 2945 ASSERT(args->length() == 3); |
| 2946 ASSERT_NE(NULL, args->at(1)->AsLiteral()); |
| 2947 int index = Smi::cast(*(args->at(1)->AsLiteral()->handle()))->value(); |
| 2948 |
| 2949 VisitForStackValue(args->at(0)); // Load the object. |
| 2950 VisitForAccumulatorValue(args->at(2)); // Load the value. |
| 2951 __ pop(ebx); // eax = value. ebx = object. |
| 2952 |
| 2953 #ifdef DEBUG |
| 2954 __ AbortIfSmi(ebx); |
| 2955 __ CmpObjectType(ebx, JS_DATE_TYPE, ecx); |
| 2956 __ Assert(equal, "Trying to set date field on non-date."); |
| 2957 #endif |
| 2958 |
| 2959 // Store the value. |
| 2960 __ mov(FieldOperand(ebx, JSDate::kValueOffset + kPointerSize * index), eax); |
| 2961 // Caches can only be smi or NaN, so we can skip the write barrier for them. |
| 2962 if (index < JSDate::kFirstBarrierFree) { |
| 2963 // Update the write barrier. Save the value as it will be |
| 2964 // overwritten by the write barrier code and is needed afterward. |
| 2965 __ mov(edx, eax); |
| 2966 __ RecordWriteField(ebx, JSDate::kValueOffset + kPointerSize * index, |
| 2967 edx, ecx, kDontSaveFPRegs); |
| 2968 } |
| 2969 context()->Plug(eax); |
| 2970 } |
| 2971 |
| 2972 |
2924 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { | 2973 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { |
2925 ZoneList<Expression*>* args = expr->arguments(); | 2974 ZoneList<Expression*>* args = expr->arguments(); |
2926 ASSERT_EQ(args->length(), 1); | 2975 ASSERT_EQ(args->length(), 1); |
2927 | 2976 |
2928 // Load the argument on the stack and call the stub. | 2977 // Load the argument on the stack and call the stub. |
2929 VisitForStackValue(args->at(0)); | 2978 VisitForStackValue(args->at(0)); |
2930 | 2979 |
2931 NumberToStringStub stub; | 2980 NumberToStringStub stub; |
2932 __ CallStub(&stub); | 2981 __ CallStub(&stub); |
2933 context()->Plug(eax); | 2982 context()->Plug(eax); |
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4380 *context_length = 0; | 4429 *context_length = 0; |
4381 return previous_; | 4430 return previous_; |
4382 } | 4431 } |
4383 | 4432 |
4384 | 4433 |
4385 #undef __ | 4434 #undef __ |
4386 | 4435 |
4387 } } // namespace v8::internal | 4436 } } // namespace v8::internal |
4388 | 4437 |
4389 #endif // V8_TARGET_ARCH_IA32 | 4438 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |