| 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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 compiler->GenerateCall(token_pos(), | 1804 compiler->GenerateCall(token_pos(), |
| 1805 &StubCode::AllocateArrayLabel(), | 1805 &StubCode::AllocateArrayLabel(), |
| 1806 PcDescriptors::kOther, | 1806 PcDescriptors::kOther, |
| 1807 locs()); | 1807 locs()); |
| 1808 ASSERT(locs()->out().reg() == RAX); | 1808 ASSERT(locs()->out().reg() == RAX); |
| 1809 } | 1809 } |
| 1810 | 1810 |
| 1811 | 1811 |
| 1812 LocationSummary* | 1812 LocationSummary* |
| 1813 AllocateObjectWithBoundsCheckInstr::MakeLocationSummary() const { | 1813 AllocateObjectWithBoundsCheckInstr::MakeLocationSummary() const { |
| 1814 const intptr_t kNumInputs = 2; | 1814 return MakeCallSummary(); |
| 1815 const intptr_t kNumTemps = 0; | |
| 1816 LocationSummary* locs = | |
| 1817 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | |
| 1818 locs->set_in(0, Location::RegisterLocation(RAX)); | |
| 1819 locs->set_in(1, Location::RegisterLocation(RCX)); | |
| 1820 locs->set_out(Location::RegisterLocation(RAX)); | |
| 1821 return locs; | |
| 1822 } | 1815 } |
| 1823 | 1816 |
| 1824 | 1817 |
| 1825 void AllocateObjectWithBoundsCheckInstr::EmitNativeCode( | 1818 void AllocateObjectWithBoundsCheckInstr::EmitNativeCode( |
| 1826 FlowGraphCompiler* compiler) { | 1819 FlowGraphCompiler* compiler) { |
| 1827 const Class& cls = Class::ZoneHandle(constructor().Owner()); | |
| 1828 Register type_arguments = locs()->in(0).reg(); | |
| 1829 Register instantiator_type_arguments = locs()->in(1).reg(); | |
| 1830 Register result = locs()->out().reg(); | |
| 1831 | |
| 1832 // Push the result place holder initialized to NULL. | |
| 1833 __ PushObject(Object::ZoneHandle()); | |
| 1834 __ PushObject(cls); | |
| 1835 __ pushq(type_arguments); | |
| 1836 __ pushq(instantiator_type_arguments); | |
| 1837 compiler->GenerateCallRuntime(token_pos(), | 1820 compiler->GenerateCallRuntime(token_pos(), |
| 1838 deopt_id(), | 1821 deopt_id(), |
| 1839 kAllocateObjectWithBoundsCheckRuntimeEntry, | 1822 kAllocateObjectWithBoundsCheckRuntimeEntry, |
| 1840 locs()); | 1823 locs()); |
| 1841 // Pop instantiator type arguments, type arguments, and class. | |
| 1842 __ Drop(3); | 1824 __ Drop(3); |
| 1843 __ popq(result); // Pop new instance. | 1825 ASSERT(locs()->out().reg() == RAX); |
| 1826 __ popq(RAX); // Pop new instance. |
| 1844 } | 1827 } |
| 1845 | 1828 |
| 1846 | 1829 |
| 1847 LocationSummary* LoadFieldInstr::MakeLocationSummary() const { | 1830 LocationSummary* LoadFieldInstr::MakeLocationSummary() const { |
| 1848 return LocationSummary::Make(1, | 1831 return LocationSummary::Make(1, |
| 1849 Location::RequiresRegister(), | 1832 Location::RequiresRegister(), |
| 1850 LocationSummary::kNoCall); | 1833 LocationSummary::kNoCall); |
| 1851 } | 1834 } |
| 1852 | 1835 |
| 1853 | 1836 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 | 1912 |
| 1930 // instantiator_reg is the instantiator type argument vector, i.e. an | 1913 // instantiator_reg is the instantiator type argument vector, i.e. an |
| 1931 // AbstractTypeArguments object (or null). | 1914 // AbstractTypeArguments object (or null). |
| 1932 ASSERT(!type_arguments().IsUninstantiatedIdentity() && | 1915 ASSERT(!type_arguments().IsUninstantiatedIdentity() && |
| 1933 !type_arguments().CanShareInstantiatorTypeArguments( | 1916 !type_arguments().CanShareInstantiatorTypeArguments( |
| 1934 instantiator_class())); | 1917 instantiator_class())); |
| 1935 // If the instantiator is null and if the type argument vector | 1918 // If the instantiator is null and if the type argument vector |
| 1936 // instantiated from null becomes a vector of dynamic, then use null as | 1919 // instantiated from null becomes a vector of dynamic, then use null as |
| 1937 // the type arguments. | 1920 // the type arguments. |
| 1938 Label type_arguments_instantiated; | 1921 Label type_arguments_instantiated; |
| 1939 const intptr_t len = type_arguments().Length(); | 1922 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length())); |
| 1940 if (type_arguments().IsRawInstantiatedRaw(len)) { | 1923 const Immediate& raw_null = |
| 1941 const Immediate& raw_null = | 1924 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1942 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1925 __ cmpq(instantiator_reg, raw_null); |
| 1943 __ cmpq(instantiator_reg, raw_null); | 1926 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); |
| 1944 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); | |
| 1945 } | |
| 1946 // Instantiate non-null type arguments. | 1927 // Instantiate non-null type arguments. |
| 1947 // In the non-factory case, we rely on the allocation stub to | 1928 // In the non-factory case, we rely on the allocation stub to |
| 1948 // instantiate the type arguments. | 1929 // instantiate the type arguments. |
| 1949 __ LoadObject(result_reg, type_arguments()); | 1930 __ LoadObject(result_reg, type_arguments()); |
| 1950 // result_reg: uninstantiated type arguments. | 1931 // result_reg: uninstantiated type arguments. |
| 1951 | 1932 |
| 1952 __ Bind(&type_arguments_instantiated); | 1933 __ Bind(&type_arguments_instantiated); |
| 1953 // result_reg: uninstantiated or instantiated type arguments. | 1934 // result_reg: uninstantiated or instantiated type arguments. |
| 1954 } | 1935 } |
| 1955 | 1936 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1973 | 1954 |
| 1974 // instantiator_reg is the instantiator AbstractTypeArguments object | 1955 // instantiator_reg is the instantiator AbstractTypeArguments object |
| 1975 // (or null). | 1956 // (or null). |
| 1976 ASSERT(!type_arguments().IsUninstantiatedIdentity() && | 1957 ASSERT(!type_arguments().IsUninstantiatedIdentity() && |
| 1977 !type_arguments().CanShareInstantiatorTypeArguments( | 1958 !type_arguments().CanShareInstantiatorTypeArguments( |
| 1978 instantiator_class())); | 1959 instantiator_class())); |
| 1979 | 1960 |
| 1980 // If the instantiator is null and if the type argument vector | 1961 // If the instantiator is null and if the type argument vector |
| 1981 // instantiated from null becomes a vector of dynamic, then use null as | 1962 // instantiated from null becomes a vector of dynamic, then use null as |
| 1982 // the type arguments and do not pass the instantiator. | 1963 // the type arguments and do not pass the instantiator. |
| 1983 const intptr_t len = type_arguments().Length(); | 1964 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length())); |
| 1984 if (type_arguments().IsRawInstantiatedRaw(len)) { | 1965 const Immediate& raw_null = |
| 1985 const Immediate& raw_null = | 1966 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1986 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1967 Label instantiator_not_null; |
| 1987 Label instantiator_not_null; | 1968 __ cmpq(instantiator_reg, raw_null); |
| 1988 __ cmpq(instantiator_reg, raw_null); | 1969 __ j(NOT_EQUAL, &instantiator_not_null, Assembler::kNearJump); |
| 1989 __ j(NOT_EQUAL, &instantiator_not_null, Assembler::kNearJump); | 1970 // Null was used in VisitExtractConstructorTypeArguments as the |
| 1990 // Null was used in VisitExtractConstructorTypeArguments as the | 1971 // instantiated type arguments, no proper instantiator needed. |
| 1991 // instantiated type arguments, no proper instantiator needed. | 1972 __ movq(instantiator_reg, |
| 1992 __ movq(instantiator_reg, | 1973 Immediate(Smi::RawValue(StubCode::kNoInstantiator))); |
| 1993 Immediate(Smi::RawValue(StubCode::kNoInstantiator))); | 1974 __ Bind(&instantiator_not_null); |
| 1994 __ Bind(&instantiator_not_null); | |
| 1995 } | |
| 1996 // instantiator_reg: instantiator or kNoInstantiator. | 1975 // instantiator_reg: instantiator or kNoInstantiator. |
| 1997 } | 1976 } |
| 1998 | 1977 |
| 1999 | 1978 |
| 2000 LocationSummary* AllocateContextInstr::MakeLocationSummary() const { | 1979 LocationSummary* AllocateContextInstr::MakeLocationSummary() const { |
| 2001 const intptr_t kNumInputs = 0; | 1980 const intptr_t kNumInputs = 0; |
| 2002 const intptr_t kNumTemps = 1; | 1981 const intptr_t kNumTemps = 1; |
| 2003 LocationSummary* locs = | 1982 LocationSummary* locs = |
| 2004 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 1983 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 2005 locs->set_temp(0, Location::RegisterLocation(R10)); | 1984 locs->set_temp(0, Location::RegisterLocation(R10)); |
| (...skipping 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4344 PcDescriptors::kOther, | 4323 PcDescriptors::kOther, |
| 4345 locs()); | 4324 locs()); |
| 4346 __ Drop(2); // Discard type arguments and receiver. | 4325 __ Drop(2); // Discard type arguments and receiver. |
| 4347 } | 4326 } |
| 4348 | 4327 |
| 4349 } // namespace dart | 4328 } // namespace dart |
| 4350 | 4329 |
| 4351 #undef __ | 4330 #undef __ |
| 4352 | 4331 |
| 4353 #endif // defined TARGET_ARCH_X64 | 4332 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |