OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 info()->CommitDependencies(code); | 96 info()->CommitDependencies(code); |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 void LChunkBuilder::Abort(BailoutReason reason) { | 100 void LChunkBuilder::Abort(BailoutReason reason) { |
101 info()->set_bailout_reason(reason); | 101 info()->set_bailout_reason(reason); |
102 status_ = ABORTED; | 102 status_ = ABORTED; |
103 } | 103 } |
104 | 104 |
105 | 105 |
106 void LCodeGen::Comment(const char* format, ...) { | |
107 if (!FLAG_code_comments) return; | |
108 char buffer[4 * KB]; | |
109 StringBuilder builder(buffer, ARRAY_SIZE(buffer)); | |
110 va_list arguments; | |
111 va_start(arguments, format); | |
112 builder.AddFormattedList(format, arguments); | |
113 va_end(arguments); | |
114 | |
115 // Copy the string before recording it in the assembler to avoid | |
116 // issues when the stack allocated buffer goes out of scope. | |
117 int length = builder.position(); | |
118 Vector<char> copy = Vector<char>::New(length + 1); | |
119 OS::MemCopy(copy.start(), builder.Finalize(), copy.length()); | |
120 masm()->RecordComment(copy.start()); | |
121 } | |
122 | |
123 | |
124 #ifdef _MSC_VER | 106 #ifdef _MSC_VER |
125 void LCodeGen::MakeSureStackPagesMapped(int offset) { | 107 void LCodeGen::MakeSureStackPagesMapped(int offset) { |
126 const int kPageSize = 4 * KB; | 108 const int kPageSize = 4 * KB; |
127 for (offset -= kPageSize; offset > 0; offset -= kPageSize) { | 109 for (offset -= kPageSize; offset > 0; offset -= kPageSize) { |
128 __ movq(Operand(rsp, offset), rax); | 110 __ movq(Operand(rsp, offset), rax); |
129 } | 111 } |
130 } | 112 } |
131 #endif | 113 #endif |
132 | 114 |
133 | 115 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 osr_pc_offset_ = masm()->pc_offset(); | 248 osr_pc_offset_ = masm()->pc_offset(); |
267 | 249 |
268 // Adjust the frame size, subsuming the unoptimized frame into the | 250 // Adjust the frame size, subsuming the unoptimized frame into the |
269 // optimized frame. | 251 // optimized frame. |
270 int slots = GetStackSlotCount() - graph()->osr()->UnoptimizedFrameSlots(); | 252 int slots = GetStackSlotCount() - graph()->osr()->UnoptimizedFrameSlots(); |
271 ASSERT(slots >= 0); | 253 ASSERT(slots >= 0); |
272 __ subq(rsp, Immediate(slots * kPointerSize)); | 254 __ subq(rsp, Immediate(slots * kPointerSize)); |
273 } | 255 } |
274 | 256 |
275 | 257 |
276 bool LCodeGen::GenerateBody() { | |
277 ASSERT(is_generating()); | |
278 bool emit_instructions = true; | |
279 for (current_instruction_ = 0; | |
280 !is_aborted() && current_instruction_ < instructions_->length(); | |
281 current_instruction_++) { | |
282 LInstruction* instr = instructions_->at(current_instruction_); | |
283 | |
284 // Don't emit code for basic blocks with a replacement. | |
285 if (instr->IsLabel()) { | |
286 emit_instructions = !LLabel::cast(instr)->HasReplacement(); | |
287 } | |
288 if (!emit_instructions) continue; | |
289 | |
290 if (FLAG_code_comments && instr->HasInterestingComment(this)) { | |
291 Comment(";;; <@%d,#%d> %s", | |
292 current_instruction_, | |
293 instr->hydrogen_value()->id(), | |
294 instr->Mnemonic()); | |
295 } | |
296 | |
297 RecordAndUpdatePosition(instr->position()); | |
298 | |
299 instr->CompileToNative(this); | |
300 } | |
301 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); | |
302 return !is_aborted(); | |
303 } | |
304 | |
305 | |
306 bool LCodeGen::GenerateJumpTable() { | 258 bool LCodeGen::GenerateJumpTable() { |
307 Label needs_frame; | 259 Label needs_frame; |
308 if (jump_table_.length() > 0) { | 260 if (jump_table_.length() > 0) { |
309 Comment(";;; -------------------- Jump table --------------------"); | 261 Comment(";;; -------------------- Jump table --------------------"); |
310 } | 262 } |
311 for (int i = 0; i < jump_table_.length(); i++) { | 263 for (int i = 0; i < jump_table_.length(); i++) { |
312 __ bind(&jump_table_[i].label); | 264 __ bind(&jump_table_[i].label); |
313 Address entry = jump_table_[i].address; | 265 Address entry = jump_table_[i].address; |
314 Deoptimizer::BailoutType type = jump_table_[i].bailout_type; | 266 Deoptimizer::BailoutType type = jump_table_[i].bailout_type; |
315 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); | 267 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); |
(...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1897 ASSERT(ToRegister(instr->left()).is(rdx)); | 1849 ASSERT(ToRegister(instr->left()).is(rdx)); |
1898 ASSERT(ToRegister(instr->right()).is(rax)); | 1850 ASSERT(ToRegister(instr->right()).is(rax)); |
1899 ASSERT(ToRegister(instr->result()).is(rax)); | 1851 ASSERT(ToRegister(instr->result()).is(rax)); |
1900 | 1852 |
1901 BinaryOpStub stub(instr->op(), NO_OVERWRITE); | 1853 BinaryOpStub stub(instr->op(), NO_OVERWRITE); |
1902 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 1854 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
1903 __ nop(); // Signals no inlined code. | 1855 __ nop(); // Signals no inlined code. |
1904 } | 1856 } |
1905 | 1857 |
1906 | 1858 |
1907 int LCodeGen::GetNextEmittedBlock() const { | |
1908 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) { | |
1909 if (!chunk_->GetLabel(i)->HasReplacement()) return i; | |
1910 } | |
1911 return -1; | |
1912 } | |
1913 | |
1914 | |
1915 template<class InstrType> | 1859 template<class InstrType> |
1916 void LCodeGen::EmitBranch(InstrType instr, Condition cc) { | 1860 void LCodeGen::EmitBranch(InstrType instr, Condition cc) { |
1917 int left_block = instr->TrueDestination(chunk_); | 1861 int left_block = instr->TrueDestination(chunk_); |
1918 int right_block = instr->FalseDestination(chunk_); | 1862 int right_block = instr->FalseDestination(chunk_); |
1919 | 1863 |
1920 int next_block = GetNextEmittedBlock(); | 1864 int next_block = GetNextEmittedBlock(); |
1921 | 1865 |
1922 if (right_block == left_block || cc == no_condition) { | 1866 if (right_block == left_block || cc == no_condition) { |
1923 EmitGoto(left_block); | 1867 EmitGoto(left_block); |
1924 } else if (left_block == next_block) { | 1868 } else if (left_block == next_block) { |
(...skipping 3589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5514 FixedArray::kHeaderSize - kPointerSize)); | 5458 FixedArray::kHeaderSize - kPointerSize)); |
5515 __ bind(&done); | 5459 __ bind(&done); |
5516 } | 5460 } |
5517 | 5461 |
5518 | 5462 |
5519 #undef __ | 5463 #undef __ |
5520 | 5464 |
5521 } } // namespace v8::internal | 5465 } } // namespace v8::internal |
5522 | 5466 |
5523 #endif // V8_TARGET_ARCH_X64 | 5467 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |