OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 va_start(arguments, format); | 66 va_start(arguments, format); |
67 OS::VPrint(format, arguments); | 67 OS::VPrint(format, arguments); |
68 va_end(arguments); | 68 va_end(arguments); |
69 PrintF("\n"); | 69 PrintF("\n"); |
70 } | 70 } |
71 status_ = ABORTED; | 71 status_ = ABORTED; |
72 } | 72 } |
73 | 73 |
74 | 74 |
75 void LCodeGen::Comment(const char* format, ...) { | 75 void LCodeGen::Comment(const char* format, ...) { |
76 Abort("Unimplemented: %s", "Comment"); | 76 if (!FLAG_code_comments) return; |
| 77 char buffer[4 * KB]; |
| 78 StringBuilder builder(buffer, ARRAY_SIZE(buffer)); |
| 79 va_list arguments; |
| 80 va_start(arguments, format); |
| 81 builder.AddFormattedList(format, arguments); |
| 82 va_end(arguments); |
| 83 |
| 84 // Copy the string before recording it in the assembler to avoid |
| 85 // issues when the stack allocated buffer goes out of scope. |
| 86 size_t length = builder.position(); |
| 87 Vector<char> copy = Vector<char>::New(length + 1); |
| 88 memcpy(copy.start(), builder.Finalize(), copy.length()); |
| 89 masm()->RecordComment(copy.start()); |
77 } | 90 } |
78 | 91 |
79 | 92 |
80 bool LCodeGen::GeneratePrologue() { | 93 bool LCodeGen::GeneratePrologue() { |
81 Abort("Unimplemented: %s", "GeneratePrologue"); | 94 Abort("Unimplemented: %s", "GeneratePrologue"); |
82 return !is_aborted(); | 95 return false; |
83 } | 96 } |
84 | 97 |
85 | 98 |
86 bool LCodeGen::GenerateBody() { | 99 bool LCodeGen::GenerateBody() { |
87 ASSERT(is_generating()); | 100 ASSERT(is_generating()); |
88 bool emit_instructions = true; | 101 bool emit_instructions = true; |
89 for (current_instruction_ = 0; | 102 for (current_instruction_ = 0; |
90 !is_aborted() && current_instruction_ < instructions_->length(); | 103 !is_aborted() && current_instruction_ < instructions_->length(); |
91 current_instruction_++) { | 104 current_instruction_++) { |
92 LInstruction* instr = instructions_->at(current_instruction_); | 105 LInstruction* instr = instructions_->at(current_instruction_); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 137 |
125 // Deferred code is the last part of the instruction sequence. Mark | 138 // Deferred code is the last part of the instruction sequence. Mark |
126 // the generated code as done unless we bailed out. | 139 // the generated code as done unless we bailed out. |
127 if (!is_aborted()) status_ = DONE; | 140 if (!is_aborted()) status_ = DONE; |
128 return !is_aborted(); | 141 return !is_aborted(); |
129 } | 142 } |
130 | 143 |
131 | 144 |
132 bool LCodeGen::GenerateSafepointTable() { | 145 bool LCodeGen::GenerateSafepointTable() { |
133 Abort("Unimplemented: %s", "GeneratePrologue"); | 146 Abort("Unimplemented: %s", "GeneratePrologue"); |
134 return !is_aborted(); | 147 return false; |
135 } | 148 } |
136 | 149 |
137 | 150 |
138 Register LCodeGen::ToRegister(int index) const { | 151 Register LCodeGen::ToRegister(int index) const { |
139 return Register::FromAllocationIndex(index); | 152 return Register::FromAllocationIndex(index); |
140 } | 153 } |
141 | 154 |
142 | 155 |
143 XMMRegister LCodeGen::ToDoubleRegister(int index) const { | 156 XMMRegister LCodeGen::ToDoubleRegister(int index) const { |
144 return XMMRegister::FromAllocationIndex(index); | 157 return XMMRegister::FromAllocationIndex(index); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 Abort("Unimplemented: %s", "DoConstantI"); | 493 Abort("Unimplemented: %s", "DoConstantI"); |
481 } | 494 } |
482 | 495 |
483 | 496 |
484 void LCodeGen::DoConstantD(LConstantD* instr) { | 497 void LCodeGen::DoConstantD(LConstantD* instr) { |
485 Abort("Unimplemented: %s", "DoConstantI"); | 498 Abort("Unimplemented: %s", "DoConstantI"); |
486 } | 499 } |
487 | 500 |
488 | 501 |
489 void LCodeGen::DoConstantT(LConstantT* instr) { | 502 void LCodeGen::DoConstantT(LConstantT* instr) { |
490 Abort("Unimplemented: %s", "DoConstantT"); | 503 ASSERT(instr->result()->IsRegister()); |
| 504 __ Move(ToRegister(instr->result()), instr->value()); |
491 } | 505 } |
492 | 506 |
493 | 507 |
494 void LCodeGen::DoJSArrayLength(LJSArrayLength* instr) { | 508 void LCodeGen::DoJSArrayLength(LJSArrayLength* instr) { |
495 Abort("Unimplemented: %s", "DoJSArrayLength"); | 509 Abort("Unimplemented: %s", "DoJSArrayLength"); |
496 } | 510 } |
497 | 511 |
498 | 512 |
499 void LCodeGen::DoFixedArrayLength(LFixedArrayLength* instr) { | 513 void LCodeGen::DoFixedArrayLength(LFixedArrayLength* instr) { |
500 Abort("Unimplemented: %s", "DoFixedArrayLength"); | 514 Abort("Unimplemented: %s", "DoFixedArrayLength"); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 Abort("Unimplemented: %s", "EmitGoto"); | 568 Abort("Unimplemented: %s", "EmitGoto"); |
555 } | 569 } |
556 | 570 |
557 | 571 |
558 void LCodeGen::DoDeferredStackCheck(LGoto* instr) { | 572 void LCodeGen::DoDeferredStackCheck(LGoto* instr) { |
559 Abort("Unimplemented: %s", "DoDeferredStackCheck"); | 573 Abort("Unimplemented: %s", "DoDeferredStackCheck"); |
560 } | 574 } |
561 | 575 |
562 | 576 |
563 void LCodeGen::DoGoto(LGoto* instr) { | 577 void LCodeGen::DoGoto(LGoto* instr) { |
564 Abort("Unimplemented: %s", "DoGoto"); | 578 class DeferredStackCheck: public LDeferredCode { |
| 579 public: |
| 580 DeferredStackCheck(LCodeGen* codegen, LGoto* instr) |
| 581 : LDeferredCode(codegen), instr_(instr) { } |
| 582 virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); } |
| 583 private: |
| 584 LGoto* instr_; |
| 585 }; |
| 586 |
| 587 DeferredStackCheck* deferred = NULL; |
| 588 if (instr->include_stack_check()) { |
| 589 deferred = new DeferredStackCheck(this, instr); |
| 590 } |
| 591 EmitGoto(instr->block_id(), deferred); |
565 } | 592 } |
566 | 593 |
567 | 594 |
568 Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) { | 595 Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) { |
569 Condition cond = no_condition; | 596 Condition cond = no_condition; |
570 switch (op) { | 597 switch (op) { |
571 case Token::EQ: | 598 case Token::EQ: |
572 case Token::EQ_STRICT: | 599 case Token::EQ_STRICT: |
573 cond = equal; | 600 cond = equal; |
574 break; | 601 break; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 Abort("Unimplemented: %s", "DoCmpT"); | 779 Abort("Unimplemented: %s", "DoCmpT"); |
753 } | 780 } |
754 | 781 |
755 | 782 |
756 void LCodeGen::DoCmpTAndBranch(LCmpTAndBranch* instr) { | 783 void LCodeGen::DoCmpTAndBranch(LCmpTAndBranch* instr) { |
757 Abort("Unimplemented: %s", "DoCmpTAndBranch"); | 784 Abort("Unimplemented: %s", "DoCmpTAndBranch"); |
758 } | 785 } |
759 | 786 |
760 | 787 |
761 void LCodeGen::DoReturn(LReturn* instr) { | 788 void LCodeGen::DoReturn(LReturn* instr) { |
762 Abort("Unimplemented: %s", "DoReturn"); | 789 if (FLAG_trace) { |
| 790 // Preserve the return value on the stack and rely on the runtime |
| 791 // call to return the value in the same register. |
| 792 __ push(rax); |
| 793 __ CallRuntime(Runtime::kTraceExit, 1); |
| 794 } |
| 795 __ movq(rsp, rbp); |
| 796 __ pop(rbp); |
| 797 __ ret((ParameterCount() + 1) * kPointerSize); |
| 798 |
763 } | 799 } |
764 | 800 |
765 | 801 |
766 void LCodeGen::DoLoadGlobal(LLoadGlobal* instr) { | 802 void LCodeGen::DoLoadGlobal(LLoadGlobal* instr) { |
767 Abort("Unimplemented: %s", "DoLoadGlobal"); | 803 Abort("Unimplemented: %s", "DoLoadGlobal"); |
768 } | 804 } |
769 | 805 |
770 | 806 |
771 void LCodeGen::DoStoreGlobal(LStoreGlobal* instr) { | 807 void LCodeGen::DoStoreGlobal(LStoreGlobal* instr) { |
772 Abort("Unimplemented: %s", "DoStoreGlobal"); | 808 Abort("Unimplemented: %s", "DoStoreGlobal"); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 | 1160 |
1125 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 1161 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
1126 Abort("Unimplemented: %s", "DoOsrEntry"); | 1162 Abort("Unimplemented: %s", "DoOsrEntry"); |
1127 } | 1163 } |
1128 | 1164 |
1129 #undef __ | 1165 #undef __ |
1130 | 1166 |
1131 } } // namespace v8::internal | 1167 } } // namespace v8::internal |
1132 | 1168 |
1133 #endif // V8_TARGET_ARCH_X64 | 1169 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |