OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 | 139 |
140 | 140 |
141 static Failure* ThrowArrayLengthRangeError(Heap* heap) { | 141 static Failure* ThrowArrayLengthRangeError(Heap* heap) { |
142 HandleScope scope(heap->isolate()); | 142 HandleScope scope(heap->isolate()); |
143 return heap->isolate()->Throw( | 143 return heap->isolate()->Throw( |
144 *heap->isolate()->factory()->NewRangeError("invalid_array_length", | 144 *heap->isolate()->factory()->NewRangeError("invalid_array_length", |
145 HandleVector<Object>(NULL, 0))); | 145 HandleVector<Object>(NULL, 0))); |
146 } | 146 } |
147 | 147 |
148 | 148 |
149 void CopySmiToSmiElements(FixedArray* from, | |
150 uint32_t from_start, | |
151 FixedArray* to, | |
152 uint32_t to_start, | |
153 int copy_size) { | |
154 ASSERT(to->map() != HEAP->fixed_cow_array_map()); | |
155 ASSERT((copy_size + static_cast<int>(to_start)) <= to->length() && | |
156 (copy_size + static_cast<int>(from_start)) <= from->length()); | |
danno
2012/11/13 22:05:12
Please handle the hole here and handle the Element
Toon Verwaest
2012/11/14 11:53:13
Removed this function again now that I just use ac
| |
157 if (copy_size == 0) return; | |
158 Address to_address = to->address() + FixedArray::kHeaderSize; | |
159 Address from_address = from->address() + FixedArray::kHeaderSize; | |
160 CopyWords(reinterpret_cast<Object**>(to_address) + to_start, | |
161 reinterpret_cast<Object**>(from_address) + from_start, | |
162 copy_size); | |
163 } | |
164 | |
165 | |
149 void CopyObjectToObjectElements(FixedArray* from, | 166 void CopyObjectToObjectElements(FixedArray* from, |
150 ElementsKind from_kind, | 167 ElementsKind from_kind, |
151 uint32_t from_start, | 168 uint32_t from_start, |
152 FixedArray* to, | 169 FixedArray* to, |
153 ElementsKind to_kind, | 170 ElementsKind to_kind, |
154 uint32_t to_start, | 171 uint32_t to_start, |
155 int raw_copy_size) { | 172 int raw_copy_size) { |
156 ASSERT(to->map() != HEAP->fixed_cow_array_map()); | 173 ASSERT(to->map() != HEAP->fixed_cow_array_map()); |
157 int copy_size = raw_copy_size; | 174 int copy_size = raw_copy_size; |
158 if (raw_copy_size < 0) { | 175 if (raw_copy_size < 0) { |
159 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd || | 176 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd || |
160 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole); | 177 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole); |
161 copy_size = Min(from->length() - from_start, | 178 copy_size = Min(from->length() - from_start, |
162 to->length() - to_start); | 179 to->length() - to_start); |
163 #ifdef DEBUG | 180 #ifdef DEBUG |
164 // FAST_*_ELEMENTS arrays cannot be uninitialized. Ensure they are already | 181 // FAST_*_ELEMENTS arrays cannot be uninitialized. Ensure they are already |
165 // marked with the hole. | 182 // marked with the hole. |
166 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) { | 183 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) { |
danno
2012/11/13 22:05:12
If you take my suggestion from the header file, th
| |
167 for (int i = to_start + copy_size; i < to->length(); ++i) { | 184 for (int i = to_start + copy_size; i < to->length(); ++i) { |
168 ASSERT(to->get(i)->IsTheHole()); | 185 ASSERT(to->get(i)->IsTheHole()); |
169 } | 186 } |
170 } | 187 } |
171 #endif | 188 #endif |
172 } | 189 } |
173 ASSERT((copy_size + static_cast<int>(to_start)) <= to->length() && | 190 ASSERT((copy_size + static_cast<int>(to_start)) <= to->length() && |
174 (copy_size + static_cast<int>(from_start)) <= from->length()); | 191 (copy_size + static_cast<int>(from_start)) <= from->length()); |
175 if (copy_size == 0) return; | 192 if (copy_size == 0) return; |
176 ASSERT(IsFastSmiOrObjectElementsKind(from_kind)); | 193 ASSERT(IsFastSmiOrObjectElementsKind(from_kind)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 if (!heap->InNewSpace(to)) { | 253 if (!heap->InNewSpace(to)) { |
237 heap->RecordWrites(to->address(), | 254 heap->RecordWrites(to->address(), |
238 to->OffsetOfElementAt(to_start), | 255 to->OffsetOfElementAt(to_start), |
239 copy_size); | 256 copy_size); |
240 } | 257 } |
241 heap->incremental_marking()->RecordWrites(to); | 258 heap->incremental_marking()->RecordWrites(to); |
242 } | 259 } |
243 } | 260 } |
244 | 261 |
245 | 262 |
246 MUST_USE_RESULT static MaybeObject* CopyDoubleToObjectElements( | 263 MUST_USE_RESULT MaybeObject* CopyDoubleToObjectElements( |
247 FixedDoubleArray* from, | 264 FixedDoubleArray* from, |
248 uint32_t from_start, | 265 uint32_t from_start, |
249 FixedArray* to, | 266 FixedArray* to, |
250 ElementsKind to_kind, | 267 ElementsKind to_kind, |
251 uint32_t to_start, | 268 uint32_t to_start, |
252 int raw_copy_size) { | 269 int raw_copy_size) { |
253 ASSERT(IsFastSmiOrObjectElementsKind(to_kind)); | 270 ASSERT(IsFastSmiOrObjectElementsKind(to_kind)); |
254 int copy_size = raw_copy_size; | 271 int copy_size = raw_copy_size; |
255 if (raw_copy_size < 0) { | 272 if (raw_copy_size < 0) { |
256 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd || | 273 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd || |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 TENURED); | 308 TENURED); |
292 if (!maybe_value_object->ToObject(&value)) return maybe_value_object; | 309 if (!maybe_value_object->ToObject(&value)) return maybe_value_object; |
293 } | 310 } |
294 to->set(i + to_start, value, UPDATE_WRITE_BARRIER); | 311 to->set(i + to_start, value, UPDATE_WRITE_BARRIER); |
295 } | 312 } |
296 } | 313 } |
297 return to; | 314 return to; |
298 } | 315 } |
299 | 316 |
300 | 317 |
301 static void CopyDoubleToDoubleElements(FixedDoubleArray* from, | 318 void CopyDoubleToDoubleElements(FixedDoubleArray* from, |
302 uint32_t from_start, | 319 uint32_t from_start, |
303 FixedDoubleArray* to, | 320 FixedDoubleArray* to, |
304 uint32_t to_start, | 321 uint32_t to_start, |
305 int raw_copy_size) { | 322 int raw_copy_size) { |
306 int copy_size = raw_copy_size; | 323 int copy_size = raw_copy_size; |
307 if (raw_copy_size < 0) { | 324 if (raw_copy_size < 0) { |
308 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd || | 325 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd || |
309 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole); | 326 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole); |
310 copy_size = Min(from->length() - from_start, | 327 copy_size = Min(from->length() - from_start, |
311 to->length() - to_start); | 328 to->length() - to_start); |
(...skipping 10 matching lines...) Expand all Loading... | |
322 Address from_address = from->address() + FixedDoubleArray::kHeaderSize; | 339 Address from_address = from->address() + FixedDoubleArray::kHeaderSize; |
323 to_address += kDoubleSize * to_start; | 340 to_address += kDoubleSize * to_start; |
324 from_address += kDoubleSize * from_start; | 341 from_address += kDoubleSize * from_start; |
325 int words_per_double = (kDoubleSize / kPointerSize); | 342 int words_per_double = (kDoubleSize / kPointerSize); |
326 CopyWords(reinterpret_cast<Object**>(to_address), | 343 CopyWords(reinterpret_cast<Object**>(to_address), |
327 reinterpret_cast<Object**>(from_address), | 344 reinterpret_cast<Object**>(from_address), |
328 words_per_double * copy_size); | 345 words_per_double * copy_size); |
329 } | 346 } |
330 | 347 |
331 | 348 |
332 static void CopySmiToDoubleElements(FixedArray* from, | 349 void CopySmiToDoubleElements(FixedArray* from, |
333 uint32_t from_start, | 350 uint32_t from_start, |
334 FixedDoubleArray* to, | 351 FixedDoubleArray* to, |
335 uint32_t to_start, | 352 uint32_t to_start, |
336 int raw_copy_size) { | 353 int raw_copy_size) { |
337 int copy_size = raw_copy_size; | 354 int copy_size = raw_copy_size; |
338 if (raw_copy_size < 0) { | 355 if (raw_copy_size < 0) { |
339 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd || | 356 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd || |
340 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole); | 357 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole); |
341 copy_size = from->length() - from_start; | 358 copy_size = from->length() - from_start; |
342 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) { | 359 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) { |
343 for (int i = to_start + copy_size; i < to->length(); ++i) { | 360 for (int i = to_start + copy_size; i < to->length(); ++i) { |
344 to->set_the_hole(i); | 361 to->set_the_hole(i); |
345 } | 362 } |
346 } | 363 } |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1747 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; | 1764 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; |
1748 new_backing_store->set(0, length); | 1765 new_backing_store->set(0, length); |
1749 { MaybeObject* result = array->SetContent(new_backing_store); | 1766 { MaybeObject* result = array->SetContent(new_backing_store); |
1750 if (result->IsFailure()) return result; | 1767 if (result->IsFailure()) return result; |
1751 } | 1768 } |
1752 return array; | 1769 return array; |
1753 } | 1770 } |
1754 | 1771 |
1755 | 1772 |
1756 } } // namespace v8::internal | 1773 } } // namespace v8::internal |
OLD | NEW |