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

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

Issue 356623002: Reduce size of PCDescriptors. Order struct fields so that they do not get padded unnecessarily. (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 | « no previous file | 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 2956 matching lines...) Expand 10 before | Expand all | Expand 10 after
2967 2967
2968 static RawLocalVarDescriptors* New(intptr_t num_variables); 2968 static RawLocalVarDescriptors* New(intptr_t num_variables);
2969 2969
2970 private: 2970 private:
2971 FINAL_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors, Object); 2971 FINAL_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors, Object);
2972 friend class Class; 2972 friend class Class;
2973 }; 2973 };
2974 2974
2975 2975
2976 class PcDescriptors : public Object { 2976 class PcDescriptors : public Object {
2977 private:
2978 // Describes the layout of PC descriptor data.
2979 enum {
2980 kPcEntry = 0, // PC value of the descriptor, unique.
2981 kKindEntry = 1,
2982 kDeoptIdEntry = 2, // Deopt id.
2983 kTokenPosEntry = 3, // Token position in source.
2984 kTryIndexEntry = 4, // Try block index.
2985 // We would potentially be adding other objects here like
2986 // pointer maps for optimized functions, local variables information etc.
2987 kNumberOfEntries = 5,
2988 };
2989
2990 public: 2977 public:
2991 enum Kind { 2978 enum Kind {
2992 kDeopt, // Deoptimization continuation point. 2979 kDeopt, // Deoptimization continuation point.
2993 kIcCall, // IC call. 2980 kIcCall, // IC call.
2994 kOptStaticCall, // Call directly to known target, e.g. static call. 2981 kOptStaticCall, // Call directly to known target, e.g. static call.
2995 kUnoptStaticCall, // Call to a known target via a stub. 2982 kUnoptStaticCall, // Call to a known target via a stub.
2996 kClosureCall, // Closure call. 2983 kClosureCall, // Closure call.
2997 kRuntimeCall, // Runtime call. 2984 kRuntimeCall, // Runtime call.
2998 kOsrEntry, // OSR entry point in unoptimized code. 2985 kOsrEntry, // OSR entry point in unoptimized code.
2999 kOther 2986 kOther
3000 }; 2987 };
3001 2988
3002 intptr_t Length() const; 2989 intptr_t Length() const;
3003 2990
3004 uword PC(intptr_t index) const; 2991 uword PC(intptr_t index) const {
3005 PcDescriptors::Kind DescriptorKind(intptr_t index) const; 2992 ASSERT(index < Length());
2993 return raw_ptr()->data()[index].pc;
2994 }
2995 PcDescriptors::Kind DescriptorKind(intptr_t index) const {
2996 ASSERT(index < Length());
2997 return static_cast<PcDescriptors::Kind>(raw_ptr()->data()[index].kind);
2998 }
2999 intptr_t DeoptId(intptr_t index) const {
3000 ASSERT(index < Length());
3001 return raw_ptr()->data()[index].deopt_id;
3002 }
3003 intptr_t TokenPos(intptr_t index) const {
3004 ASSERT(index < Length());
3005 return raw_ptr()->data()[index].token_pos;
3006 }
3007 intptr_t TryIndex(intptr_t index) const {
3008 ASSERT(index < Length());
3009 return raw_ptr()->data()[index].try_index;
3010 }
3006 const char* KindAsStr(intptr_t index) const; 3011 const char* KindAsStr(intptr_t index) const;
3007 intptr_t DeoptId(intptr_t index) const;
3008 intptr_t TokenPos(intptr_t index) const;
3009 intptr_t TryIndex(intptr_t index) const;
3010 3012
3011 void AddDescriptor(intptr_t index, 3013 void AddDescriptor(intptr_t index,
3012 uword pc, 3014 uword pc,
3013 PcDescriptors::Kind kind, 3015 PcDescriptors::Kind kind,
3014 intptr_t deopt_id, 3016 int64_t deopt_id,
3015 intptr_t token_pos, // Or deopt reason. 3017 int64_t token_pos, // Or deopt reason.
siva 2014/06/25 21:44:33 Why is the signature changed to int64_t instead of
3016 intptr_t try_index) const { // Or deopt index. 3018 intptr_t try_index) const { // Or deopt index.
siva 2014/06/25 21:44:33 Why not change this to int16_t
3017 SetPC(index, pc); 3019 RawPcDescriptors::PcDescriptorRec* rec = &raw_ptr()->data()[index];
3018 SetKind(index, kind); 3020 rec->pc = pc;
3019 SetDeoptId(index, deopt_id); 3021 rec->kind = kind;
3020 SetTokenPos(index, token_pos); 3022 ASSERT(Utils::IsInt(32, deopt_id));
3021 SetTryIndex(index, try_index); 3023 rec->deopt_id = deopt_id;
3024 ASSERT(Utils::IsInt(32, token_pos));
3025 rec->token_pos = token_pos;
3026 ASSERT(Utils::IsInt(16, try_index));
3027 rec->try_index = try_index;
3022 } 3028 }
3023 3029
3024 static const intptr_t kBytesPerElement = (kNumberOfEntries * kWordSize); 3030 static const intptr_t kBytesPerElement =
3031 sizeof(RawPcDescriptors::PcDescriptorRec);
3025 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; 3032 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
3026 3033
3027 static intptr_t InstanceSize() { 3034 static intptr_t InstanceSize() {
3028 ASSERT(sizeof(RawPcDescriptors) == 3035 ASSERT(sizeof(RawPcDescriptors) ==
3029 OFFSET_OF_RETURNED_VALUE(RawPcDescriptors, data)); 3036 OFFSET_OF_RETURNED_VALUE(RawPcDescriptors, data));
3030 return 0; 3037 return 0;
3031 } 3038 }
3032 static intptr_t InstanceSize(intptr_t len) { 3039 static intptr_t InstanceSize(intptr_t len) {
3033 ASSERT(0 <= len && len <= kMaxElements); 3040 ASSERT(0 <= len && len <= kMaxElements);
3034 return RoundedAllocationSize( 3041 return RoundedAllocationSize(
3035 sizeof(RawPcDescriptors) + (len * kBytesPerElement)); 3042 sizeof(RawPcDescriptors) + (len * kBytesPerElement));
3036 } 3043 }
3037 3044
3038 static RawPcDescriptors* New(intptr_t num_descriptors); 3045 static RawPcDescriptors* New(intptr_t num_descriptors);
3039 3046
3040 // Returns 0 if not found. 3047 // Returns 0 if not found.
3041 uword GetPcForKind(Kind kind) const; 3048 uword GetPcForKind(Kind kind) const;
3042 3049
3043 // Verify (assert) assumptions about pc descriptors in debug mode. 3050 // Verify (assert) assumptions about pc descriptors in debug mode.
3044 void Verify(const Function& function) const; 3051 void Verify(const Function& function) const;
3045 3052
3046 static void PrintHeaderString(); 3053 static void PrintHeaderString();
3047 3054
3048 void PrintToJSONObject(JSONObject* jsobj) const; 3055 void PrintToJSONObject(JSONObject* jsobj) const;
3049 3056
3050 // We would have a VisitPointers function here to traverse the 3057 // We would have a VisitPointers function here to traverse the
3051 // pc descriptors table to visit objects if any in the table. 3058 // pc descriptors table to visit objects if any in the table.
3052 3059
3053 private: 3060 private:
3054 void SetPC(intptr_t index, uword value) const;
3055 void SetKind(intptr_t index, PcDescriptors::Kind kind) const;
3056 void SetDeoptId(intptr_t index, intptr_t value) const;
3057 void SetTokenPos(intptr_t index, intptr_t value) const;
3058 void SetTryIndex(intptr_t index, intptr_t value) const;
3059
3060 void SetLength(intptr_t value) const; 3061 void SetLength(intptr_t value) const;
3061 3062
3062 intptr_t* EntryAddr(intptr_t index, intptr_t entry_offset) const {
3063 ASSERT((index >=0) && (index < Length()));
3064 intptr_t data_index = (index * kNumberOfEntries) + entry_offset;
3065 return &raw_ptr()->data()[data_index];
3066 }
3067 RawSmi** SmiAddr(intptr_t index, intptr_t entry_offset) const {
3068 return reinterpret_cast<RawSmi**>(EntryAddr(index, entry_offset));
3069 }
3070
3071 FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object); 3063 FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object);
3072 friend class Class; 3064 friend class Class;
3073 friend class Object; 3065 friend class Object;
3074 }; 3066 };
3075 3067
3076 3068
3077 class Stackmap : public Object { 3069 class Stackmap : public Object {
3078 public: 3070 public:
3079 static const intptr_t kNoMaximum = -1; 3071 static const intptr_t kNoMaximum = -1;
3080 static const intptr_t kNoMinimum = -1; 3072 static const intptr_t kNoMinimum = -1;
(...skipping 4055 matching lines...) Expand 10 before | Expand all | Expand 10 after
7136 7128
7137 7129
7138 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7130 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7139 intptr_t index) { 7131 intptr_t index) {
7140 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7132 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7141 } 7133 }
7142 7134
7143 } // namespace dart 7135 } // namespace dart
7144 7136
7145 #endif // VM_OBJECT_H_ 7137 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698