Commit 45ba023b authored by palfia@homejinni.com's avatar palfia@homejinni.com

MIPS: Use mutable heapnumbers to store doubles in fields.

Port r14597 (6e9d7149)

BUG=

Review URL: https://codereview.chromium.org/14607009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14600 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ef5211d8
...@@ -1592,7 +1592,8 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { ...@@ -1592,7 +1592,8 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
: ObjectLiteral::kNoFlags; : ObjectLiteral::kNoFlags;
__ li(a0, Operand(Smi::FromInt(flags))); __ li(a0, Operand(Smi::FromInt(flags)));
int properties_count = constant_properties->length() / 2; int properties_count = constant_properties->length() / 2;
if (expr->depth() > 1) { if ((FLAG_track_double_fields && expr->may_store_doubles()) ||
expr->depth() > 1) {
__ Push(a3, a2, a1, a0); __ Push(a3, a2, a1, a0);
__ CallRuntime(Runtime::kCreateObjectLiteral, 4); __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
} else if (Serializer::enabled() || flags != ObjectLiteral::kFastElements || } else if (Serializer::enabled() || flags != ObjectLiteral::kFastElements ||
......
...@@ -1440,6 +1440,25 @@ void KeyedStoreIC::GenerateMiss(MacroAssembler* masm, ICMissMode miss_mode) { ...@@ -1440,6 +1440,25 @@ void KeyedStoreIC::GenerateMiss(MacroAssembler* masm, ICMissMode miss_mode) {
} }
void StoreIC::GenerateSlow(MacroAssembler* masm) {
// ---------- S t a t e --------------
// -- a0 : value
// -- a2 : key
// -- a1 : receiver
// -- ra : return address
// -----------------------------------
// Push receiver, key and value for runtime call.
__ Push(a1, a2, a0);
// The slow case calls into the runtime to complete the store without causing
// an IC miss that would otherwise cause a transition to the generic stub.
ExternalReference ref =
ExternalReference(IC_Utility(kKeyedStoreIC_Slow), masm->isolate());
__ TailCallExternalReference(ref, 3, 1);
}
void KeyedStoreIC::GenerateSlow(MacroAssembler* masm) { void KeyedStoreIC::GenerateSlow(MacroAssembler* masm) {
// ---------- S t a t e -------------- // ---------- S t a t e --------------
// -- a0 : value // -- a0 : value
......
...@@ -2688,31 +2688,20 @@ void LCodeGen::DoStoreContextSlot(LStoreContextSlot* instr) { ...@@ -2688,31 +2688,20 @@ void LCodeGen::DoStoreContextSlot(LStoreContextSlot* instr) {
void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) {
int offset = instr->hydrogen()->offset();
Register object = ToRegister(instr->object()); Register object = ToRegister(instr->object());
if (!FLAG_track_double_fields) { if (instr->hydrogen()->representation().IsDouble()) {
ASSERT(!instr->hydrogen()->representation().IsDouble()); DoubleRegister result = ToDoubleRegister(instr->result());
__ ldc1(result, FieldMemOperand(object, offset));
return;
} }
Register temp = instr->hydrogen()->representation().IsDouble()
? scratch0() : ToRegister(instr->result()); Register result = ToRegister(instr->result());
if (instr->hydrogen()->is_in_object()) { if (instr->hydrogen()->is_in_object()) {
__ lw(temp, FieldMemOperand(object, instr->hydrogen()->offset())); __ lw(result, FieldMemOperand(object, offset));
} else { } else {
__ lw(temp, FieldMemOperand(object, JSObject::kPropertiesOffset)); __ lw(result, FieldMemOperand(object, JSObject::kPropertiesOffset));
__ lw(temp, FieldMemOperand(temp, instr->hydrogen()->offset())); __ lw(result, FieldMemOperand(result, offset));
}
if (instr->hydrogen()->representation().IsDouble()) {
Label load_from_heap_number, done;
DoubleRegister result = ToDoubleRegister(instr->result());
FPURegister flt_scratch = double_scratch0().low();
__ JumpIfNotSmi(temp, &load_from_heap_number);
__ SmiUntag(temp);
__ mtc1(temp, flt_scratch);
__ cvt_d_w(result, flt_scratch);
__ Branch(&done);
__ bind(&load_from_heap_number);
__ ldc1(result, FieldMemOperand(temp, HeapNumber::kValueOffset));
__ bind(&done);
} }
} }
...@@ -3911,29 +3900,26 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { ...@@ -3911,29 +3900,26 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
Representation representation = instr->representation(); Representation representation = instr->representation();
Register object = ToRegister(instr->object()); Register object = ToRegister(instr->object());
Register value = ToRegister(instr->value());
ASSERT(!object.is(value));
Register scratch = scratch0(); Register scratch = scratch0();
int offset = instr->offset(); int offset = instr->offset();
Handle<Map> transition = instr->transition();
if (FLAG_track_fields && representation.IsSmi()) { if (FLAG_track_fields && representation.IsSmi()) {
Register value = ToRegister(instr->value());
__ SmiTagCheckOverflow(value, value, scratch); __ SmiTagCheckOverflow(value, value, scratch);
if (!instr->hydrogen()->value()->range()->IsInSmiRange()) { if (!instr->hydrogen()->value()->range()->IsInSmiRange()) {
DeoptimizeIf(lt, instr->environment(), scratch, Operand(zero_reg)); DeoptimizeIf(lt, instr->environment(), scratch, Operand(zero_reg));
} }
} else if (FLAG_track_double_fields && representation.IsDouble() && } else if (FLAG_track_double_fields && representation.IsDouble()) {
!instr->hydrogen()->value()->type().IsSmi() && ASSERT(transition.is_null());
!instr->hydrogen()->value()->type().IsHeapNumber()) { ASSERT(instr->is_in_object());
Label do_store; ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
__ JumpIfSmi(value, &do_store); DoubleRegister value = ToDoubleRegister(instr->value());
Handle<Map> map(isolate()->factory()->heap_number_map()); __ sdc1(value, FieldMemOperand(object, offset));
return;
__ lw(scratch, FieldMemOperand(value, HeapObject::kMapOffset));
DoCheckMapCommon(scratch, map, REQUIRE_EXACT_MAP, instr->environment());
__ bind(&do_store);
} }
Handle<Map> transition = instr->transition();
if (!transition.is_null()) { if (!transition.is_null()) {
if (transition->CanBeDeprecated()) { if (transition->CanBeDeprecated()) {
transition_maps_.Add(transition, info()->zone()); transition_maps_.Add(transition, info()->zone());
...@@ -3955,6 +3941,8 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { ...@@ -3955,6 +3941,8 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
} }
// Do the store. // Do the store.
Register value = ToRegister(instr->value());
ASSERT(!object.is(value));
HType type = instr->hydrogen()->value()->type(); HType type = instr->hydrogen()->value()->type();
SmiCheck check_needed = SmiCheck check_needed =
type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
...@@ -5266,7 +5254,8 @@ void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { ...@@ -5266,7 +5254,8 @@ void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) {
// Pick the right runtime function or stub to call. // Pick the right runtime function or stub to call.
int properties_count = instr->hydrogen()->constant_properties_length() / 2; int properties_count = instr->hydrogen()->constant_properties_length() / 2;
if (instr->hydrogen()->depth() > 1) { if ((FLAG_track_double_fields && instr->hydrogen()->may_store_doubles()) ||
instr->hydrogen()->depth() > 1) {
__ Push(a3, a2, a1, a0); __ Push(a3, a2, a1, a0);
CallRuntime(Runtime::kCreateObjectLiteral, 4, instr); CallRuntime(Runtime::kCreateObjectLiteral, 4, instr);
} else if (flags != ObjectLiteral::kFastElements || } else if (flags != ObjectLiteral::kFastElements ||
......
...@@ -2193,17 +2193,22 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { ...@@ -2193,17 +2193,22 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
: UseRegisterAtStart(instr->object()); : UseRegisterAtStart(instr->object());
} }
LOperand* val = LOperand* val;
needs_write_barrier || if (needs_write_barrier ||
(FLAG_track_fields && instr->field_representation().IsSmi()) (FLAG_track_fields && instr->field_representation().IsSmi())) {
? UseTempRegister(instr->value()) : UseRegister(instr->value()); val = UseTempRegister(instr->value());
} else if (FLAG_track_double_fields &&
instr->field_representation().IsDouble()) {
val = UseRegisterAtStart(instr->value());
} else {
val = UseRegister(instr->value());
}
// We need a temporary register for write barrier of the map field. // We need a temporary register for write barrier of the map field.
LOperand* temp = needs_write_barrier_for_map ? TempRegister() : NULL; LOperand* temp = needs_write_barrier_for_map ? TempRegister() : NULL;
LStoreNamedField* result = new(zone()) LStoreNamedField(obj, val, temp); LStoreNamedField* result = new(zone()) LStoreNamedField(obj, val, temp);
if ((FLAG_track_fields && instr->field_representation().IsSmi()) || if (FLAG_track_fields && instr->field_representation().IsSmi()) {
(FLAG_track_double_fields && instr->field_representation().IsDouble())) {
return AssignEnvironment(result); return AssignEnvironment(result);
} }
return result; return result;
......
...@@ -307,11 +307,13 @@ void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( ...@@ -307,11 +307,13 @@ void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype(
} }
void StubCompiler::DoGenerateFastPropertyLoad(MacroAssembler* masm, void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm,
Register dst, Register dst,
Register src, Register src,
bool inobject, bool inobject,
int index) { int index,
Representation representation) {
ASSERT(!FLAG_track_double_fields || !representation.IsDouble());
int offset = index * kPointerSize; int offset = index * kPointerSize;
if (!inobject) { if (!inobject) {
// Calculate the offset into the properties array. // Calculate the offset into the properties array.
...@@ -442,8 +444,10 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm, ...@@ -442,8 +444,10 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm,
Register value_reg, Register value_reg,
Register scratch1, Register scratch1,
Register scratch2, Register scratch2,
Register scratch3,
Label* miss_label, Label* miss_label,
Label* miss_restore_name) { Label* miss_restore_name,
Label* slow) {
// a0 : value. // a0 : value.
Label exit; Label exit;
...@@ -465,16 +469,6 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm, ...@@ -465,16 +469,6 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm,
// Ensure no transitions to deprecated maps are followed. // Ensure no transitions to deprecated maps are followed.
__ CheckMapDeprecated(transition, scratch1, miss_label); __ CheckMapDeprecated(transition, scratch1, miss_label);
if (FLAG_track_fields && representation.IsSmi()) {
__ JumpIfNotSmi(value_reg, miss_label);
} else if (FLAG_track_double_fields && representation.IsDouble()) {
Label do_store;
__ JumpIfSmi(value_reg, &do_store);
__ CheckMap(value_reg, scratch1, Heap::kHeapNumberMapRootIndex,
miss_label, DONT_DO_SMI_CHECK);
__ bind(&do_store);
}
// Check that we are allowed to write this. // Check that we are allowed to write this.
if (object->GetPrototype()->IsJSObject()) { if (object->GetPrototype()->IsJSObject()) {
JSObject* holder; JSObject* holder;
...@@ -490,7 +484,7 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm, ...@@ -490,7 +484,7 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm,
} }
Register holder_reg = CheckPrototypes( Register holder_reg = CheckPrototypes(
object, receiver_reg, Handle<JSObject>(holder), name_reg, object, receiver_reg, Handle<JSObject>(holder), name_reg,
scratch1, scratch2, name, miss_restore_name); scratch1, scratch2, name, miss_restore_name, SKIP_RECEIVER);
// If no property was found, and the holder (the last object in the // If no property was found, and the holder (the last object in the
// prototype chain) is in slow mode, we need to do a negative lookup on the // prototype chain) is in slow mode, we need to do a negative lookup on the
// holder. // holder.
...@@ -509,6 +503,30 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm, ...@@ -509,6 +503,30 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm,
} }
} }
Register storage_reg = name_reg;
if (FLAG_track_fields && representation.IsSmi()) {
__ JumpIfNotSmi(value_reg, miss_restore_name);
} else if (FLAG_track_double_fields && representation.IsDouble()) {
Label do_store, heap_number;
__ LoadRoot(scratch3, Heap::kHeapNumberMapRootIndex);
__ AllocateHeapNumber(storage_reg, scratch1, scratch2, scratch3, slow);
__ JumpIfNotSmi(value_reg, &heap_number);
__ SmiUntag(scratch1, value_reg);
__ mtc1(scratch1, f6);
__ cvt_d_w(f4, f6);
__ jmp(&do_store);
__ bind(&heap_number);
__ CheckMap(value_reg, scratch1, Heap::kHeapNumberMapRootIndex,
miss_restore_name, DONT_DO_SMI_CHECK);
__ ldc1(f4, FieldMemOperand(value_reg, HeapNumber::kValueOffset));
__ bind(&do_store);
__ sdc1(f4, FieldMemOperand(storage_reg, HeapNumber::kValueOffset));
}
// Stub never generated for non-global objects that require access // Stub never generated for non-global objects that require access
// checks. // checks.
ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
...@@ -536,7 +554,7 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm, ...@@ -536,7 +554,7 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm,
__ RecordWriteField(receiver_reg, __ RecordWriteField(receiver_reg,
HeapObject::kMapOffset, HeapObject::kMapOffset,
scratch1, scratch1,
name_reg, scratch2,
kRAHasNotBeenSaved, kRAHasNotBeenSaved,
kDontSaveFPRegs, kDontSaveFPRegs,
OMIT_REMEMBERED_SET, OMIT_REMEMBERED_SET,
...@@ -554,7 +572,11 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm, ...@@ -554,7 +572,11 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm,
if (index < 0) { if (index < 0) {
// Set the property straight into the object. // Set the property straight into the object.
int offset = object->map()->instance_size() + (index * kPointerSize); int offset = object->map()->instance_size() + (index * kPointerSize);
__ sw(value_reg, FieldMemOperand(receiver_reg, offset)); if (FLAG_track_double_fields && representation.IsDouble()) {
__ sw(storage_reg, FieldMemOperand(receiver_reg, offset));
} else {
__ sw(value_reg, FieldMemOperand(receiver_reg, offset));
}
if (!FLAG_track_fields || !representation.IsSmi()) { if (!FLAG_track_fields || !representation.IsSmi()) {
// Skip updating write barrier if storing a smi. // Skip updating write barrier if storing a smi.
...@@ -562,7 +584,11 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm, ...@@ -562,7 +584,11 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm,
// Update the write barrier for the array address. // Update the write barrier for the array address.
// Pass the now unused name_reg as a scratch register. // Pass the now unused name_reg as a scratch register.
__ mov(name_reg, value_reg); if (!FLAG_track_double_fields || !representation.IsDouble()) {
__ mov(name_reg, value_reg);
} else {
ASSERT(storage_reg.is(name_reg));
}
__ RecordWriteField(receiver_reg, __ RecordWriteField(receiver_reg,
offset, offset,
name_reg, name_reg,
...@@ -576,7 +602,11 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm, ...@@ -576,7 +602,11 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm,
// Get the properties array // Get the properties array
__ lw(scratch1, __ lw(scratch1,
FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset)); FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset));
__ sw(value_reg, FieldMemOperand(scratch1, offset)); if (FLAG_track_double_fields && representation.IsDouble()) {
__ sw(storage_reg, FieldMemOperand(scratch1, offset));
} else {
__ sw(value_reg, FieldMemOperand(scratch1, offset));
}
if (!FLAG_track_fields || !representation.IsSmi()) { if (!FLAG_track_fields || !representation.IsSmi()) {
// Skip updating write barrier if storing a smi. // Skip updating write barrier if storing a smi.
...@@ -584,6 +614,11 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm, ...@@ -584,6 +614,11 @@ void StubCompiler::GenerateStoreTransition(MacroAssembler* masm,
// Update the write barrier for the array address. // Update the write barrier for the array address.
// Ok to clobber receiver_reg and name_reg, since we return. // Ok to clobber receiver_reg and name_reg, since we return.
if (!FLAG_track_double_fields || !representation.IsDouble()) {
__ mov(name_reg, value_reg);
} else {
ASSERT(storage_reg.is(name_reg));
}
__ mov(name_reg, value_reg); __ mov(name_reg, value_reg);
__ RecordWriteField(scratch1, __ RecordWriteField(scratch1,
offset, offset,
...@@ -643,11 +678,37 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm, ...@@ -643,11 +678,37 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm,
if (FLAG_track_fields && representation.IsSmi()) { if (FLAG_track_fields && representation.IsSmi()) {
__ JumpIfNotSmi(value_reg, miss_label); __ JumpIfNotSmi(value_reg, miss_label);
} else if (FLAG_track_double_fields && representation.IsDouble()) { } else if (FLAG_track_double_fields && representation.IsDouble()) {
Label do_store; // Load the double storage.
__ JumpIfSmi(value_reg, &do_store); if (index < 0) {
__ CheckMap(value_reg, scratch1, Heap::kHeapNumberMapRootIndex, int offset = object->map()->instance_size() + (index * kPointerSize);
__ lw(scratch1, FieldMemOperand(receiver_reg, offset));
} else {
__ lw(scratch1,
FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset));
int offset = index * kPointerSize + FixedArray::kHeaderSize;
__ lw(scratch1, FieldMemOperand(scratch1, offset));
}
// Store the value into the storage.
Label do_store, heap_number;
__ JumpIfNotSmi(value_reg, &heap_number);
__ SmiUntag(scratch2, value_reg);
__ mtc1(scratch2, f6);
__ cvt_d_w(f4, f6);
__ jmp(&do_store);
__ bind(&heap_number);
__ CheckMap(value_reg, scratch2, Heap::kHeapNumberMapRootIndex,
miss_label, DONT_DO_SMI_CHECK); miss_label, DONT_DO_SMI_CHECK);
__ ldc1(f4, FieldMemOperand(value_reg, HeapNumber::kValueOffset));
__ bind(&do_store); __ bind(&do_store);
__ sdc1(f4, FieldMemOperand(scratch1, HeapNumber::kValueOffset));
// Return the value (register v0).
ASSERT(value_reg.is(a0));
__ mov(v0, a0);
__ Ret();
return;
} }
// TODO(verwaest): Share this code as a code stub. // TODO(verwaest): Share this code as a code stub.
...@@ -1308,15 +1369,18 @@ void BaseLoadStubCompiler::NonexistentHandlerFrontend( ...@@ -1308,15 +1369,18 @@ void BaseLoadStubCompiler::NonexistentHandlerFrontend(
void BaseLoadStubCompiler::GenerateLoadField(Register reg, void BaseLoadStubCompiler::GenerateLoadField(Register reg,
Handle<JSObject> holder, Handle<JSObject> holder,
PropertyIndex field) { PropertyIndex field,
Representation representation) {
if (!reg.is(receiver())) __ mov(receiver(), reg); if (!reg.is(receiver())) __ mov(receiver(), reg);
if (kind() == Code::LOAD_IC) { if (kind() == Code::LOAD_IC) {
LoadFieldStub stub(field.is_inobject(holder), LoadFieldStub stub(field.is_inobject(holder),
field.translate(holder)); field.translate(holder),
representation);
GenerateTailCall(masm(), stub.GetCode(isolate())); GenerateTailCall(masm(), stub.GetCode(isolate()));
} else { } else {
KeyedLoadFieldStub stub(field.is_inobject(holder), KeyedLoadFieldStub stub(field.is_inobject(holder),
field.translate(holder)); field.translate(holder),
representation);
GenerateTailCall(masm(), stub.GetCode(isolate())); GenerateTailCall(masm(), stub.GetCode(isolate()));
} }
} }
...@@ -1548,7 +1612,8 @@ Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object, ...@@ -1548,7 +1612,8 @@ Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object,
// Do the right check and compute the holder register. // Do the right check and compute the holder register.
Register reg = CheckPrototypes(object, a0, holder, a1, a3, t0, name, &miss); Register reg = CheckPrototypes(object, a0, holder, a1, a3, t0, name, &miss);
GenerateFastPropertyLoad(masm(), a1, reg, holder, index); GenerateFastPropertyLoad(masm(), a1, reg, index.is_inobject(holder),
index.translate(holder), Representation::Tagged());
GenerateCallFunction(masm(), object, arguments(), &miss, extra_state_); GenerateCallFunction(masm(), object, arguments(), &miss, extra_state_);
......
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