28 #ifndef V8_COMPILER_H_
29 #define V8_COMPILER_H_
39 class HydrogenCodeStub;
72 bool is_lazy()
const {
return IsLazy::decode(flags_); }
73 bool is_eval()
const {
return IsEval::decode(flags_); }
74 bool is_global()
const {
return IsGlobal::decode(flags_); }
76 bool is_in_loop()
const {
return IsInLoop::decode(flags_); }
77 FunctionLiteral*
function()
const {
return function_; }
88 return cached_data_mode_;
100 flags_ |= IsEval::encode(
true);
104 flags_ |= IsGlobal::encode(
true);
108 parameter_count_ = parameter_count;
112 this_has_uses_ = has_no_uses;
115 return this_has_uses_;
119 flags_ = StrictModeField::update(flags_, strict_mode);
123 flags_ |= IsInLoop::encode(
true);
126 flags_ |= IsNative::encode(
true);
130 return IsNative::decode(flags_);
138 flags_ |= IsDeferredCalling::encode(
true);
142 return IsDeferredCalling::decode(flags_);
146 flags_ |= IsNonDeferredCalling::encode(
true);
150 return IsNonDeferredCalling::decode(flags_);
154 flags_ |= SavesCallerDoubles::encode(
true);
158 return SavesCallerDoubles::decode(flags_);
162 flags_ |= RequiresFrame::encode(
true);
166 return RequiresFrame::decode(flags_);
170 flags_ = ParseRestricitonField::update(flags_, restriction);
174 return ParseRestricitonField::decode(flags_);
207 flags_ |= IsCompilingForDebugging::encode(
true);
210 return IsCompilingForDebugging::decode(flags_);
213 SetMode(CompilationInfo::NONOPT);
218 (FLAG_trap_on_stub_deopt &&
IsStub());
233 bool IsStub()
const {
return mode_ == STUB; }
235 ASSERT(!shared_info_.is_null());
238 unoptimized_code_ = unoptimized;
245 return SupportsDeoptimization::decode(flags_);
249 flags_ |= SupportsDeoptimization::encode(
true);
257 deferred_handles_ = deferred_handles;
262 if (dependencies_[group] ==
NULL) {
265 return dependencies_[group];
273 SaveHandle(&closure_);
274 SaveHandle(&shared_info_);
275 SaveHandle(&context_);
276 SaveHandle(&script_);
277 SaveHandle(&unoptimized_code_);
285 return prologue_offset_;
297 if (no_frame_ranges_) no_frame_ranges_->Add(
OffsetRange(from, to));
302 no_frame_ranges_ =
NULL;
307 if (object_wrapper_.is_null()) {
311 return object_wrapper_;
315 ASSERT(!OptimizingCompilerThread::IsOptimizerThread(
isolate()));
316 abort_due_to_dependency_ =
true;
320 ASSERT(!OptimizingCompilerThread::IsOptimizerThread(
isolate()));
321 return abort_due_to_dependency_;
325 return osr_ast_id_ == osr_ast_id &&
function.is_identical_to(closure_);
356 void SetMode(Mode
mode) {
365 class IsLazy:
public BitField<bool, 0, 1> {};
367 class IsEval:
public BitField<bool, 1, 1> {};
368 class IsGlobal:
public BitField<bool, 2, 1> {};
370 class IsInLoop:
public BitField<bool, 3, 1> {};
372 class StrictModeField:
public BitField<StrictMode, 4, 1> {};
374 class IsNative:
public BitField<bool, 5, 1> {};
376 class SupportsDeoptimization:
public BitField<bool, 6, 1> {};
381 class IsCalling:
public BitField<bool, 8, 1> {};
383 class IsDeferredCalling:
public BitField<bool, 9, 1> {};
385 class IsNonDeferredCalling:
public BitField<bool, 10, 1> {};
387 class SavesCallerDoubles:
public BitField<bool, 11, 1> {};
389 class ParseRestricitonField:
public BitField<ParseRestriction, 12, 1> {};
391 class RequiresFrame:
public BitField<bool, 13, 1> {};
397 FunctionLiteral* function_;
402 Scope* global_scope_;
404 HydrogenCodeStub* code_stub_;
409 Handle<JSFunction> closure_;
410 Handle<SharedFunctionInfo> shared_info_;
411 Handle<Script> script_;
415 ScriptDataImpl** cached_data_;
420 Handle<Context> context_;
424 BailoutId osr_ast_id_;
428 Handle<Code> unoptimized_code_;
431 bool abort_due_to_dependency_;
437 DeferredHandles* deferred_handles_;
442 void SaveHandle(Handle<T> *
object) {
443 if (!object->is_null()) {
444 Handle<T>
handle(*(*
object));
451 int prologue_offset_;
453 List<OffsetRange>* no_frame_ranges_;
460 int parameter_count_;
464 Handle<Foreign> object_wrapper_;
466 int optimization_id_;
478 zone_(script->GetIsolate()) {}
481 zone_(shared_info->GetIsolate()) {}
484 zone_(closure->GetIsolate()) {}
507 : deferred_(info->isolate()), info_(info) {}
509 info_->set_deferred_handles(deferred_.Detach());
519 class HOptimizedGraphBuilder;
532 graph_builder_(
NULL),
536 awaiting_install_(
false) { }
565 awaiting_install_ =
true;
575 TimeDelta time_taken_to_create_graph_;
576 TimeDelta time_taken_to_optimize_;
577 TimeDelta time_taken_to_codegen_;
579 bool awaiting_install_;
582 last_status_ = status;
585 void RecordOptimizationStats();
589 : job_(job), location_(location) {
595 *location_ += timer_.Elapsed();
600 TimeDelta* location_;
624 #ifdef ENABLE_DEBUGGER_SUPPORT
641 bool is_shared_cross_origin,
675 CompilationPhase(
const char*
name, CompilationInfo*
info);
679 bool ShouldProduceTraceOutput()
const;
681 const char*
name()
const {
return name_; }
690 unsigned info_zone_start_allocation_size_;
699 #endif // V8_COMPILER_H_
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
CompilationInfoWithZone(Handle< SharedFunctionInfo > shared_info)
BailoutReason bailout_reason() const
static Handle< SharedFunctionInfo > CompileScript(Handle< String > source, Handle< Object > script_name, int line_offset, int column_offset, bool is_shared_cross_origin, Handle< Context > context, v8::Extension *extension, ScriptDataImpl **cached_data, CachedDataMode cached_data_mode, NativesFlag is_natives_code)
void MarkCompilingForDebugging()
static Handle< Code > GetCodeForDebugging(Handle< JSFunction > function)
void PrepareForCompilation(Scope *scope)
void SetParseRestriction(ParseRestriction restriction)
bool HasDeoptimizationSupport() const
void MarkAsRequiresFrame()
void SetCode(Handle< Code > code)
static Handle< Code > GetUnoptimizedCode(Handle< JSFunction > function)
~CompilationHandleScope()
CompilationInfoWithZone(Handle< JSFunction > closure)
static Handle< JSFunction > GetFunctionFromEval(Handle< String > source, Handle< Context > context, StrictMode strict_mode, ParseRestriction restriction, int scope_position)
Handle< Script > script() const
void EnableDeoptimizationSupport()
MUST_USE_RESULT Status AbortOptimization(BailoutReason reason=kNoReason)
bool HasSameOsrEntry(Handle< JSFunction > function, BailoutId osr_ast_id)
void set_this_has_uses(bool has_no_uses)
void set_bailout_reason(BailoutReason reason)
void SetOptimizing(BailoutId osr_ast_id, Handle< Code > unoptimized)
Isolate * isolate() const
static bool EnsureCompiled(Handle< JSFunction > function, ClearExceptionFlag flag)
const char * name() const
void MarkAsSavesCallerDoubles()
void MarkAsNonDeferredCalling()
#define ASSERT(condition)
void SetExtension(v8::Extension *extension)
bool IsOptimizing() const
int num_parameters() const
bool IsOptimizable() const
CompilationInfoWithZone(HydrogenCodeStub *stub, Isolate *isolate)
kInstanceClassNameOffset flag
void DisableOptimization()
void AbortDueToDependencyChange()
static Handle< Code > GetConcurrentlyOptimizedCode(OptimizedCompileJob *job)
CompilationInfoWithZone(Handle< Script > script)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization 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 VFP3 instructions if available enable use of NEON instructions if 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 d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_string(expose_natives_as
v8::Extension * extension() const
BailoutId osr_ast_id() const
Status last_status() const
bool IsWaitingForInstall()
CachedDataMode cached_data_mode() const
CompilationHandleScope(CompilationInfo *info)
Handle< Code > code() const
bool saves_caller_doubles() const
static Handle< Code > GetOptimizedCode(Handle< JSFunction > function, Handle< Code > current_code, ConcurrencyMode mode, BailoutId osr_ast_id=BailoutId::None())
bool ShouldSelfOptimize()
Code::Flags flags() const
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Handle< Code > unoptimized_code() const
Scope * global_scope() const
Handle< Foreign > object_wrapper()
void set_prologue_offset(int prologue_offset)
bool HasAbortedDueToDependencyChange()
CompilationInfo * info() const
void set_parameter_count(int parameter_count)
Handle< JSFunction > closure() const
bool ShouldTrapOnDeopt() const
int num_heap_slots() const
bool is_deferred_calling() const
Isolate * isolate() const
void MarkNonOptimizable()
void SetContext(Handle< Context > context)
HydrogenCodeStub * code_stub() const
Isolate * isolate() const
Handle< T > handle(T *t, Isolate *isolate)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
Handle< Context > context() const
void CommitDependencies(Handle< Code > code)
void SetStrictMode(StrictMode strict_mode)
ParseRestriction parse_restriction() const
bool IsCompilingForDebugging()
bool requires_frame() const
Handle< SharedFunctionInfo > shared_info() const
static const int kPrologueOffsetNotSet
OptimizedCompileJob(CompilationInfo *info)
MUST_USE_RESULT Status GenerateCode()
Handle< Foreign > NewForeign(Address addr, PretenureFlag pretenure=NOT_TENURED)
MUST_USE_RESULT Status CreateGraph()
#define ASSERT_EQ(v1, v2)
static Handle< SharedFunctionInfo > BuildFunctionInfo(FunctionLiteral *node, Handle< Script > script)
OffsetRange(int from, int to)
CompilationInfo * info() const
#define ASSERT_NE(v1, v2)
ZoneList< Handle< HeapObject > > * dependencies(DependentCode::DependencyGroup group)
GlobalObject * global_object() const
bool is_non_deferred_calling() const
bool has_global_object() const
List< OffsetRange > * ReleaseNoFrameRanges()
void SetCachedData(ScriptDataImpl **cached_data, CachedDataMode cached_data_mode)
ScriptDataImpl ** cached_data() const
int optimization_id() const
virtual ~CompilationInfo()
void AddNoFrameRange(int from, int to)
static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, CompilationInfo *info, Handle< SharedFunctionInfo > shared)
CompilationInfo(Handle< JSFunction > closure, Zone *zone)
void SetGlobalScope(Scope *global_scope)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization 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 VFP3 instructions if available enable use of NEON instructions if 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 d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
StrictMode strict_mode() const
void SetFunction(FunctionLiteral *literal)
void RollbackDependencies()
int prologue_offset() const
MUST_USE_RESULT Status AbortAndDisableOptimization(BailoutReason reason=kNoReason)
void MarkAsDeferredCalling()
MUST_USE_RESULT Status OptimizeGraph()
void set_deferred_handles(DeferredHandles *deferred_handles)
virtual ~CompilationInfoWithZone()