Chromium Code Reviews| Index: src/snapshot/serialize.cc |
| diff --git a/src/snapshot/serialize.cc b/src/snapshot/serialize.cc |
| index c819a11ea762e7cc6cc77819670023b374cc8fa6..7afa46eadbe8a68a3cfa07320f591dc0d9503107 100644 |
| --- a/src/snapshot/serialize.cc |
| +++ b/src/snapshot/serialize.cc |
| @@ -575,7 +575,7 @@ void Deserializer::Deserialize(Isolate* isolate) { |
| } |
| isolate_->heap()->set_native_contexts_list( |
| - isolate_->heap()->undefined_value()); |
| + isolate_->heap()->code_stub_context()); |
| // The allocation site list is build during root iteration, but if no sites |
| // were encountered then it needs to be initialized to undefined. |
| @@ -592,6 +592,13 @@ void Deserializer::Deserialize(Isolate* isolate) { |
| } |
| } |
| + for (int i = 0; i < CodeStubNatives::GetBuiltinsCount(); i++) { |
| + Object* source = isolate_->heap()->code_stub_natives_source_cache()->get(i); |
| + if (!source->IsUndefined()) { |
| + ExternalOneByteString::cast(source)->update_data_cache(); |
| + } |
| + } |
| + |
| FlushICacheForNewCodeObjects(); |
| // Issue code events for newly deserialized code objects. |
| @@ -907,6 +914,17 @@ Address Deserializer::Allocate(int space_index, int size) { |
| } |
| +Object** Deserializer::CopyInNativesSource(Vector<const char> source_vector, |
| + Object** current) { |
| + DCHECK(!isolate_->heap()->deserialization_complete()); |
| + NativesExternalStringResource* resource = new NativesExternalStringResource( |
| + source_vector.start(), source_vector.length()); |
| + Object* resource_obj = reinterpret_cast<Object*>(resource); |
| + UnalignedCopy(current++, &resource_obj); |
| + return current; |
| +} |
| + |
| + |
| bool Deserializer::ReadData(Object** current, Object** limit, int source_space, |
| Address current_object_address) { |
| Isolate* const isolate = isolate_; |
| @@ -1174,14 +1192,14 @@ bool Deserializer::ReadData(Object** current, Object** limit, int source_space, |
| break; |
| case kNativesStringResource: { |
|
Yang
2015/07/10 08:18:57
no need for the scoping brackets anymore.
danno
2015/07/13 09:43:37
Done
|
| - DCHECK(!isolate_->heap()->deserialization_complete()); |
| - int index = source_.Get(); |
| - Vector<const char> source_vector = Natives::GetScriptSource(index); |
| - NativesExternalStringResource* resource = |
| - new NativesExternalStringResource(source_vector.start(), |
| - source_vector.length()); |
| - Object* resource_obj = reinterpret_cast<Object*>(resource); |
| - UnalignedCopy(current++, &resource_obj); |
| + current = CopyInNativesSource(Natives::GetScriptSource(source_.Get()), |
| + current); |
| + break; |
| + } |
| + |
| + case kCodeStubNativesStringResource: { |
| + current = CopyInNativesSource( |
| + CodeStubNatives::GetScriptSource(source_.Get()), current); |
| break; |
| } |
| @@ -1419,6 +1437,17 @@ void PartialSerializer::Serialize(Object** o) { |
| Context* context = Context::cast(*o); |
| global_object_ = context->global_object(); |
| back_reference_map()->AddGlobalProxy(context->global_proxy()); |
| + // The bootstrap already snapshot has a code-stub context, when serializing |
|
Yang
2015/07/10 08:18:57
weird sentence...
danno
2015/07/13 09:43:37
Done
|
| + // the partial snapshot, it is chained into the weak context list on the |
| + // isolate and it's next context pointer may point to the code-stub context. |
| + // Clear it before serializing, it will get re-added to the context list |
| + // explicitly when it's loaded. |
| + if (context->IsNativeContext()) { |
| + context->set(Context::NEXT_CONTEXT_LINK, |
| + isolate_->heap()->undefined_value()); |
| + DCHECK(!context->global_object()->IsUndefined()); |
| + DCHECK(!context->builtins()->IsUndefined()); |
| + } |
| } |
| VisitPointer(o); |
| SerializeDeferredObjects(); |
| @@ -1623,7 +1652,10 @@ bool Serializer::SerializeKnownObject(HeapObject* obj, HowToCode how_to_code, |
| void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code, |
| WhereToPoint where_to_point, int skip) { |
| - DCHECK(!obj->IsJSFunction()); |
| + // Make sure that all functions are derived from the code-stub context |
| + DCHECK(!obj->IsJSFunction() || |
| + JSFunction::cast(obj)->GetCreationContext() == |
| + isolate()->heap()->code_stub_context()); |
| int root_index = root_index_map_.Lookup(obj); |
| // We can only encode roots as such if it has already been serialized. |
| @@ -2127,25 +2159,47 @@ void Serializer::ObjectSerializer::VisitCell(RelocInfo* rinfo) { |
| } |
| -void Serializer::ObjectSerializer::VisitExternalOneByteString( |
| - v8::String::ExternalOneByteStringResource** resource_pointer) { |
| - Address references_start = reinterpret_cast<Address>(resource_pointer); |
| - OutputRawData(references_start); |
| - for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
| - Object* source = |
| - serializer_->isolate()->heap()->natives_source_cache()->get(i); |
| +bool Serializer::ObjectSerializer::SerializeExternalNativeSourceString( |
| + int builtin_count, |
| + v8::String::ExternalOneByteStringResource** resource_pointer, |
| + FixedArray* source_cache, int resource_index, const char* begin_string, |
| + const char* end_string) { |
| + for (int i = 0; i < builtin_count; i++) { |
| + Object* source = source_cache->get(i); |
| if (!source->IsUndefined()) { |
| ExternalOneByteString* string = ExternalOneByteString::cast(source); |
| typedef v8::String::ExternalOneByteStringResource Resource; |
| const Resource* resource = string->resource(); |
| if (resource == *resource_pointer) { |
| - sink_->Put(kNativesStringResource, "NativesStringResource"); |
| - sink_->PutSection(i, "NativesStringResourceEnd"); |
| + sink_->Put(resource_index, begin_string); |
| + sink_->PutSection(i, end_string); |
| bytes_processed_so_far_ += sizeof(resource); |
| - return; |
| + return true; |
| } |
| } |
| } |
| + return false; |
| +} |
| + |
| + |
| +void Serializer::ObjectSerializer::VisitExternalOneByteString( |
| + v8::String::ExternalOneByteStringResource** resource_pointer) { |
| + Address references_start = reinterpret_cast<Address>(resource_pointer); |
| + OutputRawData(references_start); |
| + if (SerializeExternalNativeSourceString( |
| + Natives::GetBuiltinsCount(), resource_pointer, |
| + serializer_->isolate()->heap()->natives_source_cache(), |
| + kNativesStringResource, "NativesStringResource", |
|
Yang
2015/07/10 08:18:57
Those string arguments are really just for documen
danno
2015/07/13 09:43:37
Done
|
| + "NativesStringResourceEnd")) { |
| + return; |
| + } |
| + if (SerializeExternalNativeSourceString( |
| + CodeStubNatives::GetBuiltinsCount(), resource_pointer, |
| + serializer_->isolate()->heap()->code_stub_natives_source_cache(), |
| + kCodeStubNativesStringResource, "CodeStubNativesStringResource", |
| + "CodeStubNativesStringResourceEnd")) { |
| + return; |
| + } |
| // One of the strings in the natives cache should match the resource. We |
| // don't expect any other kinds of external strings here. |
| UNREACHABLE(); |