32 #if V8_TARGET_ARCH_IA32
35 #elif V8_TARGET_ARCH_X64
38 #elif V8_TARGET_ARCH_ARM
41 #elif V8_TARGET_ARCH_ARM64
44 #elif V8_TARGET_ARCH_MIPS
48 #error Unsupported target architecture.
55 HGraph* LCodeGenBase::graph()
const {
56 return chunk()->graph();
60 LCodeGenBase::LCodeGenBase(LChunk* chunk,
61 MacroAssembler* assembler,
62 CompilationInfo*
info)
63 : chunk_(static_cast<LPlatformChunk*>(chunk)),
69 current_instruction_(-1),
70 instructions_(chunk->instructions()),
71 last_lazy_deopt_pc_(0) {
75 bool LCodeGenBase::GenerateBody() {
77 bool emit_instructions =
true;
78 LCodeGen* codegen =
static_cast<LCodeGen*
>(
this);
79 for (current_instruction_ = 0;
80 !is_aborted() && current_instruction_ < instructions_->length();
81 current_instruction_++) {
82 LInstruction* instr = instructions_->at(current_instruction_);
85 if (instr->IsLabel()) {
86 emit_instructions = !LLabel::cast(instr)->HasReplacement() &&
87 (!FLAG_unreachable_code_elimination ||
88 instr->hydrogen_value()->block()->IsReachable());
89 if (FLAG_code_comments && !emit_instructions) {
91 ";;; <@%d,#%d> -------------------- B%d (unreachable/replaced) "
92 "--------------------",
94 instr->hydrogen_value()->id(),
95 instr->hydrogen_value()->block()->block_id());
98 if (!emit_instructions)
continue;
100 if (FLAG_code_comments && instr->HasInterestingComment(codegen)) {
101 Comment(
";;; <@%d,#%d> %s",
102 current_instruction_,
103 instr->hydrogen_value()->id(),
107 GenerateBodyInstructionPre(instr);
109 HValue* value = instr->hydrogen_value();
110 if (!value->position().IsUnknown()) {
111 RecordAndWritePosition(
112 chunk()->graph()->SourcePositionToScriptPosition(value->position()));
115 instr->CompileToNative(codegen);
117 GenerateBodyInstructionPost(instr);
120 last_lazy_deopt_pc_ = masm()->pc_offset();
121 return !is_aborted();
125 void LCodeGenBase::Comment(
const char* format, ...) {
126 if (!FLAG_code_comments)
return;
128 StringBuilder builder(buffer,
ARRAY_SIZE(buffer));
130 va_start(arguments, format);
131 builder.AddFormattedList(format, arguments);
136 size_t length = builder.position();
138 OS::MemCopy(copy.start(), builder.Finalize(), copy.length());
139 masm()->RecordComment(copy.start());
143 int LCodeGenBase::GetNextEmittedBlock()
const {
144 for (
int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) {
145 if (!graph()->blocks()->at(i)->IsReachable())
continue;
146 if (!chunk_->GetLabel(i)->HasReplacement())
return i;
152 void LCodeGenBase::RegisterWeakObjectsInOptimizedCode(Handle<Code>
code) {
153 ASSERT(code->is_optimized_code());
154 ZoneList<Handle<Map> > maps(1, zone());
155 ZoneList<Handle<JSObject> > objects(1, zone());
156 ZoneList<Handle<Cell> > cells(1, zone());
157 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
158 RelocInfo::ModeMask(RelocInfo::CELL);
159 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
160 RelocInfo::Mode
mode = it.rinfo()->rmode();
161 if (mode == RelocInfo::CELL &&
162 code->IsWeakObjectInOptimizedCode(it.rinfo()->target_cell())) {
163 Handle<Cell> cell(it.rinfo()->target_cell());
164 cells.Add(cell, zone());
165 }
else if (mode == RelocInfo::EMBEDDED_OBJECT &&
166 code->IsWeakObjectInOptimizedCode(it.rinfo()->target_object())) {
167 if (it.rinfo()->target_object()->IsMap()) {
168 Handle<Map>
map(
Map::cast(it.rinfo()->target_object()));
169 maps.Add(
map, zone());
170 }
else if (it.rinfo()->target_object()->IsJSObject()) {
171 Handle<JSObject> object(
JSObject::cast(it.rinfo()->target_object()));
172 objects.Add(
object, zone());
173 }
else if (it.rinfo()->target_object()->IsCell()) {
174 Handle<Cell> cell(
Cell::cast(it.rinfo()->target_object()));
175 cells.Add(cell, zone());
183 NoWeakObjectVerificationScope disable_verification_of_embedded_objects;
185 for (
int i = 0; i < maps.length(); i++) {
188 for (
int i = 0; i < objects.length(); i++) {
191 for (
int i = 0; i < cells.length(); i++) {
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 map
static Map * cast(Object *obj)
#define ASSERT(condition)
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
static Cell * cast(Object *obj)
static void MemCopy(void *dest, const void *src, size_t size)
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 code(assertions) for debugging") DEFINE_bool(code_comments
static Vector< T > New(int length)
void AddWeakObjectToCodeDependency(Heap *heap, Handle< Object > object, Handle< Code > code)
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
static JSObject * cast(Object *obj)