| 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 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1984 | 1984 | 
| 1985   ASSERT(how_to_code == kPlain && where_to_point == kStartOfObject); | 1985   ASSERT(how_to_code == kPlain && where_to_point == kStartOfObject); | 
| 1986   sink_->Put(kAttachedReference + how_to_code + where_to_point, "Source"); | 1986   sink_->Put(kAttachedReference + how_to_code + where_to_point, "Source"); | 
| 1987   sink_->PutInt(kSourceObjectIndex, "kSourceObjectIndex"); | 1987   sink_->PutInt(kSourceObjectIndex, "kSourceObjectIndex"); | 
| 1988 } | 1988 } | 
| 1989 | 1989 | 
| 1990 | 1990 | 
| 1991 Handle<SharedFunctionInfo> CodeSerializer::Deserialize(Isolate* isolate, | 1991 Handle<SharedFunctionInfo> CodeSerializer::Deserialize(Isolate* isolate, | 
| 1992                                                        ScriptData* data, | 1992                                                        ScriptData* data, | 
| 1993                                                        Handle<String> source) { | 1993                                                        Handle<String> source) { | 
|  | 1994   base::ElapsedTimer timer; | 
|  | 1995   if (FLAG_profile_deserialization) timer.Start(); | 
| 1994   SerializedCodeData scd(data, *source); | 1996   SerializedCodeData scd(data, *source); | 
| 1995   SnapshotByteSource payload(scd.Payload(), scd.PayloadLength()); | 1997   SnapshotByteSource payload(scd.Payload(), scd.PayloadLength()); | 
| 1996   Deserializer deserializer(&payload); | 1998   Deserializer deserializer(&payload); | 
| 1997   STATIC_ASSERT(NEW_SPACE == 0); | 1999   STATIC_ASSERT(NEW_SPACE == 0); | 
| 1998   // TODO(yangguo) what happens if remaining new space is too small? |  | 
| 1999   for (int i = NEW_SPACE; i <= PROPERTY_CELL_SPACE; i++) { | 2000   for (int i = NEW_SPACE; i <= PROPERTY_CELL_SPACE; i++) { | 
| 2000     deserializer.set_reservation(i, scd.GetReservation(i)); | 2001     deserializer.set_reservation(i, scd.GetReservation(i)); | 
| 2001   } | 2002   } | 
| 2002   DisallowHeapAllocation no_gc; | 2003   DisallowHeapAllocation no_gc; | 
| 2003 | 2004 | 
| 2004   // Prepare and register list of attached objects. | 2005   // Prepare and register list of attached objects. | 
| 2005   Vector<Object*> attached_objects = Vector<Object*>::New(1); | 2006   Vector<Object*> attached_objects = Vector<Object*>::New(1); | 
| 2006   attached_objects[kSourceObjectIndex] = *source; | 2007   attached_objects[kSourceObjectIndex] = *source; | 
| 2007   deserializer.SetAttachedObjects(&attached_objects); | 2008   deserializer.SetAttachedObjects(&attached_objects); | 
| 2008 | 2009 | 
| 2009   Object* root; | 2010   Object* root; | 
| 2010   deserializer.DeserializePartial(isolate, &root); | 2011   deserializer.DeserializePartial(isolate, &root); | 
| 2011   deserializer.FlushICacheForNewCodeObjects(); | 2012   deserializer.FlushICacheForNewCodeObjects(); | 
|  | 2013   if (FLAG_profile_deserialization) { | 
|  | 2014     double ms = timer.Elapsed().InMillisecondsF(); | 
|  | 2015     int length = data->length(); | 
|  | 2016     PrintF("[Deserializing from %d bytes took %0.3f ms]\n", length, ms); | 
|  | 2017   } | 
| 2012   return Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(root), isolate); | 2018   return Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(root), isolate); | 
| 2013 } | 2019 } | 
| 2014 | 2020 | 
| 2015 | 2021 | 
| 2016 SerializedCodeData::SerializedCodeData(List<byte>* payload, CodeSerializer* cs) | 2022 SerializedCodeData::SerializedCodeData(List<byte>* payload, CodeSerializer* cs) | 
| 2017     : owns_script_data_(true) { | 2023     : owns_script_data_(true) { | 
| 2018   DisallowHeapAllocation no_gc; | 2024   DisallowHeapAllocation no_gc; | 
| 2019   int data_length = payload->length() + kHeaderEntries * kIntSize; | 2025   int data_length = payload->length() + kHeaderEntries * kIntSize; | 
| 2020   byte* data = NewArray<byte>(data_length); | 2026   byte* data = NewArray<byte>(data_length); | 
| 2021   ASSERT(IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)); | 2027   ASSERT(IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)); | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 2039 | 2045 | 
| 2040 int SerializedCodeData::CheckSum(String* string) { | 2046 int SerializedCodeData::CheckSum(String* string) { | 
| 2041   int checksum = Version::Hash(); | 2047   int checksum = Version::Hash(); | 
| 2042 #ifdef DEBUG | 2048 #ifdef DEBUG | 
| 2043   uint32_t seed = static_cast<uint32_t>(checksum); | 2049   uint32_t seed = static_cast<uint32_t>(checksum); | 
| 2044   checksum = static_cast<int>(IteratingStringHasher::Hash(string, seed)); | 2050   checksum = static_cast<int>(IteratingStringHasher::Hash(string, seed)); | 
| 2045 #endif  // DEBUG | 2051 #endif  // DEBUG | 
| 2046   return checksum; | 2052   return checksum; | 
| 2047 } | 2053 } | 
| 2048 } }  // namespace v8::internal | 2054 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|