Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/x64/lithium-codegen-x64.h

Issue 22876009: Improve and simplify removal of unreachable code (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add missing file Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 14 matching lines...) Expand all
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_X64_LITHIUM_CODEGEN_X64_H_ 28 #ifndef V8_X64_LITHIUM_CODEGEN_X64_H_
29 #define V8_X64_LITHIUM_CODEGEN_X64_H_ 29 #define V8_X64_LITHIUM_CODEGEN_X64_H_
30 30
31 #include "x64/lithium-x64.h" 31 #include "x64/lithium-x64.h"
32 32
33 #include "checks.h" 33 #include "checks.h"
34 #include "deoptimizer.h" 34 #include "deoptimizer.h"
35 #include "lithium-codegen.h"
35 #include "safepoint-table.h" 36 #include "safepoint-table.h"
36 #include "scopes.h" 37 #include "scopes.h"
37 #include "v8utils.h" 38 #include "v8utils.h"
38 #include "x64/lithium-gap-resolver-x64.h" 39 #include "x64/lithium-gap-resolver-x64.h"
39 40
40 namespace v8 { 41 namespace v8 {
41 namespace internal { 42 namespace internal {
42 43
43 // Forward declarations. 44 // Forward declarations.
44 class LDeferredCode; 45 class LDeferredCode;
45 class SafepointGenerator; 46 class SafepointGenerator;
46 47
47 class LCodeGen V8_FINAL BASE_EMBEDDED { 48 class LCodeGen: public LCodeGenBase {
48 public: 49 public:
49 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) 50 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info)
50 : zone_(info->zone()), 51 : LCodeGenBase(chunk, assembler, info),
51 chunk_(static_cast<LPlatformChunk*>(chunk)),
52 masm_(assembler),
53 info_(info),
54 current_block_(-1),
55 current_instruction_(-1),
56 instructions_(chunk->instructions()),
57 deoptimizations_(4, info->zone()), 52 deoptimizations_(4, info->zone()),
58 jump_table_(4, info->zone()), 53 jump_table_(4, info->zone()),
59 deoptimization_literals_(8, info->zone()), 54 deoptimization_literals_(8, info->zone()),
60 inlined_function_count_(0), 55 inlined_function_count_(0),
61 scope_(info->scope()), 56 scope_(info->scope()),
62 status_(UNUSED),
63 translations_(info->zone()), 57 translations_(info->zone()),
64 deferred_(8, info->zone()), 58 deferred_(8, info->zone()),
65 osr_pc_offset_(-1), 59 osr_pc_offset_(-1),
66 last_lazy_deopt_pc_(0),
67 frame_is_built_(false), 60 frame_is_built_(false),
68 safepoints_(info->zone()), 61 safepoints_(info->zone()),
69 resolver_(this), 62 resolver_(this),
70 expected_safepoint_kind_(Safepoint::kSimple), 63 expected_safepoint_kind_(Safepoint::kSimple),
71 old_position_(RelocInfo::kNoPosition) { 64 old_position_(RelocInfo::kNoPosition) {
72 PopulateDeoptimizationLiteralsWithInlinedFunctions(); 65 PopulateDeoptimizationLiteralsWithInlinedFunctions();
73 } 66 }
74 67
75 // Simple accessors.
76 MacroAssembler* masm() const { return masm_; }
77 CompilationInfo* info() const { return info_; }
78 Isolate* isolate() const { return info_->isolate(); }
79 Factory* factory() const { return isolate()->factory(); }
80 Heap* heap() const { return isolate()->heap(); }
81 Zone* zone() const { return zone_; }
82
83 int LookupDestination(int block_id) const { 68 int LookupDestination(int block_id) const {
84 return chunk()->LookupDestination(block_id); 69 return chunk()->LookupDestination(block_id);
85 } 70 }
86 71
87 bool IsNextEmittedBlock(int block_id) const { 72 bool IsNextEmittedBlock(int block_id) const {
88 return LookupDestination(block_id) == GetNextEmittedBlock(); 73 return LookupDestination(block_id) == GetNextEmittedBlock();
89 } 74 }
90 75
91 bool NeedsEagerFrame() const { 76 bool NeedsEagerFrame() const {
92 return GetStackSlotCount() > 0 || 77 return GetStackSlotCount() > 0 ||
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 124
140 // Emit frame translation commands for an environment. 125 // Emit frame translation commands for an environment.
141 void WriteTranslation(LEnvironment* environment, Translation* translation); 126 void WriteTranslation(LEnvironment* environment, Translation* translation);
142 127
143 // Declare methods that deal with the individual node types. 128 // Declare methods that deal with the individual node types.
144 #define DECLARE_DO(type) void Do##type(L##type* node); 129 #define DECLARE_DO(type) void Do##type(L##type* node);
145 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) 130 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
146 #undef DECLARE_DO 131 #undef DECLARE_DO
147 132
148 private: 133 private:
149 enum Status {
150 UNUSED,
151 GENERATING,
152 DONE,
153 ABORTED
154 };
155
156 bool is_unused() const { return status_ == UNUSED; }
157 bool is_generating() const { return status_ == GENERATING; }
158 bool is_done() const { return status_ == DONE; }
159 bool is_aborted() const { return status_ == ABORTED; }
160
161 StrictModeFlag strict_mode_flag() const { 134 StrictModeFlag strict_mode_flag() const {
162 return info()->is_classic_mode() ? kNonStrictMode : kStrictMode; 135 return info()->is_classic_mode() ? kNonStrictMode : kStrictMode;
163 } 136 }
164 137
165 LPlatformChunk* chunk() const { return chunk_; } 138 LPlatformChunk* chunk() const { return chunk_; }
166 Scope* scope() const { return scope_; } 139 Scope* scope() const { return scope_; }
167 HGraph* graph() const { return chunk()->graph(); } 140 HGraph* graph() const { return chunk()->graph(); }
168 141
169 XMMRegister double_scratch0() const { return xmm0; } 142 XMMRegister double_scratch0() const { return xmm0; }
170 143
171 int GetNextEmittedBlock() const;
172
173 void EmitClassOfTest(Label* if_true, 144 void EmitClassOfTest(Label* if_true,
174 Label* if_false, 145 Label* if_false,
175 Handle<String> class_name, 146 Handle<String> class_name,
176 Register input, 147 Register input,
177 Register temporary, 148 Register temporary,
178 Register scratch); 149 Register scratch);
179 150
180 int GetStackSlotCount() const { return chunk()->spill_slot_count(); } 151 int GetStackSlotCount() const { return chunk()->spill_slot_count(); }
181 152
182 void Abort(BailoutReason reason); 153 void Abort(BailoutReason reason);
183 void FPRINTF_CHECKING Comment(const char* format, ...);
184 154
185 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); } 155 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); }
186 156
187 // Code generation passes. Returns true if code generation should 157 // Code generation passes. Returns true if code generation should
188 // continue. 158 // continue.
189 bool GeneratePrologue(); 159 bool GeneratePrologue();
190 bool GenerateBody();
191 bool GenerateDeferredCode(); 160 bool GenerateDeferredCode();
192 bool GenerateJumpTable(); 161 bool GenerateJumpTable();
193 bool GenerateSafepointTable(); 162 bool GenerateSafepointTable();
194 163
195 // Generates the custom OSR entrypoint and sets the osr_pc_offset. 164 // Generates the custom OSR entrypoint and sets the osr_pc_offset.
196 void GenerateOsrPrologue(); 165 void GenerateOsrPrologue();
197 166
198 enum SafepointMode { 167 enum SafepointMode {
199 RECORD_SIMPLE_SAFEPOINT, 168 RECORD_SIMPLE_SAFEPOINT,
200 RECORD_SAFEPOINT_WITH_REGISTERS 169 RECORD_SAFEPOINT_WITH_REGISTERS
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 void RecordSafepoint(LPointerMap* pointers, 249 void RecordSafepoint(LPointerMap* pointers,
281 Safepoint::Kind kind, 250 Safepoint::Kind kind,
282 int arguments, 251 int arguments,
283 Safepoint::DeoptMode mode); 252 Safepoint::DeoptMode mode);
284 void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode); 253 void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode);
285 void RecordSafepoint(Safepoint::DeoptMode mode); 254 void RecordSafepoint(Safepoint::DeoptMode mode);
286 void RecordSafepointWithRegisters(LPointerMap* pointers, 255 void RecordSafepointWithRegisters(LPointerMap* pointers,
287 int arguments, 256 int arguments,
288 Safepoint::DeoptMode mode); 257 Safepoint::DeoptMode mode);
289 void RecordPosition(int position); 258 void RecordPosition(int position);
290 void RecordAndUpdatePosition(int position); 259 void RecordAndUpdatePosition(int position) V8_OVERRIDE;
291 260
292 static Condition TokenToCondition(Token::Value op, bool is_unsigned); 261 static Condition TokenToCondition(Token::Value op, bool is_unsigned);
293 void EmitGoto(int block); 262 void EmitGoto(int block);
294 template<class InstrType> 263 template<class InstrType>
295 void EmitBranch(InstrType instr, Condition cc); 264 void EmitBranch(InstrType instr, Condition cc);
296 template<class InstrType> 265 template<class InstrType>
297 void EmitFalseBranch(InstrType instr, Condition cc); 266 void EmitFalseBranch(InstrType instr, Condition cc);
298 void EmitNumberUntagD( 267 void EmitNumberUntagD(
299 Register input, 268 Register input,
300 XMMRegister result, 269 XMMRegister result,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 void EmitPushTaggedOperand(LOperand* operand); 304 void EmitPushTaggedOperand(LOperand* operand);
336 305
337 // Emits optimized code to deep-copy the contents of statically known 306 // Emits optimized code to deep-copy the contents of statically known
338 // object graphs (e.g. object literal boilerplate). 307 // object graphs (e.g. object literal boilerplate).
339 void EmitDeepCopy(Handle<JSObject> object, 308 void EmitDeepCopy(Handle<JSObject> object,
340 Register result, 309 Register result,
341 Register source, 310 Register source,
342 int* offset, 311 int* offset,
343 AllocationSiteMode mode); 312 AllocationSiteMode mode);
344 313
345 void EnsureSpaceForLazyDeopt(int space_needed); 314 void EnsureSpaceForLazyDeopt(int space_needed) V8_OVERRIDE;
346 void DoLoadKeyedExternalArray(LLoadKeyed* instr); 315 void DoLoadKeyedExternalArray(LLoadKeyed* instr);
347 void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr); 316 void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr);
348 void DoLoadKeyedFixedArray(LLoadKeyed* instr); 317 void DoLoadKeyedFixedArray(LLoadKeyed* instr);
349 void DoStoreKeyedExternalArray(LStoreKeyed* instr); 318 void DoStoreKeyedExternalArray(LStoreKeyed* instr);
350 void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr); 319 void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr);
351 void DoStoreKeyedFixedArray(LStoreKeyed* instr); 320 void DoStoreKeyedFixedArray(LStoreKeyed* instr);
352 #ifdef _MSC_VER 321 #ifdef _MSC_VER
353 // On windows, you may not access the stack more than one page below 322 // On windows, you may not access the stack more than one page below
354 // the most recently mapped page. To make the allocated area randomly 323 // the most recently mapped page. To make the allocated area randomly
355 // accessible, we write an arbitrary value to each page in range 324 // accessible, we write an arbitrary value to each page in range
356 // rsp + offset - page_size .. rsp in turn. 325 // rsp + offset - page_size .. rsp in turn.
357 void MakeSureStackPagesMapped(int offset); 326 void MakeSureStackPagesMapped(int offset);
358 #endif 327 #endif
359 328
360 Zone* zone_;
361 LPlatformChunk* const chunk_;
362 MacroAssembler* const masm_;
363 CompilationInfo* const info_;
364
365 int current_block_;
366 int current_instruction_;
367 const ZoneList<LInstruction*>* instructions_;
368 ZoneList<LEnvironment*> deoptimizations_; 329 ZoneList<LEnvironment*> deoptimizations_;
369 ZoneList<Deoptimizer::JumpTableEntry> jump_table_; 330 ZoneList<Deoptimizer::JumpTableEntry> jump_table_;
370 ZoneList<Handle<Object> > deoptimization_literals_; 331 ZoneList<Handle<Object> > deoptimization_literals_;
371 int inlined_function_count_; 332 int inlined_function_count_;
372 Scope* const scope_; 333 Scope* const scope_;
373 Status status_;
374 TranslationBuffer translations_; 334 TranslationBuffer translations_;
375 ZoneList<LDeferredCode*> deferred_; 335 ZoneList<LDeferredCode*> deferred_;
376 int osr_pc_offset_; 336 int osr_pc_offset_;
377 int last_lazy_deopt_pc_;
378 bool frame_is_built_; 337 bool frame_is_built_;
379 338
380 // Builder that keeps track of safepoints in the code. The table 339 // Builder that keeps track of safepoints in the code. The table
381 // itself is emitted at the end of the generated code. 340 // itself is emitted at the end of the generated code.
382 SafepointTableBuilder safepoints_; 341 SafepointTableBuilder safepoints_;
383 342
384 // Compiler from a set of parallel moves to a sequential list of moves. 343 // Compiler from a set of parallel moves to a sequential list of moves.
385 LGapResolver resolver_; 344 LGapResolver resolver_;
386 345
387 Safepoint::Kind expected_safepoint_kind_; 346 Safepoint::Kind expected_safepoint_kind_;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 Label entry_; 402 Label entry_;
444 Label exit_; 403 Label exit_;
445 Label done_; 404 Label done_;
446 Label* external_exit_; 405 Label* external_exit_;
447 int instruction_index_; 406 int instruction_index_;
448 }; 407 };
449 408
450 } } // namespace v8::internal 409 } } // namespace v8::internal
451 410
452 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_ 411 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698