| 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/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 } | 1374 } |
| 1375 } | 1375 } |
| 1376 ASSERT(offset == (xmm_regs_count * kDoubleSize)); | 1376 ASSERT(offset == (xmm_regs_count * kDoubleSize)); |
| 1377 __ addl(ESP, Immediate(offset)); | 1377 __ addl(ESP, Immediate(offset)); |
| 1378 } | 1378 } |
| 1379 } | 1379 } |
| 1380 | 1380 |
| 1381 | 1381 |
| 1382 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, | 1382 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, |
| 1383 Register class_id_reg, | 1383 Register class_id_reg, |
| 1384 intptr_t arg_count, | 1384 intptr_t argument_count, |
| 1385 const Array& arg_names, | 1385 const Array& argument_names, |
| 1386 Label* deopt, | 1386 Label* deopt, |
| 1387 intptr_t deopt_id, | 1387 intptr_t deopt_id, |
| 1388 intptr_t token_index, | 1388 intptr_t token_index, |
| 1389 LocationSummary* locs) { | 1389 LocationSummary* locs) { |
| 1390 ASSERT(!ic_data.IsNull() && (ic_data.NumberOfChecks() > 0)); | 1390 ASSERT(!ic_data.IsNull() && (ic_data.NumberOfChecks() > 0)); |
| 1391 Label match_found; | 1391 Label match_found; |
| 1392 const intptr_t len = ic_data.NumberOfChecks(); | 1392 const intptr_t len = ic_data.NumberOfChecks(); |
| 1393 GrowableArray<CidTarget> sorted(len); | 1393 GrowableArray<CidTarget> sorted(len); |
| 1394 SortICDataByCount(ic_data, &sorted); | 1394 SortICDataByCount(ic_data, &sorted); |
| 1395 ASSERT(class_id_reg != EDX); |
| 1396 ASSERT(len > 0); // Why bother otherwise. |
| 1397 const Array& arguments_descriptor = |
| 1398 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, |
| 1399 argument_names)); |
| 1400 __ LoadObject(EDX, arguments_descriptor); |
| 1395 for (intptr_t i = 0; i < len; i++) { | 1401 for (intptr_t i = 0; i < len; i++) { |
| 1396 const bool is_last_check = (i == (len - 1)); | 1402 const bool is_last_check = (i == (len - 1)); |
| 1397 Label next_test; | 1403 Label next_test; |
| 1398 assembler()->cmpl(class_id_reg, Immediate(sorted[i].cid)); | 1404 assembler()->cmpl(class_id_reg, Immediate(sorted[i].cid)); |
| 1399 if (is_last_check) { | 1405 if (is_last_check) { |
| 1400 assembler()->j(NOT_EQUAL, deopt); | 1406 assembler()->j(NOT_EQUAL, deopt); |
| 1401 } else { | 1407 } else { |
| 1402 assembler()->j(NOT_EQUAL, &next_test); | 1408 assembler()->j(NOT_EQUAL, &next_test); |
| 1403 } | 1409 } |
| 1404 GenerateStaticCall(deopt_id, | 1410 // Do not use the code from the function, but let the code be patched so |
| 1405 token_index, | 1411 // that we can record the outgoing edges to other code. |
| 1406 *sorted[i].target, | 1412 GenerateDartCall(deopt_id, |
| 1407 arg_count, | 1413 token_index, |
| 1408 arg_names, | 1414 &StubCode::CallStaticFunctionLabel(), |
| 1409 locs); | 1415 PcDescriptors::kFuncCall, |
| 1416 locs); |
| 1417 const Function& function = *sorted[i].target; |
| 1418 AddStaticCallTarget(function); |
| 1419 __ Drop(argument_count); |
| 1410 if (!is_last_check) { | 1420 if (!is_last_check) { |
| 1411 assembler()->jmp(&match_found); | 1421 assembler()->jmp(&match_found); |
| 1412 } | 1422 } |
| 1413 assembler()->Bind(&next_test); | 1423 assembler()->Bind(&next_test); |
| 1414 } | 1424 } |
| 1415 assembler()->Bind(&match_found); | 1425 assembler()->Bind(&match_found); |
| 1416 } | 1426 } |
| 1417 | 1427 |
| 1418 | 1428 |
| 1419 void FlowGraphCompiler::EmitDoubleCompareBranch(Condition true_condition, | 1429 void FlowGraphCompiler::EmitDoubleCompareBranch(Condition true_condition, |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1699 __ popl(ECX); | 1709 __ popl(ECX); |
| 1700 __ popl(EAX); | 1710 __ popl(EAX); |
| 1701 } | 1711 } |
| 1702 | 1712 |
| 1703 | 1713 |
| 1704 #undef __ | 1714 #undef __ |
| 1705 | 1715 |
| 1706 } // namespace dart | 1716 } // namespace dart |
| 1707 | 1717 |
| 1708 #endif // defined TARGET_ARCH_IA32 | 1718 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |