| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
| (...skipping 2330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2341 table->ElementRemoved(); | 2341 table->ElementRemoved(); |
| 2342 } | 2342 } |
| 2343 } | 2343 } |
| 2344 } | 2344 } |
| 2345 | 2345 |
| 2346 | 2346 |
| 2347 void MarkCompactCollector::ClearNonLivePrototypeTransitions(Map* map) { | 2347 void MarkCompactCollector::ClearNonLivePrototypeTransitions(Map* map) { |
| 2348 int number_of_transitions = map->NumberOfProtoTransitions(); | 2348 int number_of_transitions = map->NumberOfProtoTransitions(); |
| 2349 FixedArray* prototype_transitions = map->GetPrototypeTransitions(); | 2349 FixedArray* prototype_transitions = map->GetPrototypeTransitions(); |
| 2350 | 2350 |
| 2351 const int header = Map::kProtoTransitionHeaderSize; |
| 2351 int new_number_of_transitions = 0; | 2352 int new_number_of_transitions = 0; |
| 2352 const int header = Map::kProtoTransitionHeaderSize; | |
| 2353 const int proto_offset = header + Map::kProtoTransitionPrototypeOffset; | |
| 2354 const int map_offset = header + Map::kProtoTransitionMapOffset; | |
| 2355 const int step = Map::kProtoTransitionElementsPerEntry; | |
| 2356 for (int i = 0; i < number_of_transitions; i++) { | 2353 for (int i = 0; i < number_of_transitions; i++) { |
| 2357 Object* prototype = prototype_transitions->get(proto_offset + i * step); | 2354 Object* cached_map = prototype_transitions->get(header + i); |
| 2358 Object* cached_map = prototype_transitions->get(map_offset + i * step); | 2355 if (IsMarked(cached_map)) { |
| 2359 if (IsMarked(prototype) && IsMarked(cached_map)) { | |
| 2360 DCHECK(!prototype->IsUndefined()); | |
| 2361 int proto_index = proto_offset + new_number_of_transitions * step; | |
| 2362 int map_index = map_offset + new_number_of_transitions * step; | |
| 2363 if (new_number_of_transitions != i) { | 2356 if (new_number_of_transitions != i) { |
| 2364 prototype_transitions->set(proto_index, prototype, | 2357 prototype_transitions->set(header + new_number_of_transitions, |
| 2365 UPDATE_WRITE_BARRIER); | 2358 cached_map, SKIP_WRITE_BARRIER); |
| 2366 prototype_transitions->set(map_index, cached_map, SKIP_WRITE_BARRIER); | |
| 2367 } | 2359 } |
| 2368 Object** slot = prototype_transitions->RawFieldOfElementAt(proto_index); | |
| 2369 RecordSlot(slot, slot, prototype); | |
| 2370 new_number_of_transitions++; | 2360 new_number_of_transitions++; |
| 2371 } | 2361 } |
| 2372 } | 2362 } |
| 2373 | 2363 |
| 2374 if (new_number_of_transitions != number_of_transitions) { | 2364 if (new_number_of_transitions != number_of_transitions) { |
| 2375 map->SetNumberOfProtoTransitions(new_number_of_transitions); | 2365 map->SetNumberOfProtoTransitions(new_number_of_transitions); |
| 2376 } | 2366 } |
| 2377 | 2367 |
| 2378 // Fill slots that became free with undefined value. | 2368 // Fill slots that became free with undefined value. |
| 2379 for (int i = new_number_of_transitions * step; | 2369 for (int i = new_number_of_transitions; i < number_of_transitions; i++) { |
| 2380 i < number_of_transitions * step; i++) { | |
| 2381 prototype_transitions->set_undefined(header + i); | 2370 prototype_transitions->set_undefined(header + i); |
| 2382 } | 2371 } |
| 2383 } | 2372 } |
| 2384 | 2373 |
| 2385 | 2374 |
| 2386 void MarkCompactCollector::ClearNonLiveMapTransitions(Map* map, | 2375 void MarkCompactCollector::ClearNonLiveMapTransitions(Map* map, |
| 2387 MarkBit map_mark) { | 2376 MarkBit map_mark) { |
| 2388 Object* potential_parent = map->GetBackPointer(); | 2377 Object* potential_parent = map->GetBackPointer(); |
| 2389 if (!potential_parent->IsMap()) return; | 2378 if (!potential_parent->IsMap()) return; |
| 2390 Map* parent = Map::cast(potential_parent); | 2379 Map* parent = Map::cast(potential_parent); |
| (...skipping 1936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4327 SlotsBuffer* buffer = *buffer_address; | 4316 SlotsBuffer* buffer = *buffer_address; |
| 4328 while (buffer != NULL) { | 4317 while (buffer != NULL) { |
| 4329 SlotsBuffer* next_buffer = buffer->next(); | 4318 SlotsBuffer* next_buffer = buffer->next(); |
| 4330 DeallocateBuffer(buffer); | 4319 DeallocateBuffer(buffer); |
| 4331 buffer = next_buffer; | 4320 buffer = next_buffer; |
| 4332 } | 4321 } |
| 4333 *buffer_address = NULL; | 4322 *buffer_address = NULL; |
| 4334 } | 4323 } |
| 4335 } | 4324 } |
| 4336 } // namespace v8::internal | 4325 } // namespace v8::internal |
| OLD | NEW |