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

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

Issue 382993003: More PcDescriptor cleanups. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/object.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include <limits> 8 #include <limits>
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 2981 matching lines...) Expand 10 before | Expand all | Expand 10 after
2992 2992
2993 class PcDescriptors : public Object { 2993 class PcDescriptors : public Object {
2994 public: 2994 public:
2995 void AddDescriptor(intptr_t index, 2995 void AddDescriptor(intptr_t index,
2996 uword pc, 2996 uword pc,
2997 RawPcDescriptors::Kind kind, 2997 RawPcDescriptors::Kind kind,
2998 int64_t deopt_id, 2998 int64_t deopt_id,
2999 int64_t token_pos, // Or deopt reason. 2999 int64_t token_pos, // Or deopt reason.
3000 intptr_t try_index) const { // Or deopt index. 3000 intptr_t try_index) const { // Or deopt index.
3001 RawPcDescriptors::PcDescriptorRec* rec = recAt(index); 3001 RawPcDescriptors::PcDescriptorRec* rec = recAt(index);
3002 rec->pc = pc; 3002 rec->set_pc(pc);
3003 rec->kind_ = kind; 3003 rec->set_kind(kind);
3004 ASSERT(Utils::IsInt(32, deopt_id)); 3004 ASSERT(Utils::IsInt(32, deopt_id));
3005 rec->deopt_id = deopt_id; 3005 rec->set_deopt_id(deopt_id);
3006 ASSERT(Utils::IsInt(32, token_pos)); 3006 ASSERT(Utils::IsInt(32, token_pos));
3007 rec->token_pos = token_pos; 3007 rec->set_token_pos(token_pos,
3008 RecordSizeInBytes() == RawPcDescriptors::kCompressedRecSize);
3008 ASSERT(Utils::IsInt(16, try_index)); 3009 ASSERT(Utils::IsInt(16, try_index));
3009 rec->try_index = try_index; 3010 rec->set_try_index(try_index);
3011 ASSERT(rec->try_index() == try_index);
3012 ASSERT(rec->token_pos() == token_pos);
3010 } 3013 }
3011 3014
3012 static const intptr_t kBytesPerElement = 3015 static const intptr_t kMaxBytesPerElement =
3013 sizeof(RawPcDescriptors::PcDescriptorRec); 3016 RawPcDescriptors::kFullRecSize;
3014 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; 3017 static const intptr_t kMaxElements = kSmiMax / kMaxBytesPerElement;
3015 3018
3016 static intptr_t InstanceSize() { 3019 static intptr_t InstanceSize() {
3017 ASSERT(sizeof(RawPcDescriptors) == 3020 ASSERT(sizeof(RawPcDescriptors) ==
3018 OFFSET_OF_RETURNED_VALUE(RawPcDescriptors, data)); 3021 OFFSET_OF_RETURNED_VALUE(RawPcDescriptors, data));
3019 return 0; 3022 return 0;
3020 } 3023 }
3021 static intptr_t InstanceSize(intptr_t len) { 3024 static intptr_t InstanceSize(intptr_t len, intptr_t record_size_in_bytes) {
3022 ASSERT(0 <= len && len <= kMaxElements); 3025 ASSERT(0 <= len && len <= kMaxElements);
3023 return RoundedAllocationSize( 3026 return RoundedAllocationSize(
3024 sizeof(RawPcDescriptors) + (len * kBytesPerElement)); 3027 sizeof(RawPcDescriptors) + (len * record_size_in_bytes));
3025 } 3028 }
3026 3029
3027 static RawPcDescriptors* New(intptr_t num_descriptors); 3030 static RawPcDescriptors* New(intptr_t num_descriptors, bool has_try_index);
3028 3031
3029 // Returns 0 if not found. 3032 // Returns 0 if not found.
3030 uword GetPcForKind(RawPcDescriptors::Kind kind) const; 3033 uword GetPcForKind(RawPcDescriptors::Kind kind) const;
3031 3034
3032 // Verify (assert) assumptions about pc descriptors in debug mode. 3035 // Verify (assert) assumptions about pc descriptors in debug mode.
3033 void Verify(const Function& function) const; 3036 void Verify(const Function& function) const;
3034 3037
3035 static void PrintHeaderString(); 3038 static void PrintHeaderString();
3036 3039
3037 void PrintToJSONObject(JSONObject* jsobj) const; 3040 void PrintToJSONObject(JSONObject* jsobj) const;
(...skipping 26 matching lines...) Expand all
3064 : ValueObject(), 3067 : ValueObject(),
3065 descriptors_(iter.descriptors_), 3068 descriptors_(iter.descriptors_),
3066 kind_mask_(iter.kind_mask_), 3069 kind_mask_(iter.kind_mask_),
3067 current_ix_(iter.current_ix_) {} 3070 current_ix_(iter.current_ix_) {}
3068 3071
3069 // Moves to record that matches kind_mask_. 3072 // Moves to record that matches kind_mask_.
3070 void MoveToMatching() { 3073 void MoveToMatching() {
3071 while (current_ix_ < descriptors_.Length()) { 3074 while (current_ix_ < descriptors_.Length()) {
3072 const RawPcDescriptors::PcDescriptorRec& rec = 3075 const RawPcDescriptors::PcDescriptorRec& rec =
3073 *descriptors_.recAt(current_ix_); 3076 *descriptors_.recAt(current_ix_);
3074 if ((rec.kind_ & kind_mask_) != 0) { 3077 if ((rec.kind() & kind_mask_) != 0) {
3075 return; // Current is valid. 3078 return; // Current is valid.
3076 } else { 3079 } else {
3077 ++current_ix_; 3080 ++current_ix_;
3078 } 3081 }
3079 } 3082 }
3080 } 3083 }
3081 3084
3082 const PcDescriptors& descriptors_; 3085 const PcDescriptors& descriptors_;
3083 const intptr_t kind_mask_; 3086 const intptr_t kind_mask_;
3084 intptr_t current_ix_; 3087 intptr_t current_ix_;
3085 }; 3088 };
3086 3089
3087 private: 3090 private:
3088 static const char* KindAsStr(RawPcDescriptors::Kind kind); 3091 static const char* KindAsStr(RawPcDescriptors::Kind kind);
3089 3092
3090 intptr_t Length() const; 3093 intptr_t Length() const;
3094 void SetLength(intptr_t value) const;
3095
3096 void SetRecordSizeInBytes(intptr_t value) const;
3097 intptr_t RecordSizeInBytes() const;
3091 3098
3092 RawPcDescriptors::PcDescriptorRec* recAt(intptr_t ix) const { 3099 RawPcDescriptors::PcDescriptorRec* recAt(intptr_t ix) const {
3093 ASSERT(ix < Length()); 3100 ASSERT(ix < Length());
3094 return &raw_ptr()->data()[ix]; 3101 uint8_t* d = raw_ptr()->data() + (ix * RecordSizeInBytes());
3102 return reinterpret_cast<RawPcDescriptors::PcDescriptorRec*>(d);
3095 } 3103 }
3096 void SetLength(intptr_t value) const;
3097 3104
3098 FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object); 3105 FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object);
3099 friend class Class; 3106 friend class Class;
3100 friend class Object; 3107 friend class Object;
3101 }; 3108 };
3102 3109
3103 3110
3104 class Stackmap : public Object { 3111 class Stackmap : public Object {
3105 public: 3112 public:
3106 static const intptr_t kNoMaximum = -1; 3113 static const intptr_t kNoMaximum = -1;
(...skipping 4070 matching lines...) Expand 10 before | Expand all | Expand 10 after
7177 7184
7178 7185
7179 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7186 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7180 intptr_t index) { 7187 intptr_t index) {
7181 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7188 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7182 } 7189 }
7183 7190
7184 } // namespace dart 7191 } // namespace dart
7185 7192
7186 #endif // VM_OBJECT_H_ 7193 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698