OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/snapshot/code-serializer.h" | 5 #include "src/snapshot/code-serializer.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
8 #include "src/log.h" | 10 #include "src/log.h" |
9 #include "src/macro-assembler.h" | 11 #include "src/macro-assembler.h" |
10 #include "src/snapshot/deserializer.h" | 12 #include "src/snapshot/deserializer.h" |
11 #include "src/version.h" | 13 #include "src/version.h" |
12 | 14 |
13 namespace v8 { | 15 namespace v8 { |
14 namespace internal { | 16 namespace internal { |
15 | 17 |
16 ScriptData* CodeSerializer::Serialize(Isolate* isolate, | 18 ScriptData* CodeSerializer::Serialize(Isolate* isolate, |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 PutAttachedReference(reference, how_to_code, where_to_point); | 149 PutAttachedReference(reference, how_to_code, where_to_point); |
148 } | 150 } |
149 | 151 |
150 MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize( | 152 MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize( |
151 Isolate* isolate, ScriptData* cached_data, Handle<String> source) { | 153 Isolate* isolate, ScriptData* cached_data, Handle<String> source) { |
152 base::ElapsedTimer timer; | 154 base::ElapsedTimer timer; |
153 if (FLAG_profile_deserialization) timer.Start(); | 155 if (FLAG_profile_deserialization) timer.Start(); |
154 | 156 |
155 HandleScope scope(isolate); | 157 HandleScope scope(isolate); |
156 | 158 |
157 base::SmartPointer<SerializedCodeData> scd( | 159 std::unique_ptr<SerializedCodeData> scd( |
158 SerializedCodeData::FromCachedData(isolate, cached_data, *source)); | 160 SerializedCodeData::FromCachedData(isolate, cached_data, *source)); |
159 if (scd.is_empty()) { | 161 if (!scd) { |
160 if (FLAG_profile_deserialization) PrintF("[Cached code failed check]\n"); | 162 if (FLAG_profile_deserialization) PrintF("[Cached code failed check]\n"); |
161 DCHECK(cached_data->rejected()); | 163 DCHECK(cached_data->rejected()); |
162 return MaybeHandle<SharedFunctionInfo>(); | 164 return MaybeHandle<SharedFunctionInfo>(); |
163 } | 165 } |
164 | 166 |
165 Deserializer deserializer(scd.get()); | 167 Deserializer deserializer(scd.get()); |
166 deserializer.AddAttachedObject(source); | 168 deserializer.AddAttachedObject(source); |
167 Vector<const uint32_t> code_stub_keys = scd->CodeStubKeys(); | 169 Vector<const uint32_t> code_stub_keys = scd->CodeStubKeys(); |
168 for (int i = 0; i < code_stub_keys.length(); i++) { | 170 for (int i = 0; i < code_stub_keys.length(); i++) { |
169 deserializer.AddAttachedObject( | 171 deserializer.AddAttachedObject( |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 SanityCheckResult r = scd->SanityCheck(isolate, source); | 358 SanityCheckResult r = scd->SanityCheck(isolate, source); |
357 if (r == CHECK_SUCCESS) return scd; | 359 if (r == CHECK_SUCCESS) return scd; |
358 cached_data->Reject(); | 360 cached_data->Reject(); |
359 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 361 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
360 delete scd; | 362 delete scd; |
361 return NULL; | 363 return NULL; |
362 } | 364 } |
363 | 365 |
364 } // namespace internal | 366 } // namespace internal |
365 } // namespace v8 | 367 } // namespace v8 |
OLD | NEW |