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 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2011 CHECK(!heap_object->IsHashTable()); | 2011 CHECK(!heap_object->IsHashTable()); |
2012 | 2012 |
2013 SerializeHeapObject(heap_object, how_to_code, where_to_point); | 2013 SerializeHeapObject(heap_object, how_to_code, where_to_point); |
2014 } | 2014 } |
2015 | 2015 |
2016 | 2016 |
2017 void CodeSerializer::SerializeHeapObject(HeapObject* heap_object, | 2017 void CodeSerializer::SerializeHeapObject(HeapObject* heap_object, |
2018 HowToCode how_to_code, | 2018 HowToCode how_to_code, |
2019 WhereToPoint where_to_point) { | 2019 WhereToPoint where_to_point) { |
2020 if (heap_object->IsScript()) { | 2020 if (heap_object->IsScript()) { |
2021 // The wrapper cache uses a Foreign object to point to a global handle. | 2021 // The wrapper cache uses a WeakCell. However it's not clear what |
2022 // However, the object visitor expects foreign objects to point to external | 2022 // the semantics of WeakCell are when serializing. For now we just |
2023 // references. Clear the cache to avoid this issue. | 2023 // clear the cache. |
2024 Script::cast(heap_object)->ClearWrapperCache(); | 2024 HeapObject* clear = heap_object->GetHeap()->undefined_value(); |
ulan
2014/10/14 15:45:56
Since we rebuild the WeakCell list on every GC, se
| |
2025 Script::cast(heap_object)->set_wrapper(clear); | |
ulan
2014/10/14 15:45:56
Should we also isolate->counters()->script_wrapper
| |
2025 } | 2026 } |
2026 | 2027 |
2027 if (FLAG_trace_code_serializer) { | 2028 if (FLAG_trace_code_serializer) { |
2028 PrintF("Encoding heap object: "); | 2029 PrintF("Encoding heap object: "); |
2029 heap_object->ShortPrint(); | 2030 heap_object->ShortPrint(); |
2030 PrintF("\n"); | 2031 PrintF("\n"); |
2031 } | 2032 } |
2032 | 2033 |
2033 // Object has not yet been serialized. Serialize it here. | 2034 // Object has not yet been serialized. Serialize it here. |
2034 ObjectSerializer serializer(this, heap_object, sink_, how_to_code, | 2035 ObjectSerializer serializer(this, heap_object, sink_, how_to_code, |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2189 | 2190 |
2190 int SerializedCodeData::CheckSum(String* string) { | 2191 int SerializedCodeData::CheckSum(String* string) { |
2191 int checksum = Version::Hash(); | 2192 int checksum = Version::Hash(); |
2192 #ifdef DEBUG | 2193 #ifdef DEBUG |
2193 uint32_t seed = static_cast<uint32_t>(checksum); | 2194 uint32_t seed = static_cast<uint32_t>(checksum); |
2194 checksum = static_cast<int>(IteratingStringHasher::Hash(string, seed)); | 2195 checksum = static_cast<int>(IteratingStringHasher::Hash(string, seed)); |
2195 #endif // DEBUG | 2196 #endif // DEBUG |
2196 return checksum; | 2197 return checksum; |
2197 } | 2198 } |
2198 } } // namespace v8::internal | 2199 } } // namespace v8::internal |
OLD | NEW |