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 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 } | 804 } |
805 | 805 |
806 | 806 |
807 Deserializer::~Deserializer() { | 807 Deserializer::~Deserializer() { |
808 // TODO(svenpanne) Re-enable this assertion when v8 initialization is fixed. | 808 // TODO(svenpanne) Re-enable this assertion when v8 initialization is fixed. |
809 // ASSERT(source_->AtEOF()); | 809 // ASSERT(source_->AtEOF()); |
810 if (external_reference_decoder_) { | 810 if (external_reference_decoder_) { |
811 delete external_reference_decoder_; | 811 delete external_reference_decoder_; |
812 external_reference_decoder_ = NULL; | 812 external_reference_decoder_ = NULL; |
813 } | 813 } |
| 814 if (attached_objects_) attached_objects_->Dispose(); |
814 } | 815 } |
815 | 816 |
816 | 817 |
817 // This is called on the roots. It is the driver of the deserialization | 818 // This is called on the roots. It is the driver of the deserialization |
818 // process. It is also called on the body of each function. | 819 // process. It is also called on the body of each function. |
819 void Deserializer::VisitPointers(Object** start, Object** end) { | 820 void Deserializer::VisitPointers(Object** start, Object** end) { |
820 // The space must be new space. Any other space would cause ReadChunk to try | 821 // The space must be new space. Any other space would cause ReadChunk to try |
821 // to update the remembered using NULL as the address. | 822 // to update the remembered using NULL as the address. |
822 ReadChunk(start, end, NEW_SPACE, NULL); | 823 ReadChunk(start, end, NEW_SPACE, NULL); |
823 } | 824 } |
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 SnapshotByteSource payload(scd.Payload(), scd.PayloadLength()); | 1997 SnapshotByteSource payload(scd.Payload(), scd.PayloadLength()); |
1997 Deserializer deserializer(&payload); | 1998 Deserializer deserializer(&payload); |
1998 STATIC_ASSERT(NEW_SPACE == 0); | 1999 STATIC_ASSERT(NEW_SPACE == 0); |
1999 // TODO(yangguo) what happens if remaining new space is too small? | 2000 // TODO(yangguo) what happens if remaining new space is too small? |
2000 for (int i = NEW_SPACE; i <= PROPERTY_CELL_SPACE; i++) { | 2001 for (int i = NEW_SPACE; i <= PROPERTY_CELL_SPACE; i++) { |
2001 deserializer.set_reservation(i, scd.GetReservation(i)); | 2002 deserializer.set_reservation(i, scd.GetReservation(i)); |
2002 } | 2003 } |
2003 DisallowHeapAllocation no_gc; | 2004 DisallowHeapAllocation no_gc; |
2004 | 2005 |
2005 // Prepare and register list of attached objects. | 2006 // Prepare and register list of attached objects. |
2006 List<Object*> attached_objects(1); | 2007 Vector<Object*> attached_objects = Vector<Object*>::New(1); |
2007 attached_objects.Set(kSourceObjectIndex, *source); | 2008 attached_objects[kSourceObjectIndex] = *source; |
2008 deserializer.SetAttachedObjects(&attached_objects); | 2009 deserializer.SetAttachedObjects(&attached_objects); |
2009 | 2010 |
2010 Object* root; | 2011 Object* root; |
2011 deserializer.DeserializePartial(isolate, &root); | 2012 deserializer.DeserializePartial(isolate, &root); |
2012 deserializer.FlushICacheForNewCodeObjects(); | 2013 deserializer.FlushICacheForNewCodeObjects(); |
2013 return Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(root), isolate); | 2014 return Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(root), isolate); |
2014 } | 2015 } |
2015 | 2016 |
2016 | 2017 |
2017 SerializedCodeData::SerializedCodeData(List<byte>* payload, CodeSerializer* cs) | 2018 SerializedCodeData::SerializedCodeData(List<byte>* payload, CodeSerializer* cs) |
(...skipping 11 matching lines...) Expand all Loading... |
2029 SetHeaderValue(kReservationsOffset + i, cs->CurrentAllocationAddress(i)); | 2030 SetHeaderValue(kReservationsOffset + i, cs->CurrentAllocationAddress(i)); |
2030 } | 2031 } |
2031 } | 2032 } |
2032 | 2033 |
2033 | 2034 |
2034 bool SerializedCodeData::IsSane() { | 2035 bool SerializedCodeData::IsSane() { |
2035 return GetHeaderValue(kVersionHashOffset) == Version::Hash() && | 2036 return GetHeaderValue(kVersionHashOffset) == Version::Hash() && |
2036 PayloadLength() >= SharedFunctionInfo::kSize; | 2037 PayloadLength() >= SharedFunctionInfo::kSize; |
2037 } | 2038 } |
2038 } } // namespace v8::internal | 2039 } } // namespace v8::internal |
OLD | NEW |