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" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // Remove the stub frame as we are about to jump to the dart function. | 266 // Remove the stub frame as we are about to jump to the dart function. |
267 __ LeaveFrame(); | 267 __ LeaveFrame(); |
268 __ movq(RAX, FieldAddress(RBX, Function::code_offset())); | 268 __ movq(RAX, FieldAddress(RBX, Function::code_offset())); |
269 | 269 |
270 __ movq(RBX, FieldAddress(RAX, Code::instructions_offset())); | 270 __ movq(RBX, FieldAddress(RAX, Code::instructions_offset())); |
271 __ addq(RBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 271 __ addq(RBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
272 __ jmp(RBX); | 272 __ jmp(RBX); |
273 } | 273 } |
274 | 274 |
275 | 275 |
276 // Called when number of invocations exceeds | |
277 // --optimization_invocation_threshold. | |
278 // RAX: target function. | |
279 // R10: arguments descriptor array (num_args is first Smi element). | |
280 void StubCode::GenerateOptimizeInvokedFunctionStub(Assembler* assembler) { | |
281 __ Untested("OptimizeInvokedFunction stub"); | |
282 __ EnterFrame(0); | |
283 __ pushq(R10); // Preserve arguments descriptor array. | |
284 __ pushq(RAX); // Preserve target function. | |
285 __ pushq(RAX); // Target function. | |
286 __ CallRuntimeFromStub(kOptimizeInvokedFunctionRuntimeEntry); | |
287 __ popq(RAX); // discard argument. | |
288 __ popq(RAX); // Restore function. | |
289 __ popq(R10); // Restore arguments descriptor array. | |
290 __ movq(RAX, FieldAddress(RAX, Function::code_offset())); | |
291 __ movq(RAX, FieldAddress(RAX, Code::instructions_offset())); | |
292 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | |
293 __ LeaveFrame(); | |
294 __ jmp(RAX); | |
295 __ int3(); | |
296 } | |
297 | |
298 | |
299 // Called from a static call only when an invalid code has been entered | 276 // Called from a static call only when an invalid code has been entered |
300 // (invalid because its function was optimized or deoptimized). | 277 // (invalid because its function was optimized or deoptimized). |
301 // RBX: function object. | 278 // RBX: function object. |
302 // R10: arguments descriptor array (num_args is first Smi element). | 279 // R10: arguments descriptor array (num_args is first Smi element). |
303 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { | 280 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { |
304 __ Untested("FixCallersTarget stub"); | 281 __ Untested("FixCallersTarget stub"); |
305 __ EnterFrame(0); | 282 __ EnterFrame(0); |
306 __ pushq(R10); // Preserve arguments descriptor array. | 283 __ pushq(R10); // Preserve arguments descriptor array. |
307 __ pushq(RBX); // Preserve target function. | 284 __ pushq(RBX); // Preserve target function. |
308 __ pushq(RBX); // Target function. | 285 __ pushq(RBX); // Target function. |
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 // TOS(0): return address | 1517 // TOS(0): return address |
1541 // Control flow: | 1518 // Control flow: |
1542 // - If receiver is null -> jump to IC miss. | 1519 // - If receiver is null -> jump to IC miss. |
1543 // - If receiver is Smi -> load Smi class. | 1520 // - If receiver is Smi -> load Smi class. |
1544 // - If receiver is not-Smi -> load receiver's class. | 1521 // - If receiver is not-Smi -> load receiver's class. |
1545 // - Check if 'num_args' (including receiver) match any IC data group. | 1522 // - Check if 'num_args' (including receiver) match any IC data group. |
1546 // - Match found -> jump to target. | 1523 // - Match found -> jump to target. |
1547 // - Match not found -> jump to IC miss. | 1524 // - Match not found -> jump to IC miss. |
1548 void StubCode::GenerateNArgsCheckInlineCacheStub(Assembler* assembler, | 1525 void StubCode::GenerateNArgsCheckInlineCacheStub(Assembler* assembler, |
1549 intptr_t num_args) { | 1526 intptr_t num_args) { |
| 1527 // TODO(srdjan): Add usage counter increment and test (see ia32). |
1550 ASSERT(num_args > 0); | 1528 ASSERT(num_args > 0); |
1551 // Get receiver. | 1529 // Get receiver. |
1552 __ movq(RAX, FieldAddress(R10, Array::data_offset())); | 1530 __ movq(RAX, FieldAddress(R10, Array::data_offset())); |
1553 __ movq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX (argument count) is Smi. | 1531 __ movq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX (argument count) is Smi. |
1554 | 1532 |
1555 Label get_class, ic_miss; | 1533 Label get_class, ic_miss; |
1556 __ call(&get_class); | 1534 __ call(&get_class); |
1557 // RAX: receiver's class | 1535 // RAX: receiver's class |
1558 // RBX: IC data array. | 1536 // RBX: IC data array. |
1559 | 1537 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 __ popq(R10); | 1705 __ popq(R10); |
1728 __ popq(RBX); | 1706 __ popq(RBX); |
1729 __ LeaveFrame(); | 1707 __ LeaveFrame(); |
1730 // Now call the dynamic function. | 1708 // Now call the dynamic function. |
1731 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); | 1709 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); |
1732 } | 1710 } |
1733 | 1711 |
1734 } // namespace dart | 1712 } // namespace dart |
1735 | 1713 |
1736 #endif // defined TARGET_ARCH_X64 | 1714 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |