// Copyright 2016 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/snapshot/code-serializer.h" #include "src/base/platform/platform.h" #include "src/codegen/macro-assembler.h" #include "src/common/globals.h" #include "src/debug/debug.h" #include "src/heap/heap-inl.h" #include "src/heap/local-factory-inl.h" #include "src/logging/counters.h" #include "src/logging/log.h" #include "src/objects/objects-inl.h" #include "src/objects/slots.h" #include "src/objects/visitors.h" #include "src/snapshot/object-deserializer.h" #include "src/snapshot/snapshot-utils.h" #include "src/snapshot/snapshot.h" #include "src/utils/version.h" namespace v8 { namespace internal { ScriptData::ScriptData(const byte* data, int length) : owns_data_(false), rejected_(false), data_(data), length_(length) { if (!IsAligned(reinterpret_cast(data), kPointerAlignment)) { byte* copy = NewArray(length); DCHECK(IsAligned(reinterpret_cast(copy), kPointerAlignment)); CopyBytes(copy, data, length); data_ = copy; AcquireDataOwnership(); } } CodeSerializer::CodeSerializer(Isolate* isolate, uint32_t source_hash) : Serializer(isolate, Snapshot::kDefaultSerializerFlags), source_hash_(source_hash) { allocator()->UseCustomChunkSize(FLAG_serialization_chunk_size); } // static ScriptCompiler::CachedData* CodeSerializer::Serialize( Handle info) { Isolate* isolate = info->GetIsolate(); TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute"); HistogramTimerScope histogram_timer(isolate->counters()->compile_serialize()); RuntimeCallTimerScope runtimeTimer(isolate, RuntimeCallCounterId::kCompileSerialize); TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileSerialize"); base::ElapsedTimer timer; if (FLAG_profile_deserialization) timer.Start(); Handle