| 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_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 2160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 const intptr_t kNumTemps = 1; | 2171 const intptr_t kNumTemps = 1; |
| 2172 LocationSummary* summary = | 2172 LocationSummary* summary = |
| 2173 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 2173 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 2174 summary->set_in(0, Location::RequiresRegister()); | 2174 summary->set_in(0, Location::RequiresRegister()); |
| 2175 summary->set_temp(0, Location::RequiresRegister()); | 2175 summary->set_temp(0, Location::RequiresRegister()); |
| 2176 return summary; | 2176 return summary; |
| 2177 } | 2177 } |
| 2178 | 2178 |
| 2179 | 2179 |
| 2180 void CheckClassComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 2180 void CheckClassComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2181 const intptr_t v_cid = value()->ResultCid(); |
| 2182 const intptr_t num_checks = ic_data()->NumberOfChecks(); |
| 2183 if ((num_checks == 1) && |
| 2184 (v_cid == ic_data()->GetReceiverClassIdAt(0))) { |
| 2185 // No checks needed. |
| 2186 // TODO(srdjan): Should the computation have been removed instead? |
| 2187 return; |
| 2188 } |
| 2181 Register value = locs()->in(0).reg(); | 2189 Register value = locs()->in(0).reg(); |
| 2182 Register temp = locs()->temp(0).reg(); | 2190 Register temp = locs()->temp(0).reg(); |
| 2183 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2191 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
| 2184 try_index(), | 2192 try_index(), |
| 2185 kDeoptCheckClass); | 2193 kDeoptCheckClass); |
| 2186 ASSERT(ic_data()->GetReceiverClassIdAt(0) != kSmiCid); | 2194 ASSERT(ic_data()->GetReceiverClassIdAt(0) != kSmiCid); |
| 2187 __ testl(value, Immediate(kSmiTagMask)); | 2195 __ testl(value, Immediate(kSmiTagMask)); |
| 2188 __ j(ZERO, deopt); | 2196 __ j(ZERO, deopt); |
| 2189 __ LoadClassId(temp, value); | 2197 __ LoadClassId(temp, value); |
| 2190 Label is_ok; | 2198 Label is_ok; |
| 2191 const intptr_t num_checks = ic_data()->NumberOfChecks(); | |
| 2192 const bool use_near_jump = num_checks < 5; | 2199 const bool use_near_jump = num_checks < 5; |
| 2193 for (intptr_t i = 0; i < num_checks; i++) { | 2200 for (intptr_t i = 0; i < num_checks; i++) { |
| 2194 __ cmpl(temp, Immediate(ic_data()->GetReceiverClassIdAt(i))); | 2201 __ cmpl(temp, Immediate(ic_data()->GetReceiverClassIdAt(i))); |
| 2195 if (i == (num_checks - 1)) { | 2202 if (i == (num_checks - 1)) { |
| 2196 __ j(NOT_EQUAL, deopt); | 2203 __ j(NOT_EQUAL, deopt); |
| 2197 } else { | 2204 } else { |
| 2198 if (use_near_jump) { | 2205 if (use_near_jump) { |
| 2199 __ j(EQUAL, &is_ok, Assembler::kNearJump); | 2206 __ j(EQUAL, &is_ok, Assembler::kNearJump); |
| 2200 } else { | 2207 } else { |
| 2201 __ j(EQUAL, &is_ok); | 2208 __ j(EQUAL, &is_ok); |
| 2202 } | 2209 } |
| 2203 } | 2210 } |
| 2204 } | 2211 } |
| 2205 __ Bind(&is_ok); | 2212 __ Bind(&is_ok); |
| 2206 } | 2213 } |
| 2207 | 2214 |
| 2208 } // namespace dart | 2215 } // namespace dart |
| 2209 | 2216 |
| 2210 #undef __ | 2217 #undef __ |
| 2211 | 2218 |
| 2212 #endif // defined TARGET_ARCH_X64 | 2219 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |