Files
sdk/runtime/vm/dart_api_message.h
Ryan Macnak e98e6a1198 [vm] Per isolate group roots accessed via TLS.
Remove special case for null in message snapshots; snapshots are sometimes read or written with no current isolate group.

Currently still all copies pointing into the VM isolate.

TEST=ci
Change-Id: I4d2e35a01880885d4e92e1c623c0f39a35e06065
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493866
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-04-08 15:26:06 -07:00

52 lines
1.4 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_VM_DART_API_MESSAGE_H_
#define RUNTIME_VM_DART_API_MESSAGE_H_
#include "include/dart_native_api.h"
#include "platform/utils.h"
#include "vm/allocation.h"
#include "vm/dart_api_state.h"
#include "vm/message.h"
#include "vm/raw_object.h"
#include "vm/snapshot.h"
namespace dart {
// This class handles translation of certain ObjectPtrs to CObjects for
// NativeMessageHandlers.
class ApiObjectConverter : public AllStatic {
public:
static bool CanConvert(const ObjectPtr raw_obj) {
return !raw_obj->IsHeapObject();
}
static bool Convert(const ObjectPtr raw_obj, Dart_CObject* c_obj) {
if (!raw_obj->IsHeapObject()) {
ConvertSmi(static_cast<const SmiPtr>(raw_obj), c_obj);
} else {
return false;
}
return true;
}
private:
static void ConvertSmi(const SmiPtr raw_smi, Dart_CObject* c_obj) {
ASSERT(!raw_smi->IsHeapObject());
intptr_t value = Smi::Value(raw_smi);
if (Utils::IsInt(31, value)) {
c_obj->type = Dart_CObject_kInt32;
c_obj->value.as_int32 = static_cast<int32_t>(value);
} else {
c_obj->type = Dart_CObject_kInt64;
c_obj->value.as_int64 = static_cast<int64_t>(value);
}
}
};
} // namespace dart
#endif // RUNTIME_VM_DART_API_MESSAGE_H_