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

Unified Diff: src/ia32/full-codegen-ia32.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/full-codegen-ia32.cc
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index d0d36b06be655588b3dec0f229f4e87543fbec83..57a853849db5e390038c0a1d2da1faf413f6793d 100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -2965,18 +2965,41 @@ void FullCodeGenerator::EmitDateField(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
ASSERT(args->length() == 2);
ASSERT_NE(NULL, args->at(1)->AsLiteral());
- int index = Smi::cast(*(args->at(1)->AsLiteral()->handle()))->value();
+ Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->handle()));
VisitForAccumulatorValue(args->at(0)); // Load the object.
+ Label runtime, done;
+ Register object = eax;
+ Register result = eax;
+ Register scratch = ecx;
+
#ifdef DEBUG
- __ AbortIfSmi(eax);
- __ CmpObjectType(eax, JS_DATE_TYPE, ebx);
+ __ AbortIfSmi(object);
+ __ CmpObjectType(object, JS_DATE_TYPE, scratch);
__ Assert(equal, "Trying to get date field from non-date.");
#endif
- __ mov(eax, FieldOperand(eax, JSDate::kValueOffset + kPointerSize * index));
- context()->Plug(eax);
+ if (index->value() == 0) {
+ __ mov(result, FieldOperand(object, JSDate::kValueOffset));
+ } else {
+ if (index->value() < JSDate::kFirstUncachedField) {
+ ExternalReference stamp = ExternalReference::date_cache_stamp(isolate());
+ __ mov(scratch, Operand::StaticVariable(stamp));
+ __ cmp(scratch, FieldOperand(object, JSDate::kCacheStampOffset));
+ __ j(not_equal, &runtime, Label::kNear);
+ __ mov(result, FieldOperand(object, JSDate::kValueOffset +
+ kPointerSize * index->value()));
+ __ jmp(&done);
+ }
+ __ bind(&runtime);
+ __ PrepareCallCFunction(2, scratch);
+ __ mov(Operand(esp, 0), object);
+ __ mov(Operand(esp, 1 * kPointerSize), Immediate(index));
+ __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
+ __ bind(&done);
+ }
+ context()->Plug(result);
}
@@ -3026,36 +3049,6 @@ void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) {
}
-void FullCodeGenerator::EmitSetDateField(CallRuntime* expr) {
- ZoneList<Expression*>* args = expr->arguments();
- ASSERT(args->length() == 3);
- ASSERT_NE(NULL, args->at(1)->AsLiteral());
- int index = Smi::cast(*(args->at(1)->AsLiteral()->handle()))->value();
-
- VisitForStackValue(args->at(0)); // Load the object.
- VisitForAccumulatorValue(args->at(2)); // Load the value.
- __ pop(ebx); // eax = value. ebx = object.
-
-#ifdef DEBUG
- __ AbortIfSmi(ebx);
- __ CmpObjectType(ebx, JS_DATE_TYPE, ecx);
- __ Assert(equal, "Trying to set date field on non-date.");
-#endif
-
- // Store the value.
- __ mov(FieldOperand(ebx, JSDate::kValueOffset + kPointerSize * index), eax);
- // Caches can only be smi or NaN, so we can skip the write barrier for them.
- if (index < JSDate::kFirstBarrierFree) {
- // Update the write barrier. Save the value as it will be
- // overwritten by the write barrier code and is needed afterward.
- __ mov(edx, eax);
- __ RecordWriteField(ebx, JSDate::kValueOffset + kPointerSize * index,
- edx, ecx, kDontSaveFPRegs);
- }
- context()->Plug(eax);
-}
-
-
void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
ASSERT_EQ(args->length(), 1);
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698