| 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" |
| 11 #include "vm/deferred_objects.h" | 11 #include "vm/deferred_objects.h" |
| 12 #include "vm/growable_array.h" | 12 #include "vm/growable_array.h" |
| 13 #include "vm/locations.h" | 13 #include "vm/locations.h" |
| 14 #include "vm/object.h" | 14 #include "vm/object.h" |
| 15 #include "vm/thread.h" |
| 15 | 16 |
| 16 namespace dart { | 17 namespace dart { |
| 17 | 18 |
| 18 class Location; | 19 class Location; |
| 19 class Value; | 20 class Value; |
| 20 class MaterializeObjectInstr; | 21 class MaterializeObjectInstr; |
| 21 class StackFrame; | 22 class StackFrame; |
| 22 | 23 |
| 23 // Holds all data relevant for execution of deoptimization instructions. | 24 // Holds all data relevant for execution of deoptimization instructions. |
| 24 class DeoptContext { | 25 class DeoptContext { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 ASSERT(reg < kNumberOfFpuRegisters); | 78 ASSERT(reg < kNumberOfFpuRegisters); |
| 78 const float* address = reinterpret_cast<float*>(&fpu_registers_[reg]); | 79 const float* address = reinterpret_cast<float*>(&fpu_registers_[reg]); |
| 79 return simd128_value_t().readFrom(address); | 80 return simd128_value_t().readFrom(address); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void set_dest_frame(intptr_t* dest_frame) { | 83 void set_dest_frame(intptr_t* dest_frame) { |
| 83 ASSERT(dest_frame != NULL && dest_frame_ == NULL); | 84 ASSERT(dest_frame != NULL && dest_frame_ == NULL); |
| 84 dest_frame_ = dest_frame; | 85 dest_frame_ = dest_frame; |
| 85 } | 86 } |
| 86 | 87 |
| 87 Isolate* isolate() const { return isolate_; } | 88 Zone* zone() const { return thread_->zone(); } |
| 88 | 89 |
| 89 intptr_t source_frame_size() const { return source_frame_size_; } | 90 intptr_t source_frame_size() const { return source_frame_size_; } |
| 90 intptr_t dest_frame_size() const { return dest_frame_size_; } | 91 intptr_t dest_frame_size() const { return dest_frame_size_; } |
| 91 | 92 |
| 92 RawCode* code() const { return code_; } | 93 RawCode* code() const { return code_; } |
| 93 | 94 |
| 94 ICData::DeoptReasonId deopt_reason() const { return deopt_reason_; } | 95 ICData::DeoptReasonId deopt_reason() const { return deopt_reason_; } |
| 95 bool HasDeoptFlag(ICData::DeoptFlags flag) { | 96 bool HasDeoptFlag(ICData::DeoptFlags flag) { |
| 96 return (deopt_flags_ & flag) != 0; | 97 return (deopt_flags_ & flag) != 0; |
| 97 } | 98 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 intptr_t dest_frame_size_; | 190 intptr_t dest_frame_size_; |
| 190 bool source_frame_is_allocated_; | 191 bool source_frame_is_allocated_; |
| 191 intptr_t* source_frame_; | 192 intptr_t* source_frame_; |
| 192 intptr_t source_frame_size_; | 193 intptr_t source_frame_size_; |
| 193 intptr_t* cpu_registers_; | 194 intptr_t* cpu_registers_; |
| 194 fpu_register_t* fpu_registers_; | 195 fpu_register_t* fpu_registers_; |
| 195 intptr_t num_args_; | 196 intptr_t num_args_; |
| 196 ICData::DeoptReasonId deopt_reason_; | 197 ICData::DeoptReasonId deopt_reason_; |
| 197 uint32_t deopt_flags_; | 198 uint32_t deopt_flags_; |
| 198 intptr_t caller_fp_; | 199 intptr_t caller_fp_; |
| 199 Isolate* isolate_; | 200 Thread* thread_; |
| 200 | 201 |
| 201 DeferredSlot* deferred_slots_; | 202 DeferredSlot* deferred_slots_; |
| 202 | 203 |
| 203 intptr_t deferred_objects_count_; | 204 intptr_t deferred_objects_count_; |
| 204 DeferredObject** deferred_objects_; | 205 DeferredObject** deferred_objects_; |
| 205 | 206 |
| 206 DISALLOW_COPY_AND_ASSIGN(DeoptContext); | 207 DISALLOW_COPY_AND_ASSIGN(DeoptContext); |
| 207 }; | 208 }; |
| 208 | 209 |
| 209 | 210 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 240 }; | 241 }; |
| 241 | 242 |
| 242 static DeoptInstr* Create(intptr_t kind_as_int, intptr_t source_index); | 243 static DeoptInstr* Create(intptr_t kind_as_int, intptr_t source_index); |
| 243 | 244 |
| 244 DeoptInstr() {} | 245 DeoptInstr() {} |
| 245 virtual ~DeoptInstr() {} | 246 virtual ~DeoptInstr() {} |
| 246 | 247 |
| 247 virtual const char* ToCString() const { | 248 virtual const char* ToCString() const { |
| 248 const char* args = ArgumentsToCString(); | 249 const char* args = ArgumentsToCString(); |
| 249 if (args != NULL) { | 250 if (args != NULL) { |
| 250 return Isolate::Current()->current_zone()->PrintToString( | 251 return Thread::Current()->zone()->PrintToString( |
| 251 "%s(%s)", KindToCString(kind()), args); | 252 "%s(%s)", KindToCString(kind()), args); |
| 252 } else { | 253 } else { |
| 253 return KindToCString(kind()); | 254 return KindToCString(kind()); |
| 254 } | 255 } |
| 255 } | 256 } |
| 256 | 257 |
| 257 virtual void Execute(DeoptContext* deopt_context, intptr_t* dest_addr) = 0; | 258 virtual void Execute(DeoptContext* deopt_context, intptr_t* dest_addr) = 0; |
| 258 | 259 |
| 259 virtual DeoptInstr::Kind kind() const = 0; | 260 virtual DeoptInstr::Kind kind() const = 0; |
| 260 | 261 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 context->source_frame_size() - raw_index() - 1)); | 356 context->source_frame_size() - raw_index() - 1)); |
| 356 } | 357 } |
| 357 } | 358 } |
| 358 | 359 |
| 359 intptr_t source_index() const { return source_index_; } | 360 intptr_t source_index() const { return source_index_; } |
| 360 | 361 |
| 361 const char* ToCString() const { | 362 const char* ToCString() const { |
| 362 if (is_register()) { | 363 if (is_register()) { |
| 363 return Name(reg()); | 364 return Name(reg()); |
| 364 } else { | 365 } else { |
| 365 return Isolate::Current()->current_zone()->PrintToString( | 366 return Thread::Current()->zone()->PrintToString( |
| 366 "s%" Pd "", raw_index()); | 367 "s%" Pd "", raw_index()); |
| 367 } | 368 } |
| 368 } | 369 } |
| 369 | 370 |
| 370 private: | 371 private: |
| 371 class KindField : public BitField<intptr_t, 0, 1> { }; | 372 class KindField : public BitField<intptr_t, 0, 1> { }; |
| 372 class RawIndexField : public BitField<intptr_t, 1, kBitsPerWord - 1> { }; | 373 class RawIndexField : public BitField<intptr_t, 1, kBitsPerWord - 1> { }; |
| 373 | 374 |
| 374 bool is_register() const { | 375 bool is_register() const { |
| 375 return KindField::decode(source_index_) == kRegister; | 376 return KindField::decode(source_index_) == kRegister; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 394 typedef RegisterSource<FpuRegister> FpuRegisterSource; | 395 typedef RegisterSource<FpuRegister> FpuRegisterSource; |
| 395 | 396 |
| 396 | 397 |
| 397 // Builds a deoptimization info table, one DeoptInfo at a time. Call AddXXX | 398 // Builds a deoptimization info table, one DeoptInfo at a time. Call AddXXX |
| 398 // methods in the order of their target, starting wih deoptimized code | 399 // methods in the order of their target, starting wih deoptimized code |
| 399 // continuation pc and ending with the first argument of the deoptimized | 400 // continuation pc and ending with the first argument of the deoptimized |
| 400 // code. Call CreateDeoptInfo to write the accumulated instructions into | 401 // code. Call CreateDeoptInfo to write the accumulated instructions into |
| 401 // the heap and reset the builder's internal state for the next DeoptInfo. | 402 // the heap and reset the builder's internal state for the next DeoptInfo. |
| 402 class DeoptInfoBuilder : public ValueObject { | 403 class DeoptInfoBuilder : public ValueObject { |
| 403 public: | 404 public: |
| 404 DeoptInfoBuilder(Isolate* isolate, const intptr_t num_args); | 405 DeoptInfoBuilder(Zone* zone, const intptr_t num_args); |
| 405 | 406 |
| 406 // 'object_table' holds all objects referred to by DeoptInstr in | 407 // 'object_table' holds all objects referred to by DeoptInstr in |
| 407 // all DeoptInfo instances for a single Code object. | 408 // all DeoptInfo instances for a single Code object. |
| 408 const GrowableObjectArray& object_table() { return object_table_; } | 409 const GrowableObjectArray& object_table() { return object_table_; } |
| 409 | 410 |
| 410 // Return address before instruction. | 411 // Return address before instruction. |
| 411 void AddReturnAddress(const Code& code, | 412 void AddReturnAddress(const Code& code, |
| 412 intptr_t deopt_id, | 413 intptr_t deopt_id, |
| 413 intptr_t dest_index); | 414 intptr_t dest_index); |
| 414 | 415 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 intptr_t FindOrAddObjectInTable(const Object& obj) const; | 456 intptr_t FindOrAddObjectInTable(const Object& obj) const; |
| 456 intptr_t FindMaterialization(MaterializeObjectInstr* mat) const; | 457 intptr_t FindMaterialization(MaterializeObjectInstr* mat) const; |
| 457 intptr_t CalculateStackIndex(const Location& source_loc) const; | 458 intptr_t CalculateStackIndex(const Location& source_loc) const; |
| 458 | 459 |
| 459 intptr_t FrameSize() const { | 460 intptr_t FrameSize() const { |
| 460 return instructions_.length() - frame_start_; | 461 return instructions_.length() - frame_start_; |
| 461 } | 462 } |
| 462 | 463 |
| 463 void AddConstant(const Object& obj, intptr_t dest_index); | 464 void AddConstant(const Object& obj, intptr_t dest_index); |
| 464 | 465 |
| 465 Isolate* isolate() const { return isolate_; } | 466 Zone* zone() const { return zone_; } |
| 466 | 467 |
| 467 Isolate* isolate_; | 468 Zone* zone_; |
| 468 | 469 |
| 469 GrowableArray<DeoptInstr*> instructions_; | 470 GrowableArray<DeoptInstr*> instructions_; |
| 470 const GrowableObjectArray& object_table_; | 471 const GrowableObjectArray& object_table_; |
| 471 const intptr_t num_args_; | 472 const intptr_t num_args_; |
| 472 | 473 |
| 473 // Used to compress entries by sharing suffixes. | 474 // Used to compress entries by sharing suffixes. |
| 474 TrieNode* trie_root_; | 475 TrieNode* trie_root_; |
| 475 intptr_t current_info_number_; | 476 intptr_t current_info_number_; |
| 476 | 477 |
| 477 intptr_t frame_start_; | 478 intptr_t frame_start_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 class ReasonField : public BitField<ICData::DeoptReasonId, 0, 8> { }; | 518 class ReasonField : public BitField<ICData::DeoptReasonId, 0, 8> { }; |
| 518 class FlagsField : public BitField<uint32_t, 8, 8> { }; | 519 class FlagsField : public BitField<uint32_t, 8, 8> { }; |
| 519 | 520 |
| 520 private: | 521 private: |
| 521 static const intptr_t kEntrySize = 3; | 522 static const intptr_t kEntrySize = 3; |
| 522 }; | 523 }; |
| 523 | 524 |
| 524 } // namespace dart | 525 } // namespace dart |
| 525 | 526 |
| 526 #endif // VM_DEOPT_INSTRUCTIONS_H_ | 527 #endif // VM_DEOPT_INSTRUCTIONS_H_ |
| OLD | NEW |