OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/code-assembler.h" | 5 #include "src/compiler/code-assembler.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
11 #include "src/compiler/instruction-selector.h" | 11 #include "src/compiler/instruction-selector.h" |
12 #include "src/compiler/linkage.h" | 12 #include "src/compiler/linkage.h" |
13 #include "src/compiler/node-matchers.h" | 13 #include "src/compiler/node-matchers.h" |
14 #include "src/compiler/pipeline.h" | 14 #include "src/compiler/pipeline.h" |
15 #include "src/compiler/raw-machine-assembler.h" | 15 #include "src/compiler/raw-machine-assembler.h" |
16 #include "src/compiler/schedule.h" | 16 #include "src/compiler/schedule.h" |
17 #include "src/frames.h" | 17 #include "src/frames.h" |
18 #include "src/interface-descriptors.h" | 18 #include "src/interface-descriptors.h" |
19 #include "src/interpreter/bytecodes.h" | 19 #include "src/interpreter/bytecodes.h" |
20 #include "src/machine-type.h" | 20 #include "src/machine-type.h" |
21 #include "src/macro-assembler.h" | 21 #include "src/macro-assembler.h" |
| 22 #include "src/utils.h" |
22 #include "src/zone.h" | 23 #include "src/zone.h" |
23 | 24 |
24 namespace v8 { | 25 namespace v8 { |
25 namespace internal { | 26 namespace internal { |
26 namespace compiler { | 27 namespace compiler { |
27 | 28 |
28 CodeAssembler::CodeAssembler(Isolate* isolate, Zone* zone, | 29 CodeAssembler::CodeAssembler(Isolate* isolate, Zone* zone, |
29 const CallInterfaceDescriptor& descriptor, | 30 const CallInterfaceDescriptor& descriptor, |
30 Code::Flags flags, const char* name, | 31 Code::Flags flags, const char* name, |
31 size_t result_size) | 32 size_t result_size) |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 Node* CodeAssembler::Parameter(int value) { | 156 Node* CodeAssembler::Parameter(int value) { |
156 return raw_assembler_->Parameter(value); | 157 return raw_assembler_->Parameter(value); |
157 } | 158 } |
158 | 159 |
159 void CodeAssembler::Return(Node* value) { | 160 void CodeAssembler::Return(Node* value) { |
160 return raw_assembler_->Return(value); | 161 return raw_assembler_->Return(value); |
161 } | 162 } |
162 | 163 |
163 void CodeAssembler::DebugBreak() { raw_assembler_->DebugBreak(); } | 164 void CodeAssembler::DebugBreak() { raw_assembler_->DebugBreak(); } |
164 | 165 |
| 166 void CodeAssembler::Comment(const char* format, ...) { |
| 167 if (!FLAG_code_comments) return; |
| 168 char buffer[4 * KB]; |
| 169 StringBuilder builder(buffer, arraysize(buffer)); |
| 170 va_list arguments; |
| 171 va_start(arguments, format); |
| 172 builder.AddFormattedList(format, arguments); |
| 173 va_end(arguments); |
| 174 |
| 175 // Copy the string before recording it in the assembler to avoid |
| 176 // issues when the stack allocated buffer goes out of scope. |
| 177 size_t length = builder.position() + 3; |
| 178 char* copy = reinterpret_cast<char*>(malloc(static_cast<int>(length))); |
| 179 MemCopy(copy + 2, builder.Finalize(), length); |
| 180 copy[0] = ';'; |
| 181 copy[1] = ' '; |
| 182 raw_assembler_->Comment(copy); |
| 183 } |
| 184 |
165 void CodeAssembler::Bind(CodeAssembler::Label* label) { return label->Bind(); } | 185 void CodeAssembler::Bind(CodeAssembler::Label* label) { return label->Bind(); } |
166 | 186 |
167 Node* CodeAssembler::LoadFramePointer() { | 187 Node* CodeAssembler::LoadFramePointer() { |
168 return raw_assembler_->LoadFramePointer(); | 188 return raw_assembler_->LoadFramePointer(); |
169 } | 189 } |
170 | 190 |
171 Node* CodeAssembler::LoadParentFramePointer() { | 191 Node* CodeAssembler::LoadParentFramePointer() { |
172 return raw_assembler_->LoadParentFramePointer(); | 192 return raw_assembler_->LoadParentFramePointer(); |
173 } | 193 } |
174 | 194 |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 } | 752 } |
733 } | 753 } |
734 } | 754 } |
735 | 755 |
736 bound_ = true; | 756 bound_ = true; |
737 } | 757 } |
738 | 758 |
739 } // namespace compiler | 759 } // namespace compiler |
740 } // namespace internal | 760 } // namespace internal |
741 } // namespace v8 | 761 } // namespace v8 |
OLD | NEW |