| 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1821 compiler->GenerateCall(token_pos(), | 1821 compiler->GenerateCall(token_pos(), |
| 1822 &StubCode::AllocateArrayLabel(), | 1822 &StubCode::AllocateArrayLabel(), |
| 1823 PcDescriptors::kOther, | 1823 PcDescriptors::kOther, |
| 1824 locs()); | 1824 locs()); |
| 1825 ASSERT(locs()->out().reg() == EAX); | 1825 ASSERT(locs()->out().reg() == EAX); |
| 1826 } | 1826 } |
| 1827 | 1827 |
| 1828 | 1828 |
| 1829 LocationSummary* | 1829 LocationSummary* |
| 1830 AllocateObjectWithBoundsCheckInstr::MakeLocationSummary() const { | 1830 AllocateObjectWithBoundsCheckInstr::MakeLocationSummary() const { |
| 1831 const intptr_t kNumInputs = 2; | 1831 return MakeCallSummary(); |
| 1832 const intptr_t kNumTemps = 0; | |
| 1833 LocationSummary* locs = | |
| 1834 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | |
| 1835 locs->set_in(0, Location::RegisterLocation(EAX)); | |
| 1836 locs->set_in(1, Location::RegisterLocation(ECX)); | |
| 1837 locs->set_out(Location::RegisterLocation(EAX)); | |
| 1838 return locs; | |
| 1839 } | 1832 } |
| 1840 | 1833 |
| 1841 | 1834 |
| 1842 void AllocateObjectWithBoundsCheckInstr::EmitNativeCode( | 1835 void AllocateObjectWithBoundsCheckInstr::EmitNativeCode( |
| 1843 FlowGraphCompiler* compiler) { | 1836 FlowGraphCompiler* compiler) { |
| 1844 const Class& cls = Class::ZoneHandle(constructor().Owner()); | |
| 1845 Register type_arguments = locs()->in(0).reg(); | |
| 1846 Register instantiator_type_arguments = locs()->in(1).reg(); | |
| 1847 Register result = locs()->out().reg(); | |
| 1848 | |
| 1849 // Push the result place holder initialized to NULL. | |
| 1850 __ PushObject(Object::ZoneHandle()); | |
| 1851 __ PushObject(cls); | |
| 1852 __ pushl(type_arguments); | |
| 1853 __ pushl(instantiator_type_arguments); | |
| 1854 compiler->GenerateCallRuntime(token_pos(), | 1837 compiler->GenerateCallRuntime(token_pos(), |
| 1855 deopt_id(), | 1838 deopt_id(), |
| 1856 kAllocateObjectWithBoundsCheckRuntimeEntry, | 1839 kAllocateObjectWithBoundsCheckRuntimeEntry, |
| 1857 locs()); | 1840 locs()); |
| 1858 // Pop instantiator type arguments, type arguments, and class. | |
| 1859 // source location. | |
| 1860 __ Drop(3); | 1841 __ Drop(3); |
| 1861 __ popl(result); // Pop new instance. | 1842 ASSERT(locs()->out().reg() == EAX); |
| 1843 __ popl(EAX); // Pop new instance. |
| 1862 } | 1844 } |
| 1863 | 1845 |
| 1864 | 1846 |
| 1865 LocationSummary* LoadFieldInstr::MakeLocationSummary() const { | 1847 LocationSummary* LoadFieldInstr::MakeLocationSummary() const { |
| 1866 return LocationSummary::Make(1, | 1848 return LocationSummary::Make(1, |
| 1867 Location::RequiresRegister(), | 1849 Location::RequiresRegister(), |
| 1868 LocationSummary::kNoCall); | 1850 LocationSummary::kNoCall); |
| 1869 } | 1851 } |
| 1870 | 1852 |
| 1871 | 1853 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1946 ASSERT(instantiator_reg == result_reg); | 1928 ASSERT(instantiator_reg == result_reg); |
| 1947 | 1929 |
| 1948 // instantiator_reg is the instantiator type argument vector, i.e. an | 1930 // instantiator_reg is the instantiator type argument vector, i.e. an |
| 1949 // AbstractTypeArguments object (or null). | 1931 // AbstractTypeArguments object (or null). |
| 1950 ASSERT(!type_arguments().IsUninstantiatedIdentity() && | 1932 ASSERT(!type_arguments().IsUninstantiatedIdentity() && |
| 1951 !type_arguments().CanShareInstantiatorTypeArguments( | 1933 !type_arguments().CanShareInstantiatorTypeArguments( |
| 1952 instantiator_class())); | 1934 instantiator_class())); |
| 1953 // If the instantiator is null and if the type argument vector | 1935 // If the instantiator is null and if the type argument vector |
| 1954 // instantiated from null becomes a vector of dynamic, then use null as | 1936 // instantiated from null becomes a vector of dynamic, then use null as |
| 1955 // the type arguments. | 1937 // the type arguments. |
| 1938 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length())); |
| 1956 Label type_arguments_instantiated; | 1939 Label type_arguments_instantiated; |
| 1957 const intptr_t len = type_arguments().Length(); | 1940 const Immediate& raw_null = |
| 1958 if (type_arguments().IsRawInstantiatedRaw(len)) { | 1941 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1959 const Immediate& raw_null = | 1942 __ cmpl(instantiator_reg, raw_null); |
| 1960 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1943 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); |
| 1961 __ cmpl(instantiator_reg, raw_null); | |
| 1962 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); | |
| 1963 } | |
| 1964 // Instantiate non-null type arguments. | 1944 // Instantiate non-null type arguments. |
| 1965 // In the non-factory case, we rely on the allocation stub to | 1945 // In the non-factory case, we rely on the allocation stub to |
| 1966 // instantiate the type arguments. | 1946 // instantiate the type arguments. |
| 1967 __ LoadObject(result_reg, type_arguments()); | 1947 __ LoadObject(result_reg, type_arguments()); |
| 1968 // result_reg: uninstantiated type arguments. | 1948 // result_reg: uninstantiated type arguments. |
| 1969 | 1949 |
| 1970 __ Bind(&type_arguments_instantiated); | 1950 __ Bind(&type_arguments_instantiated); |
| 1971 // result_reg: uninstantiated or instantiated type arguments. | 1951 // result_reg: uninstantiated or instantiated type arguments. |
| 1972 } | 1952 } |
| 1973 | 1953 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1991 | 1971 |
| 1992 // instantiator_reg is the instantiator AbstractTypeArguments object | 1972 // instantiator_reg is the instantiator AbstractTypeArguments object |
| 1993 // (or null). | 1973 // (or null). |
| 1994 ASSERT(!type_arguments().IsUninstantiatedIdentity() && | 1974 ASSERT(!type_arguments().IsUninstantiatedIdentity() && |
| 1995 !type_arguments().CanShareInstantiatorTypeArguments( | 1975 !type_arguments().CanShareInstantiatorTypeArguments( |
| 1996 instantiator_class())); | 1976 instantiator_class())); |
| 1997 | 1977 |
| 1998 // If the instantiator is null and if the type argument vector | 1978 // If the instantiator is null and if the type argument vector |
| 1999 // instantiated from null becomes a vector of dynamic, then use null as | 1979 // instantiated from null becomes a vector of dynamic, then use null as |
| 2000 // the type arguments and do not pass the instantiator. | 1980 // the type arguments and do not pass the instantiator. |
| 2001 const intptr_t len = type_arguments().Length(); | 1981 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length())); |
| 2002 if (type_arguments().IsRawInstantiatedRaw(len)) { | 1982 const Immediate& raw_null = |
| 2003 const Immediate& raw_null = | 1983 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 2004 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1984 Label instantiator_not_null; |
| 2005 Label instantiator_not_null; | 1985 __ cmpl(instantiator_reg, raw_null); |
| 2006 __ cmpl(instantiator_reg, raw_null); | 1986 __ j(NOT_EQUAL, &instantiator_not_null, Assembler::kNearJump); |
| 2007 __ j(NOT_EQUAL, &instantiator_not_null, Assembler::kNearJump); | 1987 // Null was used in VisitExtractConstructorTypeArguments as the |
| 2008 // Null was used in VisitExtractConstructorTypeArguments as the | 1988 // instantiated type arguments, no proper instantiator needed. |
| 2009 // instantiated type arguments, no proper instantiator needed. | 1989 __ movl(instantiator_reg, |
| 2010 __ movl(instantiator_reg, | 1990 Immediate(Smi::RawValue(StubCode::kNoInstantiator))); |
| 2011 Immediate(Smi::RawValue(StubCode::kNoInstantiator))); | 1991 __ Bind(&instantiator_not_null); |
| 2012 __ Bind(&instantiator_not_null); | |
| 2013 } | |
| 2014 // instantiator_reg: instantiator or kNoInstantiator. | 1992 // instantiator_reg: instantiator or kNoInstantiator. |
| 2015 } | 1993 } |
| 2016 | 1994 |
| 2017 | 1995 |
| 2018 LocationSummary* AllocateContextInstr::MakeLocationSummary() const { | 1996 LocationSummary* AllocateContextInstr::MakeLocationSummary() const { |
| 2019 const intptr_t kNumInputs = 0; | 1997 const intptr_t kNumInputs = 0; |
| 2020 const intptr_t kNumTemps = 1; | 1998 const intptr_t kNumTemps = 1; |
| 2021 LocationSummary* locs = | 1999 LocationSummary* locs = |
| 2022 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 2000 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 2023 locs->set_temp(0, Location::RegisterLocation(EDX)); | 2001 locs->set_temp(0, Location::RegisterLocation(EDX)); |
| (...skipping 2677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4701 PcDescriptors::kOther, | 4679 PcDescriptors::kOther, |
| 4702 locs()); | 4680 locs()); |
| 4703 __ Drop(2); // Discard type arguments and receiver. | 4681 __ Drop(2); // Discard type arguments and receiver. |
| 4704 } | 4682 } |
| 4705 | 4683 |
| 4706 } // namespace dart | 4684 } // namespace dart |
| 4707 | 4685 |
| 4708 #undef __ | 4686 #undef __ |
| 4709 | 4687 |
| 4710 #endif // defined TARGET_ARCH_IA32 | 4688 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |