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 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 object_->ShortPrint(); | 1916 object_->ShortPrint(); |
1917 PrintF("\n"); | 1917 PrintF("\n"); |
1918 } | 1918 } |
1919 | 1919 |
1920 // We cannot serialize typed array objects correctly. | 1920 // We cannot serialize typed array objects correctly. |
1921 DCHECK(!object_->IsJSTypedArray()); | 1921 DCHECK(!object_->IsJSTypedArray()); |
1922 | 1922 |
1923 // We don't expect fillers. | 1923 // We don't expect fillers. |
1924 DCHECK(!object_->IsFiller()); | 1924 DCHECK(!object_->IsFiller()); |
1925 | 1925 |
1926 if (object_->IsPrototypeInfo()) { | |
1927 Object* prototype_users = PrototypeInfo::cast(object_)->prototype_users(); | |
1928 if (prototype_users->IsWeakFixedArray()) { | |
1929 WeakFixedArray* array = WeakFixedArray::cast(prototype_users); | |
1930 array->Compact<JSObject::PrototypeRegistryCompactionCallback>(); | |
1931 } | |
1932 } | |
1933 // Compaction of a prototype users list can require the registered users | |
1934 // to update their remembered slots. That doesn't work if those users | |
1935 // have already been serialized themselves. So if this object is a | |
1936 // registered user, compact its prototype's user list now. | |
1937 if (object_->IsMap()) { | |
1938 Map* map = Map::cast(object_); | |
1939 if (map->is_prototype_map() && map->prototype_info()->IsPrototypeInfo() && | |
1940 PrototypeInfo::cast(map->prototype_info())->registry_slot() != | |
1941 PrototypeInfo::UNREGISTERED) { | |
1942 JSObject* proto = JSObject::cast(map->prototype()); | |
1943 PrototypeInfo* info = PrototypeInfo::cast(proto->map()->prototype_info()); | |
1944 WeakFixedArray* array = WeakFixedArray::cast(info->prototype_users()); | |
1945 array->Compact<JSObject::PrototypeRegistryCompactionCallback>(); | |
1946 } | |
1947 } | |
1948 | |
1949 if (object_->IsScript()) { | 1926 if (object_->IsScript()) { |
1950 // Clear cached line ends. | 1927 // Clear cached line ends. |
1951 Object* undefined = serializer_->isolate()->heap()->undefined_value(); | 1928 Object* undefined = serializer_->isolate()->heap()->undefined_value(); |
1952 Script::cast(object_)->set_line_ends(undefined); | 1929 Script::cast(object_)->set_line_ends(undefined); |
1953 Object* shared_list = Script::cast(object_)->shared_function_infos(); | |
1954 if (shared_list->IsWeakFixedArray()) { | |
1955 WeakFixedArray::cast(shared_list) | |
1956 ->Compact<WeakFixedArray::NullCallback>(); | |
1957 } | |
1958 } | 1930 } |
1959 | 1931 |
1960 if (object_->IsExternalString()) { | 1932 if (object_->IsExternalString()) { |
1961 Heap* heap = serializer_->isolate()->heap(); | 1933 Heap* heap = serializer_->isolate()->heap(); |
1962 if (object_->map() != heap->native_source_string_map()) { | 1934 if (object_->map() != heap->native_source_string_map()) { |
1963 // Usually we cannot recreate resources for external strings. To work | 1935 // Usually we cannot recreate resources for external strings. To work |
1964 // around this, external strings are serialized to look like ordinary | 1936 // around this, external strings are serialized to look like ordinary |
1965 // sequential strings. | 1937 // sequential strings. |
1966 // The exception are native source code strings, since we can recreate | 1938 // The exception are native source code strings, since we can recreate |
1967 // their resources. In that case we fall through and leave it to | 1939 // their resources. In that case we fall through and leave it to |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2800 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2772 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
2801 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2773 SanityCheckResult r = scd->SanityCheck(isolate, source); |
2802 if (r == CHECK_SUCCESS) return scd; | 2774 if (r == CHECK_SUCCESS) return scd; |
2803 cached_data->Reject(); | 2775 cached_data->Reject(); |
2804 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2776 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
2805 delete scd; | 2777 delete scd; |
2806 return NULL; | 2778 return NULL; |
2807 } | 2779 } |
2808 } // namespace internal | 2780 } // namespace internal |
2809 } // namespace v8 | 2781 } // namespace v8 |
OLD | NEW |