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

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: whitespace 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
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 2803 matching lines...) Expand 10 before | Expand all | Expand 10 after
2814 // If the object is not a value type, return the object. 2814 // If the object is not a value type, return the object.
2815 __ CmpObjectType(rax, JS_VALUE_TYPE, rbx); 2815 __ CmpObjectType(rax, JS_VALUE_TYPE, rbx);
2816 __ j(not_equal, &done); 2816 __ j(not_equal, &done);
2817 __ movq(rax, FieldOperand(rax, JSValue::kValueOffset)); 2817 __ movq(rax, FieldOperand(rax, JSValue::kValueOffset));
2818 2818
2819 __ bind(&done); 2819 __ bind(&done);
2820 context()->Plug(rax); 2820 context()->Plug(rax);
2821 } 2821 }
2822 2822
2823 2823
2824 void FullCodeGenerator::EmitDateField(CallRuntime* expr) {
2825 ZoneList<Expression*>* args = expr->arguments();
2826 ASSERT(args->length() == 2);
2827 ASSERT_NE(NULL, args->at(1)->AsLiteral());
2828 Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->handle()));
2829
2830 VisitForAccumulatorValue(args->at(0)); // Load the object.
2831
2832 Label runtime, done;
2833 Register object = rax;
2834 Register result = rax;
2835 Register scratch = rcx;
2836
2837 #ifdef DEBUG
2838 __ AbortIfSmi(object);
2839 __ CmpObjectType(object, JS_DATE_TYPE, scratch);
2840 __ Assert(equal, "Trying to get date field from non-date.");
2841 #endif
2842
2843 if (index->value() == 0) {
2844 __ movq(result, FieldOperand(object, JSDate::kValueOffset));
2845 } else {
2846 if (index->value() < JSDate::kFirstUncachedField) {
2847 ExternalReference stamp = ExternalReference::date_cache_stamp(isolate());
2848 __ movq(scratch, stamp);
2849 __ cmpq(scratch, FieldOperand(object, JSDate::kCacheStampOffset));
2850 __ j(not_equal, &runtime, Label::kNear);
2851 __ movq(result, FieldOperand(object, JSDate::kValueOffset +
2852 kPointerSize * index->value()));
2853 __ jmp(&done);
2854 }
2855 __ bind(&runtime);
2856 __ PrepareCallCFunction(2);
2857 #ifdef _WIN64
2858 __ movq(rcx, object);
2859 __ movq(rdx, index, RelocInfo::NONE);
2860 #else
2861 __ movq(rdi, object);
2862 __ movq(rsi, index, RelocInfo::NONE);
2863 #endif
2864 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
2865 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2866 __ bind(&done);
2867 }
2868 context()->Plug(rax);
2869 }
2870
2871
2824 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { 2872 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) {
2825 // Load the arguments on the stack and call the runtime function. 2873 // Load the arguments on the stack and call the runtime function.
2826 ZoneList<Expression*>* args = expr->arguments(); 2874 ZoneList<Expression*>* args = expr->arguments();
2827 ASSERT(args->length() == 2); 2875 ASSERT(args->length() == 2);
2828 VisitForStackValue(args->at(0)); 2876 VisitForStackValue(args->at(0));
2829 VisitForStackValue(args->at(1)); 2877 VisitForStackValue(args->at(1));
2830 MathPowStub stub(MathPowStub::ON_STACK); 2878 MathPowStub stub(MathPowStub::ON_STACK);
2831 __ CallStub(&stub); 2879 __ CallStub(&stub);
2832 context()->Plug(rax); 2880 context()->Plug(rax);
2833 } 2881 }
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
4353 *context_length = 0; 4401 *context_length = 0;
4354 return previous_; 4402 return previous_;
4355 } 4403 }
4356 4404
4357 4405
4358 #undef __ 4406 #undef __
4359 4407
4360 } } // namespace v8::internal 4408 } } // namespace v8::internal
4361 4409
4362 #endif // V8_TARGET_ARCH_X64 4410 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/date.cc ('K') | « 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