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

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

Issue 284013002: Improve performance of stubcode based array allocation moving stub to isolate specific area. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
« no previous file with comments | « runtime/vm/intrinsifier_mips.cc ('k') | runtime/vm/stub_code.h » ('j') | 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" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/intrinsifier.h" 8 #include "vm/intrinsifier.h"
9 9
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
11 #include "vm/flow_graph_compiler.h" 11 #include "vm/flow_graph_compiler.h"
12 #include "vm/instructions.h" 12 #include "vm/instructions.h"
13 #include "vm/object_store.h" 13 #include "vm/object_store.h"
14 #include "vm/symbols.h" 14 #include "vm/symbols.h"
15 15
16 namespace dart { 16 namespace dart {
17 17
18 DECLARE_FLAG(bool, enable_type_checks); 18 DECLARE_FLAG(bool, enable_type_checks);
19 19
20 // When entering intrinsics code: 20 // When entering intrinsics code:
21 // RBX: IC Data 21 // RBX: IC Data
22 // R10: Arguments descriptor 22 // R10: Arguments descriptor
23 // TOS: Return address 23 // TOS: Return address
24 // The RBX, R10 registers can be destroyed only if there is no slow-path (i.e., 24 // The RBX, R10 registers can be destroyed only if there is no slow-path (i.e.,
25 // the methods returns true). 25 // the methods returns true).
26 26
27 #define __ assembler-> 27 #define __ assembler->
28 28
29 29
30 void Intrinsifier::List_Allocate(Assembler* assembler) {
31 // This snippet of inlined code uses the following registers:
32 // RAX, RCX, RDI, R13
33 // and the newly allocated object is returned in RAX.
34 const intptr_t kTypeArgumentsOffset = 2 * kWordSize;
35 const intptr_t kArrayLengthOffset = 1 * kWordSize;
36 Label fall_through;
37
38 // Compute the size to be allocated, it is based on the array length
39 // and is computed as:
40 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
41 __ movq(RDI, Address(RSP, kArrayLengthOffset)); // Array Length.
42 // Check that length is a positive Smi.
43 __ testq(RDI, Immediate(kSmiTagMask));
44 __ j(NOT_ZERO, &fall_through);
45 __ cmpq(RDI, Immediate(0));
46 __ j(LESS, &fall_through);
47 // Check for maximum allowed length.
48 const Immediate& max_len =
49 Immediate(reinterpret_cast<int64_t>(Smi::New(Array::kMaxElements)));
50 __ cmpq(RDI, max_len);
51 __ j(GREATER, &fall_through);
52 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
53 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi.
54 ASSERT(kSmiTagShift == 1);
55 __ andq(RDI, Immediate(-kObjectAlignment));
56
57 Isolate* isolate = Isolate::Current();
58 Heap* heap = isolate->heap();
59
60 __ movq(RAX, Immediate(heap->TopAddress()));
61 __ movq(RAX, Address(RAX, 0));
62
63 // RDI: allocation size.
64 __ movq(RCX, RAX);
65 __ addq(RCX, RDI);
66 __ j(CARRY, &fall_through);
67
68 // Check if the allocation fits into the remaining space.
69 // RAX: potential new object start.
70 // RCX: potential next object start.
71 // RDI: allocation size.
72 __ movq(R13, Immediate(heap->EndAddress()));
73 __ cmpq(RCX, Address(R13, 0));
74 __ j(ABOVE_EQUAL, &fall_through);
75
76 // Successfully allocated the object(s), now update top to point to
77 // next object start and initialize the object.
78 __ movq(R13, Immediate(heap->TopAddress()));
79 __ movq(Address(R13, 0), RCX);
80 __ addq(RAX, Immediate(kHeapObjectTag));
81 __ UpdateAllocationStatsWithSize(kArrayCid, RDI);
82 // Initialize the tags.
83 // RAX: new object start as a tagged pointer.
84 // RDI: allocation size.
85 {
86 Label size_tag_overflow, done;
87 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag));
88 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump);
89 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2));
90 __ jmp(&done, Assembler::kNearJump);
91
92 __ Bind(&size_tag_overflow);
93 __ movq(RDI, Immediate(0));
94 __ Bind(&done);
95
96 // Get the class index and insert it into the tags.
97 const Class& cls = Class::Handle(isolate->object_store()->array_class());
98 __ orq(RDI, Immediate(RawObject::ClassIdTag::encode(cls.id())));
99 __ movq(FieldAddress(RAX, Array::tags_offset()), RDI); // Tags.
100 }
101
102 // RAX: new object start as a tagged pointer.
103 // Store the type argument field.
104 __ movq(RDI, Address(RSP, kTypeArgumentsOffset)); // type argument.
105 __ StoreIntoObjectNoBarrier(RAX,
106 FieldAddress(RAX, Array::type_arguments_offset()),
107 RDI);
108
109 // Set the length field.
110 __ movq(RDI, Address(RSP, kArrayLengthOffset)); // Array Length.
111 __ StoreIntoObjectNoBarrier(RAX,
112 FieldAddress(RAX, Array::length_offset()),
113 RDI);
114
115 // Initialize all array elements to raw_null.
116 // RAX: new object start as a tagged pointer.
117 // RCX: new object end address.
118 // RDI: iterator which initially points to the start of the variable
119 // data area to be initialized.
120 __ LoadObject(R12, Object::null_object(), PP);
121 __ leaq(RDI, FieldAddress(RAX, sizeof(RawArray)));
122 Label done;
123 Label init_loop;
124 __ Bind(&init_loop);
125 __ cmpq(RDI, RCX);
126 __ j(ABOVE_EQUAL, &done, Assembler::kNearJump);
127 __ movq(Address(RDI, 0), R12);
128 __ addq(RDI, Immediate(kWordSize));
129 __ jmp(&init_loop, Assembler::kNearJump);
130 __ Bind(&done);
131 __ ret(); // returns the newly allocated object in RAX.
132
133 __ Bind(&fall_through);
134 }
135
136
137 void Intrinsifier::Array_getLength(Assembler* assembler) { 30 void Intrinsifier::Array_getLength(Assembler* assembler) {
138 __ movq(RAX, Address(RSP, + 1 * kWordSize)); 31 __ movq(RAX, Address(RSP, + 1 * kWordSize));
139 __ movq(RAX, FieldAddress(RAX, Array::length_offset())); 32 __ movq(RAX, FieldAddress(RAX, Array::length_offset()));
140 __ ret(); 33 __ ret();
141 } 34 }
142 35
143 36
144 void Intrinsifier::ImmutableList_getLength(Assembler* assembler) { 37 void Intrinsifier::ImmutableList_getLength(Assembler* assembler) {
145 return Array_getLength(assembler); 38 return Array_getLength(assembler);
146 } 39 }
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 static ScaleFactor GetScaleFactor(intptr_t size) { 400 static ScaleFactor GetScaleFactor(intptr_t size) {
508 switch (size) { 401 switch (size) {
509 case 1: return TIMES_1; 402 case 1: return TIMES_1;
510 case 2: return TIMES_2; 403 case 2: return TIMES_2;
511 case 4: return TIMES_4; 404 case 4: return TIMES_4;
512 case 8: return TIMES_8; 405 case 8: return TIMES_8;
513 case 16: return TIMES_16; 406 case 16: return TIMES_16;
514 } 407 }
515 UNREACHABLE(); 408 UNREACHABLE();
516 return static_cast<ScaleFactor>(0); 409 return static_cast<ScaleFactor>(0);
517 }; 410 }
518 411
519 412
520 #define TYPED_DATA_ALLOCATOR(clazz) \ 413 #define TYPED_DATA_ALLOCATOR(clazz) \
521 void Intrinsifier::TypedData_##clazz##_new(Assembler* assembler) { \ 414 void Intrinsifier::TypedData_##clazz##_new(Assembler* assembler) { \
522 intptr_t size = TypedData::ElementSizeInBytes(kTypedData##clazz##Cid); \ 415 intptr_t size = TypedData::ElementSizeInBytes(kTypedData##clazz##Cid); \
523 intptr_t max_len = TypedData::MaxElements(kTypedData##clazz##Cid); \ 416 intptr_t max_len = TypedData::MaxElements(kTypedData##clazz##Cid); \
524 ScaleFactor scale = GetScaleFactor(size); \ 417 ScaleFactor scale = GetScaleFactor(size); \
525 TYPED_ARRAY_ALLOCATION(TypedData, kTypedData##clazz##Cid, max_len, scale); \ 418 TYPED_ARRAY_ALLOCATION(TypedData, kTypedData##clazz##Cid, max_len, scale); \
526 } \ 419 } \
527 void Intrinsifier::TypedData_##clazz##_factory(Assembler* assembler) { \ 420 void Intrinsifier::TypedData_##clazz##_factory(Assembler* assembler) { \
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 // Set return value to Isolate::current_tag_. 1584 // Set return value to Isolate::current_tag_.
1692 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); 1585 __ movq(RAX, Address(RBX, Isolate::current_tag_offset()));
1693 __ ret(); 1586 __ ret();
1694 } 1587 }
1695 1588
1696 #undef __ 1589 #undef __
1697 1590
1698 } // namespace dart 1591 } // namespace dart
1699 1592
1700 #endif // defined TARGET_ARCH_X64 1593 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_mips.cc ('k') | runtime/vm/stub_code.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698