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

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

Issue 1127453003: VM: Don't emit usage counter and range feedback code and when optimizations are disabled. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 7 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
« runtime/vm/stub_code_arm.cc ('K') | « runtime/vm/stub_code_mips.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "vm/flow_graph_compiler.h" 11 #include "vm/flow_graph_compiler.h"
12 #include "vm/heap.h" 12 #include "vm/heap.h"
13 #include "vm/instructions.h" 13 #include "vm/instructions.h"
14 #include "vm/object_store.h" 14 #include "vm/object_store.h"
15 #include "vm/resolver.h" 15 #include "vm/resolver.h"
16 #include "vm/scavenger.h" 16 #include "vm/scavenger.h"
17 #include "vm/stack_frame.h" 17 #include "vm/stack_frame.h"
18 #include "vm/stub_code.h" 18 #include "vm/stub_code.h"
19 #include "vm/tags.h" 19 #include "vm/tags.h"
20 20
21 #define __ assembler-> 21 #define __ assembler->
22 22
23 namespace dart { 23 namespace dart {
24 24
25 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); 25 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects.");
26 DEFINE_FLAG(bool, use_slow_path, false, 26 DEFINE_FLAG(bool, use_slow_path, false,
27 "Set to true for debugging & verifying the slow paths."); 27 "Set to true for debugging & verifying the slow paths.");
28 DECLARE_FLAG(bool, trace_optimized_ic_calls); 28 DECLARE_FLAG(bool, trace_optimized_ic_calls);
29 DECLARE_FLAG(int, optimization_counter_threshold);
29 30
30 // Input parameters: 31 // Input parameters:
31 // RSP : points to return address. 32 // RSP : points to return address.
32 // RSP + 8 : address of last argument in argument array. 33 // RSP + 8 : address of last argument in argument array.
33 // RSP + 8*R10 : address of first argument in argument array. 34 // RSP + 8*R10 : address of first argument in argument array.
34 // RSP + 8*R10 + 8 : address of return value. 35 // RSP + 8*R10 + 8 : address of return value.
35 // RBX : address of the runtime function to call. 36 // RBX : address of the runtime function to call.
36 // R10 : number of arguments to the call. 37 // R10 : number of arguments to the call.
37 // Must preserve callee saved registers R12 and R13. 38 // Must preserve callee saved registers R12 and R13.
38 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { 39 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) {
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 __ popq(func_reg); // Restore. 1208 __ popq(func_reg); // Restore.
1208 __ LeaveStubFrame(); 1209 __ LeaveStubFrame();
1209 } 1210 }
1210 __ incl(FieldAddress(func_reg, Function::usage_counter_offset())); 1211 __ incl(FieldAddress(func_reg, Function::usage_counter_offset()));
1211 } 1212 }
1212 1213
1213 1214
1214 // Loads function into 'temp_reg', preserves 'ic_reg'. 1215 // Loads function into 'temp_reg', preserves 'ic_reg'.
1215 void StubCode::GenerateUsageCounterIncrement(Assembler* assembler, 1216 void StubCode::GenerateUsageCounterIncrement(Assembler* assembler,
1216 Register temp_reg) { 1217 Register temp_reg) {
1217 Register ic_reg = RBX; 1218 if (FLAG_optimization_counter_threshold != -1) {
1218 Register func_reg = temp_reg; 1219 Register ic_reg = RBX;
1219 ASSERT(ic_reg != func_reg); 1220 Register func_reg = temp_reg;
1220 __ Comment("Increment function counter"); 1221 ASSERT(ic_reg != func_reg);
1221 __ movq(func_reg, FieldAddress(ic_reg, ICData::owner_offset())); 1222 __ Comment("Increment function counter");
1222 __ incl(FieldAddress(func_reg, Function::usage_counter_offset())); 1223 __ movq(func_reg, FieldAddress(ic_reg, ICData::owner_offset()));
1224 __ incl(FieldAddress(func_reg, Function::usage_counter_offset()));
1225 }
1223 } 1226 }
1224 1227
1225 1228
1226 // Note: RBX must be preserved. 1229 // Note: RBX must be preserved.
1227 // Attempt a quick Smi operation for known operations ('kind'). The ICData 1230 // Attempt a quick Smi operation for known operations ('kind'). The ICData
1228 // must have been primed with a Smi/Smi check that will be used for counting 1231 // must have been primed with a Smi/Smi check that will be used for counting
1229 // the invocations. 1232 // the invocations.
1230 static void EmitFastSmiOp(Assembler* assembler, 1233 static void EmitFastSmiOp(Assembler* assembler,
1231 Token::Kind kind, 1234 Token::Kind kind,
1232 intptr_t num_args, 1235 intptr_t num_args,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 Immediate(reinterpret_cast<intptr_t>(Smi::New(kSmiCid))); 1292 Immediate(reinterpret_cast<intptr_t>(Smi::New(kSmiCid)));
1290 __ cmpq(Address(R12, 0 * kWordSize), imm_smi_cid); 1293 __ cmpq(Address(R12, 0 * kWordSize), imm_smi_cid);
1291 __ j(NOT_EQUAL, &error, Assembler::kNearJump); 1294 __ j(NOT_EQUAL, &error, Assembler::kNearJump);
1292 __ cmpq(Address(R12, 1 * kWordSize), imm_smi_cid); 1295 __ cmpq(Address(R12, 1 * kWordSize), imm_smi_cid);
1293 __ j(EQUAL, &ok, Assembler::kNearJump); 1296 __ j(EQUAL, &ok, Assembler::kNearJump);
1294 __ Bind(&error); 1297 __ Bind(&error);
1295 __ Stop("Incorrect IC data"); 1298 __ Stop("Incorrect IC data");
1296 __ Bind(&ok); 1299 __ Bind(&ok);
1297 #endif 1300 #endif
1298 1301
1299 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; 1302 if (FLAG_optimization_counter_threshold != -1) {
1300 // Update counter. 1303 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize;
1301 __ movq(R8, Address(R12, count_offset)); 1304 // Update counter.
1302 __ addq(R8, Immediate(Smi::RawValue(1))); 1305 __ movq(R8, Address(R12, count_offset));
1303 __ movq(R9, Immediate(Smi::RawValue(Smi::kMaxValue))); 1306 __ addq(R8, Immediate(Smi::RawValue(1)));
1304 __ cmovnoq(R9, R8); 1307 __ movq(R9, Immediate(Smi::RawValue(Smi::kMaxValue)));
1305 __ StoreIntoSmiField(Address(R12, count_offset), R9); 1308 __ cmovnoq(R9, R8);
1309 __ StoreIntoSmiField(Address(R12, count_offset), R9);
1310 }
1306 1311
1307 __ ret(); 1312 __ ret();
1308 } 1313 }
1309 1314
1310 1315
1311 // Generate inline cache check for 'num_args'. 1316 // Generate inline cache check for 'num_args'.
1312 // RBX: Inline cache data object. 1317 // RBX: Inline cache data object.
1313 // TOS(0): return address 1318 // TOS(0): return address
1314 // Control flow: 1319 // Control flow:
1315 // - If receiver is null -> jump to IC miss. 1320 // - If receiver is null -> jump to IC miss.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 __ popq(RAX); 1451 __ popq(RAX);
1447 } 1452 }
1448 __ popq(RAX); // Pop returned function object into RAX. 1453 __ popq(RAX); // Pop returned function object into RAX.
1449 __ popq(RBX); // Restore IC data array. 1454 __ popq(RBX); // Restore IC data array.
1450 __ popq(R10); // Restore arguments descriptor array. 1455 __ popq(R10); // Restore arguments descriptor array.
1451 __ LeaveStubFrame(); 1456 __ LeaveStubFrame();
1452 Label call_target_function; 1457 Label call_target_function;
1453 __ jmp(&call_target_function); 1458 __ jmp(&call_target_function);
1454 1459
1455 __ Bind(&found); 1460 __ Bind(&found);
1456 __ Comment("Update caller's counter");
1457 // R12: Pointer to an IC data check group. 1461 // R12: Pointer to an IC data check group.
1458 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize; 1462 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize;
1459 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; 1463 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize;
1460 __ movq(RAX, Address(R12, target_offset)); 1464 __ movq(RAX, Address(R12, target_offset));
1461 1465
1462 // Update counter. 1466 if (FLAG_optimization_counter_threshold != -1) {
1463 __ movq(R8, Address(R12, count_offset)); 1467 // Update counter.
1464 __ addq(R8, Immediate(Smi::RawValue(1))); 1468 __ Comment("Update caller's counter");
1465 __ movq(R9, Immediate(Smi::RawValue(Smi::kMaxValue))); 1469 __ movq(R8, Address(R12, count_offset));
1466 __ cmovnoq(R9, R8); 1470 __ addq(R8, Immediate(Smi::RawValue(1)));
1467 __ StoreIntoSmiField(Address(R12, count_offset), R9); 1471 __ movq(R9, Immediate(Smi::RawValue(Smi::kMaxValue)));
1472 __ cmovnoq(R9, R8);
1473 __ StoreIntoSmiField(Address(R12, count_offset), R9);
1474 }
1468 1475
1469 __ Comment("Call target"); 1476 __ Comment("Call target");
1470 __ Bind(&call_target_function); 1477 __ Bind(&call_target_function);
1471 // RAX: Target function. 1478 // RAX: Target function.
1472 Label is_compiled; 1479 Label is_compiled;
1473 __ movq(RCX, FieldAddress(RAX, Function::instructions_offset())); 1480 __ movq(RCX, FieldAddress(RAX, Function::instructions_offset()));
1474 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); 1481 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
1475 if (range_collection_mode == kCollectRanges) { 1482 if (range_collection_mode == kCollectRanges) {
1476 __ movq(R8, Address(RSP, + 1 * kWordSize)); 1483 __ movq(R8, Address(RSP, + 1 * kWordSize));
1477 if (num_args == 2) { 1484 if (num_args == 2) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 __ Bind(&done_stepping); 1671 __ Bind(&done_stepping);
1665 1672
1666 // RBX: IC data object (preserved). 1673 // RBX: IC data object (preserved).
1667 __ movq(R12, FieldAddress(RBX, ICData::ic_data_offset())); 1674 __ movq(R12, FieldAddress(RBX, ICData::ic_data_offset()));
1668 // R12: ic_data_array with entries: target functions and count. 1675 // R12: ic_data_array with entries: target functions and count.
1669 __ leaq(R12, FieldAddress(R12, Array::data_offset())); 1676 __ leaq(R12, FieldAddress(R12, Array::data_offset()));
1670 // R12: points directly to the first ic data array element. 1677 // R12: points directly to the first ic data array element.
1671 const intptr_t target_offset = ICData::TargetIndexFor(0) * kWordSize; 1678 const intptr_t target_offset = ICData::TargetIndexFor(0) * kWordSize;
1672 const intptr_t count_offset = ICData::CountIndexFor(0) * kWordSize; 1679 const intptr_t count_offset = ICData::CountIndexFor(0) * kWordSize;
1673 1680
1674 // Increment count for this call. 1681 if (FLAG_optimization_counter_threshold != -1) {
1675 __ movq(R8, Address(R12, count_offset)); 1682 // Increment count for this call.
1676 __ addq(R8, Immediate(Smi::RawValue(1))); 1683 __ movq(R8, Address(R12, count_offset));
1677 __ movq(R9, Immediate(Smi::RawValue(Smi::kMaxValue))); 1684 __ addq(R8, Immediate(Smi::RawValue(1)));
1678 __ cmovnoq(R9, R8); 1685 __ movq(R9, Immediate(Smi::RawValue(Smi::kMaxValue)));
1679 __ StoreIntoSmiField(Address(R12, count_offset), R9); 1686 __ cmovnoq(R9, R8);
1687 __ StoreIntoSmiField(Address(R12, count_offset), R9);
1688 }
1680 1689
1681 // Load arguments descriptor into R10. 1690 // Load arguments descriptor into R10.
1682 __ movq(R10, FieldAddress(RBX, ICData::arguments_descriptor_offset())); 1691 __ movq(R10, FieldAddress(RBX, ICData::arguments_descriptor_offset()));
1683 1692
1684 // Get function and call it, if possible. 1693 // Get function and call it, if possible.
1685 __ movq(RAX, Address(R12, target_offset)); 1694 __ movq(RAX, Address(R12, target_offset));
1686 __ movq(RCX, FieldAddress(RAX, Function::instructions_offset())); 1695 __ movq(RCX, FieldAddress(RAX, Function::instructions_offset()));
1687 // RCX: Target instructions. 1696 // RCX: Target instructions.
1688 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); 1697 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
1689 __ jmp(RCX); 1698 __ jmp(RCX);
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 2108
2100 __ movq(left, Address(RSP, 2 * kWordSize)); 2109 __ movq(left, Address(RSP, 2 * kWordSize));
2101 __ movq(right, Address(RSP, 1 * kWordSize)); 2110 __ movq(right, Address(RSP, 1 * kWordSize));
2102 GenerateIdenticalWithNumberCheckStub(assembler, left, right); 2111 GenerateIdenticalWithNumberCheckStub(assembler, left, right);
2103 __ ret(); 2112 __ ret();
2104 } 2113 }
2105 2114
2106 } // namespace dart 2115 } // namespace dart
2107 2116
2108 #endif // defined TARGET_ARCH_X64 2117 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/stub_code_arm.cc ('K') | « runtime/vm/stub_code_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698