// 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 #include "src/code-stubs.h" #include "src/counters.h" #include "src/log.h" #include "src/macro-assembler.h" #include "src/objects-inl.h" #include "src/snapshot/object-deserializer.h" #include "src/snapshot/snapshot.h" #include "src/version.h" #include "src/visitors.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(); } } // static ScriptCompiler::CachedData* CodeSerializer::Serialize( Handle info, Handle source) { 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