| 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" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1411 __ pushq(ic_reg); // Argument. | 1411 __ pushq(ic_reg); // Argument. |
| 1412 __ pushq(func_reg); // Argument. | 1412 __ pushq(func_reg); // Argument. |
| 1413 __ CallRuntime(kTraceICCallRuntimeEntry); | 1413 __ CallRuntime(kTraceICCallRuntimeEntry); |
| 1414 __ popq(RAX); // Discard argument; | 1414 __ popq(RAX); // Discard argument; |
| 1415 __ popq(RAX); // Discard argument; | 1415 __ popq(RAX); // Discard argument; |
| 1416 __ popq(ic_reg); // Restore. | 1416 __ popq(ic_reg); // Restore. |
| 1417 __ popq(argdesc_reg); // Restore. | 1417 __ popq(argdesc_reg); // Restore. |
| 1418 __ popq(func_reg); // Restore. | 1418 __ popq(func_reg); // Restore. |
| 1419 __ LeaveFrame(); | 1419 __ LeaveFrame(); |
| 1420 } | 1420 } |
| 1421 Label is_hot; | |
| 1422 if (FlowGraphCompiler::CanOptimize()) { | |
| 1423 ASSERT(FLAG_optimization_counter_threshold > 1); | |
| 1424 __ cmpq(FieldAddress(func_reg, Function::usage_counter_offset()), | |
| 1425 Immediate(FLAG_optimization_counter_threshold)); | |
| 1426 __ j(GREATER_EQUAL, &is_hot, Assembler::kNearJump); | |
| 1427 // As long as VM has no OSR do not optimize in the middle of the function | |
| 1428 // but only at exit so that we have collected all type feedback before | |
| 1429 // optimizing. | |
| 1430 } | |
| 1431 __ incq(FieldAddress(func_reg, Function::usage_counter_offset())); | 1421 __ incq(FieldAddress(func_reg, Function::usage_counter_offset())); |
| 1432 __ Bind(&is_hot); | |
| 1433 } | 1422 } |
| 1434 | 1423 |
| 1435 | 1424 |
| 1436 // Loads function into 'temp_reg', preserves 'ic_reg'. | 1425 // Loads function into 'temp_reg', preserves 'ic_reg'. |
| 1437 void StubCode::GenerateUsageCounterIncrement(Assembler* assembler, | 1426 void StubCode::GenerateUsageCounterIncrement(Assembler* assembler, |
| 1438 Register temp_reg) { | 1427 Register temp_reg) { |
| 1439 Register ic_reg = RBX; | 1428 Register ic_reg = RBX; |
| 1440 Register func_reg = temp_reg; | 1429 Register func_reg = temp_reg; |
| 1441 ASSERT(ic_reg != func_reg); | 1430 ASSERT(ic_reg != func_reg); |
| 1442 __ movq(func_reg, FieldAddress(ic_reg, ICData::function_offset())); | 1431 __ movq(func_reg, FieldAddress(ic_reg, ICData::function_offset())); |
| 1443 Label is_hot; | |
| 1444 if (FlowGraphCompiler::CanOptimize()) { | |
| 1445 ASSERT(FLAG_optimization_counter_threshold > 1); | |
| 1446 // The usage_counter is always less than FLAG_optimization_counter_threshold | |
| 1447 // except when the function gets optimized. | |
| 1448 __ cmpq(FieldAddress(func_reg, Function::usage_counter_offset()), | |
| 1449 Immediate(FLAG_optimization_counter_threshold)); | |
| 1450 __ j(EQUAL, &is_hot, Assembler::kNearJump); | |
| 1451 // As long as VM has no OSR do not optimize in the middle of the function | |
| 1452 // but only at exit so that we have collected all type feedback before | |
| 1453 // optimizing. | |
| 1454 } | |
| 1455 __ incq(FieldAddress(func_reg, Function::usage_counter_offset())); | 1432 __ incq(FieldAddress(func_reg, Function::usage_counter_offset())); |
| 1456 __ Bind(&is_hot); | |
| 1457 } | 1433 } |
| 1458 | 1434 |
| 1435 |
| 1459 // Generate inline cache check for 'num_args'. | 1436 // Generate inline cache check for 'num_args'. |
| 1460 // RBX: Inline cache data object. | 1437 // RBX: Inline cache data object. |
| 1461 // R10: Arguments descriptor array. | 1438 // R10: Arguments descriptor array. |
| 1462 // TOS(0): return address | 1439 // TOS(0): return address |
| 1463 // Control flow: | 1440 // Control flow: |
| 1464 // - If receiver is null -> jump to IC miss. | 1441 // - If receiver is null -> jump to IC miss. |
| 1465 // - If receiver is Smi -> load Smi class. | 1442 // - If receiver is Smi -> load Smi class. |
| 1466 // - If receiver is not-Smi -> load receiver's class. | 1443 // - If receiver is not-Smi -> load receiver's class. |
| 1467 // - Check if 'num_args' (including receiver) match any IC data group. | 1444 // - Check if 'num_args' (including receiver) match any IC data group. |
| 1468 // - Match found -> jump to target. | 1445 // - Match found -> jump to target. |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2101 __ cmpq(left, right); | 2078 __ cmpq(left, right); |
| 2102 __ Bind(&done); | 2079 __ Bind(&done); |
| 2103 __ popq(right); | 2080 __ popq(right); |
| 2104 __ popq(left); | 2081 __ popq(left); |
| 2105 __ ret(); | 2082 __ ret(); |
| 2106 } | 2083 } |
| 2107 | 2084 |
| 2108 } // namespace dart | 2085 } // namespace dart |
| 2109 | 2086 |
| 2110 #endif // defined TARGET_ARCH_X64 | 2087 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |