Index: runtime/vm/intermediate_language_x64.cc |
diff --git a/runtime/vm/intermediate_language_x64.cc b/runtime/vm/intermediate_language_x64.cc |
index f47abad849b4a3c165f8aa6581e79a3564d59d75..baa36e0d830a50a1684276755fd051ca1710c701 100644 |
--- a/runtime/vm/intermediate_language_x64.cc |
+++ b/runtime/vm/intermediate_language_x64.cc |
@@ -1571,10 +1571,13 @@ void StoreInstanceFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
case kDoubleCid: |
cls = &compiler->double_class(); |
break; |
- // TODO(johnmccutchan): Add kFloat32x4Cid here. |
+ case kFloat32x4Cid: |
+ cls = &compiler->float32x4_class(); |
+ break; |
default: |
UNREACHABLE(); |
} |
+ |
StoreInstanceFieldSlowPath* slow_path = |
new StoreInstanceFieldSlowPath(this, *cls); |
compiler->AddSlowPathCode(slow_path); |
@@ -1594,9 +1597,13 @@ void StoreInstanceFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
} |
switch (cid) { |
case kDoubleCid: |
- __ movsd(FieldAddress(temp, Double::value_offset()), value); |
- // TODO(johnmccutchan): Add kFloat32x4Cid here. |
- break; |
+ __ Comment("UnboxedDoubleStoreInstanceFieldInstr"); |
+ __ movsd(FieldAddress(temp, Double::value_offset()), value); |
+ break; |
+ case kFloat32x4Cid: |
+ __ Comment("UnboxedFloat32x4StoreInstanceFieldInstr"); |
+ __ movups(FieldAddress(temp, Float32x4::value_offset()), value); |
+ break; |
default: |
UNREACHABLE(); |
} |
@@ -1610,8 +1617,8 @@ void StoreInstanceFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
FpuRegister fpu_temp = locs()->temp(2).fpu_reg(); |
Label store_pointer; |
- Label copy_double; |
Label store_double; |
+ Label store_float32x4; |
__ LoadObject(temp, Field::ZoneHandle(field().raw()), PP); |
@@ -1627,38 +1634,74 @@ void StoreInstanceFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
Immediate(kDoubleCid)); |
__ j(EQUAL, &store_double); |
+ __ cmpq(FieldAddress(temp, Field::guarded_cid_offset()), |
+ Immediate(kFloat32x4Cid)); |
+ __ j(EQUAL, &store_float32x4); |
+ |
// Fall through. |
__ jmp(&store_pointer); |
- __ Bind(&store_double); |
- |
- __ movq(temp, FieldAddress(instance_reg, field().Offset())); |
- __ CompareObject(temp, Object::null_object(), PP); |
- __ j(NOT_EQUAL, ©_double); |
- |
- StoreInstanceFieldSlowPath* slow_path = |
- new StoreInstanceFieldSlowPath(this, compiler->double_class()); |
- compiler->AddSlowPathCode(slow_path); |
- |
if (!compiler->is_optimizing()) { |
locs()->live_registers()->Add(locs()->in(0)); |
locs()->live_registers()->Add(locs()->in(1)); |
} |
- __ TryAllocate(compiler->double_class(), |
- slow_path->entry_label(), |
- Assembler::kFarJump, |
- temp, |
- PP); |
- __ Bind(slow_path->exit_label()); |
- __ movq(temp2, temp); |
- __ StoreIntoObject(instance_reg, |
- FieldAddress(instance_reg, field().Offset()), |
- temp2); |
- __ Bind(©_double); |
- __ movsd(fpu_temp, FieldAddress(value_reg, Double::value_offset())); |
- __ movsd(FieldAddress(temp, Double::value_offset()), fpu_temp); |
- __ jmp(&skip_store); |
+ { |
+ __ Bind(&store_double); |
+ Label copy_double; |
+ StoreInstanceFieldSlowPath* slow_path = |
+ new StoreInstanceFieldSlowPath(this, compiler->double_class()); |
+ compiler->AddSlowPathCode(slow_path); |
+ |
+ __ movq(temp, FieldAddress(instance_reg, field().Offset())); |
+ __ CompareObject(temp, Object::null_object(), PP); |
+ __ j(NOT_EQUAL, ©_double); |
+ |
+ __ TryAllocate(compiler->double_class(), |
+ slow_path->entry_label(), |
+ Assembler::kFarJump, |
+ temp, |
+ PP); |
+ __ Bind(slow_path->exit_label()); |
+ __ movq(temp2, temp); |
+ __ StoreIntoObject(instance_reg, |
+ FieldAddress(instance_reg, field().Offset()), |
+ temp2); |
+ |
+ __ Bind(©_double); |
+ __ movsd(fpu_temp, FieldAddress(value_reg, Double::value_offset())); |
+ __ movsd(FieldAddress(temp, Double::value_offset()), fpu_temp); |
+ __ jmp(&skip_store); |
+ } |
+ |
+ { |
+ __ Bind(&store_float32x4); |
+ Label copy_float32x4; |
+ StoreInstanceFieldSlowPath* slow_path = |
+ new StoreInstanceFieldSlowPath(this, compiler->float32x4_class()); |
+ compiler->AddSlowPathCode(slow_path); |
+ |
+ __ movq(temp, FieldAddress(instance_reg, field().Offset())); |
+ __ CompareObject(temp, Object::null_object(), PP); |
+ __ j(NOT_EQUAL, ©_float32x4); |
+ |
+ __ TryAllocate(compiler->float32x4_class(), |
+ slow_path->entry_label(), |
+ Assembler::kFarJump, |
+ temp, |
+ PP); |
+ __ Bind(slow_path->exit_label()); |
+ __ movq(temp2, temp); |
+ __ StoreIntoObject(instance_reg, |
+ FieldAddress(instance_reg, field().Offset()), |
+ temp2); |
+ |
+ __ Bind(©_float32x4); |
+ __ movups(fpu_temp, FieldAddress(value_reg, Float32x4::value_offset())); |
+ __ movups(FieldAddress(temp, Float32x4::value_offset()), fpu_temp); |
+ __ jmp(&skip_store); |
+ } |
+ |
__ Bind(&store_pointer); |
} |
@@ -1831,6 +1874,38 @@ class BoxDoubleSlowPath : public SlowPathCode { |
}; |
+class BoxFloat32x4SlowPath : public SlowPathCode { |
+ public: |
+ explicit BoxFloat32x4SlowPath(Instruction* instruction) |
+ : instruction_(instruction) { } |
+ |
+ virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
+ __ Comment("BoxFloat32x4SlowPath"); |
+ __ Bind(entry_label()); |
+ const Class& float32x4_class = compiler->float32x4_class(); |
+ const Code& stub = |
+ Code::Handle(StubCode::GetAllocationStubForClass(float32x4_class)); |
+ const ExternalLabel label(float32x4_class.ToCString(), stub.EntryPoint()); |
+ |
+ LocationSummary* locs = instruction_->locs(); |
+ locs->live_registers()->Remove(locs->out()); |
+ |
+ compiler->SaveLiveRegisters(locs); |
+ compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. |
+ &label, |
+ PcDescriptors::kOther, |
+ locs); |
+ __ MoveRegister(locs->out().reg(), RAX); |
+ compiler->RestoreLiveRegisters(locs); |
+ |
+ __ jmp(exit_label()); |
+ } |
+ |
+ private: |
+ Instruction* instruction_; |
+}; |
+ |
+ |
LocationSummary* LoadFieldInstr::MakeLocationSummary(bool opt) const { |
const intptr_t kNumInputs = 1; |
const intptr_t kNumTemps = 0; |
@@ -1864,9 +1939,13 @@ void LoadFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
intptr_t cid = field()->UnboxedFieldCid(); |
switch (cid) { |
case kDoubleCid: |
+ __ Comment("UnboxedDoubleLoadFieldInstr"); |
__ movsd(result, FieldAddress(temp, Double::value_offset())); |
break; |
- // TODO(johnmccutchan): Add Float32x4 path here. |
+ case kFloat32x4Cid: |
+ __ Comment("UnboxedFloat32x4LoadFieldInstr"); |
+ __ movups(result, FieldAddress(temp, Float32x4::value_offset())); |
+ break; |
default: |
UNREACHABLE(); |
} |
@@ -1881,6 +1960,7 @@ void LoadFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
Label load_pointer; |
Label load_double; |
+ Label load_float32x4; |
__ LoadObject(result, Field::ZoneHandle(field()->raw()), PP); |
@@ -1892,30 +1972,49 @@ void LoadFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
Immediate(kDoubleCid)); |
__ j(EQUAL, &load_double); |
+ __ cmpq(FieldAddress(result, Field::guarded_cid_offset()), |
+ Immediate(kFloat32x4Cid)); |
+ __ j(EQUAL, &load_float32x4); |
+ |
// Fall through. |
__ jmp(&load_pointer); |
- __ Bind(&load_double); |
- |
- BoxDoubleSlowPath* slow_path = new BoxDoubleSlowPath(this); |
- compiler->AddSlowPathCode(slow_path); |
- |
if (!compiler->is_optimizing()) { |
locs()->live_registers()->Add(locs()->in(0)); |
} |
- __ TryAllocate(compiler->double_class(), |
- slow_path->entry_label(), |
- Assembler::kFarJump, |
- result, |
- PP); |
- __ Bind(slow_path->exit_label()); |
- __ movq(temp, FieldAddress(instance_reg, offset_in_bytes())); |
- __ movsd(value, FieldAddress(temp, Double::value_offset())); |
- __ movsd(FieldAddress(result, Double::value_offset()), value); |
- __ jmp(&done); |
+ { |
+ __ Bind(&load_double); |
+ BoxDoubleSlowPath* slow_path = new BoxDoubleSlowPath(this); |
+ compiler->AddSlowPathCode(slow_path); |
+ |
+ __ TryAllocate(compiler->double_class(), |
+ slow_path->entry_label(), |
+ Assembler::kFarJump, |
+ result, |
+ PP); |
+ __ Bind(slow_path->exit_label()); |
+ __ movq(temp, FieldAddress(instance_reg, offset_in_bytes())); |
+ __ movsd(value, FieldAddress(temp, Double::value_offset())); |
+ __ movsd(FieldAddress(result, Double::value_offset()), value); |
+ __ jmp(&done); |
+ } |
+ { |
+ __ Bind(&load_float32x4); |
+ BoxFloat32x4SlowPath* slow_path = new BoxFloat32x4SlowPath(this); |
+ compiler->AddSlowPathCode(slow_path); |
- // TODO(johnmccutchan): Add Float32x4 path here. |
+ __ TryAllocate(compiler->float32x4_class(), |
+ slow_path->entry_label(), |
+ Assembler::kFarJump, |
+ result, |
+ PP); |
+ __ Bind(slow_path->exit_label()); |
+ __ movq(temp, FieldAddress(instance_reg, offset_in_bytes())); |
+ __ movups(value, FieldAddress(temp, Float32x4::value_offset())); |
+ __ movups(FieldAddress(result, Float32x4::value_offset()), value); |
+ __ jmp(&done); |
+ } |
__ Bind(&load_pointer); |
} |
@@ -2969,38 +3068,6 @@ LocationSummary* BoxFloat32x4Instr::MakeLocationSummary(bool opt) const { |
} |
-class BoxFloat32x4SlowPath : public SlowPathCode { |
- public: |
- explicit BoxFloat32x4SlowPath(BoxFloat32x4Instr* instruction) |
- : instruction_(instruction) { } |
- |
- virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
- __ Comment("BoxFloat32x4SlowPath"); |
- __ Bind(entry_label()); |
- const Class& float32x4_class = compiler->float32x4_class(); |
- const Code& stub = |
- Code::Handle(StubCode::GetAllocationStubForClass(float32x4_class)); |
- const ExternalLabel label(float32x4_class.ToCString(), stub.EntryPoint()); |
- |
- LocationSummary* locs = instruction_->locs(); |
- locs->live_registers()->Remove(locs->out()); |
- |
- compiler->SaveLiveRegisters(locs); |
- compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. |
- &label, |
- PcDescriptors::kOther, |
- locs); |
- __ MoveRegister(locs->out().reg(), RAX); |
- compiler->RestoreLiveRegisters(locs); |
- |
- __ jmp(exit_label()); |
- } |
- |
- private: |
- BoxFloat32x4Instr* instruction_; |
-}; |
- |
- |
void BoxFloat32x4Instr::EmitNativeCode(FlowGraphCompiler* compiler) { |
BoxFloat32x4SlowPath* slow_path = new BoxFloat32x4SlowPath(this); |
compiler->AddSlowPathCode(slow_path); |