| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2086 | 2086 |
| 2087 | 2087 |
| 2088 LocationSummary* PolymorphicInstanceCallComp::MakeLocationSummary() const { | 2088 LocationSummary* PolymorphicInstanceCallComp::MakeLocationSummary() const { |
| 2089 return MakeCallSummary(); | 2089 return MakeCallSummary(); |
| 2090 } | 2090 } |
| 2091 | 2091 |
| 2092 | 2092 |
| 2093 void PolymorphicInstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 2093 void PolymorphicInstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2094 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), | 2094 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), |
| 2095 kDeoptPolymorphicInstanceCallTestFail); | 2095 kDeoptPolymorphicInstanceCallTestFail); |
| 2096 if (!HasICData() || (ic_data()->NumberOfChecks() == 0)) { | 2096 if (ic_data().NumberOfChecks() == 0) { |
| 2097 __ jmp(deopt); | 2097 __ jmp(deopt); |
| 2098 return; | 2098 return; |
| 2099 } | 2099 } |
| 2100 ASSERT(HasICData()); | 2100 ASSERT(ic_data().num_args_tested() == 1); |
| 2101 ASSERT(ic_data()->num_args_tested() == 1); | |
| 2102 if (!with_checks()) { | 2101 if (!with_checks()) { |
| 2103 const Function& target = Function::ZoneHandle(ic_data()->GetTargetAt(0)); | 2102 const Function& target = Function::ZoneHandle(ic_data().GetTargetAt(0)); |
| 2104 compiler->GenerateStaticCall(instance_call()->deopt_id(), | 2103 compiler->GenerateStaticCall(instance_call()->deopt_id(), |
| 2105 instance_call()->token_pos(), | 2104 instance_call()->token_pos(), |
| 2106 target, | 2105 target, |
| 2107 instance_call()->ArgumentCount(), | 2106 instance_call()->ArgumentCount(), |
| 2108 instance_call()->argument_names(), | 2107 instance_call()->argument_names(), |
| 2109 locs()); | 2108 locs()); |
| 2110 return; | 2109 return; |
| 2111 } | 2110 } |
| 2112 | 2111 |
| 2113 // Load receiver into RAX. | 2112 // Load receiver into RAX. |
| 2114 __ movq(RAX, | 2113 __ movq(RAX, |
| 2115 Address(RSP, (instance_call()->ArgumentCount() - 1) * kWordSize)); | 2114 Address(RSP, (instance_call()->ArgumentCount() - 1) * kWordSize)); |
| 2116 Label done; | 2115 Label done; |
| 2117 __ movq(RDI, Immediate(kSmiCid)); | 2116 __ movq(RDI, Immediate(kSmiCid)); |
| 2118 __ testq(RAX, Immediate(kSmiTagMask)); | 2117 __ testq(RAX, Immediate(kSmiTagMask)); |
| 2119 __ j(ZERO, &done); | 2118 __ j(ZERO, &done); |
| 2120 __ LoadClassId(RDI, RAX); | 2119 __ LoadClassId(RDI, RAX); |
| 2121 __ Bind(&done); | 2120 __ Bind(&done); |
| 2122 compiler->EmitTestAndCall(*ic_data(), | 2121 compiler->EmitTestAndCall(ic_data(), |
| 2123 RDI, // Class id register. | 2122 RDI, // Class id register. |
| 2124 instance_call()->ArgumentCount(), | 2123 instance_call()->ArgumentCount(), |
| 2125 instance_call()->argument_names(), | 2124 instance_call()->argument_names(), |
| 2126 deopt, | 2125 deopt, |
| 2127 instance_call()->deopt_id(), | 2126 instance_call()->deopt_id(), |
| 2128 instance_call()->token_pos(), | 2127 instance_call()->token_pos(), |
| 2129 locs()); | 2128 locs()); |
| 2130 } | 2129 } |
| 2131 | 2130 |
| 2132 | 2131 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2144 summary->set_temp(0, Location::RequiresRegister()); | 2143 summary->set_temp(0, Location::RequiresRegister()); |
| 2145 return summary; | 2144 return summary; |
| 2146 } | 2145 } |
| 2147 | 2146 |
| 2148 | 2147 |
| 2149 void CheckClassComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 2148 void CheckClassComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2150 Register value = locs()->in(0).reg(); | 2149 Register value = locs()->in(0).reg(); |
| 2151 Register temp = locs()->temp(0).reg(); | 2150 Register temp = locs()->temp(0).reg(); |
| 2152 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2151 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
| 2153 kDeoptCheckClass); | 2152 kDeoptCheckClass); |
| 2154 ASSERT(ic_data()->GetReceiverClassIdAt(0) != kSmiCid); | 2153 ASSERT(unary_checks().GetReceiverClassIdAt(0) != kSmiCid); |
| 2155 __ testq(value, Immediate(kSmiTagMask)); | 2154 __ testq(value, Immediate(kSmiTagMask)); |
| 2156 __ j(ZERO, deopt); | 2155 __ j(ZERO, deopt); |
| 2157 __ LoadClassId(temp, value); | 2156 __ LoadClassId(temp, value); |
| 2158 Label is_ok; | 2157 Label is_ok; |
| 2159 const intptr_t num_checks = ic_data()->NumberOfChecks(); | 2158 const intptr_t num_checks = unary_checks().NumberOfChecks(); |
| 2160 const bool use_near_jump = num_checks < 5; | 2159 const bool use_near_jump = num_checks < 5; |
| 2161 for (intptr_t i = 0; i < num_checks; i++) { | 2160 for (intptr_t i = 0; i < num_checks; i++) { |
| 2162 __ cmpl(temp, Immediate(ic_data()->GetReceiverClassIdAt(i))); | 2161 __ cmpl(temp, Immediate(unary_checks().GetReceiverClassIdAt(i))); |
| 2163 if (i == (num_checks - 1)) { | 2162 if (i == (num_checks - 1)) { |
| 2164 __ j(NOT_EQUAL, deopt); | 2163 __ j(NOT_EQUAL, deopt); |
| 2165 } else { | 2164 } else { |
| 2166 if (use_near_jump) { | 2165 if (use_near_jump) { |
| 2167 __ j(EQUAL, &is_ok, Assembler::kNearJump); | 2166 __ j(EQUAL, &is_ok, Assembler::kNearJump); |
| 2168 } else { | 2167 } else { |
| 2169 __ j(EQUAL, &is_ok); | 2168 __ j(EQUAL, &is_ok); |
| 2170 } | 2169 } |
| 2171 } | 2170 } |
| 2172 } | 2171 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2221 } | 2220 } |
| 2222 __ j(ABOVE_EQUAL, deopt); | 2221 __ j(ABOVE_EQUAL, deopt); |
| 2223 } | 2222 } |
| 2224 | 2223 |
| 2225 | 2224 |
| 2226 } // namespace dart | 2225 } // namespace dart |
| 2227 | 2226 |
| 2228 #undef __ | 2227 #undef __ |
| 2229 | 2228 |
| 2230 #endif // defined TARGET_ARCH_X64 | 2229 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |