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 2947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2958 | 2958 |
2959 __ bind(&done); | 2959 __ bind(&done); |
2960 context()->Plug(eax); | 2960 context()->Plug(eax); |
2961 } | 2961 } |
2962 | 2962 |
2963 | 2963 |
2964 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { | 2964 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { |
2965 ZoneList<Expression*>* args = expr->arguments(); | 2965 ZoneList<Expression*>* args = expr->arguments(); |
2966 ASSERT(args->length() == 2); | 2966 ASSERT(args->length() == 2); |
2967 ASSERT_NE(NULL, args->at(1)->AsLiteral()); | 2967 ASSERT_NE(NULL, args->at(1)->AsLiteral()); |
2968 int index = Smi::cast(*(args->at(1)->AsLiteral()->handle()))->value(); | 2968 Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->handle())); |
2969 | 2969 |
2970 VisitForAccumulatorValue(args->at(0)); // Load the object. | 2970 VisitForAccumulatorValue(args->at(0)); // Load the object. |
2971 | 2971 |
| 2972 Label runtime, done; |
| 2973 Register object = eax; |
| 2974 Register result = eax; |
| 2975 Register scratch = ecx; |
| 2976 |
2972 #ifdef DEBUG | 2977 #ifdef DEBUG |
2973 __ AbortIfSmi(eax); | 2978 __ AbortIfSmi(object); |
2974 __ CmpObjectType(eax, JS_DATE_TYPE, ebx); | 2979 __ CmpObjectType(object, JS_DATE_TYPE, scratch); |
2975 __ Assert(equal, "Trying to get date field from non-date."); | 2980 __ Assert(equal, "Trying to get date field from non-date."); |
2976 #endif | 2981 #endif |
2977 | 2982 |
2978 __ mov(eax, FieldOperand(eax, JSDate::kValueOffset + kPointerSize * index)); | 2983 if (index->value() == 0) { |
2979 context()->Plug(eax); | 2984 __ mov(result, FieldOperand(object, JSDate::kValueOffset)); |
| 2985 } else { |
| 2986 if (index->value() < JSDate::kFirstUncachedField) { |
| 2987 ExternalReference stamp = ExternalReference::date_cache_stamp(isolate()); |
| 2988 __ mov(scratch, Operand::StaticVariable(stamp)); |
| 2989 __ cmp(scratch, FieldOperand(object, JSDate::kCacheStampOffset)); |
| 2990 __ j(not_equal, &runtime, Label::kNear); |
| 2991 __ mov(result, FieldOperand(object, JSDate::kValueOffset + |
| 2992 kPointerSize * index->value())); |
| 2993 __ jmp(&done); |
| 2994 } |
| 2995 __ bind(&runtime); |
| 2996 __ PrepareCallCFunction(2, scratch); |
| 2997 __ mov(Operand(esp, 0), object); |
| 2998 __ mov(Operand(esp, 1 * kPointerSize), Immediate(index)); |
| 2999 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); |
| 3000 __ bind(&done); |
| 3001 } |
| 3002 context()->Plug(result); |
2980 } | 3003 } |
2981 | 3004 |
2982 | 3005 |
2983 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { | 3006 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { |
2984 // Load the arguments on the stack and call the runtime function. | 3007 // Load the arguments on the stack and call the runtime function. |
2985 ZoneList<Expression*>* args = expr->arguments(); | 3008 ZoneList<Expression*>* args = expr->arguments(); |
2986 ASSERT(args->length() == 2); | 3009 ASSERT(args->length() == 2); |
2987 VisitForStackValue(args->at(0)); | 3010 VisitForStackValue(args->at(0)); |
2988 VisitForStackValue(args->at(1)); | 3011 VisitForStackValue(args->at(1)); |
2989 | 3012 |
(...skipping 29 matching lines...) Expand all Loading... |
3019 // Update the write barrier. Save the value as it will be | 3042 // Update the write barrier. Save the value as it will be |
3020 // overwritten by the write barrier code and is needed afterward. | 3043 // overwritten by the write barrier code and is needed afterward. |
3021 __ mov(edx, eax); | 3044 __ mov(edx, eax); |
3022 __ RecordWriteField(ebx, JSValue::kValueOffset, edx, ecx, kDontSaveFPRegs); | 3045 __ RecordWriteField(ebx, JSValue::kValueOffset, edx, ecx, kDontSaveFPRegs); |
3023 | 3046 |
3024 __ bind(&done); | 3047 __ bind(&done); |
3025 context()->Plug(eax); | 3048 context()->Plug(eax); |
3026 } | 3049 } |
3027 | 3050 |
3028 | 3051 |
3029 void FullCodeGenerator::EmitSetDateField(CallRuntime* expr) { | |
3030 ZoneList<Expression*>* args = expr->arguments(); | |
3031 ASSERT(args->length() == 3); | |
3032 ASSERT_NE(NULL, args->at(1)->AsLiteral()); | |
3033 int index = Smi::cast(*(args->at(1)->AsLiteral()->handle()))->value(); | |
3034 | |
3035 VisitForStackValue(args->at(0)); // Load the object. | |
3036 VisitForAccumulatorValue(args->at(2)); // Load the value. | |
3037 __ pop(ebx); // eax = value. ebx = object. | |
3038 | |
3039 #ifdef DEBUG | |
3040 __ AbortIfSmi(ebx); | |
3041 __ CmpObjectType(ebx, JS_DATE_TYPE, ecx); | |
3042 __ Assert(equal, "Trying to set date field on non-date."); | |
3043 #endif | |
3044 | |
3045 // Store the value. | |
3046 __ mov(FieldOperand(ebx, JSDate::kValueOffset + kPointerSize * index), eax); | |
3047 // Caches can only be smi or NaN, so we can skip the write barrier for them. | |
3048 if (index < JSDate::kFirstBarrierFree) { | |
3049 // Update the write barrier. Save the value as it will be | |
3050 // overwritten by the write barrier code and is needed afterward. | |
3051 __ mov(edx, eax); | |
3052 __ RecordWriteField(ebx, JSDate::kValueOffset + kPointerSize * index, | |
3053 edx, ecx, kDontSaveFPRegs); | |
3054 } | |
3055 context()->Plug(eax); | |
3056 } | |
3057 | |
3058 | |
3059 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { | 3052 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { |
3060 ZoneList<Expression*>* args = expr->arguments(); | 3053 ZoneList<Expression*>* args = expr->arguments(); |
3061 ASSERT_EQ(args->length(), 1); | 3054 ASSERT_EQ(args->length(), 1); |
3062 | 3055 |
3063 // Load the argument on the stack and call the stub. | 3056 // Load the argument on the stack and call the stub. |
3064 VisitForStackValue(args->at(0)); | 3057 VisitForStackValue(args->at(0)); |
3065 | 3058 |
3066 NumberToStringStub stub; | 3059 NumberToStringStub stub; |
3067 __ CallStub(&stub); | 3060 __ CallStub(&stub); |
3068 context()->Plug(eax); | 3061 context()->Plug(eax); |
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4515 *context_length = 0; | 4508 *context_length = 0; |
4516 return previous_; | 4509 return previous_; |
4517 } | 4510 } |
4518 | 4511 |
4519 | 4512 |
4520 #undef __ | 4513 #undef __ |
4521 | 4514 |
4522 } } // namespace v8::internal | 4515 } } // namespace v8::internal |
4523 | 4516 |
4524 #endif // V8_TARGET_ARCH_IA32 | 4517 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |