292 {
293 Create();
294
296 cls ^= GetClass();
297
298 switch (cls.id()) {
299 case kContextCid: {
300 const Context& context = Context::Cast(*object_);
301
304
305 for (intptr_t
i = 0;
i < field_count_;
i++) {
308
310 parent ^= GetValue(
i);
311 context.set_parent(parent);
312 if (FLAG_trace_deoptimization_verbose) {
314 offset.Value(), parent.ToCString());
315 }
316 } else {
319 context.SetAt(context_index,
value);
320 if (FLAG_trace_deoptimization_verbose) {
323 }
324 }
325 }
326 } break;
327 case kArrayCid: {
328 const Array& array = Array::Cast(*object_);
329
332
333 for (intptr_t
i = 0;
i < field_count_;
i++) {
337 type_args ^= GetValue(
i);
338 array.SetTypeArguments(type_args);
339 if (FLAG_trace_deoptimization_verbose) {
341 offset.Value(), type_args.ToCString());
342 }
343 } else {
346 array.SetAt(index,
value);
347 if (FLAG_trace_deoptimization_verbose) {
350 }
351 }
352 }
353 } break;
354 case kPointerCid: {
356 const int kDataIndex = 0;
357 const int kTypeArgIndex = 1;
358 ASSERT(field_count_ == 2);
363
364 const auto& pointer = Pointer::Cast(*object_);
365 const size_t address =
367 .AsInt64Value();
368 pointer.SetNativeAddress(address);
371 pointer.SetTypeArguments(type_args);
372 if (FLAG_trace_deoptimization_verbose) {
374 OS::PrintErr(
" pointer@type_args <- %s\n", type_args.ToCString());
375 }
376 } break;
377 case kRecordCid: {
378 const Record& record = Record::Cast(*object_);
379
382
383 for (intptr_t
i = 0;
i < field_count_;
i++) {
387 record.SetFieldAt(index,
value);
388 if (FLAG_trace_deoptimization_verbose) {
391 }
392 }
393 } break;
394 default:
396 const TypedData& typed_data = TypedData::Cast(*object_);
397
400 const auto cid = cls.id();
401
402 for (intptr_t
i = 0;
i < field_count_;
i++) {
404 const intptr_t element_offset =
offset.Value();
407 case kTypedDataInt8ArrayCid:
408 typed_data.SetInt8(
409 element_offset,
410 static_cast<int8_t
>(Integer::Cast(
value).AsInt64Value()));
411 break;
412 case kTypedDataUint8ArrayCid:
413 case kTypedDataUint8ClampedArrayCid:
414 typed_data.SetUint8(
415 element_offset,
416 static_cast<uint8_t
>(Integer::Cast(
value).AsInt64Value()));
417 break;
418 case kTypedDataInt16ArrayCid:
419 typed_data.SetInt16(
420 element_offset,
421 static_cast<int16_t
>(Integer::Cast(
value).AsInt64Value()));
422 break;
423 case kTypedDataUint16ArrayCid:
424 typed_data.SetUint16(
425 element_offset,
426 static_cast<uint16_t
>(Integer::Cast(
value).AsInt64Value()));
427 break;
428 case kTypedDataInt32ArrayCid:
429 typed_data.SetInt32(
430 element_offset,
431 static_cast<int32_t
>(Integer::Cast(
value).AsInt64Value()));
432 break;
433 case kTypedDataUint32ArrayCid:
434 typed_data.SetUint32(
435 element_offset,
436 static_cast<uint32_t
>(Integer::Cast(
value).AsInt64Value()));
437 break;
438 case kTypedDataInt64ArrayCid:
439 typed_data.SetInt64(element_offset,
440 Integer::Cast(
value).AsInt64Value());
441 break;
442 case kTypedDataUint64ArrayCid:
443 typed_data.SetUint64(
444 element_offset,
445 static_cast<uint64_t
>(Integer::Cast(
value).AsInt64Value()));
446 break;
447 case kTypedDataFloat32ArrayCid:
448 typed_data.SetFloat32(
449 element_offset,
450 static_cast<float>(Double::Cast(
value).
value()));
451 break;
452 case kTypedDataFloat64ArrayCid:
453 typed_data.SetFloat64(element_offset,
455 break;
456 case kTypedDataFloat32x4ArrayCid:
457 typed_data.SetFloat32x4(element_offset,
459 break;
460 case kTypedDataInt32x4ArrayCid:
461 typed_data.SetInt32x4(element_offset,
463 break;
464 case kTypedDataFloat64x2ArrayCid:
465 typed_data.SetFloat64x2(element_offset,
467 break;
468 default:
470 }
471 if (FLAG_trace_deoptimization_verbose) {
473 element_offset,
value.ToCString());
474 }
475 }
476 } else {
477 const Instance& obj = Instance::Cast(*object_);
478
482 const Array& offset_map =
Array::Handle(cls.OffsetToFieldMap());
483
484 for (intptr_t
i = 0;
i < field_count_;
i++) {
488 ASSERT((
value.ptr() != Object::sentinel().ptr()) ||
489 (!field.IsNull() && field.is_late()));
490 if (!field.IsNull() && (
value.ptr() != Object::sentinel().ptr())) {
491 obj.SetField(field,
value);
492 if (FLAG_trace_deoptimization_verbose) {
496 }
497 } else {
498
499
500
501
504 if (FLAG_trace_deoptimization_verbose) {
506 " %s @ offset(%" Pd ") <- %s\n",
507 (field.IsNull() ? "null Field"
510 }
511 }
512 }
513
514 if (obj.IsTypedDataView()) {
515
516
517 TypedDataView::Cast(obj).RecomputeDataField();
518 }
519 }
520 break;
521 }
522}
static intptr_t type_arguments_offset()
static intptr_t index_at_offset(intptr_t offset_in_bytes)
static intptr_t parent_offset()
static IsolateGroup * Current()
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
virtual const char * ToCString() const
static intptr_t data_offset()
static intptr_t type_arguments_offset()
static intptr_t field_index_at_offset(intptr_t offset_in_bytes)
static Thread * Current()
bool IsTypedDataClassId(intptr_t index)
static intptr_t ToContextIndex(intptr_t offset_in_bytes)
static constexpr intptr_t kCompressedWordSize