| 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" |
| 11 #include "vm/pages.h" | 11 #include "vm/pages.h" |
| 12 #include "vm/resolver.h" | 12 #include "vm/resolver.h" |
| 13 #include "vm/scavenger.h" | 13 #include "vm/scavenger.h" |
| 14 #include "vm/stub_code.h" | 14 #include "vm/stub_code.h" |
| 15 | 15 |
| 16 | 16 |
| 17 #define __ assembler-> | 17 #define __ assembler-> |
| 18 | 18 |
| 19 namespace dart { | 19 namespace dart { |
| 20 | 20 |
| 21 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); | 21 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); |
| 22 DEFINE_FLAG(bool, use_slow_path, false, | 22 DEFINE_FLAG(bool, use_slow_path, false, |
| 23 "Set to true for debugging & verifying the slow paths."); | 23 "Set to true for debugging & verifying the slow paths."); |
| 24 DECLARE_FLAG(int, optimization_counter_threshold); |
| 24 | 25 |
| 25 // Input parameters: | 26 // Input parameters: |
| 26 // RSP : points to return address. | 27 // RSP : points to return address. |
| 27 // RSP + 8 : address of last argument in argument array. | 28 // RSP + 8 : address of last argument in argument array. |
| 28 // RSP + 8*R10 : address of first argument in argument array. | 29 // RSP + 8*R10 : address of first argument in argument array. |
| 29 // RSP + 8*R10 + 8 : address of return value. | 30 // RSP + 8*R10 + 8 : address of return value. |
| 30 // RBX : address of the runtime function to call. | 31 // RBX : address of the runtime function to call. |
| 31 // R10 : number of arguments to the call. | 32 // R10 : number of arguments to the call. |
| 32 // Must preserve callee saved registers R12 and R13. | 33 // Must preserve callee saved registers R12 and R13. |
| 33 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { | 34 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 __ addq(RBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 246 __ addq(RBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 246 __ jmp(RBX); | 247 __ jmp(RBX); |
| 247 } | 248 } |
| 248 | 249 |
| 249 | 250 |
| 250 // Called from a static call only when an invalid code has been entered | 251 // Called from a static call only when an invalid code has been entered |
| 251 // (invalid because its function was optimized or deoptimized). | 252 // (invalid because its function was optimized or deoptimized). |
| 252 // RBX: function object. | 253 // RBX: function object. |
| 253 // R10: arguments descriptor array (num_args is first Smi element). | 254 // R10: arguments descriptor array (num_args is first Smi element). |
| 254 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { | 255 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { |
| 255 __ Untested("FixCallersTarget stub"); | |
| 256 __ EnterFrame(0); | 256 __ EnterFrame(0); |
| 257 __ pushq(R10); // Preserve arguments descriptor array. | 257 __ pushq(R10); // Preserve arguments descriptor array. |
| 258 __ pushq(RBX); // Preserve target function. | 258 __ pushq(RBX); // Preserve target function. |
| 259 __ pushq(RBX); // Target function. | 259 __ pushq(RBX); // Target function. |
| 260 __ CallRuntime(kFixCallersTargetRuntimeEntry); | 260 __ CallRuntime(kFixCallersTargetRuntimeEntry); |
| 261 __ popq(RAX); // discard argument. | 261 __ popq(RAX); // discard argument. |
| 262 __ popq(RAX); // Restore function. | 262 __ popq(RAX); // Restore function. |
| 263 __ popq(R10); // Restore arguments descriptor array. | 263 __ popq(R10); // Restore arguments descriptor array. |
| 264 __ movq(RAX, FieldAddress(RAX, Function::code_offset())); | 264 __ movq(RAX, FieldAddress(RAX, Function::code_offset())); |
| 265 __ movq(RAX, FieldAddress(RAX, Code::instructions_offset())); | 265 __ movq(RAX, FieldAddress(RAX, Code::instructions_offset())); |
| (...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 // TOS(0): return address | 1510 // TOS(0): return address |
| 1511 // Control flow: | 1511 // Control flow: |
| 1512 // - If receiver is null -> jump to IC miss. | 1512 // - If receiver is null -> jump to IC miss. |
| 1513 // - If receiver is Smi -> load Smi class. | 1513 // - If receiver is Smi -> load Smi class. |
| 1514 // - If receiver is not-Smi -> load receiver's class. | 1514 // - If receiver is not-Smi -> load receiver's class. |
| 1515 // - Check if 'num_args' (including receiver) match any IC data group. | 1515 // - Check if 'num_args' (including receiver) match any IC data group. |
| 1516 // - Match found -> jump to target. | 1516 // - Match found -> jump to target. |
| 1517 // - Match not found -> jump to IC miss. | 1517 // - Match not found -> jump to IC miss. |
| 1518 void StubCode::GenerateNArgsCheckInlineCacheStub(Assembler* assembler, | 1518 void StubCode::GenerateNArgsCheckInlineCacheStub(Assembler* assembler, |
| 1519 intptr_t num_args) { | 1519 intptr_t num_args) { |
| 1520 // TODO(srdjan): Add usage counter increment and test (see ia32). | 1520 __ movq(RCX, FieldAddress(RBX, ICData::function_offset())); |
| 1521 __ incq(FieldAddress(RCX, Function::usage_counter_offset())); |
| 1522 if (CodeGenerator::CanOptimize()) { |
| 1523 __ cmpq(FieldAddress(RCX, Function::usage_counter_offset()), |
| 1524 Immediate(FLAG_optimization_counter_threshold)); |
| 1525 Label not_yet_hot; |
| 1526 __ j(LESS_EQUAL, ¬_yet_hot, Assembler::kNearJump); |
| 1527 __ EnterFrame(0); |
| 1528 __ pushq(RBX); // Preserve inline cache data object. |
| 1529 __ pushq(R10); // Preserve arguments array. |
| 1530 __ pushq(RCX); // Argument for runtime: function object. |
| 1531 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); |
| 1532 __ popq(RCX); // Remove argument. |
| 1533 __ popq(R10); // Restore arguments array. |
| 1534 __ popq(RBX); // Restore inline cache data object. |
| 1535 __ LeaveFrame(); |
| 1536 __ Bind(¬_yet_hot); |
| 1537 } |
| 1521 ASSERT(num_args > 0); | 1538 ASSERT(num_args > 0); |
| 1522 // Get receiver (first read number of arguments from argument descriptor array | 1539 // Get receiver (first read number of arguments from argument descriptor array |
| 1523 // and then access the receiver from the stack). | 1540 // and then access the receiver from the stack). |
| 1524 __ movq(RAX, FieldAddress(R10, Array::data_offset())); | 1541 __ movq(RAX, FieldAddress(R10, Array::data_offset())); |
| 1525 __ movq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX (argument count) is Smi. | 1542 __ movq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX (argument count) is Smi. |
| 1526 | 1543 |
| 1527 Label get_class, ic_miss; | 1544 Label get_class, ic_miss; |
| 1528 __ call(&get_class); | 1545 __ call(&get_class); |
| 1529 // RAX: receiver's class | 1546 // RAX: receiver's class |
| 1530 // RBX: IC data array. | 1547 // RBX: IC data array. |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1732 __ Unimplemented("Subtype2TestCache Stub"); | 1749 __ Unimplemented("Subtype2TestCache Stub"); |
| 1733 } | 1750 } |
| 1734 | 1751 |
| 1735 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { | 1752 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { |
| 1736 __ Unimplemented("Subtype3TestCache Stub"); | 1753 __ Unimplemented("Subtype3TestCache Stub"); |
| 1737 } | 1754 } |
| 1738 | 1755 |
| 1739 } // namespace dart | 1756 } // namespace dart |
| 1740 | 1757 |
| 1741 #endif // defined TARGET_ARCH_X64 | 1758 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |