| Index: runtime/vm/object.cc
|
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
|
| index 9d90a3544f20fb3a9896bbda70240303d09b0d47..8f5750cea4a7b1456fe06c71da7a9d5509313f26 100644
|
| --- a/runtime/vm/object.cc
|
| +++ b/runtime/vm/object.cc
|
| @@ -397,6 +397,9 @@ void Object::Init(Isolate* isolate) {
|
| cls = Class::New<Bool>();
|
| object_store->set_bool_class(cls);
|
|
|
| + cls = Class::New<ExternalArray>();
|
| + object_store->set_external_array_class(cls);
|
| +
|
| cls = Class::New<UnhandledException>();
|
| object_store->set_unhandled_exception_class(cls);
|
|
|
| @@ -626,6 +629,9 @@ void Object::InitFromSnapshot(Isolate* isolate) {
|
| cls = Class::New<ImmutableArray>();
|
| object_store->set_immutable_array_class(cls);
|
|
|
| + cls = Class::New<ExternalArray>();
|
| + object_store->set_external_array_class(cls);
|
| +
|
| cls = Class::New<Instance>();
|
| object_store->set_object_class(cls);
|
|
|
| @@ -1109,6 +1115,9 @@ RawClass* Class::GetClass(ObjectKind kind) {
|
| case kImmutableArray:
|
| ASSERT(object_store->immutable_array_class() != Class::null());
|
| return object_store->immutable_array_class();
|
| + case kExternalArray:
|
| + ASSERT(object_store->external_array_class() != Class::null());
|
| + return object_store->external_array_class();
|
| case kStacktrace:
|
| ASSERT(object_store->stacktrace_class() != Class::null());
|
| return object_store->stacktrace_class();
|
| @@ -6503,6 +6512,53 @@ const char* ImmutableArray::ToCString() const {
|
| }
|
|
|
|
|
| +RawExternalArray* ExternalArray::New(uint8_t* data,
|
| + intptr_t len,
|
| + Heap::Space space) {
|
| + Isolate* isolate = Isolate::Current();
|
| + const Class& external_array_class =
|
| + Class::Handle(isolate->object_store()->external_array_class());
|
| + ExternalArray& result = ExternalArray::Handle();
|
| + {
|
| + RawObject* raw = Object::Allocate(external_array_class,
|
| + ExternalArray::InstanceSize(),
|
| + space);
|
| + NoGCScope no_gc;
|
| + result ^= raw;
|
| + result.SetLength(len);
|
| + result.SetData(data);
|
| + }
|
| + return result.raw();
|
| +}
|
| +
|
| +
|
| +bool ExternalArray::Equals(const Instance& other) const {
|
| + if (this->raw() == other.raw()) {
|
| + // Both handles point to the same raw instance.
|
| + return true;
|
| + }
|
| +
|
| + if (!other.IsExternalArray() || other.IsNull()) {
|
| + return false;
|
| + }
|
| +
|
| + ExternalArray& other_array = ExternalArray::Handle();
|
| + other_array ^= other.raw();
|
| +
|
| + intptr_t len = this->Length();
|
| + if (len != other_array.Length()) {
|
| + return false;
|
| + }
|
| +
|
| + return !memcmp(this->Addr<uint8_t>(0), other_array.Addr<uint8_t>(0), len);
|
| +}
|
| +
|
| +
|
| +const char* ExternalArray::ToCString() const {
|
| + return "ExternalArray";
|
| +}
|
| +
|
| +
|
| RawClosure* Closure::New(const Function& function,
|
| const Context& context,
|
| Heap::Space space) {
|
|
|