Merge V8 5.3.332.45. DO NOT MERGE
Test: Manual
FPIIM-449
Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/src/snapshot/startup-serializer.cc b/src/snapshot/startup-serializer.cc
index c3f9b3e..80598e8 100644
--- a/src/snapshot/startup-serializer.cc
+++ b/src/snapshot/startup-serializer.cc
@@ -11,10 +11,11 @@
namespace internal {
StartupSerializer::StartupSerializer(
- Isolate* isolate, SnapshotByteSink* sink,
- FunctionCodeHandling function_code_handling)
- : Serializer(isolate, sink),
- function_code_handling_(function_code_handling),
+ Isolate* isolate,
+ v8::SnapshotCreator::FunctionCodeHandling function_code_handling)
+ : Serializer(isolate),
+ clear_function_code_(function_code_handling ==
+ v8::SnapshotCreator::FunctionCodeHandling::kClear),
serializing_builtins_(false) {
InitializeCodeAddressMap();
}
@@ -27,21 +28,21 @@
WhereToPoint where_to_point, int skip) {
DCHECK(!obj->IsJSFunction());
- if (function_code_handling_ == CLEAR_FUNCTION_CODE) {
+ if (clear_function_code_) {
if (obj->IsCode()) {
Code* code = Code::cast(obj);
// If the function code is compiled (either as native code or bytecode),
// replace it with lazy-compile builtin. Only exception is when we are
// serializing the canonical interpreter-entry-trampoline builtin.
if (code->kind() == Code::FUNCTION ||
- (!serializing_builtins_ && code->is_interpreter_entry_trampoline())) {
+ (!serializing_builtins_ &&
+ code->is_interpreter_trampoline_builtin())) {
obj = isolate()->builtins()->builtin(Builtins::kCompileLazy);
}
} else if (obj->IsBytecodeArray()) {
obj = isolate()->heap()->undefined_value();
}
} else if (obj->IsCode()) {
- DCHECK_EQ(KEEP_FUNCTION_CODE, function_code_handling_);
Code* code = Code::cast(obj);
if (code->kind() == Code::FUNCTION) {
code->ClearInlineCaches();
@@ -49,6 +50,8 @@
}
}
+ if (SerializeHotObject(obj, how_to_code, where_to_point, skip)) return;
+
int root_index = root_index_map_.Lookup(obj);
// We can only encode roots as such if it has already been serialized.
// That applies to root indices below the wave front.
@@ -59,12 +62,12 @@
}
}
- if (SerializeKnownObject(obj, how_to_code, where_to_point, skip)) return;
+ if (SerializeBackReference(obj, how_to_code, where_to_point, skip)) return;
FlushSkip(skip);
// Object has not yet been serialized. Serialize it here.
- ObjectSerializer object_serializer(this, obj, sink_, how_to_code,
+ ObjectSerializer object_serializer(this, obj, &sink_, how_to_code,
where_to_point);
object_serializer.Serialize();
@@ -89,11 +92,22 @@
Pad();
}
+int StartupSerializer::PartialSnapshotCacheIndex(HeapObject* heap_object) {
+ int index;
+ if (!partial_cache_index_map_.LookupOrInsert(heap_object, &index)) {
+ // This object is not part of the partial snapshot cache yet. Add it to the
+ // startup snapshot so we can refer to it via partial snapshot index from
+ // the partial snapshot.
+ VisitPointer(reinterpret_cast<Object**>(&heap_object));
+ }
+ return index;
+}
+
void StartupSerializer::Synchronize(VisitorSynchronization::SyncTag tag) {
// We expect the builtins tag after builtins have been serialized.
DCHECK(!serializing_builtins_ || tag == VisitorSynchronization::kBuiltins);
serializing_builtins_ = (tag == VisitorSynchronization::kHandleScope);
- sink_->Put(kSynchronize, "Synchronize");
+ sink_.Put(kSynchronize, "Synchronize");
}
void StartupSerializer::SerializeStrongReferences() {