HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Android 10
|
10.0.0_r6
下载
查看原文件
收藏
根目录
external
v8
src
compiler.h
// 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
#include "src/allocation.h" #include "src/bailout-reason.h" #include "src/code-events.h" #include "src/contexts.h" #include "src/isolate.h" #include "src/unicode-cache.h" #include "src/zone/zone.h" namespace v8 { namespace internal { // Forward declarations. class JavaScriptFrame; class OptimizedCompilationInfo; class OptimizedCompilationJob; class ParseInfo; class Parser; class ScriptData; struct ScriptStreamingData; class UnoptimizedCompilationInfo; class UnoptimizedCompilationJob; typedef std::forward_list
> UnoptimizedCompilationJobList; // 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 }; // =========================================================================== // 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
shared, ClearExceptionFlag flag); static bool Compile(Handle
function, ClearExceptionFlag flag); static bool CompileOptimized(Handle
function, ConcurrencyMode); V8_WARN_UNUSED_RESULT static MaybeHandle
CompileForLiveEdit(ParseInfo* parse_info, Isolate* isolate); // Creates a new task that when run will parse and compile the streamed // script associated with |streaming_data| and can be finalized with // Compiler::GetSharedFunctionInfoForStreamedScript. // Note: does not take ownership of streaming_data. static ScriptCompiler::ScriptStreamingTask* NewBackgroundCompileTask( ScriptStreamingData* streaming_data, Isolate* isolate); // Generate and install code from previously queued compilation job. static bool FinalizeCompilationJob(UnoptimizedCompilationJob* job, Handle
shared_info, Isolate* isolate); static bool FinalizeCompilationJob(OptimizedCompilationJob* job, Isolate* isolate); // Give the compiler a chance to perform low-latency initialization tasks of // the given {function} on its instantiation. Note that only the runtime will // offer this chance, optimized closure instantiation will not call this. static void PostInstantiation(Handle
function, PretenureFlag); // Parser::Parse, then Compiler::Analyze. static bool ParseAndAnalyze(ParseInfo* parse_info, Handle
shared_info, Isolate* isolate); // Rewrite and analyze scopes. static bool Analyze(ParseInfo* parse_info); // =========================================================================== // The following family of methods instantiates new functions for scripts or // function literals. The decision whether those functions will be compiled, // is left to the discretion of the compiler. // // Please note this interface returns shared function infos. This means you // need to call Factory::NewFunctionFromSharedFunctionInfo before you have a // real function with a context. // Create a (bound) function for a String source within a context for eval. V8_WARN_UNUSED_RESULT static MaybeHandle
GetFunctionFromEval( Handle
source, Handle
outer_info, Handle
context, LanguageMode language_mode, ParseRestriction restriction, int parameters_end_pos, int eval_scope_position, int eval_position, int line_offset = 0, int column_offset = 0, Handle
script_name = Handle
(), ScriptOriginOptions options = ScriptOriginOptions()); struct ScriptDetails { ScriptDetails() : line_offset(0), column_offset(0) {} explicit ScriptDetails(Handle
script_name) : line_offset(0), column_offset(0), name_obj(script_name) {} int line_offset; int column_offset; i::MaybeHandle
name_obj; i::MaybeHandle
source_map_url; i::MaybeHandle
host_defined_options; }; // Create a function that results from wrapping |source| in a function, // with |arguments| being a list of parameters for that function. V8_WARN_UNUSED_RESULT static MaybeHandle
GetWrappedFunction( Handle
source, Handle
arguments, Handle
context, const ScriptDetails& script_details, ScriptOriginOptions origin_options, ScriptData* cached_data, v8::ScriptCompiler::CompileOptions compile_options, v8::ScriptCompiler::NoCacheReason no_cache_reason); // Returns true if the embedder permits compiling the given source string in // the given context. static bool CodeGenerationFromStringsAllowed(Isolate* isolate, Handle
context, Handle
source); // Create a (bound) function for a String source within a context for eval. V8_WARN_UNUSED_RESULT static MaybeHandle
GetFunctionFromString( Handle
context, Handle
source, ParseRestriction restriction, int parameters_end_pos); // Create a shared function info object for a String source. static MaybeHandle
GetSharedFunctionInfoForScript( Isolate* isolate, Handle
source, const ScriptDetails& script_details, ScriptOriginOptions origin_options, v8::Extension* extension, ScriptData* cached_data, ScriptCompiler::CompileOptions compile_options, ScriptCompiler::NoCacheReason no_cache_reason, NativesFlag is_natives_code); // Create a shared function info object for a Script source that has already // been parsed and possibly compiled on a background thread while being loaded // from a streamed source. On return, the data held by |streaming_data| will // have been released, however the object itself isn't freed and is still // owned by the caller. static MaybeHandle
GetSharedFunctionInfoForStreamedScript( Isolate* isolate, Handle
source, const ScriptDetails& script_details, ScriptOriginOptions origin_options, ScriptStreamingData* streaming_data); // Create a shared function info object for the given function literal // node (the code may be lazily compiled). static Handle
GetSharedFunctionInfo(FunctionLiteral* node, Handle
登录后可以享受更多权益
您还没有登录,登录后您可以:
收藏Android系统代码
收藏喜欢的文章
多个平台共享账号
去登录
首次使用?从这里
注册