28 #ifndef V8_COMPILER_H_
29 #define V8_COMPILER_H_
51 ASSERT(Isolate::Current() == isolate_);
57 bool is_lazy()
const {
return IsLazy::decode(flags_); }
58 bool is_eval()
const {
return IsEval::decode(flags_); }
59 bool is_global()
const {
return IsGlobal::decode(flags_); }
63 return LanguageModeField::decode(flags_);
65 bool is_in_loop()
const {
return IsInLoop::decode(flags_); }
80 flags_ |= IsEval::encode(
true);
84 flags_ |= IsGlobal::encode(
true);
90 flags_ = LanguageModeField::update(flags_, language_mode);
94 flags_ |= IsInLoop::encode(
true);
97 flags_ |= IsNative::encode(
true);
100 return IsNative::decode(flags_);
127 ASSERT(mode_ != OPTIMIZE);
128 ASSERT(current_code->kind() == Code::FUNCTION);
129 flags_ |= IsCompilingForDebugging::encode(
true);
130 if (current_code->is_compiled_optimizable()) {
133 mode_ = CompilationInfo::NONOPT;
137 return IsCompilingForDebugging::decode(flags_);
160 return SupportsDeoptimization::decode(flags_);
164 flags_ |= SupportsDeoptimization::encode(
true);
176 deferred_handles_ = deferred_handles;
180 SaveHandle(&closure_);
181 SaveHandle(&shared_info_);
182 SaveHandle(&context_);
183 SaveHandle(&script_);
203 void Initialize(Mode mode) {
205 ASSERT(!script_.is_null());
209 if (!shared_info_.is_null()) {
216 void SetMode(Mode mode) {
225 class IsLazy:
public BitField<bool, 0, 1> {};
227 class IsEval:
public BitField<bool, 1, 1> {};
228 class IsGlobal:
public BitField<bool, 2, 1> {};
230 class IsInLoop:
public BitField<bool, 3, 1> {};
232 class LanguageModeField:
public BitField<LanguageMode, 4, 2> {};
234 class IsNative:
public BitField<bool, 6, 1> {};
236 class SupportsDeoptimization:
public BitField<bool, 7, 1> {};
246 FunctionLiteral* function_;
251 Scope* global_scope_;
256 Handle<JSFunction> closure_;
257 Handle<SharedFunctionInfo> shared_info_;
258 Handle<Script> script_;
262 ScriptDataImpl* pre_parse_data_;
266 Handle<Context> context_;
270 BailoutId osr_ast_id_;
276 DeferredHandles* deferred_handles_;
279 void SaveHandle(Handle<T> *
object) {
280 if (!object->is_null()) {
281 Handle<T> handle(*(*
object));
286 const char* bailout_reason_;
298 zone_(script->GetIsolate()),
302 zone_(shared_info->GetIsolate()),
306 zone_(closure->GetIsolate()),
311 ZoneScope zone_scope_;
321 : deferred_(info->isolate()), info_(info) {}
323 info_->set_deferred_handles(deferred_.Detach());
347 graph_builder_(
NULL),
350 time_taken_to_create_graph_(0),
351 time_taken_to_optimize_(0),
352 time_taken_to_codegen_(0),
378 int64_t time_taken_to_create_graph_;
379 int64_t time_taken_to_optimize_;
380 int64_t time_taken_to_codegen_;
384 last_status_ = status;
387 void RecordOptimizationStats();
391 : compiler_(compiler),
393 location_(location) { }
465 #ifdef ENABLE_DEBUGGER_SUPPORT
477 #endif // V8_COMPILER_H_
CompilationInfoWithZone(Handle< SharedFunctionInfo > shared_info)
const char * bailout_reason() const
void MarkCompilingForDebugging(Handle< Code > current_code)
MUST_USE_RESULT Status CreateGraph()
LanguageMode language_mode() const
bool HasDeoptimizationSupport() const
static bool UseCrankshaft()
void SetScope(Scope *scope)
void SetCode(Handle< Code > code)
ScriptDataImpl * pre_parse_data() const
CompilationInfo * info() const
~CompilationHandleScope()
CompilationInfoWithZone(Handle< JSFunction > closure)
Handle< Script > script() const
void EnableDeoptimizationSupport()
kPropertyAccessorsOffset kNamedPropertyHandlerOffset kInstanceTemplateOffset kAccessCheckInfoOffset kEvalFrominstructionsOffsetOffset kInstanceClassNameOffset kHiddenPrototypeBit kReadOnlyPrototypeBit is_toplevel
void SetPreParseData(ScriptDataImpl *pre_parse_data)
#define ASSERT(condition)
void SetExtension(v8::Extension *extension)
void SetLanguageMode(LanguageMode language_mode)
bool IsOptimizing() const
bool IsOptimizable() const
static Handle< SharedFunctionInfo > CompileEval(Handle< String > source, Handle< Context > context, bool is_global, LanguageMode language_mode, int scope_position)
static void RecompileParallel(Handle< JSFunction > function)
MUST_USE_RESULT Status AbortOptimization()
void DisableOptimization()
CompilationInfoWithZone(Handle< Script > script)
static void InstallOptimizedCode(OptimizingCompiler *info)
void SetOptimizing(BailoutId osr_ast_id)
v8::Extension * extension() const
BailoutId osr_ast_id() const
CompilationInfo(Handle< Script > script, Zone *zone)
CompilationHandleScope(CompilationInfo *info)
Handle< Code > code() const
bool ShouldSelfOptimize()
MUST_USE_RESULT Status GenerateAndInstallCode()
Scope * global_scope() const
static void SetFunctionInfo(Handle< SharedFunctionInfo > function_info, FunctionLiteral *lit, bool is_toplevel, Handle< Script > script)
Handle< JSFunction > closure() const
bool is_classic_mode() const
void SetContext(Handle< Context > context)
Status last_status() const
static Handle< SharedFunctionInfo > Compile(Handle< String > source, Handle< Object > script_name, int line_offset, int column_offset, Handle< Context > context, v8::Extension *extension, ScriptDataImpl *pre_data, Handle< Object > script_data, NativesFlag is_natives_code)
Handle< Context > context() const
void set_bailout_reason(const char *reason)
bool is_extended_mode() const
bool IsCompilingForDebugging()
Handle< SharedFunctionInfo > shared_info() const
OptimizingCompiler(CompilationInfo *info)
static Handle< SharedFunctionInfo > BuildFunctionInfo(FunctionLiteral *node, Handle< Script > script)
static bool CompileLazy(CompilationInfo *info)
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 use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra 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 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
GlobalObject * global_object() const
static const int kMaxInliningLevels
bool has_global_object() const
virtual ~CompilationInfo()
MUST_USE_RESULT Status OptimizeGraph()
static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, CompilationInfo *info, Handle< SharedFunctionInfo > shared)
void SetGlobalScope(Scope *global_scope)
void SetFunction(FunctionLiteral *literal)
static const int kCallsUntilPrimitiveOpt
void set_deferred_handles(DeferredHandles *deferred_handles)