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

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

Issue 502953002: Implement native _List. constructor in the flow-graph builder. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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/method_recognizer.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::ObjectArrayAllocate(Assembler* assembler) {
31 Label fall_through;
32 const intptr_t kTypeArgumentsOffset = 2 * kWordSize;
33 const intptr_t kLengthOffset = 1 * kWordSize;
34
35 __ movq(RDI, Address(RSP, kLengthOffset));
36
37 // Compute the size to be allocated, it is based on the array length
38 // and is computed as:
39 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
40 // Check that length is a positive Smi.
41 __ testq(RDI, Immediate(kSmiTagMask));
42 __ j(NOT_ZERO, &fall_through);
43 __ cmpq(RDI, Immediate(0));
44 __ j(LESS, &fall_through);
45 // Check for maximum allowed length.
46 const Immediate& max_len =
47 Immediate(reinterpret_cast<int64_t>(Smi::New(Array::kMaxElements)));
48 __ cmpq(RDI, max_len);
49 __ j(GREATER, &fall_through);
50 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
51 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi.
52 ASSERT(kSmiTagShift == 1);
53 __ andq(RDI, Immediate(-kObjectAlignment));
54
55 Isolate* isolate = Isolate::Current();
56 Heap* heap = isolate->heap();
57
58 __ movq(RAX, Immediate(heap->TopAddress()));
59 __ movq(RAX, Address(RAX, 0));
60
61 // RDI: allocation size.
62 __ movq(RCX, RAX);
63 __ addq(RCX, RDI);
64 __ j(CARRY, &fall_through);
65
66 // Check if the allocation fits into the remaining space.
67 // RAX: potential new object start.
68 // RCX: potential next object start.
69 // RDI: allocation size.
70 __ movq(R13, Immediate(heap->EndAddress()));
71 __ cmpq(RCX, Address(R13, 0));
72 __ j(ABOVE_EQUAL, &fall_through);
73
74 // Successfully allocated the object(s), now update top to point to
75 // next object start and initialize the object.
76 __ movq(R13, Immediate(heap->TopAddress()));
77 __ movq(Address(R13, 0), RCX);
78 __ addq(RAX, Immediate(kHeapObjectTag));
79 __ UpdateAllocationStatsWithSize(kArrayCid, RDI);
80 // Initialize the tags.
81 // RAX: new object start as a tagged pointer.
82 // RDI: allocation size.
83 {
84 Label size_tag_overflow, done;
85 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag));
86 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump);
87 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2));
88 __ jmp(&done, Assembler::kNearJump);
89
90 __ Bind(&size_tag_overflow);
91 __ movq(RDI, Immediate(0));
92 __ Bind(&done);
93
94 // Get the class index and insert it into the tags.
95 const Class& cls = Class::Handle(isolate->object_store()->array_class());
96 __ orq(RDI, Immediate(RawObject::ClassIdTag::encode(cls.id())));
97 __ movq(FieldAddress(RAX, Array::tags_offset()), RDI); // Tags.
98 }
99
100 // RAX: new object start as a tagged pointer.
101 // Store the type argument field.
102 __ movq(R13, Address(RSP, kTypeArgumentsOffset));
103 __ StoreIntoObjectNoBarrier(RAX,
104 FieldAddress(RAX, Array::type_arguments_offset()),
105 R13);
106
107 // Set the length field.
108 __ movq(RDI, Address(RSP, kLengthOffset));
109 __ StoreIntoObjectNoBarrier(RAX,
110 FieldAddress(RAX, Array::length_offset()),
111 RDI);
112
113 // Initialize all array elements to raw_null.
114 // RAX: new object start as a tagged pointer.
115 // RCX: new object end address.
116 // RDI: iterator which initially points to the start of the variable
117 // data area to be initialized.
118 __ LoadObject(R12, Object::null_object(), PP);
119 __ leaq(RDI, FieldAddress(RAX, sizeof(RawArray)));
120 Label done;
121 Label init_loop;
122 __ Bind(&init_loop);
123 __ cmpq(RDI, RCX);
124 __ j(ABOVE_EQUAL, &done, Assembler::kNearJump);
125 __ movq(Address(RDI, 0), R12);
126 __ addq(RDI, Immediate(kWordSize));
127 __ jmp(&init_loop, Assembler::kNearJump);
128 __ Bind(&done);
129 __ ret(); // returns the newly allocated object in RAX.
130
131 __ Bind(&fall_through);
132 }
133
134
135 void Intrinsifier::ObjectArrayLength(Assembler* assembler) { 30 void Intrinsifier::ObjectArrayLength(Assembler* assembler) {
136 __ movq(RAX, Address(RSP, + 1 * kWordSize)); 31 __ movq(RAX, Address(RSP, + 1 * kWordSize));
137 __ movq(RAX, FieldAddress(RAX, Array::length_offset())); 32 __ movq(RAX, FieldAddress(RAX, Array::length_offset()));
138 __ ret(); 33 __ ret();
139 } 34 }
140 35
141 36
142 void Intrinsifier::ImmutableArrayLength(Assembler* assembler) { 37 void Intrinsifier::ImmutableArrayLength(Assembler* assembler) {
143 ObjectArrayLength(assembler); 38 ObjectArrayLength(assembler);
144 } 39 }
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 // Set return value to Isolate::current_tag_. 1694 // Set return value to Isolate::current_tag_.
1800 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); 1695 __ movq(RAX, Address(RBX, Isolate::current_tag_offset()));
1801 __ ret(); 1696 __ ret();
1802 } 1697 }
1803 1698
1804 #undef __ 1699 #undef __
1805 1700
1806 } // namespace dart 1701 } // namespace dart
1807 1702
1808 #endif // defined TARGET_ARCH_X64 1703 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_mips.cc ('k') | runtime/vm/method_recognizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698