// Copyright 2012 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/compiler.h" #include #include #include "src/api-inl.h" #include "src/asmjs/asm-js.h" #include "src/assembler-inl.h" #include "src/ast/prettyprinter.h" #include "src/ast/scopes.h" #include "src/base/optional.h" #include "src/bootstrapper.h" #include "src/compilation-cache.h" #include "src/compiler-dispatcher/compiler-dispatcher.h" #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h" #include "src/compiler/pipeline.h" #include "src/debug/debug.h" #include "src/debug/liveedit.h" #include "src/frames-inl.h" #include "src/globals.h" #include "src/heap/heap.h" #include "src/interpreter/interpreter.h" #include "src/isolate-inl.h" #include "src/log-inl.h" #include "src/messages.h" #include "src/objects/map.h" #include "src/optimized-compilation-info.h" #include "src/parsing/parse-info.h" #include "src/parsing/parser.h" #include "src/parsing/parsing.h" #include "src/parsing/rewriter.h" #include "src/parsing/scanner-character-streams.h" #include "src/runtime-profiler.h" #include "src/snapshot/code-serializer.h" #include "src/unicode-cache.h" #include "src/unoptimized-compilation-info.h" #include "src/vm-state-inl.h" namespace v8 { namespace internal { // A wrapper around a OptimizedCompilationInfo that detaches the Handles from // the underlying DeferredHandleScope and stores them in info_ on // destruction. class CompilationHandleScope final { public: explicit CompilationHandleScope(Isolate* isolate, OptimizedCompilationInfo* info) : deferred_(isolate), info_(info) {} ~CompilationHandleScope() { info_->set_deferred_handles(deferred_.Detach()); } private: DeferredHandleScope deferred_; OptimizedCompilationInfo* info_; }; // Helper that times a scoped region and records the elapsed time. struct ScopedTimer { explicit ScopedTimer(base::TimeDelta* location) : location_(location) { DCHECK_NOT_NULL(location_); timer_.Start(); } ~ScopedTimer() { *location_ += timer_.Elapsed(); } base::ElapsedTimer timer_; base::TimeDelta* location_; }; namespace { void LogFunctionCompilation(CodeEventListener::LogEventsAndTags tag, Handle shared, Handle