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..0e9b22d9f9b09b9d0f09d63e2de069bfefb88c1d 100644 |
--- a/src/ia32/full-codegen-ia32.cc |
+++ b/src/ia32/full-codegen-ia32.cc |
@@ -2875,6 +2875,27 @@ 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. |
+ |
+ Label done; |
+ // If the object is a smi return the object. |
+ __ JumpIfSmi(eax, &done, Label::kNear); |
ulan
2012/01/25 13:08:48
As discussed offline, it's better to crash if Date
rossberg
2012/01/25 15:48:37
I removed all (non-debug-mode) type checks, and ch
|
+ // If the object is not a date type, return the object. |
+ __ CmpObjectType(eax, JS_DATE_TYPE, ebx); |
+ __ j(not_equal, &done, Label::kNear); |
+ __ mov(eax, FieldOperand(eax, JSDate::kYearOffset + kPointerSize * index)); |
+ |
+ __ bind(&done); |
+ 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 +2942,38 @@ 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. |
ulan
2012/01/25 13:08:48
Is it possible/faster to do
VisitForAccumulatorVa
rossberg
2012/01/25 15:48:37
No, the second Visit can clobber any register. Kee
|
+ VisitForAccumulatorValue(args->at(2)); // Load the value. |
+ __ pop(ebx); // eax = value. ebx = object. |
+ |
+ Label done; |
+ // If the object is a smi, return the value. |
+ __ JumpIfSmi(ebx, &done, Label::kNear); |
ulan
2012/01/25 13:08:48
As discussed offline, it's better to crash if Date
rossberg
2012/01/25 15:48:37
Done.
|
+ |
+ // If the object is not a value type, return the value. |
+ __ CmpObjectType(ebx, JS_DATE_TYPE, ecx); |
+ __ j(not_equal, &done, Label::kNear); |
+ |
+ // Store the value. |
+ __ mov(FieldOperand(ebx, JSDate::kYearOffset + kPointerSize * index), eax); |
+ |
+ // 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::kYearOffset + kPointerSize * index, |
ulan
2012/01/25 13:08:48
Can we avoid the write barrier by making sure that
rossberg
2012/01/25 15:48:37
Done.
|
+ edx, ecx, kDontSaveFPRegs); |
+ |
+ __ bind(&done); |
+ context()->Plug(eax); |
+} |
+ |
+ |
void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { |
ZoneList<Expression*>* args = expr->arguments(); |
ASSERT_EQ(args->length(), 1); |