Index: src/ia32/full-codegen-ia32.cc |
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc |
index ede810c7b7b3ad6c01a0bad86cad5201db3358b5..d6cfd6ed412cbe5d04742aa741726f6cdd5c951e 100644 |
--- a/src/ia32/full-codegen-ia32.cc |
+++ b/src/ia32/full-codegen-ia32.cc |
@@ -2875,6 +2875,25 @@ void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { |
} |
+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(); |
+ |
+ VisitForAccumulatorValue(args->at(0)); // Load the object. |
+ |
+#ifdef DEBUG |
+ __ AbortIfSmi(eax); |
+ __ CmpObjectType(eax, JS_DATE_TYPE, ebx); |
+ __ Assert(equal, "Trying to get date field from non-date."); |
+#endif |
+ |
+ __ mov(eax, FieldOperand(eax, JSDate::kValueOffset + kPointerSize * index)); |
+ context()->Plug(eax); |
+} |
+ |
+ |
void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { |
// Load the arguments on the stack and call the runtime function. |
ZoneList<Expression*>* args = expr->arguments(); |
@@ -2921,6 +2940,36 @@ 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); |