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

Side by Side Diff: src/ia32/lithium-codegen-ia32.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_IA32_LITHIUM_CODEGEN_IA32_H_ 28 #ifndef V8_IA32_LITHIUM_CODEGEN_IA32_H_
29 #define V8_IA32_LITHIUM_CODEGEN_IA32_H_ 29 #define V8_IA32_LITHIUM_CODEGEN_IA32_H_
30 30
31 #include "ia32/lithium-ia32.h" 31 #include "ia32/lithium-ia32.h"
32 32
33 #include "checks.h" 33 #include "checks.h"
34 #include "deoptimizer.h" 34 #include "deoptimizer.h"
35 #include "lithium-codegen.h"
Michael Starzinger 2013/10/01 11:17:47 nit: Can we alpha-sort the includes.
danno 2013/10/23 11:46:51 Done.
35 #include "ia32/lithium-gap-resolver-ia32.h" 36 #include "ia32/lithium-gap-resolver-ia32.h"
36 #include "safepoint-table.h" 37 #include "safepoint-table.h"
37 #include "scopes.h" 38 #include "scopes.h"
38 #include "v8utils.h" 39 #include "v8utils.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 LGapNode; 46 class LGapNode;
46 class SafepointGenerator; 47 class SafepointGenerator;
47 48
48 class LCodeGen V8_FINAL BASE_EMBEDDED { 49 class LCodeGen: public LCodeGenBase {
49 public: 50 public:
50 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) 51 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info)
51 : zone_(info->zone()), 52 : LCodeGenBase(chunk, assembler, info),
52 chunk_(static_cast<LPlatformChunk*>(chunk)),
53 masm_(assembler),
54 info_(info),
55 current_block_(-1),
56 current_instruction_(-1),
57 instructions_(chunk->instructions()),
58 deoptimizations_(4, info->zone()), 53 deoptimizations_(4, info->zone()),
59 jump_table_(4, info->zone()), 54 jump_table_(4, info->zone()),
60 deoptimization_literals_(8, info->zone()), 55 deoptimization_literals_(8, info->zone()),
61 inlined_function_count_(0), 56 inlined_function_count_(0),
62 scope_(info->scope()), 57 scope_(info->scope()),
63 status_(UNUSED),
64 translations_(info->zone()), 58 translations_(info->zone()),
65 deferred_(8, info->zone()), 59 deferred_(8, info->zone()),
66 dynamic_frame_alignment_(false), 60 dynamic_frame_alignment_(false),
67 support_aligned_spilled_doubles_(false), 61 support_aligned_spilled_doubles_(false),
68 osr_pc_offset_(-1), 62 osr_pc_offset_(-1),
69 last_lazy_deopt_pc_(0),
70 frame_is_built_(false), 63 frame_is_built_(false),
71 x87_stack_(assembler), 64 x87_stack_(assembler),
72 safepoints_(info->zone()), 65 safepoints_(info->zone()),
73 resolver_(this), 66 resolver_(this),
74 expected_safepoint_kind_(Safepoint::kSimple), 67 expected_safepoint_kind_(Safepoint::kSimple),
75 old_position_(RelocInfo::kNoPosition) { 68 old_position_(RelocInfo::kNoPosition) {
76 PopulateDeoptimizationLiteralsWithInlinedFunctions(); 69 PopulateDeoptimizationLiteralsWithInlinedFunctions();
77 } 70 }
78 71
79 // Simple accessors.
80 MacroAssembler* masm() const { return masm_; }
81 CompilationInfo* info() const { return info_; }
82 Isolate* isolate() const { return info_->isolate(); }
83 Factory* factory() const { return isolate()->factory(); }
84 Heap* heap() const { return isolate()->heap(); }
85 Zone* zone() const { return zone_; }
86
87 int LookupDestination(int block_id) const { 72 int LookupDestination(int block_id) const {
88 return chunk()->LookupDestination(block_id); 73 return chunk()->LookupDestination(block_id);
89 } 74 }
90 75
91 bool IsNextEmittedBlock(int block_id) const { 76 bool IsNextEmittedBlock(int block_id) const {
92 return LookupDestination(block_id) == GetNextEmittedBlock(); 77 return LookupDestination(block_id) == GetNextEmittedBlock();
93 } 78 }
94 79
95 bool NeedsEagerFrame() const { 80 bool NeedsEagerFrame() const {
96 return GetStackSlotCount() > 0 || 81 return GetStackSlotCount() > 0 ||
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 void WriteTranslation(LEnvironment* environment, Translation* translation); 167 void WriteTranslation(LEnvironment* environment, Translation* translation);
183 168
184 void EnsureRelocSpaceForDeoptimization(); 169 void EnsureRelocSpaceForDeoptimization();
185 170
186 // Declare methods that deal with the individual node types. 171 // Declare methods that deal with the individual node types.
187 #define DECLARE_DO(type) void Do##type(L##type* node); 172 #define DECLARE_DO(type) void Do##type(L##type* node);
188 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) 173 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
189 #undef DECLARE_DO 174 #undef DECLARE_DO
190 175
191 private: 176 private:
192 enum Status {
193 UNUSED,
194 GENERATING,
195 DONE,
196 ABORTED
197 };
198
199 bool is_unused() const { return status_ == UNUSED; }
200 bool is_generating() const { return status_ == GENERATING; }
201 bool is_done() const { return status_ == DONE; }
202 bool is_aborted() const { return status_ == ABORTED; }
203
204 StrictModeFlag strict_mode_flag() const { 177 StrictModeFlag strict_mode_flag() const {
205 return info()->is_classic_mode() ? kNonStrictMode : kStrictMode; 178 return info()->is_classic_mode() ? kNonStrictMode : kStrictMode;
206 } 179 }
207 180
208 LPlatformChunk* chunk() const { return chunk_; }
209 Scope* scope() const { return scope_; } 181 Scope* scope() const { return scope_; }
210 HGraph* graph() const { return chunk()->graph(); }
211 182
212 XMMRegister double_scratch0() const { return xmm0; } 183 XMMRegister double_scratch0() const { return xmm0; }
213 184
214 int GetNextEmittedBlock() const;
215
216 void EmitClassOfTest(Label* if_true, 185 void EmitClassOfTest(Label* if_true,
217 Label* if_false, 186 Label* if_false,
218 Handle<String> class_name, 187 Handle<String> class_name,
219 Register input, 188 Register input,
220 Register temporary, 189 Register temporary,
221 Register temporary2); 190 Register temporary2);
222 191
223 int GetStackSlotCount() const { return chunk()->spill_slot_count(); } 192 int GetStackSlotCount() const { return chunk()->spill_slot_count(); }
224 193
225 void Abort(BailoutReason reason); 194 void Abort(BailoutReason reason);
226 void FPRINTF_CHECKING Comment(const char* format, ...);
227 195
228 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); } 196 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); }
229 197
230 // Code generation passes. Returns true if code generation should 198 // Code generation passes. Returns true if code generation should
231 // continue. 199 // continue.
200 void GenerateBodyInstructionPre(LInstruction* instr) V8_OVERRIDE;
201 void GenerateBodyInstructionPost(LInstruction* instr) V8_OVERRIDE;
232 bool GeneratePrologue(); 202 bool GeneratePrologue();
233 bool GenerateBody();
234 bool GenerateDeferredCode(); 203 bool GenerateDeferredCode();
235 bool GenerateJumpTable(); 204 bool GenerateJumpTable();
236 bool GenerateSafepointTable(); 205 bool GenerateSafepointTable();
237 206
238 // Generates the custom OSR entrypoint and sets the osr_pc_offset. 207 // Generates the custom OSR entrypoint and sets the osr_pc_offset.
239 void GenerateOsrPrologue(); 208 void GenerateOsrPrologue();
240 209
241 enum SafepointMode { 210 enum SafepointMode {
242 RECORD_SIMPLE_SAFEPOINT, 211 RECORD_SIMPLE_SAFEPOINT,
243 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS 212 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 Safepoint::Kind kind, 298 Safepoint::Kind kind,
330 int arguments, 299 int arguments,
331 Safepoint::DeoptMode mode); 300 Safepoint::DeoptMode mode);
332 void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode); 301 void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode);
333 void RecordSafepoint(Safepoint::DeoptMode mode); 302 void RecordSafepoint(Safepoint::DeoptMode mode);
334 void RecordSafepointWithRegisters(LPointerMap* pointers, 303 void RecordSafepointWithRegisters(LPointerMap* pointers,
335 int arguments, 304 int arguments,
336 Safepoint::DeoptMode mode); 305 Safepoint::DeoptMode mode);
337 void RecordPosition(int position); 306 void RecordPosition(int position);
338 307
339 void RecordAndUpdatePosition(int position); 308 void RecordAndUpdatePosition(int position) V8_OVERRIDE;
340 309
341 static Condition TokenToCondition(Token::Value op, bool is_unsigned); 310 static Condition TokenToCondition(Token::Value op, bool is_unsigned);
342 void EmitGoto(int block); 311 void EmitGoto(int block);
343 template<class InstrType> 312 template<class InstrType>
344 void EmitBranch(InstrType instr, Condition cc); 313 void EmitBranch(InstrType instr, Condition cc);
345 template<class InstrType> 314 template<class InstrType>
346 void EmitFalseBranch(InstrType instr, Condition cc); 315 void EmitFalseBranch(InstrType instr, Condition cc);
347 void EmitNumberUntagD( 316 void EmitNumberUntagD(
348 Register input, 317 Register input,
349 Register temp, 318 Register temp,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 void EmitIsConstructCall(Register temp); 360 void EmitIsConstructCall(Register temp);
392 361
393 // Emits optimized code to deep-copy the contents of statically known 362 // Emits optimized code to deep-copy the contents of statically known
394 // object graphs (e.g. object literal boilerplate). 363 // object graphs (e.g. object literal boilerplate).
395 void EmitDeepCopy(Handle<JSObject> object, 364 void EmitDeepCopy(Handle<JSObject> object,
396 Register result, 365 Register result,
397 Register source, 366 Register source,
398 int* offset, 367 int* offset,
399 AllocationSiteMode mode); 368 AllocationSiteMode mode);
400 369
401 void EnsureSpaceForLazyDeopt(); 370 void EnsureSpaceForLazyDeopt(int space_needed) V8_OVERRIDE;
402 void DoLoadKeyedExternalArray(LLoadKeyed* instr); 371 void DoLoadKeyedExternalArray(LLoadKeyed* instr);
403 void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr); 372 void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr);
404 void DoLoadKeyedFixedArray(LLoadKeyed* instr); 373 void DoLoadKeyedFixedArray(LLoadKeyed* instr);
405 void DoStoreKeyedExternalArray(LStoreKeyed* instr); 374 void DoStoreKeyedExternalArray(LStoreKeyed* instr);
406 void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr); 375 void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr);
407 void DoStoreKeyedFixedArray(LStoreKeyed* instr); 376 void DoStoreKeyedFixedArray(LStoreKeyed* instr);
408 377
409 void EmitReturn(LReturn* instr, bool dynamic_frame_alignment); 378 void EmitReturn(LReturn* instr, bool dynamic_frame_alignment);
410 379
411 // Emits code for pushing either a tagged constant, a (non-double) 380 // Emits code for pushing either a tagged constant, a (non-double)
412 // register, or a stack slot operand. 381 // register, or a stack slot operand.
413 void EmitPushTaggedOperand(LOperand* operand); 382 void EmitPushTaggedOperand(LOperand* operand);
414 383
415 void X87Fld(Operand src, X87OperandType opts); 384 void X87Fld(Operand src, X87OperandType opts);
416 385
417 void EmitFlushX87ForDeopt(); 386 void EmitFlushX87ForDeopt();
418 void FlushX87StackIfNecessary(LInstruction* instr) { 387 void FlushX87StackIfNecessary(LInstruction* instr) {
419 x87_stack_.FlushIfNecessary(instr, this); 388 x87_stack_.FlushIfNecessary(instr, this);
420 } 389 }
421 friend class LGapResolver; 390 friend class LGapResolver;
422 391
423 #ifdef _MSC_VER 392 #ifdef _MSC_VER
424 // On windows, you may not access the stack more than one page below 393 // On windows, you may not access the stack more than one page below
425 // the most recently mapped page. To make the allocated area randomly 394 // the most recently mapped page. To make the allocated area randomly
426 // accessible, we write an arbitrary value to each page in range 395 // accessible, we write an arbitrary value to each page in range
427 // esp + offset - page_size .. esp in turn. 396 // esp + offset - page_size .. esp in turn.
428 void MakeSureStackPagesMapped(int offset); 397 void MakeSureStackPagesMapped(int offset);
429 #endif 398 #endif
430 399
431 Zone* zone_;
432 LPlatformChunk* const chunk_;
433 MacroAssembler* const masm_;
434 CompilationInfo* const info_;
435
436 int current_block_;
437 int current_instruction_;
438 const ZoneList<LInstruction*>* instructions_;
439 ZoneList<LEnvironment*> deoptimizations_; 400 ZoneList<LEnvironment*> deoptimizations_;
440 ZoneList<Deoptimizer::JumpTableEntry> jump_table_; 401 ZoneList<Deoptimizer::JumpTableEntry> jump_table_;
441 ZoneList<Handle<Object> > deoptimization_literals_; 402 ZoneList<Handle<Object> > deoptimization_literals_;
442 int inlined_function_count_; 403 int inlined_function_count_;
443 Scope* const scope_; 404 Scope* const scope_;
444 Status status_;
445 TranslationBuffer translations_; 405 TranslationBuffer translations_;
446 ZoneList<LDeferredCode*> deferred_; 406 ZoneList<LDeferredCode*> deferred_;
447 bool dynamic_frame_alignment_; 407 bool dynamic_frame_alignment_;
448 bool support_aligned_spilled_doubles_; 408 bool support_aligned_spilled_doubles_;
449 int osr_pc_offset_; 409 int osr_pc_offset_;
450 int last_lazy_deopt_pc_;
451 bool frame_is_built_; 410 bool frame_is_built_;
452 411
453 class X87Stack { 412 class X87Stack {
454 public: 413 public:
455 explicit X87Stack(MacroAssembler* masm) 414 explicit X87Stack(MacroAssembler* masm)
456 : stack_depth_(0), is_mutable_(true), masm_(masm) { } 415 : stack_depth_(0), is_mutable_(true), masm_(masm) { }
457 explicit X87Stack(const X87Stack& other) 416 explicit X87Stack(const X87Stack& other)
458 : stack_depth_(other.stack_depth_), is_mutable_(false), masm_(masm()) { 417 : stack_depth_(other.stack_depth_), is_mutable_(false), masm_(masm()) {
459 for (int i = 0; i < stack_depth_; i++) { 418 for (int i = 0; i < stack_depth_; i++) {
460 stack_[i] = other.stack_[i]; 419 stack_[i] = other.stack_[i];
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 Label exit_; 527 Label exit_;
569 Label* external_exit_; 528 Label* external_exit_;
570 Label done_; 529 Label done_;
571 int instruction_index_; 530 int instruction_index_;
572 LCodeGen::X87Stack x87_stack_; 531 LCodeGen::X87Stack x87_stack_;
573 }; 532 };
574 533
575 } } // namespace v8::internal 534 } } // namespace v8::internal
576 535
577 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ 536 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698