Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: runtime/vm/deopt_instructions.h

Issue 2734323003: Re-landing of "replace TrySync with Metadata". (Closed)
Patch Set: Address review comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/deopt_instructions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 RUNTIME_VM_DEOPT_INSTRUCTIONS_H_ 5 #ifndef RUNTIME_VM_DEOPT_INSTRUCTIONS_H_
6 #define RUNTIME_VM_DEOPT_INSTRUCTIONS_H_ 6 #define RUNTIME_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_descriptors.h"
10 #include "vm/code_generator.h" 11 #include "vm/code_generator.h"
11 #include "vm/deferred_objects.h" 12 #include "vm/deferred_objects.h"
12 #include "vm/flow_graph_compiler.h" 13 #include "vm/flow_graph_compiler.h"
13 #include "vm/growable_array.h" 14 #include "vm/growable_array.h"
14 #include "vm/locations.h" 15 #include "vm/locations.h"
15 #include "vm/object.h" 16 #include "vm/object.h"
16 #include "vm/stack_frame.h" 17 #include "vm/stack_frame.h"
17 #include "vm/thread.h" 18 #include "vm/thread.h"
18 19
19 namespace dart { 20 namespace dart {
(...skipping 30 matching lines...) Expand all
50 intptr_t* GetSourceFrameAddressAt(intptr_t index) const { 51 intptr_t* GetSourceFrameAddressAt(intptr_t index) const {
51 ASSERT(source_frame_ != NULL); 52 ASSERT(source_frame_ != NULL);
52 ASSERT((0 <= index) && (index < source_frame_size_)); 53 ASSERT((0 <= index) && (index < source_frame_size_));
53 #if !defined(TARGET_ARCH_DBC) 54 #if !defined(TARGET_ARCH_DBC)
54 // Convert FP relative index to SP relative one. 55 // Convert FP relative index to SP relative one.
55 index = source_frame_size_ - 1 - index; 56 index = source_frame_size_ - 1 - index;
56 #endif // !defined(TARGET_ARCH_DBC) 57 #endif // !defined(TARGET_ARCH_DBC)
57 return &source_frame_[index]; 58 return &source_frame_[index];
58 } 59 }
59 60
61 // Returns index in stack slot notation where -1 is the first argument
62 // For DBC returns index directly relative to FP.
63 intptr_t GetStackSlot(intptr_t index) const {
64 ASSERT((0 <= index) && (index < source_frame_size_));
65 index -= num_args_;
66 #if defined(TARGET_ARCH_DBC)
67 return index < 0 ? index - kDartFrameFixedSize : index;
68 #else
69 return index < 0 ? index : index - kDartFrameFixedSize;
70 #endif // defined(TARGET_ARCH_DBC)
71 }
72
60 intptr_t GetSourceFp() const; 73 intptr_t GetSourceFp() const;
61 intptr_t GetSourcePp() const; 74 intptr_t GetSourcePp() const;
62 intptr_t GetSourcePc() const; 75 intptr_t GetSourcePc() const;
63 76
64 intptr_t GetCallerFp() const; 77 intptr_t GetCallerFp() const;
65 void SetCallerFp(intptr_t callers_fp); 78 void SetCallerFp(intptr_t callers_fp);
66 79
67 RawObject* ObjectAt(intptr_t index) const { 80 RawObject* ObjectAt(intptr_t index) const {
68 const ObjectPool& object_pool = ObjectPool::Handle(object_pool_); 81 const ObjectPool& object_pool = ObjectPool::Handle(object_pool_);
69 return object_pool.ObjectAt(index); 82 return object_pool.ObjectAt(index);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 bool HasDeoptFlag(ICData::DeoptFlags flag) { 159 bool HasDeoptFlag(ICData::DeoptFlags flag) {
147 return (deopt_flags_ & flag) != 0; 160 return (deopt_flags_ & flag) != 0;
148 } 161 }
149 162
150 RawTypedData* deopt_info() const { return deopt_info_; } 163 RawTypedData* deopt_info() const { return deopt_info_; }
151 164
152 // Fills the destination frame but defers materialization of 165 // Fills the destination frame but defers materialization of
153 // objects. 166 // objects.
154 void FillDestFrame(); 167 void FillDestFrame();
155 168
169 // Allocate and prepare exceptions metadata for TrySync
170 intptr_t* CatchEntryState(intptr_t num_vars);
171
156 // Materializes all deferred objects. Returns the total number of 172 // Materializes all deferred objects. Returns the total number of
157 // artificial arguments used during deoptimization. 173 // artificial arguments used during deoptimization.
158 intptr_t MaterializeDeferredObjects(); 174 intptr_t MaterializeDeferredObjects();
159 175
160 RawArray* DestFrameAsArray(); 176 RawArray* DestFrameAsArray();
161 177
162 void VisitObjectPointers(ObjectPointerVisitor* visitor); 178 void VisitObjectPointers(ObjectPointerVisitor* visitor);
163 179
164 void DeferMaterializedObjectRef(intptr_t idx, intptr_t* slot) { 180 void DeferMaterializedObjectRef(intptr_t idx, intptr_t* slot) {
165 deferred_slots_ = new DeferredObjectRef( 181 deferred_slots_ = new DeferredObjectRef(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 280
265 intptr_t deferred_objects_count_; 281 intptr_t deferred_objects_count_;
266 DeferredObject** deferred_objects_; 282 DeferredObject** deferred_objects_;
267 283
268 const bool is_lazy_deopt_; 284 const bool is_lazy_deopt_;
269 const bool deoptimizing_code_; 285 const bool deoptimizing_code_;
270 286
271 DISALLOW_COPY_AND_ASSIGN(DeoptContext); 287 DISALLOW_COPY_AND_ASSIGN(DeoptContext);
272 }; 288 };
273 289
274
275 // Represents one deopt instruction, e.g, setup return address, store object, 290 // Represents one deopt instruction, e.g, setup return address, store object,
276 // store register, etc. The target is defined by instruction's position in 291 // store register, etc. The target is defined by instruction's position in
277 // the deopt-info array. 292 // the deopt-info array.
278 class DeoptInstr : public ZoneAllocated { 293 class DeoptInstr : public ZoneAllocated {
279 public: 294 public:
280 enum Kind { 295 enum Kind {
281 kRetAddress, 296 kRetAddress,
282 kConstant, 297 kConstant,
283 kWord, 298 kWord,
284 kDouble, 299 kDouble,
(...skipping 27 matching lines...) Expand all
312 if (args != NULL) { 327 if (args != NULL) {
313 return Thread::Current()->zone()->PrintToString( 328 return Thread::Current()->zone()->PrintToString(
314 "%s(%s)", KindToCString(kind()), args); 329 "%s(%s)", KindToCString(kind()), args);
315 } else { 330 } else {
316 return KindToCString(kind()); 331 return KindToCString(kind());
317 } 332 }
318 } 333 }
319 334
320 virtual void Execute(DeoptContext* deopt_context, intptr_t* dest_addr) = 0; 335 virtual void Execute(DeoptContext* deopt_context, intptr_t* dest_addr) = 0;
321 336
337 // Convert DeoptInstr to TrySync metadata entry.
338 virtual CatchEntryStatePair ToCatchEntryStatePair(DeoptContext* deopt_context,
339 intptr_t dest_slot) {
340 UNREACHABLE();
341 return CatchEntryStatePair();
342 }
343
322 virtual DeoptInstr::Kind kind() const = 0; 344 virtual DeoptInstr::Kind kind() const = 0;
323 345
324 bool Equals(const DeoptInstr& other) const { 346 bool Equals(const DeoptInstr& other) const {
325 return (kind() == other.kind()) && (source_index() == other.source_index()); 347 return (kind() == other.kind()) && (source_index() == other.source_index());
326 } 348 }
327 349
328 // Get the code and return address which is encoded in this 350 // Get the code and return address which is encoded in this
329 // kRetAfterAddress deopt instruction. 351 // kRetAfterAddress deopt instruction.
330 static uword GetRetAddress(DeoptInstr* instr, 352 static uword GetRetAddress(DeoptInstr* instr,
331 const ObjectPool& object_pool, 353 const ObjectPool& object_pool,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 T Value(DeoptContext* context) const { 427 T Value(DeoptContext* context) const {
406 if (is_register()) { 428 if (is_register()) {
407 return static_cast<T>( 429 return static_cast<T>(
408 RegisterReader<RegisterType, T>::Read(context, reg())); 430 RegisterReader<RegisterType, T>::Read(context, reg()));
409 } else { 431 } else {
410 return *reinterpret_cast<T*>( 432 return *reinterpret_cast<T*>(
411 context->GetSourceFrameAddressAt(raw_index())); 433 context->GetSourceFrameAddressAt(raw_index()));
412 } 434 }
413 } 435 }
414 436
437 intptr_t StackSlot(DeoptContext* context) const {
438 if (is_register()) {
439 return raw_index(); // in DBC stack slots are registers.
440 } else {
441 return context->GetStackSlot(raw_index());
442 }
443 }
444
415 intptr_t source_index() const { return source_index_; } 445 intptr_t source_index() const { return source_index_; }
416 446
417 const char* ToCString() const { 447 const char* ToCString() const {
418 if (is_register()) { 448 if (is_register()) {
419 return Name(reg()); 449 return Name(reg());
420 } else { 450 } else {
421 return Thread::Current()->zone()->PrintToString("s%" Pd "", raw_index()); 451 return Thread::Current()->zone()->PrintToString("s%" Pd "", raw_index());
422 } 452 }
423 } 453 }
424 454
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 class ReasonField : public BitField<intptr_t, ICData::DeoptReasonId, 0, 8> {}; 602 class ReasonField : public BitField<intptr_t, ICData::DeoptReasonId, 0, 8> {};
573 class FlagsField : public BitField<intptr_t, uint32_t, 8, 8> {}; 603 class FlagsField : public BitField<intptr_t, uint32_t, 8, 8> {};
574 604
575 private: 605 private:
576 static const intptr_t kEntrySize = 3; 606 static const intptr_t kEntrySize = 3;
577 }; 607 };
578 608
579 } // namespace dart 609 } // namespace dart
580 610
581 #endif // RUNTIME_VM_DEOPT_INSTRUCTIONS_H_ 611 #endif // RUNTIME_VM_DEOPT_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/deopt_instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698