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

Side by Side Diff: src/x64/full-codegen-x64.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/serialize.cc ('k') | src/x64/lithium-codegen-x64.cc » ('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 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 2831
2832 __ bind(&done); 2832 __ bind(&done);
2833 context()->Plug(rax); 2833 context()->Plug(rax);
2834 } 2834 }
2835 2835
2836 2836
2837 void FullCodeGenerator::EmitDateField(CallRuntime* expr) { 2837 void FullCodeGenerator::EmitDateField(CallRuntime* expr) {
2838 ZoneList<Expression*>* args = expr->arguments(); 2838 ZoneList<Expression*>* args = expr->arguments();
2839 ASSERT(args->length() == 2); 2839 ASSERT(args->length() == 2);
2840 ASSERT_NE(NULL, args->at(1)->AsLiteral()); 2840 ASSERT_NE(NULL, args->at(1)->AsLiteral());
2841 int index = Smi::cast(*(args->at(1)->AsLiteral()->handle()))->value(); 2841 Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->handle()));
2842 2842
2843 VisitForAccumulatorValue(args->at(0)); // Load the object. 2843 VisitForAccumulatorValue(args->at(0)); // Load the object.
2844 2844
2845 Label runtime, done;
2846 Register object = rax;
2847 Register result = rax;
2848 Register scratch = rcx;
2849
2845 #ifdef DEBUG 2850 #ifdef DEBUG
2846 __ AbortIfSmi(rax); 2851 __ AbortIfSmi(object);
2847 __ CmpObjectType(rax, JS_DATE_TYPE, rbx); 2852 __ CmpObjectType(object, JS_DATE_TYPE, scratch);
2848 __ Assert(equal, "Trying to get date field from non-date."); 2853 __ Assert(equal, "Trying to get date field from non-date.");
2849 #endif 2854 #endif
2850 2855
2851 __ movq(rax, FieldOperand(rax, JSDate::kValueOffset + kPointerSize * index)); 2856 if (index->value() == 0) {
2857 __ movq(result, FieldOperand(object, JSDate::kValueOffset));
2858 } else {
2859 if (index->value() < JSDate::kFirstUncachedField) {
2860 ExternalReference stamp = ExternalReference::date_cache_stamp(isolate());
2861 __ movq(scratch, stamp);
2862 __ cmpq(scratch, FieldOperand(object, JSDate::kCacheStampOffset));
2863 __ j(not_equal, &runtime, Label::kNear);
2864 __ movq(result, FieldOperand(object, JSDate::kValueOffset +
2865 kPointerSize * index->value()));
2866 __ jmp(&done);
2867 }
2868 __ bind(&runtime);
2869 __ PrepareCallCFunction(2);
2870 #ifdef _WIN64
2871 __ movq(rcx, object);
2872 __ movq(rdx, index, RelocInfo::NONE);
2873 #else
2874 __ movq(rdi, object);
2875 __ movq(rsi, index, RelocInfo::NONE);
2876 #endif
2877 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
2878 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2879 __ bind(&done);
2880 }
2852 context()->Plug(rax); 2881 context()->Plug(rax);
2853 } 2882 }
2854 2883
2855 2884
2856 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { 2885 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) {
2857 // Load the arguments on the stack and call the runtime function. 2886 // Load the arguments on the stack and call the runtime function.
2858 ZoneList<Expression*>* args = expr->arguments(); 2887 ZoneList<Expression*>* args = expr->arguments();
2859 ASSERT(args->length() == 2); 2888 ASSERT(args->length() == 2);
2860 VisitForStackValue(args->at(0)); 2889 VisitForStackValue(args->at(0));
2861 VisitForStackValue(args->at(1)); 2890 VisitForStackValue(args->at(1));
(...skipping 24 matching lines...) Expand all
2886 // Update the write barrier. Save the value as it will be 2915 // Update the write barrier. Save the value as it will be
2887 // overwritten by the write barrier code and is needed afterward. 2916 // overwritten by the write barrier code and is needed afterward.
2888 __ movq(rdx, rax); 2917 __ movq(rdx, rax);
2889 __ RecordWriteField(rbx, JSValue::kValueOffset, rdx, rcx, kDontSaveFPRegs); 2918 __ RecordWriteField(rbx, JSValue::kValueOffset, rdx, rcx, kDontSaveFPRegs);
2890 2919
2891 __ bind(&done); 2920 __ bind(&done);
2892 context()->Plug(rax); 2921 context()->Plug(rax);
2893 } 2922 }
2894 2923
2895 2924
2896 void FullCodeGenerator::EmitSetDateField(CallRuntime* expr) {
2897 ZoneList<Expression*>* args = expr->arguments();
2898 ASSERT(args->length() == 3);
2899 ASSERT_NE(NULL, args->at(1)->AsLiteral());
2900 int index = Smi::cast(*(args->at(1)->AsLiteral()->handle()))->value();
2901
2902 VisitForStackValue(args->at(0)); // Load the object.
2903 VisitForAccumulatorValue(args->at(2)); // Load the value.
2904 __ pop(rbx); // rax = value. rbx = object.
2905
2906 #ifdef DEBUG
2907 __ AbortIfSmi(rbx);
2908 __ CmpObjectType(rbx, JS_DATE_TYPE, rcx);
2909 __ Assert(equal, "Trying to set date field on non-date.");
2910 #endif
2911
2912 // Store the value.
2913 __ movq(FieldOperand(rbx, JSDate::kValueOffset + kPointerSize * index), rax);
2914 // Caches can only be smi or NaN, so we can skip the write barrier for them.
2915 if (index < JSDate::kFirstBarrierFree) {
2916 // Update the write barrier. Save the value as it will be
2917 // overwritten by the write barrier code and is needed afterward.
2918 __ movq(rdx, rax);
2919 __ RecordWriteField(rbx, JSDate::kValueOffset + kPointerSize * index,
2920 rdx, rcx, kDontSaveFPRegs);
2921 }
2922 context()->Plug(rax);
2923 }
2924
2925
2926 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { 2925 void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) {
2927 ZoneList<Expression*>* args = expr->arguments(); 2926 ZoneList<Expression*>* args = expr->arguments();
2928 ASSERT_EQ(args->length(), 1); 2927 ASSERT_EQ(args->length(), 1);
2929 2928
2930 // Load the argument on the stack and call the stub. 2929 // Load the argument on the stack and call the stub.
2931 VisitForStackValue(args->at(0)); 2930 VisitForStackValue(args->at(0));
2932 2931
2933 NumberToStringStub stub; 2932 NumberToStringStub stub;
2934 __ CallStub(&stub); 2933 __ CallStub(&stub);
2935 context()->Plug(rax); 2934 context()->Plug(rax);
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
4415 *context_length = 0; 4414 *context_length = 0;
4416 return previous_; 4415 return previous_;
4417 } 4416 }
4418 4417
4419 4418
4420 #undef __ 4419 #undef __
4421 4420
4422 } } // namespace v8::internal 4421 } } // namespace v8::internal
4423 4422
4424 #endif // V8_TARGET_ARCH_X64 4423 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/serialize.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698