// 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. #ifndef V8_COMPILER_H_ #define V8_COMPILER_H_ #include #include "src/allocation.h" #include "src/bailout-reason.h" #include "src/contexts.h" #include "src/isolate.h" #include "src/zone/zone.h" namespace v8 { namespace internal { // Forward declarations. class CompilationInfo; class CompilationJob; class JavaScriptFrame; class ParseInfo; class ScriptData; template class ThreadedList; template class ThreadedListZoneEntry; // The V8 compiler API. // // This is the central hub for dispatching to the various compilers within V8. // Logic for which compiler to choose and how to wire compilation results into // the object heap should be kept inside this class. // // General strategy: Scripts are translated into anonymous functions w/o // parameters which then can be executed. If the source code contains other // functions, they might be compiled and allocated as part of the compilation // of the source code or deferred for lazy compilation at a later point. class V8_EXPORT_PRIVATE Compiler : public AllStatic { public: enum ClearExceptionFlag { KEEP_EXCEPTION, CLEAR_EXCEPTION }; enum ConcurrencyMode { NOT_CONCURRENT, CONCURRENT }; enum CompilationTier { INTERPRETED, BASELINE, OPTIMIZED }; // =========================================================================== // The following family of methods ensures a given function is compiled. The // general contract is that failures will be reported by returning {false}, // whereas successful compilation ensures the {is_compiled} predicate on the // given function holds (except for live-edit, which compiles the world). static bool Compile(Handle function, ClearExceptionFlag flag); static bool CompileBaseline(Handle function); static bool CompileOptimized(Handle function, ConcurrencyMode); static bool CompileDebugCode(Handle shared); static MaybeHandle CompileForLiveEdit(Handle