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

Side by Side Diff: vm/intrinsifier_ia32.cc

Issue 9072011: - Add a size field to the header. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 8 years, 11 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // The intrinsic code below is executed before a method has built its frame. 5 // The intrinsic code below is executed before a method has built its frame.
6 // The return address is on the stack and the arguments below it. 6 // The return address is on the stack and the arguments below it.
7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved.
8 // Each intrinsification method returns true if the corresponding 8 // Each intrinsification method returns true if the corresponding
9 // Dart method was intrinsified. 9 // Dart method was intrinsified.
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 const intptr_t kTypeArgumentsOffset = 2 * kWordSize; 91 const intptr_t kTypeArgumentsOffset = 2 * kWordSize;
92 const intptr_t kArrayLengthOffset = 1 * kWordSize; 92 const intptr_t kArrayLengthOffset = 1 * kWordSize;
93 Label fall_through; 93 Label fall_through;
94 94
95 // Compute the size to be allocated, it is based on the array length 95 // Compute the size to be allocated, it is based on the array length
96 // and it computed as: 96 // and it computed as:
97 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). 97 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
98 __ movl(EDI, Address(ESP, kArrayLengthOffset)); // Array Length. 98 __ movl(EDI, Address(ESP, kArrayLengthOffset)); // Array Length.
99 // Assert that length is a Smi. 99 // Assert that length is a Smi.
100 __ testl(EDI, Immediate(kSmiTagSize)); 100 __ testl(EDI, Immediate(kSmiTagSize));
101 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); 101 __ j(NOT_ZERO, &fall_through);
102 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; 102 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
103 __ leal(EDI, Address(EDI, TIMES_2, fixed_size)); // EDI is a Smi. 103 __ leal(EDI, Address(EDI, TIMES_2, fixed_size)); // EDI is a Smi.
104 ASSERT(kSmiTagShift == 1); 104 ASSERT(kSmiTagShift == 1);
105 __ andl(EDI, Immediate(-kObjectAlignment)); 105 __ andl(EDI, Immediate(-kObjectAlignment));
106 106
107 Heap* heap = Isolate::Current()->heap(); 107 Heap* heap = Isolate::Current()->heap();
108 108
109 // EDI: size to allocate. 109 // EDI: size to allocate.
110 __ movl(EAX, Address::Absolute(heap->TopAddress())); 110 __ movl(EAX, Address::Absolute(heap->TopAddress()));
111 __ leal(EBX, Address(EAX, EDI, TIMES_1, 0)); 111 __ leal(EBX, Address(EAX, EDI, TIMES_1, 0));
112 112
113 // Check if the allocation fits into the remaining space. 113 // Check if the allocation fits into the remaining space.
114 // EAX: potential new object start. 114 // EAX: potential new object start.
115 // EBX: potential next object start. 115 // EBX: potential next object start.
116 __ cmpl(EBX, Address::Absolute(heap->EndAddress())); 116 __ cmpl(EBX, Address::Absolute(heap->EndAddress()));
117 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); 117 __ j(ABOVE_EQUAL, &fall_through);
118 118
119 // Successfully allocated the object(s), now update top to point to 119 // Successfully allocated the object(s), now update top to point to
120 // next object start and initialize the object. 120 // next object start and initialize the object.
121 __ movl(Address::Absolute(heap->TopAddress()), EBX); 121 __ movl(Address::Absolute(heap->TopAddress()), EBX);
122 __ addl(EAX, Immediate(kHeapObjectTag)); 122 __ addl(EAX, Immediate(kHeapObjectTag));
123 123
124 // EAX: new object start as a tagged pointer. 124 // EAX: new object start as a tagged pointer.
125 // EBX: new object end address. 125 // EBX: new object end address.
126 // Store class value for array. 126 // Store class value for array.
127 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset())); 127 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset()));
128 __ movl(EDI, Address(EDI, Isolate::object_store_offset())); 128 __ movl(EDI, Address(EDI, Isolate::object_store_offset()));
129 __ movl(EDI, Address(EDI, ObjectStore::array_class_offset())); 129 __ movl(EDI, Address(EDI, ObjectStore::array_class_offset()));
130 __ StoreIntoObject(EAX, FieldAddress(EAX, Array::class_offset()), EDI); 130 __ StoreIntoObject(EAX, FieldAddress(EAX, Array::class_offset()), EDI);
131 131
132 // Initialize the tags. 132 // Initialize the tags.
133 __ movl(FieldAddress(EAX, Array::tags_offset()), Immediate(0)); 133 // EAX: new object start as a tagged pointer.
134 // EBX: new object end address.
135 {
136 Label size_tag_overflow, done;
137 __ movl(EDI, Address(ESP, kArrayLengthOffset)); // Array length.
138 __ leal(EDI, Address(EDI, TIMES_2, fixed_size)); // EDX is Smi.
siva 2012/01/04 01:56:03 EDI is Smi? Also if you moved this block of code
Ivan Posva 2012/01/04 07:59:42 Rearranged setting of class and tags to avoid reca
139 ASSERT(kSmiTagShift == 1);
140 __ andl(EDI, Immediate(-kObjectAlignment));
141 __ cmpl(EDI,
142 Immediate(RawObject::SizeTag::kMaxSizeTag));
siva 2012/01/04 01:56:03 Can this fit in one line?
Ivan Posva 2012/01/04 07:59:42 Done.
143 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump);
144 __ shll(EDI, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2));
145 __ movl(FieldAddress(EAX, Array::tags_offset()), EDI); // Tags.
146 __ jmp(&done);
147
148 __ Bind(&size_tag_overflow);
149 __ movl(FieldAddress(EAX, Array::tags_offset()), Immediate(0));
150 __ Bind(&done);
151 }
134 152
135 // Store the type argument field. 153 // Store the type argument field.
136 __ movl(EDI, Address(ESP, kTypeArgumentsOffset)); // type argument. 154 __ movl(EDI, Address(ESP, kTypeArgumentsOffset)); // type argument.
137 __ StoreIntoObject(EAX, 155 __ StoreIntoObject(EAX,
138 FieldAddress(EAX, Array::type_arguments_offset()), 156 FieldAddress(EAX, Array::type_arguments_offset()),
139 EDI); 157 EDI);
140 158
141 // Set the length field. 159 // Set the length field.
142 __ movl(EDI, Address(ESP, kArrayLengthOffset)); // Array Length. 160 __ movl(EDI, Address(ESP, kArrayLengthOffset)); // Array Length.
143 __ StoreIntoObject(EAX, FieldAddress(EAX, Array::length_offset()), EDI); 161 __ StoreIntoObject(EAX, FieldAddress(EAX, Array::length_offset()), EDI);
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 } \ 1063 } \
1046 1064
1047 INTRINSIC_LIST(FIND_INTRINSICS); 1065 INTRINSIC_LIST(FIND_INTRINSICS);
1048 #undef FIND_INTRINSICS 1066 #undef FIND_INTRINSICS
1049 return false; 1067 return false;
1050 } 1068 }
1051 1069
1052 } // namespace dart 1070 } // namespace dart
1053 1071
1054 #endif // defined TARGET_ARCH_IA32 1072 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698