Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1089)

Unified Diff: src/snapshot/serialize.cc

Issue 1213203007: Create a internal, global native context used only for generated code stubs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Merge with latest Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/snapshot/serialize.cc
diff --git a/src/snapshot/serialize.cc b/src/snapshot/serialize.cc
index c819a11ea762e7cc6cc77819670023b374cc8fa6..652d67a03bedaf878e126a51817390e217616c60 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.
@@ -1185,6 +1192,19 @@ bool Deserializer::ReadData(Object** current, Object** limit, int source_space,
break;
}
+ case kCodeStubNativesStringResource: {
+ DCHECK(!isolate_->heap()->deserialization_complete());
+ int index = source_.Get();
Yang 2015/07/08 08:32:54 This duplicate code could be refactored into a hel
danno 2015/07/08 20:25:59 Done.
+ Vector<const char> source_vector =
+ CodeStubNatives::GetScriptSource(index);
+ NativesExternalStringResource* resource =
+ new NativesExternalStringResource(source_vector.start(),
+ source_vector.length());
+ Object* resource_obj = reinterpret_cast<Object*>(resource);
+ UnalignedCopy(current++, &resource_obj);
+ break;
+ }
+
// Deserialize raw data of variable length.
case kVariableRawData: {
int size_in_bytes = source_.GetInt();
@@ -1419,6 +1439,12 @@ void PartialSerializer::Serialize(Object** o) {
Context* context = Context::cast(*o);
global_object_ = context->global_object();
back_reference_map()->AddGlobalProxy(context->global_proxy());
+ if (context->IsNativeContext()) {
+ context->set(Context::NEXT_CONTEXT_LINK,
Yang 2015/07/08 08:32:54 Some comment here would be great.
danno 2015/07/08 20:25:59 Done.
+ isolate_->heap()->undefined_value());
+ DCHECK(!context->global_object()->IsUndefined());
+ DCHECK(!context->builtins()->IsUndefined());
+ }
}
VisitPointer(o);
SerializeDeferredObjects();
@@ -1623,7 +1649,16 @@ 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());
+#if DEBUG
+ // Make sure that all contexts are derived from the code-stub context
Yang 2015/07/08 08:32:54 ... all *functions* are derived ...
danno 2015/07/08 20:25:59 Done.
+ if (obj->IsJSFunction()) {
+ Context* current = JSFunction::cast(obj)->context();
Yang 2015/07/08 08:32:54 Can you replace this with DCHECK(!obj->IsJSFuncti
danno 2015/07/08 20:25:59 Done.
+ while (current != isolate()->heap()->code_stub_context()) {
+ current = current->previous();
+ }
+ DCHECK_EQ(isolate()->heap()->code_stub_context(), current);
+ }
+#endif
int root_index = root_index_map_.Lookup(obj);
// We can only encode roots as such if it has already been serialized.
@@ -2146,6 +2181,23 @@ void Serializer::ObjectSerializer::VisitExternalOneByteString(
}
}
}
+ for (int i = 0; i < CodeStubNatives::GetBuiltinsCount(); i++) {
Yang 2015/07/08 08:32:54 Could you refactor this duplicate code into a help
danno 2015/07/08 20:25:59 Done.
+ Object* source =
+ serializer_->isolate()->heap()->code_stub_natives_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(kCodeStubNativesStringResource,
+ "CodeStubNativesStringResource");
+ sink_->PutSection(i, "CodeStubNativesStringResourceEnd");
+ bytes_processed_so_far_ += sizeof(resource);
+ 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();
« src/bootstrapper.cc ('K') | « src/snapshot/serialize.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698