Lines Matching refs:kind
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
51 * The location kind used to populate the Dex register information in a
71 enum class Kind : uint8_t {
73 // for the kind, 5 bits for the value) in a DexRegisterMap.
82 // kind, 4 bytes for the value).
101 sizeof(Kind) == 1u,
102 "art::DexRegisterLocation::Kind has a size different from one byte.");
104 static bool IsShortLocationKind(Kind kind) {
105 switch (kind) {
106 case Kind::kInStack:
107 case Kind::kInRegister:
108 case Kind::kInRegisterHigh:
109 case Kind::kInFpuRegister:
110 case Kind::kInFpuRegisterHigh:
111 case Kind::kConstant:
114 case Kind::kInStackLargeOffset:
115 case Kind::kConstantLargeValue:
118 case Kind::kNone:
119 LOG(FATAL) << "Unexpected location kind";
124 // Convert `kind` to a "surface" kind, i.e. one that doesn't include
126 // TODO: Introduce another enum type for the surface kind?
127 static Kind ConvertToSurfaceKind(Kind kind) {
128 switch (kind) {
129 case Kind::kInStack:
130 case Kind::kInRegister:
131 case Kind::kInRegisterHigh:
132 case Kind::kInFpuRegister:
133 case Kind::kInFpuRegisterHigh:
134 case Kind::kConstant:
135 return kind;
137 case Kind::kInStackLargeOffset:
138 return Kind::kInStack;
140 case Kind::kConstantLargeValue:
141 return Kind::kConstant;
143 case Kind::kNone:
144 return kind;
150 DexRegisterLocation() : kind_(Kind::kNone), value_(0) {}
152 DexRegisterLocation(Kind kind, int32_t value) : kind_(kind), value_(value) {}
155 return DexRegisterLocation(Kind::kNone, 0);
158 // Get the "surface" kind of the location, i.e., the one that doesn't
160 Kind GetKind() const {
167 // Get the actual kind of the location.
168 Kind GetInternalKind() const { return kind_; }
179 Kind kind_;
185 std::ostream& operator<<(std::ostream& stream, const DexRegisterLocation::Kind& kind);
193 * DexRegisterLocations are either 1- or 5-byte wide (see art::DexRegisterLocation::Kind).
203 DexRegisterLocation::Kind kind = ComputeCompressedKind(dex_register_location);
205 if (DexRegisterLocation::IsShortLocationKind(kind)) {
206 // Short location. Compress the kind and the value as a single byte.
207 if (kind == DexRegisterLocation::Kind::kInStack) {
218 region_.StoreUnaligned<ShortLocation>(offset, MakeShortLocation(kind, value));
223 if (kind == DexRegisterLocation::Kind::kInStackLargeOffset) {
232 region_.StoreUnaligned<DexRegisterLocation::Kind>(offset, kind);
233 region_.StoreUnaligned<int32_t>(offset + sizeof(DexRegisterLocation::Kind), value);
244 DexRegisterLocation::Kind kind = ExtractKindAtOffset(offset);
245 if (DexRegisterLocation::IsShortLocationKind(kind)) {
256 // Get the internal kind of entry at `location_catalog_entry_index`.
257 DexRegisterLocation::Kind GetLocationInternalKind(size_t location_catalog_entry_index) const {
259 return DexRegisterLocation::Kind::kNone;
264 // Get the (surface) kind and value of entry at `location_catalog_entry_index`.
272 DexRegisterLocation::Kind kind = ExtractKindFromShortLocation(first_byte);
273 if (DexRegisterLocation::IsShortLocationKind(kind)) {
276 if (kind == DexRegisterLocation::Kind::kInStack) {
280 return DexRegisterLocation(kind, value);
283 int32_t value = region_.LoadUnaligned<int32_t>(offset + sizeof(DexRegisterLocation::Kind));
284 if (kind == DexRegisterLocation::Kind::kInStackLargeOffset) {
288 return DexRegisterLocation(kind, value);
292 // Compute the compressed kind of `location`.
293 static DexRegisterLocation::Kind ComputeCompressedKind(const DexRegisterLocation& location) {
294 DexRegisterLocation::Kind kind = location.GetInternalKind();
295 switch (kind) {
296 case DexRegisterLocation::Kind::kInStack:
298 ? DexRegisterLocation::Kind::kInStack
299 : DexRegisterLocation::Kind::kInStackLargeOffset;
301 case DexRegisterLocation::Kind::kInRegister:
302 case DexRegisterLocation::Kind::kInRegisterHigh:
305 return kind;
307 case DexRegisterLocation::Kind::kInFpuRegister:
308 case DexRegisterLocation::Kind::kInFpuRegisterHigh:
311 return kind;
313 case DexRegisterLocation::Kind::kConstant:
315 ? DexRegisterLocation::Kind::kConstant
316 : DexRegisterLocation::Kind::kConstantLargeValue;
318 case DexRegisterLocation::Kind::kConstantLargeValue:
319 case DexRegisterLocation::Kind::kInStackLargeOffset:
320 case DexRegisterLocation::Kind::kNone:
321 LOG(FATAL) << "Unexpected location kind " << kind;
328 DexRegisterLocation::Kind kind = location.GetInternalKind();
329 switch (kind) {
330 case DexRegisterLocation::Kind::kInStack:
333 case DexRegisterLocation::Kind::kInRegister:
334 case DexRegisterLocation::Kind::kInRegisterHigh:
335 case DexRegisterLocation::Kind::kInFpuRegister:
336 case DexRegisterLocation::Kind::kInFpuRegisterHigh:
339 case DexRegisterLocation::Kind::kConstant:
342 case DexRegisterLocation::Kind::kConstantLargeValue:
343 case DexRegisterLocation::Kind::kInStackLargeOffset:
344 case DexRegisterLocation::Kind::kNone:
345 LOG(FATAL) << "Unexpected location kind " << kind;
359 return sizeof(DexRegisterLocation::Kind) + sizeof(int32_t);
370 // mapped to a DexRegisterLocation::Kind::kNone location).
376 // Width of the kind "field" in a short location, in bits.
399 static ShortLocation MakeShortLocation(DexRegisterLocation::Kind kind, int32_t value) {
400 uint8_t kind_integer_value = static_cast<uint8_t>(kind);
407 static DexRegisterLocation::Kind ExtractKindFromShortLocation(ShortLocation location) {
408 uint8_t kind = (location >> kKindOffset) & kKindMask;
409 DCHECK_LE(kind, static_cast<uint8_t>(DexRegisterLocation::Kind::kLastLocationKind));
411 DCHECK_NE(kind, static_cast<uint8_t>(DexRegisterLocation::Kind::kNone));
412 return static_cast<DexRegisterLocation::Kind>(kind);
419 // Extract a location kind from the byte at position `offset`.
420 DexRegisterLocation::Kind ExtractKindAtOffset(size_t offset) const {
449 // Get the surface kind of Dex register `dex_register_number`.
450 DexRegisterLocation::Kind GetLocationKind(uint16_t dex_register_number,
458 // Get the internal kind of Dex register `dex_register_number`.
459 DexRegisterLocation::Kind GetLocationInternalKind(uint16_t dex_register_number,
476 DCHECK(location.GetKind() == DexRegisterLocation::Kind::kInStack);
487 DCHECK_EQ(location.GetKind(), DexRegisterLocation::Kind::kConstant);
497 DCHECK(location.GetInternalKind() == DexRegisterLocation::Kind::kInRegister ||
498 location.GetInternalKind() == DexRegisterLocation::Kind::kInRegisterHigh ||
499 location.GetInternalKind() == DexRegisterLocation::Kind::kInFpuRegister ||
500 location.GetInternalKind() == DexRegisterLocation::Kind::kInFpuRegisterHigh)
640 // have been mapped to a DexRegisterLocation::Kind::kNone location).
1299 DexRegisterLocation::Kind kind =
1301 if (DexRegisterLocation::IsShortLocationKind(kind)) {