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

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

Issue 1634863002: Introduce CodeSourceMap object to hold pc -> token position mappings (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/code_descriptors_test.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 "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 static RawClass* field_class() { return field_class_; } 500 static RawClass* field_class() { return field_class_; }
501 static RawClass* literal_token_class() { return literal_token_class_; } 501 static RawClass* literal_token_class() { return literal_token_class_; }
502 static RawClass* token_stream_class() { return token_stream_class_; } 502 static RawClass* token_stream_class() { return token_stream_class_; }
503 static RawClass* script_class() { return script_class_; } 503 static RawClass* script_class() { return script_class_; }
504 static RawClass* library_class() { return library_class_; } 504 static RawClass* library_class() { return library_class_; }
505 static RawClass* namespace_class() { return namespace_class_; } 505 static RawClass* namespace_class() { return namespace_class_; }
506 static RawClass* code_class() { return code_class_; } 506 static RawClass* code_class() { return code_class_; }
507 static RawClass* instructions_class() { return instructions_class_; } 507 static RawClass* instructions_class() { return instructions_class_; }
508 static RawClass* object_pool_class() { return object_pool_class_; } 508 static RawClass* object_pool_class() { return object_pool_class_; }
509 static RawClass* pc_descriptors_class() { return pc_descriptors_class_; } 509 static RawClass* pc_descriptors_class() { return pc_descriptors_class_; }
510 static RawClass* code_source_map_class() { return code_source_map_class_; }
510 static RawClass* stackmap_class() { return stackmap_class_; } 511 static RawClass* stackmap_class() { return stackmap_class_; }
511 static RawClass* var_descriptors_class() { return var_descriptors_class_; } 512 static RawClass* var_descriptors_class() { return var_descriptors_class_; }
512 static RawClass* exception_handlers_class() { 513 static RawClass* exception_handlers_class() {
513 return exception_handlers_class_; 514 return exception_handlers_class_;
514 } 515 }
515 static RawClass* deopt_info_class() { return deopt_info_class_; } 516 static RawClass* deopt_info_class() { return deopt_info_class_; }
516 static RawClass* context_class() { return context_class_; } 517 static RawClass* context_class() { return context_class_; }
517 static RawClass* context_scope_class() { return context_scope_class_; } 518 static RawClass* context_scope_class() { return context_scope_class_; }
518 static RawClass* api_error_class() { return api_error_class_; } 519 static RawClass* api_error_class() { return api_error_class_; }
519 static RawClass* language_error_class() { return language_error_class_; } 520 static RawClass* language_error_class() { return language_error_class_; }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 static RawClass* field_class_; // Class of the Field vm object. 762 static RawClass* field_class_; // Class of the Field vm object.
762 static RawClass* literal_token_class_; // Class of LiteralToken vm object. 763 static RawClass* literal_token_class_; // Class of LiteralToken vm object.
763 static RawClass* token_stream_class_; // Class of the TokenStream vm object. 764 static RawClass* token_stream_class_; // Class of the TokenStream vm object.
764 static RawClass* script_class_; // Class of the Script vm object. 765 static RawClass* script_class_; // Class of the Script vm object.
765 static RawClass* library_class_; // Class of the Library vm object. 766 static RawClass* library_class_; // Class of the Library vm object.
766 static RawClass* namespace_class_; // Class of Namespace vm object. 767 static RawClass* namespace_class_; // Class of Namespace vm object.
767 static RawClass* code_class_; // Class of the Code vm object. 768 static RawClass* code_class_; // Class of the Code vm object.
768 static RawClass* instructions_class_; // Class of the Instructions vm object. 769 static RawClass* instructions_class_; // Class of the Instructions vm object.
769 static RawClass* object_pool_class_; // Class of the ObjectPool vm object. 770 static RawClass* object_pool_class_; // Class of the ObjectPool vm object.
770 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. 771 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object.
772 static RawClass* code_source_map_class_; // Class of CodeSourceMap vm object.
771 static RawClass* stackmap_class_; // Class of Stackmap vm object. 773 static RawClass* stackmap_class_; // Class of Stackmap vm object.
772 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors. 774 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors.
773 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. 775 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers.
774 static RawClass* deopt_info_class_; // Class of DeoptInfo. 776 static RawClass* deopt_info_class_; // Class of DeoptInfo.
775 static RawClass* context_class_; // Class of the Context vm object. 777 static RawClass* context_class_; // Class of the Context vm object.
776 static RawClass* context_scope_class_; // Class of ContextScope vm object. 778 static RawClass* context_scope_class_; // Class of ContextScope vm object.
777 static RawClass* icdata_class_; // Class of ICData. 779 static RawClass* icdata_class_; // Class of ICData.
778 static RawClass* megamorphic_cache_class_; // Class of MegamorphiCache. 780 static RawClass* megamorphic_cache_class_; // Class of MegamorphiCache.
779 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache. 781 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache.
780 static RawClass* api_error_class_; // Class of ApiError. 782 static RawClass* api_error_class_; // Class of ApiError.
(...skipping 3185 matching lines...) Expand 10 before | Expand all | Expand 10 after
3966 intptr_t Length() const; 3968 intptr_t Length() const;
3967 void SetLength(intptr_t value) const; 3969 void SetLength(intptr_t value) const;
3968 void CopyData(GrowableArray<uint8_t>* data); 3970 void CopyData(GrowableArray<uint8_t>* data);
3969 3971
3970 FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object); 3972 FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object);
3971 friend class Class; 3973 friend class Class;
3972 friend class Object; 3974 friend class Object;
3973 }; 3975 };
3974 3976
3975 3977
3978 class CodeSourceMap : public Object {
3979 public:
3980 static const intptr_t kBytesPerElement = 1;
3981 static const intptr_t kMaxElements = kMaxInt32 / kBytesPerElement;
3982
3983 static intptr_t InstanceSize() {
3984 ASSERT(sizeof(RawCodeSourceMap) ==
3985 OFFSET_OF_RETURNED_VALUE(RawCodeSourceMap, data));
3986 return 0;
3987 }
3988 static intptr_t InstanceSize(intptr_t len) {
3989 ASSERT(0 <= len && len <= kMaxElements);
3990 return RoundedAllocationSize(sizeof(RawCodeSourceMap) + len);
3991 }
3992
3993 static RawCodeSourceMap* New(GrowableArray<uint8_t>* delta_encoded_data);
3994
3995 void PrintToJSONObject(JSONObject* jsobj, bool ref) const;
3996
3997 // Encode integer in SLEB128 format.
3998 static void EncodeInteger(GrowableArray<uint8_t>* data, intptr_t value);
3999
4000 // Decode SLEB128 encoded integer. Update byte_index to the next integer.
4001 intptr_t DecodeInteger(intptr_t* byte_index) const;
4002
4003 class Iterator : ValueObject {
4004 public:
4005 explicit Iterator(const CodeSourceMap& code_source_map)
4006 : code_source_map_(code_source_map),
4007 cur_pc_offset_(0),
4008 cur_token_pos_(0) {
4009 }
4010
4011 bool MoveNext() {
4012 // Moves to the next record.
4013 while (byte_index_ < code_source_map_.Length()) {
4014 cur_pc_offset_ += code_source_map_.DecodeInteger(&byte_index_);
4015 cur_token_pos_ += code_source_map_.DecodeInteger(&byte_index_);
4016
4017 return true;
4018 }
4019 return false;
4020 }
4021
4022 uword PcOffset() const { return cur_pc_offset_; }
4023 intptr_t TokenPos() const { return cur_token_pos_; }
4024
4025 private:
4026 friend class CodeSourceMap;
4027
4028 const CodeSourceMap& code_source_map_;
4029 intptr_t byte_index_;
4030
4031 intptr_t cur_pc_offset_;
4032 intptr_t cur_token_pos_;
4033 };
4034
4035 private:
4036 static RawCodeSourceMap* New(intptr_t length);
4037
4038 intptr_t Length() const;
4039 void SetLength(intptr_t value) const;
4040 void CopyData(GrowableArray<uint8_t>* data);
4041
4042 FINAL_HEAP_OBJECT_IMPLEMENTATION(CodeSourceMap, Object);
4043 friend class Class;
4044 friend class Object;
4045 };
4046
4047
3976 class Stackmap : public Object { 4048 class Stackmap : public Object {
3977 public: 4049 public:
3978 static const intptr_t kNoMaximum = -1; 4050 static const intptr_t kNoMaximum = -1;
3979 static const intptr_t kNoMinimum = -1; 4051 static const intptr_t kNoMinimum = -1;
3980 4052
3981 bool IsObject(intptr_t index) const { 4053 bool IsObject(intptr_t index) const {
3982 ASSERT(InRange(index)); 4054 ASSERT(InRange(index));
3983 return GetBit(index); 4055 return GetBit(index);
3984 } 4056 }
3985 4057
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
4196 bool HasBreakpoint() const; 4268 bool HasBreakpoint() const;
4197 4269
4198 RawPcDescriptors* pc_descriptors() const { 4270 RawPcDescriptors* pc_descriptors() const {
4199 return raw_ptr()->pc_descriptors_; 4271 return raw_ptr()->pc_descriptors_;
4200 } 4272 }
4201 void set_pc_descriptors(const PcDescriptors& descriptors) const { 4273 void set_pc_descriptors(const PcDescriptors& descriptors) const {
4202 ASSERT(descriptors.IsOld()); 4274 ASSERT(descriptors.IsOld());
4203 StorePointer(&raw_ptr()->pc_descriptors_, descriptors.raw()); 4275 StorePointer(&raw_ptr()->pc_descriptors_, descriptors.raw());
4204 } 4276 }
4205 4277
4278 RawCodeSourceMap* code_source_map() const {
4279 return raw_ptr()->code_source_map_;
4280 }
4281
4282 void set_code_source_map(const CodeSourceMap& code_source_map) const {
4283 ASSERT(code_source_map.IsOld());
4284 StorePointer(&raw_ptr()->code_source_map_, code_source_map.raw());
4285 }
4286
4206 // Array of DeoptInfo objects. 4287 // Array of DeoptInfo objects.
4207 RawArray* deopt_info_array() const { 4288 RawArray* deopt_info_array() const {
4208 return raw_ptr()->deopt_info_array_; 4289 return raw_ptr()->deopt_info_array_;
4209 } 4290 }
4210 void set_deopt_info_array(const Array& array) const; 4291 void set_deopt_info_array(const Array& array) const;
4211 4292
4212 RawArray* stackmaps() const { 4293 RawArray* stackmaps() const {
4213 return raw_ptr()->stackmaps_; 4294 return raw_ptr()->stackmaps_;
4214 } 4295 }
4215 void set_stackmaps(const Array& maps) const; 4296 void set_stackmaps(const Array& maps) const;
(...skipping 4079 matching lines...) Expand 10 before | Expand all | Expand 10 after
8295 8376
8296 8377
8297 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 8378 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
8298 intptr_t index) { 8379 intptr_t index) {
8299 return array.At((index * kEntryLength) + kTargetFunctionIndex); 8380 return array.At((index * kEntryLength) + kTargetFunctionIndex);
8300 } 8381 }
8301 8382
8302 } // namespace dart 8383 } // namespace dart
8303 8384
8304 #endif // VM_OBJECT_H_ 8385 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/code_descriptors_test.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698