Chromium Code Reviews| 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 Label done; | |
| 2887 // If the object is a smi return the object. | |
| 2888 __ JumpIfSmi(eax, &done, Label::kNear); | |
|
ulan
2012/01/25 13:08:48
As discussed offline, it's better to crash if Date
rossberg
2012/01/25 15:48:37
I removed all (non-debug-mode) type checks, and ch
| |
| 2889 // If the object is not a date type, return the object. | |
| 2890 __ CmpObjectType(eax, JS_DATE_TYPE, ebx); | |
| 2891 __ j(not_equal, &done, Label::kNear); | |
| 2892 __ mov(eax, FieldOperand(eax, JSDate::kYearOffset + kPointerSize * index)); | |
| 2893 | |
| 2894 __ bind(&done); | |
| 2895 context()->Plug(eax); | |
| 2896 } | |
| 2897 | |
| 2898 | |
| 2878 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { | 2899 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { |
| 2879 // Load the arguments on the stack and call the runtime function. | 2900 // Load the arguments on the stack and call the runtime function. |
| 2880 ZoneList<Expression*>* args = expr->arguments(); | 2901 ZoneList<Expression*>* args = expr->arguments(); |
| 2881 ASSERT(args->length() == 2); | 2902 ASSERT(args->length() == 2); |
| 2882 VisitForStackValue(args->at(0)); | 2903 VisitForStackValue(args->at(0)); |
| 2883 VisitForStackValue(args->at(1)); | 2904 VisitForStackValue(args->at(1)); |
| 2884 | 2905 |
| 2885 if (CpuFeatures::IsSupported(SSE2)) { | 2906 if (CpuFeatures::IsSupported(SSE2)) { |
| 2886 MathPowStub stub(MathPowStub::ON_STACK); | 2907 MathPowStub stub(MathPowStub::ON_STACK); |
| 2887 __ CallStub(&stub); | 2908 __ CallStub(&stub); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 2914 // Update the write barrier. Save the value as it will be | 2935 // Update the write barrier. Save the value as it will be |
| 2915 // overwritten by the write barrier code and is needed afterward. | 2936 // overwritten by the write barrier code and is needed afterward. |
| 2916 __ mov(edx, eax); | 2937 __ mov(edx, eax); |
| 2917 __ RecordWriteField(ebx, JSValue::kValueOffset, edx, ecx, kDontSaveFPRegs); | 2938 __ RecordWriteField(ebx, JSValue::kValueOffset, edx, ecx, kDontSaveFPRegs); |
| 2918 | 2939 |
| 2919 __ bind(&done); | 2940 __ bind(&done); |
| 2920 context()->Plug(eax); | 2941 context()->Plug(eax); |
| 2921 } | 2942 } |
| 2922 | 2943 |
| 2923 | 2944 |
| 2945 void FullCodeGenerator::EmitSetDateField(CallRuntime* expr) { | |
| 2946 ZoneList<Expression*>* args = expr->arguments(); | |
| 2947 ASSERT(args->length() == 3); | |
| 2948 ASSERT_NE(NULL, args->at(1)->AsLiteral()); | |
| 2949 int index = Smi::cast(*(args->at(1)->AsLiteral()->handle()))->value(); | |
| 2950 | |
| 2951 VisitForStackValue(args->at(0)); // Load the object. | |
|
ulan
2012/01/25 13:08:48
Is it possible/faster to do
VisitForAccumulatorVa
rossberg
2012/01/25 15:48:37
No, the second Visit can clobber any register. Kee
| |
| 2952 VisitForAccumulatorValue(args->at(2)); // Load the value. | |
| 2953 __ pop(ebx); // eax = value. ebx = object. | |
| 2954 | |
| 2955 Label done; | |
| 2956 // If the object is a smi, return the value. | |
| 2957 __ JumpIfSmi(ebx, &done, Label::kNear); | |
|
ulan
2012/01/25 13:08:48
As discussed offline, it's better to crash if Date
rossberg
2012/01/25 15:48:37
Done.
| |
| 2958 | |
| 2959 // If the object is not a value type, return the value. | |
| 2960 __ CmpObjectType(ebx, JS_DATE_TYPE, ecx); | |
| 2961 __ j(not_equal, &done, Label::kNear); | |
| 2962 | |
| 2963 // Store the value. | |
| 2964 __ mov(FieldOperand(ebx, JSDate::kYearOffset + kPointerSize * index), eax); | |
| 2965 | |
| 2966 // Update the write barrier. Save the value as it will be | |
| 2967 // overwritten by the write barrier code and is needed afterward. | |
| 2968 __ mov(edx, eax); | |
| 2969 __ RecordWriteField(ebx, JSDate::kYearOffset + kPointerSize * index, | |
|
ulan
2012/01/25 13:08:48
Can we avoid the write barrier by making sure that
rossberg
2012/01/25 15:48:37
Done.
| |
| 2970 edx, ecx, kDontSaveFPRegs); | |
| 2971 | |
| 2972 __ bind(&done); | |
| 2973 context()->Plug(eax); | |
| 2974 } | |
| 2975 | |
| 2976 | |
| 2924 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { | 2977 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { |
| 2925 ZoneList<Expression*>* args = expr->arguments(); | 2978 ZoneList<Expression*>* args = expr->arguments(); |
| 2926 ASSERT_EQ(args->length(), 1); | 2979 ASSERT_EQ(args->length(), 1); |
| 2927 | 2980 |
| 2928 // Load the argument on the stack and call the stub. | 2981 // Load the argument on the stack and call the stub. |
| 2929 VisitForStackValue(args->at(0)); | 2982 VisitForStackValue(args->at(0)); |
| 2930 | 2983 |
| 2931 NumberToStringStub stub; | 2984 NumberToStringStub stub; |
| 2932 __ CallStub(&stub); | 2985 __ CallStub(&stub); |
| 2933 context()->Plug(eax); | 2986 context()->Plug(eax); |
| (...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4380 *context_length = 0; | 4433 *context_length = 0; |
| 4381 return previous_; | 4434 return previous_; |
| 4382 } | 4435 } |
| 4383 | 4436 |
| 4384 | 4437 |
| 4385 #undef __ | 4438 #undef __ |
| 4386 | 4439 |
| 4387 } } // namespace v8::internal | 4440 } } // namespace v8::internal |
| 4388 | 4441 |
| 4389 #endif // V8_TARGET_ARCH_IA32 | 4442 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |