Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: runtime/vm/stub_code_x64.cc

Issue 9460015: Do not count invocations but usage of a function, i.e., increment a function's counter at IC calls … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 // R10: Arguments array. 1516 // R10: Arguments array.
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) {
regis 2012/02/24 23:56:25 How about adding a TODO to check the usage counter
srdjan 2012/02/25 00:22:10 Done.
1550 ASSERT(num_args > 0); 1527 ASSERT(num_args > 0);
1551 // Get receiver. 1528 // Get receiver.
1552 __ movq(RAX, FieldAddress(R10, Array::data_offset())); 1529 __ movq(RAX, FieldAddress(R10, Array::data_offset()));
1553 __ movq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX (argument count) is Smi. 1530 __ movq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX (argument count) is Smi.
1554 1531
1555 Label get_class, ic_miss; 1532 Label get_class, ic_miss;
1556 __ call(&get_class); 1533 __ call(&get_class);
1557 // RAX: receiver's class 1534 // RAX: receiver's class
1558 // RBX: IC data array. 1535 // RBX: IC data array.
1559 1536
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 __ popq(R10); 1704 __ popq(R10);
1728 __ popq(RBX); 1705 __ popq(RBX);
1729 __ LeaveFrame(); 1706 __ LeaveFrame();
1730 // Now call the dynamic function. 1707 // Now call the dynamic function.
1731 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); 1708 __ jmp(&StubCode::OneArgCheckInlineCacheLabel());
1732 } 1709 }
1733 1710
1734 } // namespace dart 1711 } // namespace dart
1735 1712
1736 #endif // defined TARGET_ARCH_X64 1713 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698