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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 // Sentinel is the undefined object, which is a root so it will not normally | 1516 // Sentinel is the undefined object, which is a root so it will not normally |
1517 // be found in the cache. | 1517 // be found in the cache. |
1518 if (cache->at(i)->IsUndefined()) break; | 1518 if (cache->at(i)->IsUndefined()) break; |
1519 } | 1519 } |
1520 } | 1520 } |
1521 | 1521 |
1522 | 1522 |
1523 int PartialSerializer::PartialSnapshotCacheIndex(HeapObject* heap_object) { | 1523 int PartialSerializer::PartialSnapshotCacheIndex(HeapObject* heap_object) { |
1524 Isolate* isolate = this->isolate(); | 1524 Isolate* isolate = this->isolate(); |
1525 List<Object*>* cache = isolate->partial_snapshot_cache(); | 1525 List<Object*>* cache = isolate->partial_snapshot_cache(); |
1526 for (int i = 0; i < cache->length(); ++i) { | 1526 int new_index = cache->length(); |
1527 Object* entry = cache->at(i); | 1527 |
1528 if (entry == heap_object) return i; | 1528 int index = partial_cache_index_map_.LookupOrInsert(heap_object, new_index); |
| 1529 if (index == PartialCacheIndexMap::kInvalidIndex) { |
| 1530 // We didn't find the object in the cache. So we add it to the cache and |
| 1531 // then visit the pointer so that it becomes part of the startup snapshot |
| 1532 // and we can refer to it from the partial snapshot. |
| 1533 cache->Add(heap_object); |
| 1534 startup_serializer_->VisitPointer(reinterpret_cast<Object**>(&heap_object)); |
| 1535 // We don't recurse from the startup snapshot generator into the partial |
| 1536 // snapshot generator. |
| 1537 return new_index; |
1529 } | 1538 } |
1530 | 1539 return index; |
1531 // We didn't find the object in the cache. So we add it to the cache and | |
1532 // then visit the pointer so that it becomes part of the startup snapshot | |
1533 // and we can refer to it from the partial snapshot. | |
1534 cache->Add(heap_object); | |
1535 startup_serializer_->VisitPointer(reinterpret_cast<Object**>(&heap_object)); | |
1536 // We don't recurse from the startup snapshot generator into the partial | |
1537 // snapshot generator. | |
1538 return cache->length() - 1; | |
1539 } | 1540 } |
1540 | 1541 |
1541 | 1542 |
1542 #ifdef DEBUG | 1543 #ifdef DEBUG |
1543 bool Serializer::BackReferenceIsAlreadyAllocated(BackReference reference) { | 1544 bool Serializer::BackReferenceIsAlreadyAllocated(BackReference reference) { |
1544 DCHECK(reference.is_valid()); | 1545 DCHECK(reference.is_valid()); |
1545 DCHECK(!reference.is_source()); | 1546 DCHECK(!reference.is_source()); |
1546 DCHECK(!reference.is_global_proxy()); | 1547 DCHECK(!reference.is_global_proxy()); |
1547 AllocationSpace space = reference.space(); | 1548 AllocationSpace space = reference.space(); |
1548 int chunk_index = reference.chunk_index(); | 1549 int chunk_index = reference.chunk_index(); |
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2663 DisallowHeapAllocation no_gc; | 2664 DisallowHeapAllocation no_gc; |
2664 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2665 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
2665 SanityCheckResult r = scd->SanityCheck(source); | 2666 SanityCheckResult r = scd->SanityCheck(source); |
2666 if (r == CHECK_SUCCESS) return scd; | 2667 if (r == CHECK_SUCCESS) return scd; |
2667 cached_data->Reject(); | 2668 cached_data->Reject(); |
2668 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2669 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
2669 delete scd; | 2670 delete scd; |
2670 return NULL; | 2671 return NULL; |
2671 } | 2672 } |
2672 } } // namespace v8::internal | 2673 } } // namespace v8::internal |
OLD | NEW |