Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: src/arm/full-codegen-arm.cc

Issue 9572008: Implement date library functions in C++. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/api.cc ('k') | src/arm/lithium-arm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2933 matching lines...) Expand 10 before | Expand all | Expand 10 after
2944 2944
2945 __ bind(&done); 2945 __ bind(&done);
2946 context()->Plug(r0); 2946 context()->Plug(r0);
2947 } 2947 }
2948 2948
2949 2949
2950 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { 2950 void FullCodeGenerator::EmitDateField(CallRuntime* expr) {
2951 ZoneList<Expression*>* args = expr->arguments(); 2951 ZoneList<Expression*>* args = expr->arguments();
2952 ASSERT(args->length() == 2); 2952 ASSERT(args->length() == 2);
2953 ASSERT_NE(NULL, args->at(1)->AsLiteral()); 2953 ASSERT_NE(NULL, args->at(1)->AsLiteral());
2954 int index = Smi::cast(*(args->at(1)->AsLiteral()->handle()))->value(); 2954 Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->handle()));
2955 2955
2956 VisitForAccumulatorValue(args->at(0)); // Load the object. 2956 VisitForAccumulatorValue(args->at(0)); // Load the object.
2957 2957
2958 Label runtime, done;
2959 Register object = r0;
2960 Register result = r0;
2961 Register scratch0 = r9;
2962 Register scratch1 = r1;
2963
2958 #ifdef DEBUG 2964 #ifdef DEBUG
2959 __ AbortIfSmi(r0); 2965 __ AbortIfSmi(object);
2960 __ CompareObjectType(r0, r1, r1, JS_DATE_TYPE); 2966 __ CompareObjectType(object, scratch1, scratch1, JS_DATE_TYPE);
2961 __ Assert(eq, "Trying to get date field from non-date."); 2967 __ Assert(eq, "Trying to get date field from non-date.");
2962 #endif 2968 #endif
2963 2969
2964 __ ldr(r0, FieldMemOperand(r0, JSDate::kValueOffset + kPointerSize * index)); 2970 if (index->value() == 0) {
2971 __ ldr(result, FieldMemOperand(object, JSDate::kValueOffset));
2972 } else {
2973 if (index->value() < JSDate::kFirstUncachedField) {
2974 ExternalReference stamp = ExternalReference::date_cache_stamp(isolate());
2975 __ mov(scratch1, Operand(stamp));
2976 __ ldr(scratch1, MemOperand(scratch1));
2977 __ ldr(scratch0, FieldMemOperand(object, JSDate::kCacheStampOffset));
2978 __ cmp(scratch1, scratch0);
2979 __ b(ne, &runtime);
2980 __ ldr(result, FieldMemOperand(object, JSDate::kValueOffset +
2981 kPointerSize * index->value()));
2982 __ jmp(&done);
2983 }
2984 __ bind(&runtime);
2985 __ PrepareCallCFunction(2, scratch1);
2986 __ mov(r1, Operand(index));
2987 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
2988 __ bind(&done);
2989 }
2965 context()->Plug(r0); 2990 context()->Plug(r0);
2966 } 2991 }
2967 2992
2968 2993
2969 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { 2994 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) {
2970 // Load the arguments on the stack and call the runtime function. 2995 // Load the arguments on the stack and call the runtime function.
2971 ZoneList<Expression*>* args = expr->arguments(); 2996 ZoneList<Expression*>* args = expr->arguments();
2972 ASSERT(args->length() == 2); 2997 ASSERT(args->length() == 2);
2973 VisitForStackValue(args->at(0)); 2998 VisitForStackValue(args->at(0));
2974 VisitForStackValue(args->at(1)); 2999 VisitForStackValue(args->at(1));
(...skipping 28 matching lines...) Expand all
3003 // overwritten by the write barrier code and is needed afterward. 3028 // overwritten by the write barrier code and is needed afterward.
3004 __ mov(r2, r0); 3029 __ mov(r2, r0);
3005 __ RecordWriteField( 3030 __ RecordWriteField(
3006 r1, JSValue::kValueOffset, r2, r3, kLRHasBeenSaved, kDontSaveFPRegs); 3031 r1, JSValue::kValueOffset, r2, r3, kLRHasBeenSaved, kDontSaveFPRegs);
3007 3032
3008 __ bind(&done); 3033 __ bind(&done);
3009 context()->Plug(r0); 3034 context()->Plug(r0);
3010 } 3035 }
3011 3036
3012 3037
3013 void FullCodeGenerator::EmitSetDateField(CallRuntime* expr) {
3014 ZoneList<Expression*>* args = expr->arguments();
3015 ASSERT(args->length() == 3);
3016 ASSERT_NE(NULL, args->at(1)->AsLiteral());
3017 int index = Smi::cast(*(args->at(1)->AsLiteral()->handle()))->value();
3018
3019 VisitForStackValue(args->at(0)); // Load the object.
3020 VisitForAccumulatorValue(args->at(2)); // Load the value.
3021 __ pop(r1); // r0 = value. r1 = object.
3022
3023 #ifdef DEBUG
3024 __ AbortIfSmi(r1);
3025 __ CompareObjectType(r1, r2, r2, JS_DATE_TYPE);
3026 __ Assert(eq, "Trying to get date field from non-date.");
3027 #endif
3028
3029 // Store the value.
3030 __ str(r0, FieldMemOperand(r1, JSDate::kValueOffset + kPointerSize * index));
3031 // Caches can only be smi or NaN, so we can skip the write barrier for them.
3032 if (index < JSDate::kFirstBarrierFree) {
3033 // Update the write barrier. Save the value as it will be
3034 // overwritten by the write barrier code and is needed afterward.
3035 __ mov(r2, r0);
3036 __ RecordWriteField(
3037 r1, JSDate::kValueOffset + kPointerSize * index,
3038 r2, r3, kLRHasBeenSaved, kDontSaveFPRegs);
3039 }
3040 context()->Plug(r0);
3041 }
3042
3043
3044 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { 3038 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) {
3045 ZoneList<Expression*>* args = expr->arguments(); 3039 ZoneList<Expression*>* args = expr->arguments();
3046 ASSERT_EQ(args->length(), 1); 3040 ASSERT_EQ(args->length(), 1);
3047 // Load the argument on the stack and call the stub. 3041 // Load the argument on the stack and call the stub.
3048 VisitForStackValue(args->at(0)); 3042 VisitForStackValue(args->at(0));
3049 3043
3050 NumberToStringStub stub; 3044 NumberToStringStub stub;
3051 __ CallStub(&stub); 3045 __ CallStub(&stub);
3052 context()->Plug(r0); 3046 context()->Plug(r0);
3053 } 3047 }
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
4455 *context_length = 0; 4449 *context_length = 0;
4456 return previous_; 4450 return previous_;
4457 } 4451 }
4458 4452
4459 4453
4460 #undef __ 4454 #undef __
4461 4455
4462 } } // namespace v8::internal 4456 } } // namespace v8::internal
4463 4457
4464 #endif // V8_TARGET_ARCH_ARM 4458 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/arm/lithium-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698