Commit 85611e37 authored by ulan@chromium.org's avatar ulan@chromium.org

MIPS: Port Date-related changes.

Port r10981 (5ea074), r10982 (5f0d413) and r10983 (663a897d5).

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/9668045
Patch from Daniel Kalmar <kalmard@homejinni.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11003 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 165e42c2
......@@ -2970,6 +2970,52 @@ 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());
Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->handle()));
VisitForAccumulatorValue(args->at(0)); // Load the object.
Label runtime, done;
Register object = v0;
Register result = v0;
Register scratch0 = t5;
Register scratch1 = a1;
#ifdef DEBUG
__ AbortIfSmi(object);
__ GetObjectType(object, scratch1, scratch1);
__ Assert(eq, "Trying to get date field from non-date.",
scratch1, Operand(JS_DATE_TYPE));
#endif
if (index->value() == 0) {
__ lw(result, FieldMemOperand(object, JSDate::kValueOffset));
} else {
if (index->value() < JSDate::kFirstUncachedField) {
ExternalReference stamp = ExternalReference::date_cache_stamp(isolate());
__ li(scratch1, Operand(stamp));
__ lw(scratch1, MemOperand(scratch1));
__ lw(scratch0, FieldMemOperand(object, JSDate::kCacheStampOffset));
__ Branch(&runtime, ne, scratch1, Operand(scratch0));
__ lw(result, FieldMemOperand(object, JSDate::kValueOffset +
kPointerSize * index->value()));
__ jmp(&done);
}
__ bind(&runtime);
__ PrepareCallCFunction(2, scratch1);
__ li(a1, Operand(index));
__ Move(a0, object);
__ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
__ bind(&done);
}
context()->Plug(v0);
}
void FullCodeGenerator::EmitMathPow(CallRuntime* expr) {
// Load the arguments on the stack and call the runtime function.
ZoneList<Expression*>* args = expr->arguments();
......
......@@ -1261,6 +1261,46 @@ void LCodeGen::DoValueOf(LValueOf* instr) {
}
void LCodeGen::DoDateField(LDateField* instr) {
Register object = ToRegister(instr->InputAt(0));
Register result = ToRegister(instr->result());
Register scratch = ToRegister(instr->TempAt(0));
Smi* index = instr->index();
Label runtime, done;
ASSERT(object.is(a0));
ASSERT(result.is(v0));
ASSERT(!scratch.is(scratch0()));
ASSERT(!scratch.is(object));
#ifdef DEBUG
__ AbortIfSmi(object);
__ GetObjectType(object, scratch, scratch);
__ Assert(eq, "Trying to get date field from non-date.",
scratch, Operand(JS_DATE_TYPE));
#endif
if (index->value() == 0) {
__ lw(result, FieldMemOperand(object, JSDate::kValueOffset));
} else {
if (index->value() < JSDate::kFirstUncachedField) {
ExternalReference stamp = ExternalReference::date_cache_stamp(isolate());
__ li(scratch, Operand(stamp));
__ lw(scratch, MemOperand(scratch));
__ lw(scratch0(), FieldMemOperand(object, JSDate::kCacheStampOffset));
__ Branch(&runtime, ne, scratch, Operand(scratch0()));
__ lw(result, FieldMemOperand(object, JSDate::kValueOffset +
kPointerSize * index->value()));
__ jmp(&done);
}
__ bind(&runtime);
__ PrepareCallCFunction(2, scratch);
__ li(a1, Operand(index));
__ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
__ bind(&done);
}
}
void LCodeGen::DoBitNotI(LBitNotI* instr) {
Register input = ToRegister(instr->InputAt(0));
Register result = ToRegister(instr->result());
......
......@@ -1604,6 +1604,13 @@ LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) {
}
LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
LOperand* object = UseFixed(instr->value(), a0);
LDateField* result = new LDateField(object, FixedTemp(a1), instr->index());
return MarkAsCall(DefineFixed(result, v0), instr);
}
LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
LOperand* value = UseRegisterAtStart(instr->index());
LOperand* length = UseRegister(instr->length());
......
......@@ -177,8 +177,8 @@ class LCodeGen;
V(ForInPrepareMap) \
V(ForInCacheArray) \
V(CheckMapValue) \
V(LoadFieldByIndex)
V(LoadFieldByIndex) \
V(DateField)
#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
virtual Opcode opcode() const { return LInstruction::k##type; } \
......@@ -989,6 +989,22 @@ class LValueOf: public LTemplateInstruction<1, 1, 1> {
};
class LDateField: public LTemplateInstruction<1, 1, 1> {
public:
LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
inputs_[0] = date;
temps_[0] = temp;
}
DECLARE_CONCRETE_INSTRUCTION(ValueOf, "date-field")
DECLARE_HYDROGEN_ACCESSOR(ValueOf)
Smi* index() const { return index_; }
private:
Smi* index_;
};
class LThrow: public LTemplateInstruction<0, 1, 0> {
public:
explicit LThrow(LOperand* value) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment