OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
12 #include "vm/flow_graph.h" | 12 #include "vm/flow_graph.h" |
13 #include "vm/flow_graph_compiler.h" | 13 #include "vm/flow_graph_compiler.h" |
14 #include "vm/flow_graph_range_analysis.h" | 14 #include "vm/flow_graph_range_analysis.h" |
15 #include "vm/locations.h" | 15 #include "vm/locations.h" |
16 #include "vm/object_store.h" | 16 #include "vm/object_store.h" |
17 #include "vm/parser.h" | 17 #include "vm/parser.h" |
18 #include "vm/stack_frame.h" | 18 #include "vm/stack_frame.h" |
19 #include "vm/stub_code.h" | 19 #include "vm/stub_code.h" |
20 #include "vm/symbols.h" | 20 #include "vm/symbols.h" |
21 | 21 |
22 #define __ compiler->assembler()-> | 22 #define __ compiler->assembler()-> |
| 23 #define Z (compiler->zone()) |
23 | 24 |
24 namespace dart { | 25 namespace dart { |
25 | 26 |
26 // Generic summary for call instructions that have all arguments pushed | 27 // Generic summary for call instructions that have all arguments pushed |
27 // on the stack and return the result in a fixed register RAX. | 28 // on the stack and return the result in a fixed register RAX. |
28 LocationSummary* Instruction::MakeCallSummary(Zone* zone) { | 29 LocationSummary* Instruction::MakeCallSummary(Zone* zone) { |
29 LocationSummary* result = new(zone) LocationSummary( | 30 LocationSummary* result = new(zone) LocationSummary( |
30 zone, 0, 0, LocationSummary::kCall); | 31 zone, 0, 0, LocationSummary::kCall); |
31 result->set_out(0, Location::RegisterLocation(RAX)); | 32 result->set_out(0, Location::RegisterLocation(RAX)); |
32 return result; | 33 return result; |
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 locs()->temp(locs()->temp_count() - 1).reg() : kNoRegister; | 1477 locs()->temp(locs()->temp_count() - 1).reg() : kNoRegister; |
1477 | 1478 |
1478 Label ok, fail_label; | 1479 Label ok, fail_label; |
1479 | 1480 |
1480 Label* deopt = compiler->is_optimizing() ? | 1481 Label* deopt = compiler->is_optimizing() ? |
1481 compiler->AddDeoptStub(deopt_id(), ICData::kDeoptGuardField) : NULL; | 1482 compiler->AddDeoptStub(deopt_id(), ICData::kDeoptGuardField) : NULL; |
1482 | 1483 |
1483 Label* fail = (deopt != NULL) ? deopt : &fail_label; | 1484 Label* fail = (deopt != NULL) ? deopt : &fail_label; |
1484 | 1485 |
1485 if (emit_full_guard) { | 1486 if (emit_full_guard) { |
1486 __ LoadObject(field_reg, Field::ZoneHandle(field().raw())); | 1487 __ LoadObject(field_reg, Field::ZoneHandle(field().Original())); |
1487 | 1488 |
1488 FieldAddress field_cid_operand(field_reg, Field::guarded_cid_offset()); | 1489 FieldAddress field_cid_operand(field_reg, Field::guarded_cid_offset()); |
1489 FieldAddress field_nullability_operand( | 1490 FieldAddress field_nullability_operand( |
1490 field_reg, Field::is_nullable_offset()); | 1491 field_reg, Field::is_nullable_offset()); |
1491 | 1492 |
1492 if (value_cid == kDynamicCid) { | 1493 if (value_cid == kDynamicCid) { |
1493 LoadValueCid(compiler, value_cid_reg, value_reg); | 1494 LoadValueCid(compiler, value_cid_reg, value_reg); |
1494 | 1495 |
1495 __ cmpl(value_cid_reg, field_cid_operand); | 1496 __ cmpl(value_cid_reg, field_cid_operand); |
1496 __ j(EQUAL, &ok); | 1497 __ j(EQUAL, &ok); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 const Register value_reg = locs()->in(0).reg(); | 1611 const Register value_reg = locs()->in(0).reg(); |
1611 | 1612 |
1612 if (!compiler->is_optimizing() || | 1613 if (!compiler->is_optimizing() || |
1613 (field().guarded_list_length() == Field::kUnknownFixedLength)) { | 1614 (field().guarded_list_length() == Field::kUnknownFixedLength)) { |
1614 const Register field_reg = locs()->temp(0).reg(); | 1615 const Register field_reg = locs()->temp(0).reg(); |
1615 const Register offset_reg = locs()->temp(1).reg(); | 1616 const Register offset_reg = locs()->temp(1).reg(); |
1616 const Register length_reg = locs()->temp(2).reg(); | 1617 const Register length_reg = locs()->temp(2).reg(); |
1617 | 1618 |
1618 Label ok; | 1619 Label ok; |
1619 | 1620 |
1620 __ LoadObject(field_reg, Field::ZoneHandle(field().raw())); | 1621 __ LoadObject(field_reg, Field::ZoneHandle(field().Original())); |
1621 | 1622 |
1622 __ movsxb(offset_reg, FieldAddress(field_reg, | 1623 __ movsxb(offset_reg, FieldAddress(field_reg, |
1623 Field::guarded_list_length_in_object_offset_offset())); | 1624 Field::guarded_list_length_in_object_offset_offset())); |
1624 __ movq(length_reg, FieldAddress(field_reg, | 1625 __ movq(length_reg, FieldAddress(field_reg, |
1625 Field::guarded_list_length_offset())); | 1626 Field::guarded_list_length_offset())); |
1626 | 1627 |
1627 __ cmpq(offset_reg, Immediate(0)); | 1628 __ cmpq(offset_reg, Immediate(0)); |
1628 __ j(NEGATIVE, &ok); | 1629 __ j(NEGATIVE, &ok); |
1629 | 1630 |
1630 // Load the length from the value. GuardFieldClass already verified that | 1631 // Load the length from the value. GuardFieldClass already verified that |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1848 // Value input is a writable register and should be manually preserved | 1849 // Value input is a writable register and should be manually preserved |
1849 // across allocation slow-path. | 1850 // across allocation slow-path. |
1850 locs()->live_registers()->Add(locs()->in(1), kTagged); | 1851 locs()->live_registers()->Add(locs()->in(1), kTagged); |
1851 } | 1852 } |
1852 | 1853 |
1853 Label store_pointer; | 1854 Label store_pointer; |
1854 Label store_double; | 1855 Label store_double; |
1855 Label store_float32x4; | 1856 Label store_float32x4; |
1856 Label store_float64x2; | 1857 Label store_float64x2; |
1857 | 1858 |
1858 __ LoadObject(temp, Field::ZoneHandle(field().raw())); | 1859 __ LoadObject(temp, Field::ZoneHandle(Z, field().Original())); |
1859 | 1860 |
1860 __ cmpl(FieldAddress(temp, Field::is_nullable_offset()), | 1861 __ cmpl(FieldAddress(temp, Field::is_nullable_offset()), |
1861 Immediate(kNullCid)); | 1862 Immediate(kNullCid)); |
1862 __ j(EQUAL, &store_pointer); | 1863 __ j(EQUAL, &store_pointer); |
1863 | 1864 |
1864 __ movzxb(temp2, FieldAddress(temp, Field::kind_bits_offset())); | 1865 __ movzxb(temp2, FieldAddress(temp, Field::kind_bits_offset())); |
1865 __ testq(temp2, Immediate(1 << Field::kUnboxingCandidateBit)); | 1866 __ testq(temp2, Immediate(1 << Field::kUnboxingCandidateBit)); |
1866 __ j(ZERO, &store_pointer); | 1867 __ j(ZERO, &store_pointer); |
1867 | 1868 |
1868 __ cmpl(FieldAddress(temp, Field::guarded_cid_offset()), | 1869 __ cmpl(FieldAddress(temp, Field::guarded_cid_offset()), |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 : Location::RequiresRegister()); | 1991 : Location::RequiresRegister()); |
1991 locs->set_temp(0, Location::RequiresRegister()); | 1992 locs->set_temp(0, Location::RequiresRegister()); |
1992 return locs; | 1993 return locs; |
1993 } | 1994 } |
1994 | 1995 |
1995 | 1996 |
1996 void StoreStaticFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1997 void StoreStaticFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
1997 Register value = locs()->in(0).reg(); | 1998 Register value = locs()->in(0).reg(); |
1998 Register temp = locs()->temp(0).reg(); | 1999 Register temp = locs()->temp(0).reg(); |
1999 | 2000 |
2000 __ LoadObject(temp, field()); | 2001 __ LoadObject(temp, Field::ZoneHandle(Z, field().Original())); |
2001 if (this->value()->NeedsStoreBuffer()) { | 2002 if (this->value()->NeedsStoreBuffer()) { |
2002 __ StoreIntoObject(temp, | 2003 __ StoreIntoObject(temp, |
2003 FieldAddress(temp, Field::static_value_offset()), | 2004 FieldAddress(temp, Field::static_value_offset()), |
2004 value, | 2005 value, |
2005 CanValueBeSmi()); | 2006 CanValueBeSmi()); |
2006 } else { | 2007 } else { |
2007 __ StoreIntoObjectNoBarrier( | 2008 __ StoreIntoObjectNoBarrier( |
2008 temp, FieldAddress(temp, Field::static_value_offset()), value); | 2009 temp, FieldAddress(temp, Field::static_value_offset()), value); |
2009 } | 2010 } |
2010 } | 2011 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2208 Register result = locs()->out(0).reg(); | 2209 Register result = locs()->out(0).reg(); |
2209 if (IsPotentialUnboxedLoad()) { | 2210 if (IsPotentialUnboxedLoad()) { |
2210 Register temp = locs()->temp(1).reg(); | 2211 Register temp = locs()->temp(1).reg(); |
2211 XmmRegister value = locs()->temp(0).fpu_reg(); | 2212 XmmRegister value = locs()->temp(0).fpu_reg(); |
2212 | 2213 |
2213 Label load_pointer; | 2214 Label load_pointer; |
2214 Label load_double; | 2215 Label load_double; |
2215 Label load_float32x4; | 2216 Label load_float32x4; |
2216 Label load_float64x2; | 2217 Label load_float64x2; |
2217 | 2218 |
2218 __ LoadObject(result, Field::ZoneHandle(field()->raw())); | 2219 __ LoadObject(result, Field::ZoneHandle(field()->Original())); |
2219 | 2220 |
2220 __ cmpl(FieldAddress(result, Field::is_nullable_offset()), | 2221 __ cmpl(FieldAddress(result, Field::is_nullable_offset()), |
2221 Immediate(kNullCid)); | 2222 Immediate(kNullCid)); |
2222 __ j(EQUAL, &load_pointer); | 2223 __ j(EQUAL, &load_pointer); |
2223 | 2224 |
2224 __ cmpl(FieldAddress(result, Field::guarded_cid_offset()), | 2225 __ cmpl(FieldAddress(result, Field::guarded_cid_offset()), |
2225 Immediate(kDoubleCid)); | 2226 Immediate(kDoubleCid)); |
2226 __ j(EQUAL, &load_double); | 2227 __ j(EQUAL, &load_double); |
2227 | 2228 |
2228 __ cmpl(FieldAddress(result, Field::guarded_cid_offset()), | 2229 __ cmpl(FieldAddress(result, Field::guarded_cid_offset()), |
(...skipping 4167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6396 __ Drop(1); | 6397 __ Drop(1); |
6397 __ popq(result); | 6398 __ popq(result); |
6398 } | 6399 } |
6399 | 6400 |
6400 | 6401 |
6401 } // namespace dart | 6402 } // namespace dart |
6402 | 6403 |
6403 #undef __ | 6404 #undef __ |
6404 | 6405 |
6405 #endif // defined TARGET_ARCH_X64 | 6406 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |