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 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 __ incq(FieldAddress(func_reg, Function::usage_counter_offset())); | 1206 __ incq(FieldAddress(func_reg, Function::usage_counter_offset())); |
1207 } | 1207 } |
1208 | 1208 |
1209 | 1209 |
1210 // Loads function into 'temp_reg', preserves 'ic_reg'. | 1210 // Loads function into 'temp_reg', preserves 'ic_reg'. |
1211 void StubCode::GenerateUsageCounterIncrement(Assembler* assembler, | 1211 void StubCode::GenerateUsageCounterIncrement(Assembler* assembler, |
1212 Register temp_reg) { | 1212 Register temp_reg) { |
1213 Register ic_reg = RBX; | 1213 Register ic_reg = RBX; |
1214 Register func_reg = temp_reg; | 1214 Register func_reg = temp_reg; |
1215 ASSERT(ic_reg != func_reg); | 1215 ASSERT(ic_reg != func_reg); |
1216 __ movq(func_reg, FieldAddress(ic_reg, ICData::function_offset())); | 1216 __ movq(func_reg, FieldAddress(ic_reg, ICData::owner_offset())); |
1217 __ incq(FieldAddress(func_reg, Function::usage_counter_offset())); | 1217 __ incq(FieldAddress(func_reg, Function::usage_counter_offset())); |
1218 } | 1218 } |
1219 | 1219 |
1220 | 1220 |
1221 // Generate inline cache check for 'num_args'. | 1221 // Generate inline cache check for 'num_args'. |
1222 // RBX: Inline cache data object. | 1222 // RBX: Inline cache data object. |
1223 // TOS(0): return address | 1223 // TOS(0): return address |
1224 // Control flow: | 1224 // Control flow: |
1225 // - If receiver is null -> jump to IC miss. | 1225 // - If receiver is null -> jump to IC miss. |
1226 // - If receiver is Smi -> load Smi class. | 1226 // - If receiver is Smi -> load Smi class. |
1227 // - If receiver is not-Smi -> load receiver's class. | 1227 // - If receiver is not-Smi -> load receiver's class. |
1228 // - Check if 'num_args' (including receiver) match any IC data group. | 1228 // - Check if 'num_args' (including receiver) match any IC data group. |
1229 // - Match found -> jump to target. | 1229 // - Match found -> jump to target. |
1230 // - Match not found -> jump to IC miss. | 1230 // - Match not found -> jump to IC miss. |
1231 void StubCode::GenerateNArgsCheckInlineCacheStub( | 1231 void StubCode::GenerateNArgsCheckInlineCacheStub( |
1232 Assembler* assembler, | 1232 Assembler* assembler, |
1233 intptr_t num_args, | 1233 intptr_t num_args, |
1234 const RuntimeEntry& handle_ic_miss) { | 1234 const RuntimeEntry& handle_ic_miss) { |
1235 ASSERT(num_args > 0); | 1235 ASSERT(num_args > 0); |
1236 #if defined(DEBUG) | 1236 #if defined(DEBUG) |
1237 { Label ok; | 1237 { Label ok; |
1238 // Check that the IC data array has NumberOfArgumentsChecked() == num_args. | 1238 // Check that the IC data array has NumArgsTested() == num_args. |
1239 // 'num_args_tested' is stored as an untagged int. | 1239 // 'NumArgsTested' is stored in the least significant bits of 'state_bits'. |
1240 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset())); | 1240 __ movl(RCX, FieldAddress(RBX, ICData::state_bits_offset())); |
| 1241 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. |
| 1242 __ andq(RCX, Immediate(ICData::NumArgsTestedMask())); |
1241 __ cmpq(RCX, Immediate(num_args)); | 1243 __ cmpq(RCX, Immediate(num_args)); |
1242 __ j(EQUAL, &ok, Assembler::kNearJump); | 1244 __ j(EQUAL, &ok, Assembler::kNearJump); |
1243 __ Stop("Incorrect stub for IC data"); | 1245 __ Stop("Incorrect stub for IC data"); |
1244 __ Bind(&ok); | 1246 __ Bind(&ok); |
1245 } | 1247 } |
1246 #endif // DEBUG | 1248 #endif // DEBUG |
1247 | 1249 |
1248 // Check single stepping. | 1250 // Check single stepping. |
1249 Label not_stepping; | 1251 Label not_stepping; |
1250 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); | 1252 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 } | 1455 } |
1454 | 1456 |
1455 | 1457 |
1456 // Intermediary stub between a static call and its target. ICData contains | 1458 // Intermediary stub between a static call and its target. ICData contains |
1457 // the target function and the call count. | 1459 // the target function and the call count. |
1458 // RBX: ICData | 1460 // RBX: ICData |
1459 void StubCode::GenerateZeroArgsUnoptimizedStaticCallStub(Assembler* assembler) { | 1461 void StubCode::GenerateZeroArgsUnoptimizedStaticCallStub(Assembler* assembler) { |
1460 GenerateUsageCounterIncrement(assembler, RCX); | 1462 GenerateUsageCounterIncrement(assembler, RCX); |
1461 #if defined(DEBUG) | 1463 #if defined(DEBUG) |
1462 { Label ok; | 1464 { Label ok; |
1463 // Check that the IC data array has NumberOfArgumentsChecked() == 0. | 1465 // Check that the IC data array has NumArgsTested() == 0. |
1464 // 'num_args_tested' is stored as an untagged int. | 1466 // 'NumArgsTested' is stored in the least significant bits of 'state_bits'. |
1465 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset())); | 1467 __ movl(RCX, FieldAddress(RBX, ICData::state_bits_offset())); |
| 1468 ASSERT(ICData::NumArgsTestedShift() == 0); // No shift needed. |
| 1469 __ andq(RCX, Immediate(ICData::NumArgsTestedMask())); |
1466 __ cmpq(RCX, Immediate(0)); | 1470 __ cmpq(RCX, Immediate(0)); |
1467 __ j(EQUAL, &ok, Assembler::kNearJump); | 1471 __ j(EQUAL, &ok, Assembler::kNearJump); |
1468 __ Stop("Incorrect IC data for unoptimized static call"); | 1472 __ Stop("Incorrect IC data for unoptimized static call"); |
1469 __ Bind(&ok); | 1473 __ Bind(&ok); |
1470 } | 1474 } |
1471 #endif // DEBUG | 1475 #endif // DEBUG |
1472 | 1476 |
1473 // Check single stepping. | 1477 // Check single stepping. |
1474 Label not_stepping; | 1478 Label not_stepping; |
1475 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); | 1479 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 | 1845 |
1842 __ movq(left, Address(RSP, 2 * kWordSize)); | 1846 __ movq(left, Address(RSP, 2 * kWordSize)); |
1843 __ movq(right, Address(RSP, 1 * kWordSize)); | 1847 __ movq(right, Address(RSP, 1 * kWordSize)); |
1844 GenerateIdenticalWithNumberCheckStub(assembler, left, right); | 1848 GenerateIdenticalWithNumberCheckStub(assembler, left, right); |
1845 __ ret(); | 1849 __ ret(); |
1846 } | 1850 } |
1847 | 1851 |
1848 } // namespace dart | 1852 } // namespace dart |
1849 | 1853 |
1850 #endif // defined TARGET_ARCH_X64 | 1854 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |