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

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

Issue 145773008: A64: Synchronize with r17104. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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
« no previous file with comments | « src/ia32/ic-ia32.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 15 matching lines...) Expand all
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 "ia32/lithium-gap-resolver-ia32.h" 35 #include "ia32/lithium-gap-resolver-ia32.h"
36 #include "lithium-codegen.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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 X87Register left, X87Register right, X87Register result); 114 X87Register left, X87Register right, X87Register result);
130 115
131 void X87LoadForUsage(X87Register reg); 116 void X87LoadForUsage(X87Register reg);
132 void X87LoadForUsage(X87Register reg1, X87Register reg2); 117 void X87LoadForUsage(X87Register reg1, X87Register reg2);
133 void X87PrepareToWrite(X87Register reg) { x87_stack_.PrepareToWrite(reg); } 118 void X87PrepareToWrite(X87Register reg) { x87_stack_.PrepareToWrite(reg); }
134 void X87CommitWrite(X87Register reg) { x87_stack_.CommitWrite(reg); } 119 void X87CommitWrite(X87Register reg) { x87_stack_.CommitWrite(reg); }
135 120
136 void X87Fxch(X87Register reg, int other_slot = 0) { 121 void X87Fxch(X87Register reg, int other_slot = 0) {
137 x87_stack_.Fxch(reg, other_slot); 122 x87_stack_.Fxch(reg, other_slot);
138 } 123 }
124 void X87Free(X87Register reg) {
125 x87_stack_.Free(reg);
126 }
127
139 128
140 bool X87StackEmpty() { 129 bool X87StackEmpty() {
141 return x87_stack_.depth() == 0; 130 return x87_stack_.depth() == 0;
142 } 131 }
143 132
144 Handle<Object> ToHandle(LConstantOperand* op) const; 133 Handle<Object> ToHandle(LConstantOperand* op) const;
145 134
146 // The operand denoting the second word (the one with a higher address) of 135 // The operand denoting the second word (the one with a higher address) of
147 // a double stack slot. 136 // a double stack slot.
148 Operand HighOperand(LOperand* op); 137 Operand HighOperand(LOperand* op);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 void WriteTranslation(LEnvironment* environment, Translation* translation); 171 void WriteTranslation(LEnvironment* environment, Translation* translation);
183 172
184 void EnsureRelocSpaceForDeoptimization(); 173 void EnsureRelocSpaceForDeoptimization();
185 174
186 // Declare methods that deal with the individual node types. 175 // Declare methods that deal with the individual node types.
187 #define DECLARE_DO(type) void Do##type(L##type* node); 176 #define DECLARE_DO(type) void Do##type(L##type* node);
188 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) 177 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
189 #undef DECLARE_DO 178 #undef DECLARE_DO
190 179
191 private: 180 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 { 181 StrictModeFlag strict_mode_flag() const {
205 return info()->is_classic_mode() ? kNonStrictMode : kStrictMode; 182 return info()->is_classic_mode() ? kNonStrictMode : kStrictMode;
206 } 183 }
207 184
208 LPlatformChunk* chunk() const { return chunk_; }
209 Scope* scope() const { return scope_; } 185 Scope* scope() const { return scope_; }
210 HGraph* graph() const { return chunk()->graph(); }
211 186
212 XMMRegister double_scratch0() const { return xmm0; } 187 XMMRegister double_scratch0() const { return xmm0; }
213 188
214 int GetNextEmittedBlock() const;
215
216 void EmitClassOfTest(Label* if_true, 189 void EmitClassOfTest(Label* if_true,
217 Label* if_false, 190 Label* if_false,
218 Handle<String> class_name, 191 Handle<String> class_name,
219 Register input, 192 Register input,
220 Register temporary, 193 Register temporary,
221 Register temporary2); 194 Register temporary2);
222 195
223 int GetStackSlotCount() const { return chunk()->spill_slot_count(); } 196 int GetStackSlotCount() const { return chunk()->spill_slot_count(); }
224 197
225 void Abort(BailoutReason reason); 198 void Abort(BailoutReason reason);
226 void FPRINTF_CHECKING Comment(const char* format, ...);
227 199
228 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); } 200 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); }
229 201
230 // Code generation passes. Returns true if code generation should 202 // Code generation passes. Returns true if code generation should
231 // continue. 203 // continue.
204 void GenerateBodyInstructionPre(LInstruction* instr) V8_OVERRIDE;
205 void GenerateBodyInstructionPost(LInstruction* instr) V8_OVERRIDE;
232 bool GeneratePrologue(); 206 bool GeneratePrologue();
233 bool GenerateBody();
234 bool GenerateDeferredCode(); 207 bool GenerateDeferredCode();
235 bool GenerateJumpTable(); 208 bool GenerateJumpTable();
236 bool GenerateSafepointTable(); 209 bool GenerateSafepointTable();
237 210
238 // Generates the custom OSR entrypoint and sets the osr_pc_offset. 211 // Generates the custom OSR entrypoint and sets the osr_pc_offset.
239 void GenerateOsrPrologue(); 212 void GenerateOsrPrologue();
240 213
241 enum SafepointMode { 214 enum SafepointMode {
242 RECORD_SIMPLE_SAFEPOINT, 215 RECORD_SIMPLE_SAFEPOINT,
243 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS 216 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS
244 }; 217 };
245 218
246 void CallCode(Handle<Code> code, 219 void CallCode(Handle<Code> code,
247 RelocInfo::Mode mode, 220 RelocInfo::Mode mode,
248 LInstruction* instr); 221 LInstruction* instr);
249 222
250 void CallCodeGeneric(Handle<Code> code, 223 void CallCodeGeneric(Handle<Code> code,
251 RelocInfo::Mode mode, 224 RelocInfo::Mode mode,
252 LInstruction* instr, 225 LInstruction* instr,
253 SafepointMode safepoint_mode); 226 SafepointMode safepoint_mode);
254 227
255 void CallRuntime(const Runtime::Function* fun, 228 void CallRuntime(const Runtime::Function* fun,
256 int argc, 229 int argc,
257 LInstruction* instr); 230 LInstruction* instr,
231 SaveFPRegsMode save_doubles = kDontSaveFPRegs);
258 232
259 void CallRuntime(Runtime::FunctionId id, 233 void CallRuntime(Runtime::FunctionId id,
260 int argc, 234 int argc,
261 LInstruction* instr) { 235 LInstruction* instr) {
262 const Runtime::Function* function = Runtime::FunctionForId(id); 236 const Runtime::Function* function = Runtime::FunctionForId(id);
263 CallRuntime(function, argc, instr); 237 CallRuntime(function, argc, instr);
264 } 238 }
265 239
266 void CallRuntimeFromDeferred(Runtime::FunctionId id, 240 void CallRuntimeFromDeferred(Runtime::FunctionId id,
267 int argc, 241 int argc,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 Safepoint::Kind kind, 303 Safepoint::Kind kind,
330 int arguments, 304 int arguments,
331 Safepoint::DeoptMode mode); 305 Safepoint::DeoptMode mode);
332 void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode); 306 void RecordSafepoint(LPointerMap* pointers, Safepoint::DeoptMode mode);
333 void RecordSafepoint(Safepoint::DeoptMode mode); 307 void RecordSafepoint(Safepoint::DeoptMode mode);
334 void RecordSafepointWithRegisters(LPointerMap* pointers, 308 void RecordSafepointWithRegisters(LPointerMap* pointers,
335 int arguments, 309 int arguments,
336 Safepoint::DeoptMode mode); 310 Safepoint::DeoptMode mode);
337 void RecordPosition(int position); 311 void RecordPosition(int position);
338 312
339 void RecordAndUpdatePosition(int position); 313 void RecordAndUpdatePosition(int position) V8_OVERRIDE;
340 314
341 static Condition TokenToCondition(Token::Value op, bool is_unsigned); 315 static Condition TokenToCondition(Token::Value op, bool is_unsigned);
342 void EmitGoto(int block); 316 void EmitGoto(int block);
343 template<class InstrType> 317 template<class InstrType>
344 void EmitBranch(InstrType instr, Condition cc); 318 void EmitBranch(InstrType instr, Condition cc);
345 template<class InstrType> 319 template<class InstrType>
346 void EmitFalseBranch(InstrType instr, Condition cc); 320 void EmitFalseBranch(InstrType instr, Condition cc);
347 void EmitNumberUntagD( 321 void EmitNumberUntagD(
348 Register input, 322 Register input,
349 Register temp, 323 Register temp,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 void EmitIsConstructCall(Register temp); 365 void EmitIsConstructCall(Register temp);
392 366
393 // Emits optimized code to deep-copy the contents of statically known 367 // Emits optimized code to deep-copy the contents of statically known
394 // object graphs (e.g. object literal boilerplate). 368 // object graphs (e.g. object literal boilerplate).
395 void EmitDeepCopy(Handle<JSObject> object, 369 void EmitDeepCopy(Handle<JSObject> object,
396 Register result, 370 Register result,
397 Register source, 371 Register source,
398 int* offset, 372 int* offset,
399 AllocationSiteMode mode); 373 AllocationSiteMode mode);
400 374
401 void EnsureSpaceForLazyDeopt(); 375 void EnsureSpaceForLazyDeopt(int space_needed) V8_OVERRIDE;
402 void DoLoadKeyedExternalArray(LLoadKeyed* instr); 376 void DoLoadKeyedExternalArray(LLoadKeyed* instr);
403 void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr); 377 void DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr);
404 void DoLoadKeyedFixedArray(LLoadKeyed* instr); 378 void DoLoadKeyedFixedArray(LLoadKeyed* instr);
405 void DoStoreKeyedExternalArray(LStoreKeyed* instr); 379 void DoStoreKeyedExternalArray(LStoreKeyed* instr);
406 void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr); 380 void DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr);
407 void DoStoreKeyedFixedArray(LStoreKeyed* instr); 381 void DoStoreKeyedFixedArray(LStoreKeyed* instr);
408 382
409 void EmitReturn(LReturn* instr, bool dynamic_frame_alignment); 383 void EmitReturn(LReturn* instr, bool dynamic_frame_alignment);
410 384
411 // Emits code for pushing either a tagged constant, a (non-double) 385 // Emits code for pushing either a tagged constant, a (non-double)
412 // register, or a stack slot operand. 386 // register, or a stack slot operand.
413 void EmitPushTaggedOperand(LOperand* operand); 387 void EmitPushTaggedOperand(LOperand* operand);
414 388
415 void X87Fld(Operand src, X87OperandType opts); 389 void X87Fld(Operand src, X87OperandType opts);
416 390
417 void EmitFlushX87ForDeopt(); 391 void EmitFlushX87ForDeopt();
418 void FlushX87StackIfNecessary(LInstruction* instr) { 392 void FlushX87StackIfNecessary(LInstruction* instr) {
419 x87_stack_.FlushIfNecessary(instr, this); 393 x87_stack_.FlushIfNecessary(instr, this);
420 } 394 }
421 friend class LGapResolver; 395 friend class LGapResolver;
422 396
423 #ifdef _MSC_VER 397 #ifdef _MSC_VER
424 // On windows, you may not access the stack more than one page below 398 // 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 399 // the most recently mapped page. To make the allocated area randomly
426 // accessible, we write an arbitrary value to each page in range 400 // accessible, we write an arbitrary value to each page in range
427 // esp + offset - page_size .. esp in turn. 401 // esp + offset - page_size .. esp in turn.
428 void MakeSureStackPagesMapped(int offset); 402 void MakeSureStackPagesMapped(int offset);
429 #endif 403 #endif
430 404
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_; 405 ZoneList<LEnvironment*> deoptimizations_;
440 ZoneList<Deoptimizer::JumpTableEntry> jump_table_; 406 ZoneList<Deoptimizer::JumpTableEntry> jump_table_;
441 ZoneList<Handle<Object> > deoptimization_literals_; 407 ZoneList<Handle<Object> > deoptimization_literals_;
442 int inlined_function_count_; 408 int inlined_function_count_;
443 Scope* const scope_; 409 Scope* const scope_;
444 Status status_;
445 TranslationBuffer translations_; 410 TranslationBuffer translations_;
446 ZoneList<LDeferredCode*> deferred_; 411 ZoneList<LDeferredCode*> deferred_;
447 bool dynamic_frame_alignment_; 412 bool dynamic_frame_alignment_;
448 bool support_aligned_spilled_doubles_; 413 bool support_aligned_spilled_doubles_;
449 int osr_pc_offset_; 414 int osr_pc_offset_;
450 int last_lazy_deopt_pc_;
451 bool frame_is_built_; 415 bool frame_is_built_;
452 416
453 class X87Stack { 417 class X87Stack {
454 public: 418 public:
455 explicit X87Stack(MacroAssembler* masm) 419 explicit X87Stack(MacroAssembler* masm)
456 : stack_depth_(0), is_mutable_(true), masm_(masm) { } 420 : stack_depth_(0), is_mutable_(true), masm_(masm) { }
457 explicit X87Stack(const X87Stack& other) 421 explicit X87Stack(const X87Stack& other)
458 : stack_depth_(other.stack_depth_), is_mutable_(false), masm_(masm()) { 422 : stack_depth_(other.stack_depth_), is_mutable_(false), masm_(masm()) {
459 for (int i = 0; i < stack_depth_; i++) { 423 for (int i = 0; i < stack_depth_; i++) {
460 stack_[i] = other.stack_[i]; 424 stack_[i] = other.stack_[i];
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 Label exit_; 532 Label exit_;
569 Label* external_exit_; 533 Label* external_exit_;
570 Label done_; 534 Label done_;
571 int instruction_index_; 535 int instruction_index_;
572 LCodeGen::X87Stack x87_stack_; 536 LCodeGen::X87Stack x87_stack_;
573 }; 537 };
574 538
575 } } // namespace v8::internal 539 } } // namespace v8::internal
576 540
577 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ 541 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_
OLDNEW
« no previous file with comments | « src/ia32/ic-ia32.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698