| 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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 __ testq(left, Immediate(kSmiTagMask)); | 722 __ testq(left, Immediate(kSmiTagMask)); |
| 723 __ j(ZERO, &done); | 723 __ j(ZERO, &done); |
| 724 __ LoadClassId(RDI, left); | 724 __ LoadClassId(RDI, left); |
| 725 __ Bind(&done); | 725 __ Bind(&done); |
| 726 const intptr_t kNumArguments = 2; | 726 const intptr_t kNumArguments = 2; |
| 727 compiler->EmitTestAndCall(ICData::Handle(ic_data()->AsUnaryClassChecks()), | 727 compiler->EmitTestAndCall(ICData::Handle(ic_data()->AsUnaryClassChecks()), |
| 728 RDI, // Class id register. | 728 RDI, // Class id register. |
| 729 kNumArguments, | 729 kNumArguments, |
| 730 Array::Handle(), // No named arguments. | 730 Array::Handle(), // No named arguments. |
| 731 deopt, // Deoptimize target. | 731 deopt, // Deoptimize target. |
| 732 NULL, // Fallthrough when done. | |
| 733 deopt_id(), | 732 deopt_id(), |
| 734 token_pos(), | 733 token_pos(), |
| 735 try_index(), | 734 try_index(), |
| 736 locs()); | 735 locs()); |
| 737 ASSERT(locs()->out().reg() == RAX); | 736 ASSERT(locs()->out().reg() == RAX); |
| 738 return; | 737 return; |
| 739 } | 738 } |
| 740 const String& function_name = | 739 const String& function_name = |
| 741 String::ZoneHandle(Symbols::New(Token::Str(kind()))); | 740 String::ZoneHandle(Symbols::New(Token::Str(kind()))); |
| 742 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, | 741 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, |
| (...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2137 const Function& target = Function::ZoneHandle(ic_data()->GetTargetAt(0)); | 2136 const Function& target = Function::ZoneHandle(ic_data()->GetTargetAt(0)); |
| 2138 compiler->GenerateStaticCall(instance_call()->deopt_id(), | 2137 compiler->GenerateStaticCall(instance_call()->deopt_id(), |
| 2139 instance_call()->token_pos(), | 2138 instance_call()->token_pos(), |
| 2140 instance_call()->try_index(), | 2139 instance_call()->try_index(), |
| 2141 target, | 2140 target, |
| 2142 instance_call()->ArgumentCount(), | 2141 instance_call()->ArgumentCount(), |
| 2143 instance_call()->argument_names(), | 2142 instance_call()->argument_names(), |
| 2144 locs()); | 2143 locs()); |
| 2145 return; | 2144 return; |
| 2146 } | 2145 } |
| 2147 Label handle_smi; | |
| 2148 Label* is_smi_label = | |
| 2149 ic_data()->GetReceiverClassIdAt(0) == kSmiCid ? &handle_smi : deopt; | |
| 2150 | 2146 |
| 2151 // Load receiver into RAX. | 2147 // Load receiver into RAX. |
| 2152 __ movq(RAX, | 2148 __ movq(RAX, |
| 2153 Address(RSP, (instance_call()->ArgumentCount() - 1) * kWordSize)); | 2149 Address(RSP, (instance_call()->ArgumentCount() - 1) * kWordSize)); |
| 2150 Label done; |
| 2151 __ movq(RDI, Immediate(kSmiCid)); |
| 2154 __ testq(RAX, Immediate(kSmiTagMask)); | 2152 __ testq(RAX, Immediate(kSmiTagMask)); |
| 2155 __ j(ZERO, is_smi_label); | 2153 __ j(ZERO, &done); |
| 2156 Label done; | |
| 2157 __ LoadClassId(RDI, RAX); | 2154 __ LoadClassId(RDI, RAX); |
| 2155 __ Bind(&done); |
| 2158 compiler->EmitTestAndCall(*ic_data(), | 2156 compiler->EmitTestAndCall(*ic_data(), |
| 2159 RDI, // Class id register. | 2157 RDI, // Class id register. |
| 2160 instance_call()->ArgumentCount(), | 2158 instance_call()->ArgumentCount(), |
| 2161 instance_call()->argument_names(), | 2159 instance_call()->argument_names(), |
| 2162 deopt, | 2160 deopt, |
| 2163 (is_smi_label == &handle_smi) ? &done : NULL, | |
| 2164 instance_call()->deopt_id(), | 2161 instance_call()->deopt_id(), |
| 2165 instance_call()->token_pos(), | 2162 instance_call()->token_pos(), |
| 2166 instance_call()->try_index(), | 2163 instance_call()->try_index(), |
| 2167 locs()); | 2164 locs()); |
| 2168 if (is_smi_label == &handle_smi) { | |
| 2169 __ Bind(&handle_smi); | |
| 2170 ASSERT(ic_data()->GetReceiverClassIdAt(0) == kSmiCid); | |
| 2171 const Function& target = Function::ZoneHandle(ic_data()->GetTargetAt(0)); | |
| 2172 compiler->GenerateStaticCall(instance_call()->deopt_id(), | |
| 2173 instance_call()->token_pos(), | |
| 2174 instance_call()->try_index(), | |
| 2175 target, | |
| 2176 instance_call()->ArgumentCount(), | |
| 2177 instance_call()->argument_names(), | |
| 2178 locs()); | |
| 2179 } | |
| 2180 __ Bind(&done); | |
| 2181 } | 2165 } |
| 2182 | 2166 |
| 2183 | 2167 |
| 2184 // TODO(srdjan): Move to shared. | 2168 // TODO(srdjan): Move to shared. |
| 2185 static bool ICDataWithBothClassIds(const ICData& ic_data, intptr_t class_id) { | 2169 static bool ICDataWithBothClassIds(const ICData& ic_data, intptr_t class_id) { |
| 2186 if (ic_data.num_args_tested() != 2) return false; | 2170 if (ic_data.num_args_tested() != 2) return false; |
| 2187 if (ic_data.NumberOfChecks() != 1) return false; | 2171 if (ic_data.NumberOfChecks() != 1) return false; |
| 2188 Function& target = Function::Handle(); | 2172 Function& target = Function::Handle(); |
| 2189 GrowableArray<intptr_t> class_ids; | 2173 GrowableArray<intptr_t> class_ids; |
| 2190 ic_data.GetCheckAt(0, &class_ids, &target); | 2174 ic_data.GetCheckAt(0, &class_ids, &target); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2376 __ testq(value, Immediate(kSmiTagMask)); | 2360 __ testq(value, Immediate(kSmiTagMask)); |
| 2377 __ j(NOT_ZERO, deopt); | 2361 __ j(NOT_ZERO, deopt); |
| 2378 } | 2362 } |
| 2379 | 2363 |
| 2380 | 2364 |
| 2381 } // namespace dart | 2365 } // namespace dart |
| 2382 | 2366 |
| 2383 #undef __ | 2367 #undef __ |
| 2384 | 2368 |
| 2385 #endif // defined TARGET_ARCH_X64 | 2369 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |