28 #ifndef V8_COMPILER_H_
29 #define V8_COMPILER_H_
44 explicit CompilationInfo(Handle<Script> script);
45 explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info);
46 explicit CompilationInfo(Handle<JSFunction> closure);
49 ASSERT(Isolate::Current() == isolate_);
52 bool is_lazy()
const {
return IsLazy::decode(flags_); }
53 bool is_eval()
const {
return IsEval::decode(flags_); }
54 bool is_global()
const {
return IsGlobal::decode(flags_); }
58 return LanguageModeField::decode(flags_);
60 bool is_in_loop()
const {
return IsInLoop::decode(flags_); }
75 flags_ |= IsEval::encode(
true);
79 flags_ |= IsGlobal::encode(
true);
83 this->language_mode() == language_mode ||
85 flags_ = LanguageModeField::update(flags_, language_mode);
89 flags_ |= IsInLoop::encode(
true);
92 flags_ |= IsNative::encode(
true);
95 return IsNative::decode(flags_);
107 global_scope_ = global_scope;
112 extension_ = extension;
116 pre_parse_data_ = pre_parse_data;
120 calling_context_ = context;
124 osr_ast_id_ = osr_ast_id;
127 ASSERT(mode_ != OPTIMIZE);
129 flags_ |= IsCompilingForDebugging::encode(
true);
130 if (current_code->is_compiled_optimizable()) {
131 EnableDeoptimizationSupport();
133 mode_ = CompilationInfo::NONOPT;
137 return IsCompilingForDebugging::decode(flags_);
141 return !closure().is_null() && (closure()->context()->global() !=
NULL);
145 return has_global_object() ? closure()->context()->global() :
NULL;
153 osr_ast_id_ = osr_ast_id;
155 void DisableOptimization();
159 return SupportsDeoptimization::decode(flags_);
163 flags_ |= SupportsDeoptimization::encode(
true);
167 bool ShouldSelfOptimize();
171 void AbortOptimization();
187 CompilationInfo() : function_(
NULL) {}
189 void Initialize(Mode mode) {
191 ASSERT(!script_.is_null());
195 if (!shared_info_.is_null()) {
197 SetLanguageMode(shared_info_->language_mode());
201 void SetMode(Mode mode) {
210 class IsLazy:
public BitField<bool, 0, 1> {};
212 class IsEval:
public BitField<bool, 1, 1> {};
213 class IsGlobal:
public BitField<bool, 2, 1> {};
215 class IsInLoop:
public BitField<bool, 3, 1> {};
217 class LanguageModeField:
public BitField<LanguageMode, 4, 2> {};
219 class IsNative:
public BitField<bool, 6, 1> {};
221 class SupportsDeoptimization:
public BitField<bool, 7, 1> {};
224 class IsCompilingForDebugging:
public BitField<bool, 8, 1> {};
231 FunctionLiteral* function_;
236 Scope* global_scope_;
241 Handle<JSFunction> closure_;
242 Handle<SharedFunctionInfo> shared_info_;
243 Handle<Script> script_;
247 ScriptDataImpl* pre_parse_data_;
251 Handle<Context> calling_context_;
319 #ifdef ENABLE_DEBUGGER_SUPPORT
320 static bool MakeCodeForLiveEdit(CompilationInfo* info);
324 CompilationInfo* info,
331 #endif // V8_COMPILER_H_
GlobalObject * global_object() const
LanguageMode language_mode() const
static const int kDefaultMaxOptCount
bool is_extended_mode() const
void EnableDeoptimizationSupport()
static bool UseCrankshaft()
v8::Extension * extension() const
void SetGlobalScope(Scope *global_scope)
bool has_global_object() const
void SetCode(Handle< Code > code)
#define ASSERT(condition)
void SetExtension(v8::Extension *extension)
static Handle< SharedFunctionInfo > CompileEval(Handle< String > source, Handle< Context > context, bool is_global, LanguageMode language_mode, int scope_position)
bool IsOptimizable() const
bool IsOptimizing() const
ScriptDataImpl * pre_parse_data() const
bool IsCompilingForDebugging()
Scope * global_scope() const
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
static void SetFunctionInfo(Handle< SharedFunctionInfo > function_info, FunctionLiteral *lit, bool is_toplevel, Handle< Script > script)
bool HasDeoptimizationSupport() const
Handle< SharedFunctionInfo > shared_info() const
void SetPreParseData(ScriptDataImpl *pre_parse_data)
void SetOptimizing(int osr_ast_id)
Handle< Code > code() const
void SetLanguageMode(LanguageMode language_mode)
static Handle< SharedFunctionInfo > Compile(Handle< String > source, Handle< Object > script_name, int line_offset, int column_offset, v8::Extension *extension, ScriptDataImpl *pre_data, Handle< Object > script_data, NativesFlag is_natives_code)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
static Handle< SharedFunctionInfo > BuildFunctionInfo(FunctionLiteral *node, Handle< Script > script)
Handle< Context > calling_context() const
void SetFunction(FunctionLiteral *literal)
Handle< Script > script() const
Handle< JSFunction > closure() const
static bool CompileLazy(CompilationInfo *info)
void MarkCompilingForDebugging(Handle< Code > current_code)
static const int kMaxInliningLevels
void SetOsrAstId(int osr_ast_id)
void SetCallingContext(Handle< Context > context)
static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, CompilationInfo *info, Handle< SharedFunctionInfo > shared)
void SetScope(Scope *scope)
static const int kCallsUntilPrimitiveOpt
bool is_classic_mode() const