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

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

Issue 24957003: Add tool to visualize machine code/lithium. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Final polish before review 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 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return !is_aborted(); 292 return !is_aborted();
293 } 293 }
294 294
295 295
296 bool LCodeGen::GenerateDeferredCode() { 296 bool LCodeGen::GenerateDeferredCode() {
297 ASSERT(is_generating()); 297 ASSERT(is_generating());
298 if (deferred_.length() > 0) { 298 if (deferred_.length() > 0) {
299 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) { 299 for (int i = 0; !is_aborted() && i < deferred_.length(); i++) {
300 LDeferredCode* code = deferred_[i]; 300 LDeferredCode* code = deferred_[i];
301 301
302 int pos = instructions_->at(code->instruction_index())->position(); 302 HValue* value =
303 RecordAndUpdatePosition(pos); 303 instructions_->at(code->instruction_index())->hydrogen_value();
304 RecordAndWritePosition(value->position());
304 305
305 Comment(";;; <@%d,#%d> " 306 Comment(";;; <@%d,#%d> "
306 "-------------------- Deferred %s --------------------", 307 "-------------------- Deferred %s --------------------",
307 code->instruction_index(), 308 code->instruction_index(),
308 code->instr()->hydrogen_value()->id(), 309 code->instr()->hydrogen_value()->id(),
309 code->instr()->Mnemonic()); 310 code->instr()->Mnemonic());
310 __ bind(code->entry()); 311 __ bind(code->entry());
311 if (NeedsDeferredFrame()) { 312 if (NeedsDeferredFrame()) {
312 Comment(";;; Build frame"); 313 Comment(";;; Build frame");
313 ASSERT(!frame_is_built_); 314 ASSERT(!frame_is_built_);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 } 557 }
557 558
558 559
559 void LCodeGen::CallCodeGeneric(Handle<Code> code, 560 void LCodeGen::CallCodeGeneric(Handle<Code> code,
560 RelocInfo::Mode mode, 561 RelocInfo::Mode mode,
561 LInstruction* instr, 562 LInstruction* instr,
562 SafepointMode safepoint_mode, 563 SafepointMode safepoint_mode,
563 int argc) { 564 int argc) {
564 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size() - masm()->CallSize(code)); 565 EnsureSpaceForLazyDeopt(Deoptimizer::patch_size() - masm()->CallSize(code));
565 ASSERT(instr != NULL); 566 ASSERT(instr != NULL);
566 LPointerMap* pointers = instr->pointer_map();
567 RecordPosition(pointers->position());
568 __ call(code, mode); 567 __ call(code, mode);
569 RecordSafepointWithLazyDeopt(instr, safepoint_mode, argc); 568 RecordSafepointWithLazyDeopt(instr, safepoint_mode, argc);
570 569
571 // Signal that we don't inline smi code before these stubs in the 570 // Signal that we don't inline smi code before these stubs in the
572 // optimizing code generator. 571 // optimizing code generator.
573 if (code->kind() == Code::BINARY_OP_IC || 572 if (code->kind() == Code::BINARY_OP_IC ||
574 code->kind() == Code::COMPARE_IC) { 573 code->kind() == Code::COMPARE_IC) {
575 __ nop(); 574 __ nop();
576 } 575 }
577 } 576 }
578 577
579 578
580 void LCodeGen::CallCode(Handle<Code> code, 579 void LCodeGen::CallCode(Handle<Code> code,
581 RelocInfo::Mode mode, 580 RelocInfo::Mode mode,
582 LInstruction* instr) { 581 LInstruction* instr) {
583 CallCodeGeneric(code, mode, instr, RECORD_SIMPLE_SAFEPOINT, 0); 582 CallCodeGeneric(code, mode, instr, RECORD_SIMPLE_SAFEPOINT, 0);
584 } 583 }
585 584
586 585
587 void LCodeGen::CallRuntime(const Runtime::Function* function, 586 void LCodeGen::CallRuntime(const Runtime::Function* function,
588 int num_arguments, 587 int num_arguments,
589 LInstruction* instr, 588 LInstruction* instr,
590 SaveFPRegsMode save_doubles) { 589 SaveFPRegsMode save_doubles) {
591 ASSERT(instr != NULL); 590 ASSERT(instr != NULL);
592 ASSERT(instr->HasPointerMap()); 591 ASSERT(instr->HasPointerMap());
593 LPointerMap* pointers = instr->pointer_map();
594 RecordPosition(pointers->position());
595 592
596 __ CallRuntime(function, num_arguments, save_doubles); 593 __ CallRuntime(function, num_arguments, save_doubles);
597 594
598 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT, 0); 595 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT, 0);
599 } 596 }
600 597
601 598
602 void LCodeGen::CallRuntimeFromDeferred(Runtime::FunctionId id, 599 void LCodeGen::CallRuntimeFromDeferred(Runtime::FunctionId id,
603 int argc, 600 int argc,
604 LInstruction* instr) { 601 LInstruction* instr) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 } 830 }
834 831
835 832
836 void LCodeGen::RecordSafepoint(LPointerMap* pointers, 833 void LCodeGen::RecordSafepoint(LPointerMap* pointers,
837 Safepoint::DeoptMode deopt_mode) { 834 Safepoint::DeoptMode deopt_mode) {
838 RecordSafepoint(pointers, Safepoint::kSimple, 0, deopt_mode); 835 RecordSafepoint(pointers, Safepoint::kSimple, 0, deopt_mode);
839 } 836 }
840 837
841 838
842 void LCodeGen::RecordSafepoint(Safepoint::DeoptMode deopt_mode) { 839 void LCodeGen::RecordSafepoint(Safepoint::DeoptMode deopt_mode) {
843 LPointerMap empty_pointers(RelocInfo::kNoPosition, zone()); 840 LPointerMap empty_pointers(zone());
844 RecordSafepoint(&empty_pointers, deopt_mode); 841 RecordSafepoint(&empty_pointers, deopt_mode);
845 } 842 }
846 843
847 844
848 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers, 845 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers,
849 int arguments, 846 int arguments,
850 Safepoint::DeoptMode deopt_mode) { 847 Safepoint::DeoptMode deopt_mode) {
851 RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments, deopt_mode); 848 RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments, deopt_mode);
852 } 849 }
853 850
854 851
855 void LCodeGen::RecordPosition(int position) { 852 void LCodeGen::RecordAndWritePosition(int position) {
856 if (position == RelocInfo::kNoPosition) return; 853 if (position == RelocInfo::kNoPosition) return;
857 masm()->positions_recorder()->RecordPosition(position); 854 masm()->positions_recorder()->RecordPosition(position);
855 masm()->positions_recorder()->WriteRecordedPositions();
858 } 856 }
859 857
860 858
861 void LCodeGen::RecordAndUpdatePosition(int position) {
862 if (position >= 0 && position != old_position_) {
863 masm()->positions_recorder()->RecordPosition(position);
864 old_position_ = position;
865 }
866 }
867
868
869 static const char* LabelType(LLabel* label) { 859 static const char* LabelType(LLabel* label) {
870 if (label->is_loop_header()) return " (loop header)"; 860 if (label->is_loop_header()) return " (loop header)";
871 if (label->is_osr_entry()) return " (OSR entry)"; 861 if (label->is_osr_entry()) return " (OSR entry)";
872 return ""; 862 return "";
873 } 863 }
874 864
875 865
876 void LCodeGen::DoLabel(LLabel* label) { 866 void LCodeGen::DoLabel(LLabel* label) {
877 Comment(";;; <@%d,#%d> -------------------- B%d%s --------------------", 867 Comment(";;; <@%d,#%d> -------------------- B%d%s --------------------",
878 current_instruction_, 868 current_instruction_,
(...skipping 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after
3165 StackArgumentsAccessor args(elements, length, 3155 StackArgumentsAccessor args(elements, length,
3166 ARGUMENTS_DONT_CONTAIN_RECEIVER); 3156 ARGUMENTS_DONT_CONTAIN_RECEIVER);
3167 __ push(args.GetArgumentOperand(0)); 3157 __ push(args.GetArgumentOperand(0));
3168 __ decl(length); 3158 __ decl(length);
3169 __ j(not_zero, &loop); 3159 __ j(not_zero, &loop);
3170 3160
3171 // Invoke the function. 3161 // Invoke the function.
3172 __ bind(&invoke); 3162 __ bind(&invoke);
3173 ASSERT(instr->HasPointerMap()); 3163 ASSERT(instr->HasPointerMap());
3174 LPointerMap* pointers = instr->pointer_map(); 3164 LPointerMap* pointers = instr->pointer_map();
3175 RecordPosition(pointers->position());
3176 SafepointGenerator safepoint_generator( 3165 SafepointGenerator safepoint_generator(
3177 this, pointers, Safepoint::kLazyDeopt); 3166 this, pointers, Safepoint::kLazyDeopt);
3178 ParameterCount actual(rax); 3167 ParameterCount actual(rax);
3179 __ InvokeFunction(function, actual, CALL_FUNCTION, 3168 __ InvokeFunction(function, actual, CALL_FUNCTION,
3180 safepoint_generator, CALL_AS_METHOD); 3169 safepoint_generator, CALL_AS_METHOD);
3181 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 3170 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
3182 } 3171 }
3183 3172
3184 3173
3185 void LCodeGen::DoPushArgument(LPushArgument* instr) { 3174 void LCodeGen::DoPushArgument(LPushArgument* instr) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3239 int arity, 3228 int arity,
3240 LInstruction* instr, 3229 LInstruction* instr,
3241 CallKind call_kind, 3230 CallKind call_kind,
3242 RDIState rdi_state) { 3231 RDIState rdi_state) {
3243 bool dont_adapt_arguments = 3232 bool dont_adapt_arguments =
3244 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; 3233 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel;
3245 bool can_invoke_directly = 3234 bool can_invoke_directly =
3246 dont_adapt_arguments || formal_parameter_count == arity; 3235 dont_adapt_arguments || formal_parameter_count == arity;
3247 3236
3248 LPointerMap* pointers = instr->pointer_map(); 3237 LPointerMap* pointers = instr->pointer_map();
3249 RecordPosition(pointers->position());
3250 3238
3251 if (can_invoke_directly) { 3239 if (can_invoke_directly) {
3252 if (rdi_state == RDI_UNINITIALIZED) { 3240 if (rdi_state == RDI_UNINITIALIZED) {
3253 __ LoadHeapObject(rdi, function); 3241 __ LoadHeapObject(rdi, function);
3254 } 3242 }
3255 3243
3256 // Change context. 3244 // Change context.
3257 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 3245 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
3258 3246
3259 // Set rax to arguments count if adaption is not needed. Assumes that rax 3247 // Set rax to arguments count if adaption is not needed. Assumes that rax
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
3700 } 3688 }
3701 3689
3702 3690
3703 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { 3691 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) {
3704 ASSERT(ToRegister(instr->function()).is(rdi)); 3692 ASSERT(ToRegister(instr->function()).is(rdi));
3705 ASSERT(instr->HasPointerMap()); 3693 ASSERT(instr->HasPointerMap());
3706 3694
3707 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); 3695 Handle<JSFunction> known_function = instr->hydrogen()->known_function();
3708 if (known_function.is_null()) { 3696 if (known_function.is_null()) {
3709 LPointerMap* pointers = instr->pointer_map(); 3697 LPointerMap* pointers = instr->pointer_map();
3710 RecordPosition(pointers->position());
3711 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); 3698 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt);
3712 ParameterCount count(instr->arity()); 3699 ParameterCount count(instr->arity());
3713 __ InvokeFunction(rdi, count, CALL_FUNCTION, generator, CALL_AS_METHOD); 3700 __ InvokeFunction(rdi, count, CALL_FUNCTION, generator, CALL_AS_METHOD);
3714 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 3701 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
3715 } else { 3702 } else {
3716 CallKnownFunction(known_function, 3703 CallKnownFunction(known_function,
3717 instr->hydrogen()->formal_parameter_count(), 3704 instr->hydrogen()->formal_parameter_count(),
3718 instr->arity(), 3705 instr->arity(),
3719 instr, 3706 instr,
3720 CALL_AS_METHOD, 3707 CALL_AS_METHOD,
(...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after
5452 FixedArray::kHeaderSize - kPointerSize)); 5439 FixedArray::kHeaderSize - kPointerSize));
5453 __ bind(&done); 5440 __ bind(&done);
5454 } 5441 }
5455 5442
5456 5443
5457 #undef __ 5444 #undef __
5458 5445
5459 } } // namespace v8::internal 5446 } } // namespace v8::internal
5460 5447
5461 #endif // V8_TARGET_ARCH_X64 5448 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698