OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 17 matching lines...) Expand all Loading... |
28 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 28 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
29 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 |
31 // The original source code covered by the above license above has been | 31 // The original source code covered by the above license above has been |
32 // modified significantly by Google Inc. | 32 // modified significantly by Google Inc. |
33 // Copyright 2012 the V8 project authors. All rights reserved. | 33 // Copyright 2012 the V8 project authors. All rights reserved. |
34 | 34 |
35 #ifndef V8_ASSEMBLER_H_ | 35 #ifndef V8_ASSEMBLER_H_ |
36 #define V8_ASSEMBLER_H_ | 36 #define V8_ASSEMBLER_H_ |
37 | 37 |
| 38 #include <forward_list> |
| 39 |
38 #include "src/allocation.h" | 40 #include "src/allocation.h" |
39 #include "src/builtins/builtins.h" | 41 #include "src/builtins/builtins.h" |
40 #include "src/deoptimize-reason.h" | 42 #include "src/deoptimize-reason.h" |
41 #include "src/globals.h" | 43 #include "src/globals.h" |
42 #include "src/isolate.h" | 44 #include "src/isolate.h" |
43 #include "src/label.h" | 45 #include "src/label.h" |
44 #include "src/log.h" | 46 #include "src/log.h" |
45 #include "src/register-configuration.h" | 47 #include "src/register-configuration.h" |
46 #include "src/runtime/runtime.h" | 48 #include "src/runtime/runtime.h" |
47 | 49 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 constant_pool_available_ = available; | 142 constant_pool_available_ = available; |
141 } else { | 143 } else { |
142 // Embedded constant pool not supported on this architecture. | 144 // Embedded constant pool not supported on this architecture. |
143 UNREACHABLE(); | 145 UNREACHABLE(); |
144 } | 146 } |
145 } | 147 } |
146 | 148 |
147 // The program counter, which points into the buffer above and moves forward. | 149 // The program counter, which points into the buffer above and moves forward. |
148 byte* pc_; | 150 byte* pc_; |
149 | 151 |
| 152 // The following two functions help with avoiding allocations of heap numbers |
| 153 // during the code assembly phase. {RequestHeapNumber} records the need for a |
| 154 // future heap number allocation, together with the current pc offset. After |
| 155 // code assembly, {AllocateRequestedHeapNumbers} will allocate these numbers |
| 156 // and, with the help of {Assembler::set_heap_number}, place them where they |
| 157 // are expected (determined by the recorded pc offset). |
| 158 void RequestHeapNumber(double value) { |
| 159 heap_numbers_.emplace_front(value, pc_offset()); |
| 160 } |
| 161 void AllocateRequestedHeapNumbers(Isolate* isolate); |
| 162 |
150 private: | 163 private: |
151 IsolateData isolate_data_; | 164 IsolateData isolate_data_; |
152 uint64_t enabled_cpu_features_; | 165 uint64_t enabled_cpu_features_; |
153 bool emit_debug_code_; | 166 bool emit_debug_code_; |
154 bool predictable_code_size_; | 167 bool predictable_code_size_; |
155 | 168 |
156 // Indicates whether the constant pool can be accessed, which is only possible | 169 // Indicates whether the constant pool can be accessed, which is only possible |
157 // if the pp register points to the current code object's constant pool. | 170 // if the pp register points to the current code object's constant pool. |
158 bool constant_pool_available_; | 171 bool constant_pool_available_; |
159 | 172 |
160 // Constant pool. | 173 // Constant pool. |
161 friend class FrameAndConstantPoolScope; | 174 friend class FrameAndConstantPoolScope; |
162 friend class ConstantPoolUnavailableScope; | 175 friend class ConstantPoolUnavailableScope; |
| 176 |
| 177 // Delayed allocation of heap numbers. |
| 178 struct RequestedHeapNumber { |
| 179 RequestedHeapNumber(double value, int offset); |
| 180 double value; // The number for which we later need to create a HeapObject. |
| 181 int offset; // The {buffer_} offset where we emitted a dummy that needs to |
| 182 // get replaced by the actual HeapObject via |
| 183 // {Assembler::set_heap_number}. |
| 184 }; |
| 185 std::forward_list<RequestedHeapNumber> heap_numbers_; |
163 }; | 186 }; |
164 | 187 |
165 | 188 |
166 // Avoids emitting debug code during the lifetime of this scope object. | 189 // Avoids emitting debug code during the lifetime of this scope object. |
167 class DontEmitDebugCodeScope BASE_EMBEDDED { | 190 class DontEmitDebugCodeScope BASE_EMBEDDED { |
168 public: | 191 public: |
169 explicit DontEmitDebugCodeScope(AssemblerBase* assembler) | 192 explicit DontEmitDebugCodeScope(AssemblerBase* assembler) |
170 : assembler_(assembler), old_value_(assembler->emit_debug_code()) { | 193 : assembler_(assembler), old_value_(assembler->emit_debug_code()) { |
171 assembler_->set_emit_debug_code(false); | 194 assembler_->set_emit_debug_code(false); |
172 } | 195 } |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 std::vector<ConstantPoolEntry> shared_entries; | 1284 std::vector<ConstantPoolEntry> shared_entries; |
1262 }; | 1285 }; |
1263 | 1286 |
1264 Label emitted_label_; // Records pc_offset of emitted pool | 1287 Label emitted_label_; // Records pc_offset of emitted pool |
1265 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES]; | 1288 PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES]; |
1266 }; | 1289 }; |
1267 | 1290 |
1268 } // namespace internal | 1291 } // namespace internal |
1269 } // namespace v8 | 1292 } // namespace v8 |
1270 #endif // V8_ASSEMBLER_H_ | 1293 #endif // V8_ASSEMBLER_H_ |
OLD | NEW |