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/snapshot/serialize.h" | 5 #include "src/snapshot/serialize.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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 | 594 |
595 DisallowHeapAllocation no_gc; | 595 DisallowHeapAllocation no_gc; |
596 // Keep track of the code space start and end pointers in case new | 596 // Keep track of the code space start and end pointers in case new |
597 // code objects were unserialized | 597 // code objects were unserialized |
598 OldSpace* code_space = isolate_->heap()->code_space(); | 598 OldSpace* code_space = isolate_->heap()->code_space(); |
599 Address start_address = code_space->top(); | 599 Address start_address = code_space->top(); |
600 Object* root; | 600 Object* root; |
601 VisitPointer(&root); | 601 VisitPointer(&root); |
602 DeserializeDeferredObjects(); | 602 DeserializeDeferredObjects(); |
603 | 603 |
| 604 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); |
| 605 |
604 // There's no code deserialized here. If this assert fires then that's | 606 // There's no code deserialized here. If this assert fires then that's |
605 // changed and logging should be added to notify the profiler et al of the | 607 // changed and logging should be added to notify the profiler et al of the |
606 // new code, which also has to be flushed from instruction cache. | 608 // new code, which also has to be flushed from instruction cache. |
607 CHECK_EQ(start_address, code_space->top()); | 609 CHECK_EQ(start_address, code_space->top()); |
608 return Handle<Object>(root, isolate); | 610 return Handle<Object>(root, isolate); |
609 } | 611 } |
610 | 612 |
611 | 613 |
612 MaybeHandle<SharedFunctionInfo> Deserializer::DeserializeCode( | 614 MaybeHandle<SharedFunctionInfo> Deserializer::DeserializeCode( |
613 Isolate* isolate) { | 615 Isolate* isolate) { |
614 Initialize(isolate); | 616 Initialize(isolate); |
615 if (!ReserveSpace()) { | 617 if (!ReserveSpace()) { |
616 return Handle<SharedFunctionInfo>(); | 618 return Handle<SharedFunctionInfo>(); |
617 } else { | 619 } else { |
618 deserializing_user_code_ = true; | 620 deserializing_user_code_ = true; |
619 HandleScope scope(isolate); | 621 HandleScope scope(isolate); |
620 Handle<SharedFunctionInfo> result; | 622 Handle<SharedFunctionInfo> result; |
621 { | 623 { |
622 DisallowHeapAllocation no_gc; | 624 DisallowHeapAllocation no_gc; |
623 Object* root; | 625 Object* root; |
624 VisitPointer(&root); | 626 VisitPointer(&root); |
625 DeserializeDeferredObjects(); | 627 DeserializeDeferredObjects(); |
626 FlushICacheForNewCodeObjects(); | 628 FlushICacheForNewCodeObjects(); |
627 result = Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(root)); | 629 result = Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(root)); |
628 } | 630 } |
629 CommitPostProcessedObjects(isolate); | 631 CommitPostProcessedObjects(isolate); |
| 632 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); |
630 return scope.CloseAndEscape(result); | 633 return scope.CloseAndEscape(result); |
631 } | 634 } |
632 } | 635 } |
633 | 636 |
634 | 637 |
635 Deserializer::~Deserializer() { | 638 Deserializer::~Deserializer() { |
636 // TODO(svenpanne) Re-enable this assertion when v8 initialization is fixed. | 639 // TODO(svenpanne) Re-enable this assertion when v8 initialization is fixed. |
637 // DCHECK(source_.AtEOF()); | 640 // DCHECK(source_.AtEOF()); |
638 attached_objects_.Dispose(); | 641 attached_objects_.Dispose(); |
639 } | 642 } |
(...skipping 2216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2856 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2859 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
2857 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2860 SanityCheckResult r = scd->SanityCheck(isolate, source); |
2858 if (r == CHECK_SUCCESS) return scd; | 2861 if (r == CHECK_SUCCESS) return scd; |
2859 cached_data->Reject(); | 2862 cached_data->Reject(); |
2860 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2863 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
2861 delete scd; | 2864 delete scd; |
2862 return NULL; | 2865 return NULL; |
2863 } | 2866 } |
2864 } // namespace internal | 2867 } // namespace internal |
2865 } // namespace v8 | 2868 } // namespace v8 |
OLD | NEW |