Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_RAW_OBJECT_H_ | 5 #ifndef VM_RAW_OBJECT_H_ |
| 6 #define VM_RAW_OBJECT_H_ | 6 #define VM_RAW_OBJECT_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/atomic.h" | 9 #include "vm/atomic.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 class RawPcDescriptors : public RawObject { | 1023 class RawPcDescriptors : public RawObject { |
| 1024 public: | 1024 public: |
| 1025 enum Kind { | 1025 enum Kind { |
| 1026 kDeopt = 1, // Deoptimization continuation point. | 1026 kDeopt = 1, // Deoptimization continuation point. |
| 1027 kIcCall = kDeopt << 1, // IC call. | 1027 kIcCall = kDeopt << 1, // IC call. |
| 1028 kOptStaticCall = kIcCall << 1, // Call directly to known target. | 1028 kOptStaticCall = kIcCall << 1, // Call directly to known target. |
| 1029 kUnoptStaticCall = kOptStaticCall << 1, // Call to a known target via stub. | 1029 kUnoptStaticCall = kOptStaticCall << 1, // Call to a known target via stub. |
| 1030 kClosureCall = kUnoptStaticCall << 1, // Closure call. | 1030 kClosureCall = kUnoptStaticCall << 1, // Closure call. |
| 1031 kRuntimeCall = kClosureCall << 1, // Runtime call. | 1031 kRuntimeCall = kClosureCall << 1, // Runtime call. |
| 1032 kOsrEntry = kRuntimeCall << 1, // OSR entry point in unopt. code. | 1032 kOsrEntry = kRuntimeCall << 1, // OSR entry point in unopt. code. |
| 1033 kOther = kOsrEntry << 1, | 1033 kOther = kOsrEntry << 1, |
|
Florian Schneider
2015/05/18 11:33:28
kLastKind = kOther,
| |
| 1034 kAnyKind = 0xFF | 1034 kAnyKind = 0xFF |
|
Florian Schneider
2015/05/18 11:33:28
I think -1 would be a more useful value for kAnyKi
rmacnak
2015/05/18 18:03:54
sgtm
| |
| 1035 }; | 1035 }; |
| 1036 | 1036 |
| 1037 // Compressed version assumes try_index is always -1 and does not store it. | 1037 class MergedKindTry { |
| 1038 struct PcDescriptorRec { | 1038 public: |
| 1039 uword pc_offset() const { return pc_offset_; } | 1039 // Most of the time try_index will be small and merged field will fit into |
| 1040 void set_pc_offset(uword value) { | 1040 // one byte. |
| 1041 // Some C compilers warn about the comparison always being true when using | 1041 static intptr_t Encode(intptr_t kind, intptr_t try_index) { |
| 1042 // <= due to limited range of data type. | 1042 intptr_t kind_shift = Utils::ShiftForPowerOfTwo(kind); |
| 1043 ASSERT((value == static_cast<uword>(kMaxUint32)) || | 1043 ASSERT(Utils::IsUint(kKindShiftSize, kind_shift)); |
| 1044 (value < static_cast<uword>(kMaxUint32))); | 1044 ASSERT(Utils::IsInt(kTryIndexSize, try_index)); |
| 1045 pc_offset_ = value; | 1045 return (try_index << kTryIndexPos) | (kind_shift << kKindShiftPos); |
| 1046 } | 1046 } |
| 1047 | 1047 |
| 1048 Kind kind() const { | 1048 static intptr_t DecodeKind(intptr_t merged_kind_try) { |
| 1049 return static_cast<Kind>(deopt_id_and_kind_ & kAnyKind); | 1049 const intptr_t kKindShiftMask = (1 << kKindShiftSize) - 1; |
| 1050 } | 1050 return 1 << (merged_kind_try & kKindShiftMask); |
| 1051 void set_kind(Kind kind) { | |
| 1052 deopt_id_and_kind_ = (deopt_id_and_kind_ & 0xFFFFFF00) | kind; | |
| 1053 } | 1051 } |
| 1054 | 1052 |
| 1055 int16_t try_index() const { return is_compressed() ? -1 : try_index_; } | 1053 static intptr_t DecodeTryIndex(intptr_t merged_kind_try) { |
| 1056 void set_try_index(int16_t value) { | 1054 // Arithmetic shift. |
| 1057 if (is_compressed()) { | 1055 return merged_kind_try >> kTryIndexPos; |
| 1058 ASSERT(value == -1); | |
| 1059 return; | |
| 1060 } | |
| 1061 try_index_ = value; | |
| 1062 } | |
| 1063 | |
| 1064 intptr_t token_pos() const { return token_pos_ >> 1; } | |
| 1065 void set_token_pos(int32_t value, bool compressed) { | |
| 1066 int32_t bit = compressed ? 0x1 : 0x0; | |
| 1067 token_pos_ = (value << 1) | bit; | |
| 1068 } | |
| 1069 | |
| 1070 intptr_t deopt_id() const { return deopt_id_and_kind_ >> 8; } | |
| 1071 void set_deopt_id(int32_t value) { | |
| 1072 ASSERT(Utils::IsInt(24, value)); | |
| 1073 deopt_id_and_kind_ = (deopt_id_and_kind_ & 0xFF) | (value << 8); | |
| 1074 } | 1056 } |
| 1075 | 1057 |
| 1076 private: | 1058 private: |
| 1077 bool is_compressed() const { | 1059 static const intptr_t kKindShiftPos = 0; |
| 1078 return (token_pos_ & 0x1) == 1; | 1060 static const intptr_t kKindShiftSize = 3; |
|
Florian Schneider
2015/05/18 11:33:28
Maybe assert that 3 bits is enough: kLastKind <= 1
rmacnak
2015/05/18 18:03:54
Done.
| |
| 1079 } | 1061 static const intptr_t kTryIndexPos = kKindShiftSize; |
| 1080 | 1062 static const intptr_t kTryIndexSize = kBitsPerWord - kKindShiftSize; |
| 1081 uint32_t pc_offset_; | |
| 1082 int32_t deopt_id_and_kind_; // Bits 31..8 -> deopt_id, bits 7..0 kind. | |
| 1083 int32_t token_pos_; // Bits 31..1 -> token_pos, bit 1 -> compressed flag; | |
| 1084 int16_t try_index_; | |
| 1085 }; | 1063 }; |
| 1086 | 1064 |
| 1087 // This structure is only used to compute what the size of PcDescriptorRec | |
| 1088 // should be when the try_index_ field is omitted. | |
| 1089 struct CompressedPcDescriptorRec { | |
| 1090 uint32_t pc_offset_; | |
| 1091 int32_t deopt_id_and_kind_; | |
| 1092 int32_t token_pos_; | |
| 1093 }; | |
| 1094 | |
| 1095 static intptr_t RecordSize(bool has_try_index); | |
| 1096 | |
| 1097 private: | 1065 private: |
| 1098 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); | 1066 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); |
| 1099 | 1067 |
| 1100 static const intptr_t kFullRecSize; | |
| 1101 static const intptr_t kCompressedRecSize; | |
| 1102 | |
| 1103 int32_t record_size_in_bytes_; | |
| 1104 int32_t length_; // Number of descriptors. | 1068 int32_t length_; // Number of descriptors. |
| 1105 | 1069 |
| 1106 // Variable length data follows here. | 1070 // Variable length data follows here. |
| 1107 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); } | 1071 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); } |
| 1108 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, intptr_t); } | 1072 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, intptr_t); } |
| 1109 | 1073 |
| 1110 friend class Object; | 1074 friend class Object; |
| 1111 }; | 1075 }; |
| 1112 | 1076 |
| 1113 | 1077 |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2154 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2118 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
| 2155 kTypedDataInt8ArrayViewCid + 15); | 2119 kTypedDataInt8ArrayViewCid + 15); |
| 2156 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2120 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
| 2157 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2121 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
| 2158 return (kNullCid - kTypedDataInt8ArrayCid); | 2122 return (kNullCid - kTypedDataInt8ArrayCid); |
| 2159 } | 2123 } |
| 2160 | 2124 |
| 2161 } // namespace dart | 2125 } // namespace dart |
| 2162 | 2126 |
| 2163 #endif // VM_RAW_OBJECT_H_ | 2127 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |