OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_DEOPT_INSTRUCTIONS_H_ | 5 #ifndef VM_DEOPT_INSTRUCTIONS_H_ |
6 #define VM_DEOPT_INSTRUCTIONS_H_ | 6 #define VM_DEOPT_INSTRUCTIONS_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/code_generator.h" | 10 #include "vm/code_generator.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 | 48 |
49 intptr_t GetSourceFp() const; | 49 intptr_t GetSourceFp() const; |
50 intptr_t GetSourcePp() const; | 50 intptr_t GetSourcePp() const; |
51 intptr_t GetSourcePc() const; | 51 intptr_t GetSourcePc() const; |
52 | 52 |
53 intptr_t GetCallerFp() const; | 53 intptr_t GetCallerFp() const; |
54 void SetCallerFp(intptr_t callers_fp); | 54 void SetCallerFp(intptr_t callers_fp); |
55 | 55 |
56 RawObject* ObjectAt(intptr_t index) const { | 56 RawObject* ObjectAt(intptr_t index) const { |
57 const Array& object_table = Array::Handle(object_table_); | 57 const Array& object_pool = Array::Handle(object_pool_); |
58 return object_table.At(index); | 58 return object_pool.At(index); |
59 } | 59 } |
60 | 60 |
61 intptr_t RegisterValue(Register reg) const { | 61 intptr_t RegisterValue(Register reg) const { |
62 ASSERT(cpu_registers_ != NULL); | 62 ASSERT(cpu_registers_ != NULL); |
63 ASSERT(reg >= 0); | 63 ASSERT(reg >= 0); |
64 ASSERT(reg < kNumberOfCpuRegisters); | 64 ASSERT(reg < kNumberOfCpuRegisters); |
65 return cpu_registers_[reg]; | 65 return cpu_registers_[reg]; |
66 } | 66 } |
67 | 67 |
68 double FpuRegisterValue(FpuRegister reg) const { | 68 double FpuRegisterValue(FpuRegister reg) const { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // Claims ownership of the memory for 'object'. | 198 // Claims ownership of the memory for 'object'. |
199 void SetDeferredObjectAt(intptr_t idx, DeferredObject* object) { | 199 void SetDeferredObjectAt(intptr_t idx, DeferredObject* object) { |
200 deferred_objects_[idx] = object; | 200 deferred_objects_[idx] = object; |
201 } | 201 } |
202 | 202 |
203 intptr_t DeferredObjectsCount() const { | 203 intptr_t DeferredObjectsCount() const { |
204 return deferred_objects_count_; | 204 return deferred_objects_count_; |
205 } | 205 } |
206 | 206 |
207 RawCode* code_; | 207 RawCode* code_; |
208 RawArray* object_table_; | 208 RawArray* object_pool_; |
209 RawTypedData* deopt_info_; | 209 RawTypedData* deopt_info_; |
210 bool dest_frame_is_allocated_; | 210 bool dest_frame_is_allocated_; |
211 intptr_t* dest_frame_; | 211 intptr_t* dest_frame_; |
212 intptr_t dest_frame_size_; | 212 intptr_t dest_frame_size_; |
213 bool source_frame_is_allocated_; | 213 bool source_frame_is_allocated_; |
214 intptr_t* source_frame_; | 214 intptr_t* source_frame_; |
215 intptr_t source_frame_size_; | 215 intptr_t source_frame_size_; |
216 intptr_t* cpu_registers_; | 216 intptr_t* cpu_registers_; |
217 fpu_register_t* fpu_registers_; | 217 fpu_register_t* fpu_registers_; |
218 intptr_t num_args_; | 218 intptr_t num_args_; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 280 |
281 virtual DeoptInstr::Kind kind() const = 0; | 281 virtual DeoptInstr::Kind kind() const = 0; |
282 | 282 |
283 bool Equals(const DeoptInstr& other) const { | 283 bool Equals(const DeoptInstr& other) const { |
284 return (kind() == other.kind()) && (source_index() == other.source_index()); | 284 return (kind() == other.kind()) && (source_index() == other.source_index()); |
285 } | 285 } |
286 | 286 |
287 // Get the code and return address which is encoded in this | 287 // Get the code and return address which is encoded in this |
288 // kRetAfterAddress deopt instruction. | 288 // kRetAfterAddress deopt instruction. |
289 static uword GetRetAddress(DeoptInstr* instr, | 289 static uword GetRetAddress(DeoptInstr* instr, |
290 const Array& object_table, | 290 const Array& object_pool, |
291 Code* code); | 291 Code* code); |
292 | 292 |
293 // Return number of initialized fields in the object that will be | 293 // Return number of initialized fields in the object that will be |
294 // materialized by kMaterializeObject instruction. | 294 // materialized by kMaterializeObject instruction. |
295 static intptr_t GetFieldCount(DeoptInstr* instr) { | 295 static intptr_t GetFieldCount(DeoptInstr* instr) { |
296 ASSERT(instr->kind() == DeoptInstr::kMaterializeObject); | 296 ASSERT(instr->kind() == DeoptInstr::kMaterializeObject); |
297 return instr->source_index(); | 297 return instr->source_index(); |
298 } | 298 } |
299 | 299 |
300 protected: | 300 protected: |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 typedef RegisterSource<FpuRegister> FpuRegisterSource; | 412 typedef RegisterSource<FpuRegister> FpuRegisterSource; |
413 | 413 |
414 | 414 |
415 // Builds a deoptimization info table, one DeoptInfo at a time. Call AddXXX | 415 // Builds a deoptimization info table, one DeoptInfo at a time. Call AddXXX |
416 // methods in the order of their target, starting wih deoptimized code | 416 // methods in the order of their target, starting wih deoptimized code |
417 // continuation pc and ending with the first argument of the deoptimized | 417 // continuation pc and ending with the first argument of the deoptimized |
418 // code. Call CreateDeoptInfo to write the accumulated instructions into | 418 // code. Call CreateDeoptInfo to write the accumulated instructions into |
419 // the heap and reset the builder's internal state for the next DeoptInfo. | 419 // the heap and reset the builder's internal state for the next DeoptInfo. |
420 class DeoptInfoBuilder : public ValueObject { | 420 class DeoptInfoBuilder : public ValueObject { |
421 public: | 421 public: |
422 DeoptInfoBuilder(Zone* zone, const intptr_t num_args); | 422 DeoptInfoBuilder(Zone* zone, const intptr_t num_args, Assembler* assembler); |
423 | |
424 // 'object_table' holds all objects referred to by DeoptInstr in | |
425 // all DeoptInfo instances for a single Code object. | |
426 const GrowableObjectArray& object_table() { return object_table_; } | |
427 | 423 |
428 // Return address before instruction. | 424 // Return address before instruction. |
429 void AddReturnAddress(const Function& function, | 425 void AddReturnAddress(const Function& function, |
430 intptr_t deopt_id, | 426 intptr_t deopt_id, |
431 intptr_t dest_index); | 427 intptr_t dest_index); |
432 | 428 |
433 // Copy from optimized frame to unoptimized. | 429 // Copy from optimized frame to unoptimized. |
434 void AddCopy(Value* value, const Location& source_loc, intptr_t dest_index); | 430 void AddCopy(Value* value, const Location& source_loc, intptr_t dest_index); |
435 void AddPcMarker(const Function& function, intptr_t dest_index); | 431 void AddPcMarker(const Function& function, intptr_t dest_index); |
436 void AddPp(const Function& function, intptr_t dest_index); | 432 void AddPp(const Function& function, intptr_t dest_index); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 return instructions_.length() - frame_start_; | 474 return instructions_.length() - frame_start_; |
479 } | 475 } |
480 | 476 |
481 void AddConstant(const Object& obj, intptr_t dest_index); | 477 void AddConstant(const Object& obj, intptr_t dest_index); |
482 | 478 |
483 Zone* zone() const { return zone_; } | 479 Zone* zone() const { return zone_; } |
484 | 480 |
485 Zone* zone_; | 481 Zone* zone_; |
486 | 482 |
487 GrowableArray<DeoptInstr*> instructions_; | 483 GrowableArray<DeoptInstr*> instructions_; |
488 const GrowableObjectArray& object_table_; | |
489 const intptr_t num_args_; | 484 const intptr_t num_args_; |
| 485 Assembler* assembler_; |
490 | 486 |
491 // Used to compress entries by sharing suffixes. | 487 // Used to compress entries by sharing suffixes. |
492 TrieNode* trie_root_; | 488 TrieNode* trie_root_; |
493 intptr_t current_info_number_; | 489 intptr_t current_info_number_; |
494 | 490 |
495 intptr_t frame_start_; | 491 intptr_t frame_start_; |
496 GrowableArray<MaterializeObjectInstr*> materializations_; | 492 GrowableArray<MaterializeObjectInstr*> materializations_; |
497 | 493 |
498 DISALLOW_COPY_AND_ASSIGN(DeoptInfoBuilder); | 494 DISALLOW_COPY_AND_ASSIGN(DeoptInfoBuilder); |
499 }; | 495 }; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 class ReasonField : public BitField<ICData::DeoptReasonId, 0, 8> { }; | 533 class ReasonField : public BitField<ICData::DeoptReasonId, 0, 8> { }; |
538 class FlagsField : public BitField<uint32_t, 8, 8> { }; | 534 class FlagsField : public BitField<uint32_t, 8, 8> { }; |
539 | 535 |
540 private: | 536 private: |
541 static const intptr_t kEntrySize = 3; | 537 static const intptr_t kEntrySize = 3; |
542 }; | 538 }; |
543 | 539 |
544 } // namespace dart | 540 } // namespace dart |
545 | 541 |
546 #endif // VM_DEOPT_INSTRUCTIONS_H_ | 542 #endif // VM_DEOPT_INSTRUCTIONS_H_ |
OLD | NEW |