OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 5377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5388 if (new_length == 0) return heap->empty_fixed_array(); | 5388 if (new_length == 0) return heap->empty_fixed_array(); |
5389 Object* obj; | 5389 Object* obj; |
5390 { MaybeObject* maybe_obj = heap->AllocateFixedArray(new_length); | 5390 { MaybeObject* maybe_obj = heap->AllocateFixedArray(new_length); |
5391 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 5391 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
5392 } | 5392 } |
5393 FixedArray* result = FixedArray::cast(obj); | 5393 FixedArray* result = FixedArray::cast(obj); |
5394 // Copy the content | 5394 // Copy the content |
5395 AssertNoAllocation no_gc; | 5395 AssertNoAllocation no_gc; |
5396 int len = length(); | 5396 int len = length(); |
5397 if (new_length < len) len = new_length; | 5397 if (new_length < len) len = new_length; |
5398 result->set_map(map()); | 5398 // We are taking the map from the old fixed array so the map is sure to |
| 5399 // be an immortal immutable object. |
| 5400 result->set_map_unsafe(map()); |
5399 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); | 5401 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
5400 for (int i = 0; i < len; i++) { | 5402 for (int i = 0; i < len; i++) { |
5401 result->set(i, get(i), mode); | 5403 result->set(i, get(i), mode); |
5402 } | 5404 } |
5403 return result; | 5405 return result; |
5404 } | 5406 } |
5405 | 5407 |
5406 | 5408 |
5407 void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) { | 5409 void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) { |
5408 AssertNoAllocation no_gc; | 5410 AssertNoAllocation no_gc; |
(...skipping 2699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8108 PrintF("RelocInfo (size = %d)\n", relocation_size()); | 8110 PrintF("RelocInfo (size = %d)\n", relocation_size()); |
8109 for (RelocIterator it(this); !it.done(); it.next()) it.rinfo()->Print(out); | 8111 for (RelocIterator it(this); !it.done(); it.next()) it.rinfo()->Print(out); |
8110 PrintF(out, "\n"); | 8112 PrintF(out, "\n"); |
8111 } | 8113 } |
8112 #endif // ENABLE_DISASSEMBLER | 8114 #endif // ENABLE_DISASSEMBLER |
8113 | 8115 |
8114 | 8116 |
8115 static void CopyFastElementsToFast(FixedArray* source, | 8117 static void CopyFastElementsToFast(FixedArray* source, |
8116 FixedArray* destination, | 8118 FixedArray* destination, |
8117 WriteBarrierMode mode) { | 8119 WriteBarrierMode mode) { |
8118 uint32_t count = static_cast<uint32_t>(source->length()); | 8120 int count = source->length(); |
8119 for (uint32_t i = 0; i < count; ++i) { | 8121 if (mode == SKIP_WRITE_BARRIER || |
8120 destination->set(i, source->get(i), mode); | 8122 !Page::FromAddress(destination->address())->IsFlagSet( |
| 8123 MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING)) { |
| 8124 ASSERT(count <= destination->length()); |
| 8125 Address to = destination->address() + FixedArray::kHeaderSize; |
| 8126 Address from = source->address() + FixedArray::kHeaderSize; |
| 8127 memcpy(reinterpret_cast<void*>(to), |
| 8128 reinterpret_cast<void*>(from), |
| 8129 kPointerSize * count); |
| 8130 } else { |
| 8131 for (int i = 0; i < count; ++i) { |
| 8132 destination->set(i, source->get(i), mode); |
| 8133 } |
8121 } | 8134 } |
8122 } | 8135 } |
8123 | 8136 |
8124 | 8137 |
8125 static void CopySlowElementsToFast(NumberDictionary* source, | 8138 static void CopySlowElementsToFast(NumberDictionary* source, |
8126 FixedArray* destination, | 8139 FixedArray* destination, |
8127 WriteBarrierMode mode) { | 8140 WriteBarrierMode mode) { |
8128 for (int i = 0; i < source->Capacity(); ++i) { | 8141 for (int i = 0; i < source->Capacity(); ++i) { |
8129 Object* key = source->KeyAt(i); | 8142 Object* key = source->KeyAt(i); |
8130 if (key->IsNumber()) { | 8143 if (key->IsNumber()) { |
(...skipping 4381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12512 if (break_point_objects()->IsUndefined()) return 0; | 12525 if (break_point_objects()->IsUndefined()) return 0; |
12513 // Single break point. | 12526 // Single break point. |
12514 if (!break_point_objects()->IsFixedArray()) return 1; | 12527 if (!break_point_objects()->IsFixedArray()) return 1; |
12515 // Multiple break points. | 12528 // Multiple break points. |
12516 return FixedArray::cast(break_point_objects())->length(); | 12529 return FixedArray::cast(break_point_objects())->length(); |
12517 } | 12530 } |
12518 #endif // ENABLE_DEBUGGER_SUPPORT | 12531 #endif // ENABLE_DEBUGGER_SUPPORT |
12519 | 12532 |
12520 | 12533 |
12521 } } // namespace v8::internal | 12534 } } // namespace v8::internal |
OLD | NEW |