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

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

Issue 9395016: First part of new ICData infrastructure: use a wrapper object instead of an array. (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/ic_data.h"
11 #include "vm/object_store.h" 10 #include "vm/object_store.h"
12 #include "vm/pages.h" 11 #include "vm/pages.h"
13 #include "vm/resolver.h" 12 #include "vm/resolver.h"
14 #include "vm/scavenger.h" 13 #include "vm/scavenger.h"
15 #include "vm/stub_code.h" 14 #include "vm/stub_code.h"
16 15
17 16
18 #define __ assembler-> 17 #define __ assembler->
19 18
20 namespace dart { 19 namespace dart {
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // Iterate and search for identical name. 363 // Iterate and search for identical name.
365 __ leaq(R12, FieldAddress(RAX, Array::data_offset())); 364 __ leaq(R12, FieldAddress(RAX, Array::data_offset()));
366 365
367 // R12 is pointing into content of functions_map_ array. 366 // R12 is pointing into content of functions_map_ array.
368 __ Bind(&loop); 367 __ Bind(&loop);
369 __ movq(R13, Address(R12, FunctionsCache::kFunctionName * kWordSize)); 368 __ movq(R13, Address(R12, FunctionsCache::kFunctionName * kWordSize));
370 369
371 __ cmpq(R13, raw_null); 370 __ cmpq(R13, raw_null);
372 __ j(EQUAL, &not_found, Assembler::kNearJump); 371 __ j(EQUAL, &not_found, Assembler::kNearJump);
373 372
374 ASSERT(ICData::kNameIndex == 0); 373 __ cmpq(R13, FieldAddress(RBX, ICData::target_name_offset()));
375 __ cmpq(R13, FieldAddress(RBX, Array::data_offset()));
376 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); 374 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump);
377 375
378 // Name found, check total argument count and named argument count. 376 // Name found, check total argument count and named argument count.
379 __ movq(RAX, FieldAddress(R10, Array::data_offset())); 377 __ movq(RAX, FieldAddress(R10, Array::data_offset()));
380 // RAX is total argument count as Smi. 378 // RAX is total argument count as Smi.
381 __ movq(R13, Address(R12, FunctionsCache::kArgCount * kWordSize)); 379 __ movq(R13, Address(R12, FunctionsCache::kArgCount * kWordSize));
382 __ cmpq(RAX, R13); // Compare total argument counts. 380 __ cmpq(RAX, R13); // Compare total argument counts.
383 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); 381 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump);
384 __ subq(RAX, FieldAddress(R10, Array::data_offset() + kWordSize)); 382 __ subq(RAX, FieldAddress(R10, Array::data_offset() + kWordSize));
385 // RAX is named argument count as Smi. 383 // RAX is named argument count as Smi.
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 __ popq(RAX); // Get result into RAX. 1528 __ popq(RAX); // Get result into RAX.
1531 1529
1532 // Remove the stub frame as we are about to return. 1530 // Remove the stub frame as we are about to return.
1533 __ LeaveFrame(); 1531 __ LeaveFrame();
1534 __ ret(); 1532 __ ret();
1535 } 1533 }
1536 1534
1537 1535
1538 1536
1539 // Generate inline cache check for 'num_args'. 1537 // Generate inline cache check for 'num_args'.
1540 // RBX: Inline cache data array. 1538 // RBX: Inline cache data object.
1541 // R10: Arguments array. 1539 // R10: Arguments array.
1542 // TOS(0): return address 1540 // TOS(0): return address
1543 // Control flow: 1541 // Control flow:
1544 // - If receiver is null -> jump to IC miss. 1542 // - If receiver is null -> jump to IC miss.
1545 // - If receiver is Smi -> load Smi class. 1543 // - If receiver is Smi -> load Smi class.
1546 // - If receiver is not-Smi -> load receiver's class. 1544 // - If receiver is not-Smi -> load receiver's class.
1547 // - Check if 'num_args' (including receiver) match any IC data group. 1545 // - Check if 'num_args' (including receiver) match any IC data group.
1548 // - Match found -> jump to target. 1546 // - Match found -> jump to target.
1549 // - Match not found -> jump to IC miss. 1547 // - Match not found -> jump to IC miss.
1550 void StubCode::GenerateNArgsCheckInlineCacheStub(Assembler* assembler, 1548 void StubCode::GenerateNArgsCheckInlineCacheStub(Assembler* assembler,
1551 intptr_t num_args) { 1549 intptr_t num_args) {
1552 ASSERT(num_args > 0); 1550 ASSERT(num_args > 0);
1553 // Get receiver. 1551 // Get receiver.
1554 __ movq(RAX, FieldAddress(R10, Array::data_offset())); 1552 __ movq(RAX, FieldAddress(R10, Array::data_offset()));
1555 __ movq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX is Smi. 1553 __ movq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX (argument count) is Smi.
1556 1554
1557 Label get_class, ic_miss; 1555 Label get_class, ic_miss;
1558 __ call(&get_class); 1556 __ call(&get_class);
1559 // RAX: receiver's class 1557 // RAX: receiver's class
1560 // RBX: IC data array. 1558 // RBX: IC data array.
1561 1559
1562 #if defined(DEBUG) 1560 #if defined(DEBUG)
1563 { Label ok; 1561 { Label ok;
1564 // Check that the IC data array has NumberOfArgumentsChecked() == num_args. 1562 // Check that the IC data array has NumberOfArgumentsChecked() == num_args.
1565 __ movq(RCX, FieldAddress(RBX, 1563 // 'num_args_tested' is stored as an untagged int.
1566 Array::data_offset() + ICData::kNumArgsCheckedIndex * kWordSize)); 1564 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset()));
1567 const Immediate value = 1565 __ cmpq(RCX, Immediate(num_args));
1568 Immediate(reinterpret_cast<int64_t>(Smi::New(num_args)));
1569 __ cmpq(RCX, value);
1570 __ j(EQUAL, &ok, Assembler::kNearJump); 1566 __ j(EQUAL, &ok, Assembler::kNearJump);
1571 __ Stop("Incorrect stub for IC data"); 1567 __ Stop("Incorrect stub for IC data");
1572 __ Bind(&ok); 1568 __ Bind(&ok);
1573 } 1569 }
1574 #endif // DEBUG 1570 #endif // DEBUG
1575 1571
1576 // Loop that checks if there is an IC data match. 1572 // Loop that checks if there is an IC data match.
1577 // RAX: receiver's class. 1573 // RAX: receiver's class.
1578 // RBX: IC data array (preserved). 1574 // RBX: IC data object (preserved).
1579 __ leaq(R12, FieldAddress(RBX, 1575 __ movq(R12, FieldAddress(RBX, ICData::ic_data_offset()));
1580 Array::data_offset() + ICData::kChecksStartIndex * kWordSize)); 1576 // R12: ic_data_array with check entries: classes and target functions.
1581 // R12: pointing to a class to check against (into IC data array). 1577 __ leaq(R12, FieldAddress(R12, Array::data_offset()));
1578 // R12: points directly to the first ic data array element.
1582 const Immediate raw_null = 1579 const Immediate raw_null =
1583 Immediate(reinterpret_cast<intptr_t>(Object::null())); 1580 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1584 Label loop, found; 1581 Label loop, found;
1585 if (num_args == 1) { 1582 if (num_args == 1) {
1586 __ Bind(&loop); 1583 __ Bind(&loop);
1587 __ movq(R13, Address(R12, 0)); // Get class to check. 1584 __ movq(R13, Address(R12, 0)); // Get class to check.
1588 __ cmpq(RAX, R13); // Match? 1585 __ cmpq(RAX, R13); // Match?
1589 __ j(EQUAL, &found, Assembler::kNearJump); 1586 __ j(EQUAL, &found, Assembler::kNearJump);
1590 __ addq(R12, Immediate(kWordSize * 2)); // Next element (class + target). 1587 __ addq(R12, Immediate(kWordSize * 2)); // Next element (class + target).
1591 __ cmpq(R13, raw_null); // Done? 1588 __ cmpq(R13, raw_null); // Done?
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 __ popq(R10); 1727 __ popq(R10);
1731 __ popq(RBX); 1728 __ popq(RBX);
1732 __ LeaveFrame(); 1729 __ LeaveFrame();
1733 // Now call the dynamic function. 1730 // Now call the dynamic function.
1734 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); 1731 __ jmp(&StubCode::OneArgCheckInlineCacheLabel());
1735 } 1732 }
1736 1733
1737 } // namespace dart 1734 } // namespace dart
1738 1735
1739 #endif // defined TARGET_ARCH_X64 1736 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698