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

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

Issue 14371005: Various improvements regarding the way we print code code comments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 7 years, 8 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/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('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 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 254 }
255 255
256 256
257 bool LCodeGen::GenerateBody() { 257 bool LCodeGen::GenerateBody() {
258 ASSERT(is_generating()); 258 ASSERT(is_generating());
259 bool emit_instructions = true; 259 bool emit_instructions = true;
260 for (current_instruction_ = 0; 260 for (current_instruction_ = 0;
261 !is_aborted() && current_instruction_ < instructions_->length(); 261 !is_aborted() && current_instruction_ < instructions_->length();
262 current_instruction_++) { 262 current_instruction_++) {
263 LInstruction* instr = instructions_->at(current_instruction_); 263 LInstruction* instr = instructions_->at(current_instruction_);
264
265 // Don't emit code for basic blocks with a replacement.
264 if (instr->IsLabel()) { 266 if (instr->IsLabel()) {
265 LLabel* label = LLabel::cast(instr); 267 emit_instructions = !LLabel::cast(instr)->HasReplacement();
266 emit_instructions = !label->HasReplacement(); 268 }
269 if (!emit_instructions) continue;
270
271 if (FLAG_code_comments && instr->HasInterestingComment(this)) {
272 Comment(";;; <@%d,#%d> %s",
273 current_instruction_,
274 instr->hydrogen_value()->id(),
275 instr->Mnemonic());
267 } 276 }
268 277
269 if (emit_instructions) { 278 instr->CompileToNative(this);
270 if (FLAG_code_comments) {
271 HValue* hydrogen = instr->hydrogen_value();
272 if (hydrogen != NULL) {
273 if (hydrogen->IsChange()) {
274 HValue* changed_value = HChange::cast(hydrogen)->value();
275 int use_id = 0;
276 const char* use_mnemo = "dead";
277 if (hydrogen->UseCount() >= 1) {
278 HValue* use_value = hydrogen->uses().value();
279 use_id = use_value->id();
280 use_mnemo = use_value->Mnemonic();
281 }
282 Comment(";;; @%d: %s. <of #%d %s for #%d %s>",
283 current_instruction_, instr->Mnemonic(),
284 changed_value->id(), changed_value->Mnemonic(),
285 use_id, use_mnemo);
286 } else {
287 Comment(";;; @%d: %s. <#%d>", current_instruction_,
288 instr->Mnemonic(), hydrogen->id());
289 }
290 } else {
291 Comment(";;; @%d: %s.", current_instruction_, instr->Mnemonic());
292 }
293 }
294 instr->CompileToNative(this);
295 }
296 } 279 }
297 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size()); 280 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size());
298 return !is_aborted(); 281 return !is_aborted();
299 } 282 }
300 283
301 284
302 bool LCodeGen::GenerateJumpTable() { 285 bool LCodeGen::GenerateJumpTable() {
303 Label needs_frame_not_call; 286 Label needs_frame_not_call;
304 Label needs_frame_is_call; 287 Label needs_frame_is_call;
288 if (jump_table_.length() > 0) {
289 Comment(";;; -------------------- Jump table --------------------");
290 }
305 for (int i = 0; i < jump_table_.length(); i++) { 291 for (int i = 0; i < jump_table_.length(); i++) {
306 __ bind(&jump_table_[i].label); 292 __ bind(&jump_table_[i].label);
307 Address entry = jump_table_[i].address; 293 Address entry = jump_table_[i].address;
308 bool is_lazy_deopt = jump_table_[i].is_lazy_deopt; 294 bool is_lazy_deopt = jump_table_[i].is_lazy_deopt;
309 Deoptimizer::BailoutType type = 295 Deoptimizer::BailoutType type =
310 is_lazy_deopt ? Deoptimizer::LAZY : Deoptimizer::EAGER; 296 is_lazy_deopt ? Deoptimizer::LAZY : Deoptimizer::EAGER;
311 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); 297 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type);
312 if (id == Deoptimizer::kNotDeoptimizationEntry) { 298 if (id == Deoptimizer::kNotDeoptimizationEntry) {
313 Comment(";;; jump table entry %d.", i); 299 Comment(";;; jump table entry %d.", i);
314 } else { 300 } else {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } 347 }
362 return !is_aborted(); 348 return !is_aborted();
363 } 349 }
364 350
365 351
366 bool LCodeGen::GenerateDeferredCode() { 352 bool LCodeGen::GenerateDeferredCode() {
367 ASSERT(is_generating()); 353 ASSERT(is_generating());
368 if (deferred_.length() > 0) { 354 if (deferred_.length() > 0) {
369 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { 355 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) {
370 LDeferredCode* code = deferred_[i]; 356 LDeferredCode* code = deferred_[i];
357 Comment(";;; <@%d,#%d> "
358 "-------------------- Deferred %s --------------------",
359 code->instruction_index(),
360 code->instr()->hydrogen_value()->id(),
361 code->instr()->Mnemonic());
371 __ bind(code->entry()); 362 __ bind(code->entry());
372 if (NeedsDeferredFrame()) { 363 if (NeedsDeferredFrame()) {
373 Comment(";;; Deferred build frame @%d: %s.", 364 Comment(";;; Build frame");
374 code->instruction_index(),
375 code->instr()->Mnemonic());
376 ASSERT(!frame_is_built_); 365 ASSERT(!frame_is_built_);
377 ASSERT(info()->IsStub()); 366 ASSERT(info()->IsStub());
378 frame_is_built_ = true; 367 frame_is_built_ = true;
379 // Build the frame in such a way that esi isn't trashed. 368 // Build the frame in such a way that esi isn't trashed.
380 __ push(rbp); // Caller's frame pointer. 369 __ push(rbp); // Caller's frame pointer.
381 __ push(Operand(rbp, StandardFrameConstants::kContextOffset)); 370 __ push(Operand(rbp, StandardFrameConstants::kContextOffset));
382 __ Push(Smi::FromInt(StackFrame::STUB)); 371 __ Push(Smi::FromInt(StackFrame::STUB));
383 __ lea(rbp, Operand(rsp, 2 * kPointerSize)); 372 __ lea(rbp, Operand(rsp, 2 * kPointerSize));
373 Comment(";;; Deferred code");
384 } 374 }
385 Comment(";;; Deferred code @%d: %s.",
386 code->instruction_index(),
387 code->instr()->Mnemonic());
388 code->Generate(); 375 code->Generate();
389 if (NeedsDeferredFrame()) { 376 if (NeedsDeferredFrame()) {
390 Comment(";;; Deferred destroy frame @%d: %s.", 377 Comment(";;; Destroy frame");
391 code->instruction_index(),
392 code->instr()->Mnemonic());
393 ASSERT(frame_is_built_); 378 ASSERT(frame_is_built_);
394 frame_is_built_ = false; 379 frame_is_built_ = false;
395 __ movq(rsp, rbp); 380 __ movq(rsp, rbp);
396 __ pop(rbp); 381 __ pop(rbp);
397 } 382 }
398 __ jmp(code->exit()); 383 __ jmp(code->exit());
399 } 384 }
400 } 385 }
401 386
402 // Deferred code is the last part of the instruction sequence. Mark 387 // Deferred code is the last part of the instruction sequence. Mark
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments, deopt_mode); 903 RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments, deopt_mode);
919 } 904 }
920 905
921 906
922 void LCodeGen::RecordPosition(int position) { 907 void LCodeGen::RecordPosition(int position) {
923 if (position == RelocInfo::kNoPosition) return; 908 if (position == RelocInfo::kNoPosition) return;
924 masm()->positions_recorder()->RecordPosition(position); 909 masm()->positions_recorder()->RecordPosition(position);
925 } 910 }
926 911
927 912
913 static const char* LabelType(LLabel* label) {
914 if (label->is_loop_header()) return " (loop header)";
915 if (label->is_osr_entry()) return " (OSR entry)";
916 return "";
917 }
918
919
928 void LCodeGen::DoLabel(LLabel* label) { 920 void LCodeGen::DoLabel(LLabel* label) {
929 Comment(";;; -------------------- B%d%s --------------------", 921 Comment(";;; <@%d,#%d> -------------------- B%d%s --------------------",
922 current_instruction_,
923 label->hydrogen_value()->id(),
930 label->block_id(), 924 label->block_id(),
931 label->is_loop_header() ? " (loop header)" : ""); 925 LabelType(label));
932 __ bind(label->label()); 926 __ bind(label->label());
933 current_block_ = label->block_id(); 927 current_block_ = label->block_id();
934 DoGap(label); 928 DoGap(label);
935 } 929 }
936 930
937 931
938 void LCodeGen::DoParallelMove(LParallelMove* move) { 932 void LCodeGen::DoParallelMove(LParallelMove* move) {
939 resolver_.Resolve(move); 933 resolver_.Resolve(move);
940 } 934 }
941 935
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 ASSERT(ToRegister(instr->left()).is(rdx)); 1809 ASSERT(ToRegister(instr->left()).is(rdx));
1816 ASSERT(ToRegister(instr->right()).is(rax)); 1810 ASSERT(ToRegister(instr->right()).is(rax));
1817 ASSERT(ToRegister(instr->result()).is(rax)); 1811 ASSERT(ToRegister(instr->result()).is(rax));
1818 1812
1819 BinaryOpStub stub(instr->op(), NO_OVERWRITE); 1813 BinaryOpStub stub(instr->op(), NO_OVERWRITE);
1820 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); 1814 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
1821 __ nop(); // Signals no inlined code. 1815 __ nop(); // Signals no inlined code.
1822 } 1816 }
1823 1817
1824 1818
1825 int LCodeGen::GetNextEmittedBlock() { 1819 int LCodeGen::GetNextEmittedBlock() const {
1826 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) { 1820 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) {
1827 if (!chunk_->GetLabel(i)->HasReplacement()) return i; 1821 if (!chunk_->GetLabel(i)->HasReplacement()) return i;
1828 } 1822 }
1829 return -1; 1823 return -1;
1830 } 1824 }
1831 1825
1832 1826
1833 void LCodeGen::EmitBranch(int left_block, int right_block, Condition cc) { 1827 void LCodeGen::EmitBranch(int left_block, int right_block, Condition cc) {
1834 int next_block = GetNextEmittedBlock(); 1828 int next_block = GetNextEmittedBlock();
1835 right_block = chunk_->LookupDestination(right_block); 1829 right_block = chunk_->LookupDestination(right_block);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 } 1948 }
1955 1949
1956 // We've seen something for the first time -> deopt. 1950 // We've seen something for the first time -> deopt.
1957 DeoptimizeIf(no_condition, instr->environment()); 1951 DeoptimizeIf(no_condition, instr->environment());
1958 } 1952 }
1959 } 1953 }
1960 } 1954 }
1961 1955
1962 1956
1963 void LCodeGen::EmitGoto(int block) { 1957 void LCodeGen::EmitGoto(int block) {
1964 int destination = chunk_->LookupDestination(block); 1958 if (!IsNextEmittedBlock(block)) {
1965 if (destination != GetNextEmittedBlock()) { 1959 __ jmp(chunk_->GetAssemblyLabel(chunk_->LookupDestination(block)));
1966 __ jmp(chunk_->GetAssemblyLabel(destination));
1967 } 1960 }
1968 } 1961 }
1969 1962
1970 1963
1971 void LCodeGen::DoGoto(LGoto* instr) { 1964 void LCodeGen::DoGoto(LGoto* instr) {
1972 EmitGoto(instr->block_id()); 1965 EmitGoto(instr->block_id());
1973 } 1966 }
1974 1967
1975 1968
1976 inline Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) { 1969 inline Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) {
(...skipping 3709 matching lines...) Expand 10 before | Expand all | Expand 10 after
5686 FixedArray::kHeaderSize - kPointerSize)); 5679 FixedArray::kHeaderSize - kPointerSize));
5687 __ bind(&done); 5680 __ bind(&done);
5688 } 5681 }
5689 5682
5690 5683
5691 #undef __ 5684 #undef __
5692 5685
5693 } } // namespace v8::internal 5686 } } // namespace v8::internal
5694 5687
5695 #endif // V8_TARGET_ARCH_X64 5688 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698