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

Side by Side Diff: src/snapshot/partial-serializer.cc

Issue 2741683004: [rename] Rename internal field to embedder field. (Closed)
Patch Set: [rename] Rename internal field to embedder field. Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « src/snapshot/partial-serializer.h ('k') | src/snapshot/serializer-common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/partial-serializer.h" 5 #include "src/snapshot/partial-serializer.h"
6 #include "src/snapshot/startup-serializer.h" 6 #include "src/snapshot/startup-serializer.h"
7 7
8 #include "src/objects-inl.h" 8 #include "src/objects-inl.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 12
13 PartialSerializer::PartialSerializer( 13 PartialSerializer::PartialSerializer(
14 Isolate* isolate, StartupSerializer* startup_serializer, 14 Isolate* isolate, StartupSerializer* startup_serializer,
15 v8::SerializeInternalFieldsCallback callback) 15 v8::SerializeEmbedderFieldsCallback callback)
16 : Serializer(isolate), 16 : Serializer(isolate),
17 startup_serializer_(startup_serializer), 17 startup_serializer_(startup_serializer),
18 serialize_internal_fields_(callback) { 18 serialize_embedder_fields_(callback) {
19 InitializeCodeAddressMap(); 19 InitializeCodeAddressMap();
20 } 20 }
21 21
22 PartialSerializer::~PartialSerializer() { 22 PartialSerializer::~PartialSerializer() {
23 OutputStatistics("PartialSerializer"); 23 OutputStatistics("PartialSerializer");
24 } 24 }
25 25
26 void PartialSerializer::Serialize(Object** o, bool include_global_proxy) { 26 void PartialSerializer::Serialize(Object** o, bool include_global_proxy) {
27 if ((*o)->IsContext()) { 27 if ((*o)->IsContext()) {
28 Context* context = Context::cast(*o); 28 Context* context = Context::cast(*o);
29 reference_map()->AddAttachedReference(context->global_proxy()); 29 reference_map()->AddAttachedReference(context->global_proxy());
30 // The bootstrap snapshot has a code-stub context. When serializing the 30 // The bootstrap snapshot has a code-stub context. When serializing the
31 // partial snapshot, it is chained into the weak context list on the isolate 31 // partial snapshot, it is chained into the weak context list on the isolate
32 // and it's next context pointer may point to the code-stub context. Clear 32 // and it's next context pointer may point to the code-stub context. Clear
33 // it before serializing, it will get re-added to the context list 33 // it before serializing, it will get re-added to the context list
34 // explicitly when it's loaded. 34 // explicitly when it's loaded.
35 if (context->IsNativeContext()) { 35 if (context->IsNativeContext()) {
36 context->set(Context::NEXT_CONTEXT_LINK, 36 context->set(Context::NEXT_CONTEXT_LINK,
37 isolate_->heap()->undefined_value()); 37 isolate_->heap()->undefined_value());
38 DCHECK(!context->global_object()->IsUndefined(context->GetIsolate())); 38 DCHECK(!context->global_object()->IsUndefined(context->GetIsolate()));
39 // Reset math random cache to get fresh random numbers. 39 // Reset math random cache to get fresh random numbers.
40 context->set_math_random_index(Smi::kZero); 40 context->set_math_random_index(Smi::kZero);
41 context->set_math_random_cache(isolate_->heap()->undefined_value()); 41 context->set_math_random_cache(isolate_->heap()->undefined_value());
42 } 42 }
43 } 43 }
44 VisitPointer(o); 44 VisitPointer(o);
45 SerializeDeferredObjects(); 45 SerializeDeferredObjects();
46 SerializeInternalFields(); 46 SerializeEmbedderFields();
47 Pad(); 47 Pad();
48 } 48 }
49 49
50 void PartialSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code, 50 void PartialSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
51 WhereToPoint where_to_point, int skip) { 51 WhereToPoint where_to_point, int skip) {
52 if (obj->IsMap()) { 52 if (obj->IsMap()) {
53 // The code-caches link to context-specific code objects, which 53 // The code-caches link to context-specific code objects, which
54 // the startup and context serializes cannot currently handle. 54 // the startup and context serializes cannot currently handle.
55 DCHECK(Map::cast(obj)->code_cache() == obj->GetHeap()->empty_fixed_array()); 55 DCHECK(Map::cast(obj)->code_cache() == obj->GetHeap()->empty_fixed_array());
56 } 56 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 FlushSkip(skip); 91 FlushSkip(skip);
92 92
93 // Clear literal boilerplates. 93 // Clear literal boilerplates.
94 if (obj->IsJSFunction()) { 94 if (obj->IsJSFunction()) {
95 JSFunction* function = JSFunction::cast(obj); 95 JSFunction* function = JSFunction::cast(obj);
96 function->ClearTypeFeedbackInfo(); 96 function->ClearTypeFeedbackInfo();
97 } 97 }
98 98
99 if (obj->IsJSObject()) { 99 if (obj->IsJSObject()) {
100 JSObject* jsobj = JSObject::cast(obj); 100 JSObject* jsobj = JSObject::cast(obj);
101 if (jsobj->GetInternalFieldCount() > 0) { 101 if (jsobj->GetEmbedderFieldCount() > 0) {
102 DCHECK_NOT_NULL(serialize_internal_fields_.callback); 102 DCHECK_NOT_NULL(serialize_embedder_fields_.callback);
103 internal_field_holders_.Add(jsobj); 103 embedder_field_holders_.Add(jsobj);
104 } 104 }
105 } 105 }
106 106
107 // Object has not yet been serialized. Serialize it here. 107 // Object has not yet been serialized. Serialize it here.
108 ObjectSerializer serializer(this, obj, &sink_, how_to_code, where_to_point); 108 ObjectSerializer serializer(this, obj, &sink_, how_to_code, where_to_point);
109 serializer.Serialize(); 109 serializer.Serialize();
110 } 110 }
111 111
112 bool PartialSerializer::ShouldBeInThePartialSnapshotCache(HeapObject* o) { 112 bool PartialSerializer::ShouldBeInThePartialSnapshotCache(HeapObject* o) {
113 // Scripts should be referred only through shared function infos. We can't 113 // Scripts should be referred only through shared function infos. We can't
114 // allow them to be part of the partial snapshot because they contain a 114 // allow them to be part of the partial snapshot because they contain a
115 // unique ID, and deserializing several partial snapshots containing script 115 // unique ID, and deserializing several partial snapshots containing script
116 // would cause dupes. 116 // would cause dupes.
117 DCHECK(!o->IsScript()); 117 DCHECK(!o->IsScript());
118 return o->IsName() || o->IsSharedFunctionInfo() || o->IsHeapNumber() || 118 return o->IsName() || o->IsSharedFunctionInfo() || o->IsHeapNumber() ||
119 o->IsCode() || o->IsScopeInfo() || o->IsAccessorInfo() || 119 o->IsCode() || o->IsScopeInfo() || o->IsAccessorInfo() ||
120 o->IsTemplateInfo() || 120 o->IsTemplateInfo() ||
121 o->map() == 121 o->map() ==
122 startup_serializer_->isolate()->heap()->fixed_cow_array_map(); 122 startup_serializer_->isolate()->heap()->fixed_cow_array_map();
123 } 123 }
124 124
125 void PartialSerializer::SerializeInternalFields() { 125 void PartialSerializer::SerializeEmbedderFields() {
126 int count = internal_field_holders_.length(); 126 int count = embedder_field_holders_.length();
127 if (count == 0) return; 127 if (count == 0) return;
128 DisallowHeapAllocation no_gc; 128 DisallowHeapAllocation no_gc;
129 DisallowJavascriptExecution no_js(isolate()); 129 DisallowJavascriptExecution no_js(isolate());
130 DisallowCompilation no_compile(isolate()); 130 DisallowCompilation no_compile(isolate());
131 DCHECK_NOT_NULL(serialize_internal_fields_.callback); 131 DCHECK_NOT_NULL(serialize_embedder_fields_.callback);
132 sink_.Put(kInternalFieldsData, "internal fields data"); 132 sink_.Put(kEmbedderFieldsData, "embedder fields data");
133 while (internal_field_holders_.length() > 0) { 133 while (embedder_field_holders_.length() > 0) {
134 HandleScope scope(isolate()); 134 HandleScope scope(isolate());
135 Handle<JSObject> obj(internal_field_holders_.RemoveLast(), isolate()); 135 Handle<JSObject> obj(embedder_field_holders_.RemoveLast(), isolate());
136 SerializerReference reference = reference_map_.Lookup(*obj); 136 SerializerReference reference = reference_map_.Lookup(*obj);
137 DCHECK(reference.is_back_reference()); 137 DCHECK(reference.is_back_reference());
138 int internal_fields_count = obj->GetInternalFieldCount(); 138 int embedder_fields_count = obj->GetEmbedderFieldCount();
139 for (int i = 0; i < internal_fields_count; i++) { 139 for (int i = 0; i < embedder_fields_count; i++) {
140 if (obj->GetInternalField(i)->IsHeapObject()) continue; 140 if (obj->GetEmbedderField(i)->IsHeapObject()) continue;
141 StartupData data = serialize_internal_fields_.callback( 141 StartupData data = serialize_embedder_fields_.callback(
142 v8::Utils::ToLocal(obj), i, serialize_internal_fields_.data); 142 v8::Utils::ToLocal(obj), i, serialize_embedder_fields_.data);
143 sink_.Put(kNewObject + reference.space(), "internal field holder"); 143 sink_.Put(kNewObject + reference.space(), "embedder field holder");
144 PutBackReference(*obj, reference); 144 PutBackReference(*obj, reference);
145 sink_.PutInt(i, "internal field index"); 145 sink_.PutInt(i, "embedder field index");
146 sink_.PutInt(data.raw_size, "internal fields data size"); 146 sink_.PutInt(data.raw_size, "embedder fields data size");
147 sink_.PutRaw(reinterpret_cast<const byte*>(data.data), data.raw_size, 147 sink_.PutRaw(reinterpret_cast<const byte*>(data.data), data.raw_size,
148 "internal fields data"); 148 "embedder fields data");
149 delete[] data.data; 149 delete[] data.data;
150 } 150 }
151 } 151 }
152 sink_.Put(kSynchronize, "Finished with internal fields data"); 152 sink_.Put(kSynchronize, "Finished with embedder fields data");
153 } 153 }
154 154
155 } // namespace internal 155 } // namespace internal
156 } // namespace v8 156 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/partial-serializer.h ('k') | src/snapshot/serializer-common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698