| 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 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 | 1904 |
| 1905 // We cannot serialize typed array objects correctly. | 1905 // We cannot serialize typed array objects correctly. |
| 1906 DCHECK(!object_->IsJSTypedArray()); | 1906 DCHECK(!object_->IsJSTypedArray()); |
| 1907 | 1907 |
| 1908 // We don't expect fillers. | 1908 // We don't expect fillers. |
| 1909 DCHECK(!object_->IsFiller()); | 1909 DCHECK(!object_->IsFiller()); |
| 1910 | 1910 |
| 1911 if (object_->IsPrototypeInfo()) { | 1911 if (object_->IsPrototypeInfo()) { |
| 1912 Object* prototype_users = PrototypeInfo::cast(object_)->prototype_users(); | 1912 Object* prototype_users = PrototypeInfo::cast(object_)->prototype_users(); |
| 1913 if (prototype_users->IsWeakFixedArray()) { | 1913 if (prototype_users->IsWeakFixedArray()) { |
| 1914 WeakFixedArray::cast(prototype_users)->Compact(); | 1914 WeakFixedArray* array = WeakFixedArray::cast(prototype_users); |
| 1915 array->Compact<JSObject::PrototypeRegistryCompactionCallback>(); |
| 1916 } |
| 1917 } |
| 1918 // Compaction of a prototype users list can require the registered users |
| 1919 // to update their remembered slots. That doesn't work if those users |
| 1920 // have already been serialized themselves. So if this object is a |
| 1921 // registered user, compact its prototype's user list now. |
| 1922 if (object_->IsMap()) { |
| 1923 Map* map = Map::cast(object_); |
| 1924 if (map->is_prototype_map() && map->prototype_info()->IsPrototypeInfo() && |
| 1925 PrototypeInfo::cast(map->prototype_info())->registry_slot() != |
| 1926 PrototypeInfo::UNREGISTERED) { |
| 1927 JSObject* proto = JSObject::cast(map->prototype()); |
| 1928 PrototypeInfo* info = PrototypeInfo::cast(proto->map()->prototype_info()); |
| 1929 WeakFixedArray* array = WeakFixedArray::cast(info->prototype_users()); |
| 1930 array->Compact<JSObject::PrototypeRegistryCompactionCallback>(); |
| 1915 } | 1931 } |
| 1916 } | 1932 } |
| 1917 | 1933 |
| 1918 if (object_->IsScript()) { | 1934 if (object_->IsScript()) { |
| 1919 // Clear cached line ends. | 1935 // Clear cached line ends. |
| 1920 Object* undefined = serializer_->isolate()->heap()->undefined_value(); | 1936 Object* undefined = serializer_->isolate()->heap()->undefined_value(); |
| 1921 Script::cast(object_)->set_line_ends(undefined); | 1937 Script::cast(object_)->set_line_ends(undefined); |
| 1922 Object* shared_list = Script::cast(object_)->shared_function_infos(); | 1938 Object* shared_list = Script::cast(object_)->shared_function_infos(); |
| 1923 if (shared_list->IsWeakFixedArray()) { | 1939 if (shared_list->IsWeakFixedArray()) { |
| 1924 WeakFixedArray::cast(shared_list)->Compact(); | 1940 WeakFixedArray::cast(shared_list) |
| 1941 ->Compact<WeakFixedArray::NullCallback>(); |
| 1925 } | 1942 } |
| 1926 } | 1943 } |
| 1927 | 1944 |
| 1928 if (object_->IsExternalString()) { | 1945 if (object_->IsExternalString()) { |
| 1929 Heap* heap = serializer_->isolate()->heap(); | 1946 Heap* heap = serializer_->isolate()->heap(); |
| 1930 if (object_->map() != heap->native_source_string_map()) { | 1947 if (object_->map() != heap->native_source_string_map()) { |
| 1931 // Usually we cannot recreate resources for external strings. To work | 1948 // Usually we cannot recreate resources for external strings. To work |
| 1932 // around this, external strings are serialized to look like ordinary | 1949 // around this, external strings are serialized to look like ordinary |
| 1933 // sequential strings. | 1950 // sequential strings. |
| 1934 // The exception are native source code strings, since we can recreate | 1951 // The exception are native source code strings, since we can recreate |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2749 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2766 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
| 2750 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2767 SanityCheckResult r = scd->SanityCheck(isolate, source); |
| 2751 if (r == CHECK_SUCCESS) return scd; | 2768 if (r == CHECK_SUCCESS) return scd; |
| 2752 cached_data->Reject(); | 2769 cached_data->Reject(); |
| 2753 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2770 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
| 2754 delete scd; | 2771 delete scd; |
| 2755 return NULL; | 2772 return NULL; |
| 2756 } | 2773 } |
| 2757 } // namespace internal | 2774 } // namespace internal |
| 2758 } // namespace v8 | 2775 } // namespace v8 |
| OLD | NEW |