| Index: runtime/vm/object.cc
|
| ===================================================================
|
| --- runtime/vm/object.cc (revision 40444)
|
| +++ runtime/vm/object.cc (working copy)
|
| @@ -16264,6 +16264,8 @@
|
|
|
|
|
| void Bigint::set_digits(const TypedData& value) const {
|
| + // The VM expects digits_ to be a Uint32List (not null).
|
| + ASSERT(!value.IsNull() && (value.GetClassId() == kTypedDataUint32ArrayCid));
|
| StorePointer(&raw_ptr()->digits_, value.raw());
|
| }
|
|
|
| @@ -16341,15 +16343,16 @@
|
| ASSERT(!digits_.IsNull());
|
| set_digits(digits_);
|
| } else {
|
| - ASSERT(digits() == TypedData::null());
|
| + ASSERT(digits() == TypedData::EmptyUint32Array(Isolate::Current()));
|
| }
|
| return true;
|
| }
|
|
|
|
|
| RawBigint* Bigint::New(Heap::Space space) {
|
| - ASSERT(Isolate::Current()->object_store()->bigint_class() != Class::null());
|
| - Bigint& result = Bigint::Handle();
|
| + Isolate* isolate = Isolate::Current();
|
| + ASSERT(isolate->object_store()->bigint_class() != Class::null());
|
| + Bigint& result = Bigint::Handle(isolate);
|
| {
|
| RawObject* raw = Object::Allocate(Bigint::kClassId,
|
| Bigint::InstanceSize(),
|
| @@ -16358,7 +16361,9 @@
|
| result ^= raw;
|
| }
|
| result.set_neg(Bool::Get(false));
|
| - result.set_used(Smi::Handle(Smi::New(0)));
|
| + result.set_used(Smi::Handle(isolate, Smi::New(0)));
|
| + result.set_digits(
|
| + TypedData::Handle(isolate, TypedData::EmptyUint32Array(isolate)));
|
| return result.raw();
|
| }
|
|
|
| @@ -16423,10 +16428,10 @@
|
| void Bigint::EnsureLength(intptr_t length, Heap::Space space) const {
|
| ASSERT(length >= 0);
|
| TypedData& old_digits = TypedData::Handle(digits());
|
| - if ((length > 0) && (old_digits.IsNull() || (length > old_digits.Length()))) {
|
| + if ((length > 0) && (length > old_digits.Length())) {
|
| TypedData& new_digits = TypedData::Handle(
|
| TypedData::New(kTypedDataUint32ArrayCid, length + kExtraDigits, space));
|
| - if (!old_digits.IsNull()) {
|
| + if (old_digits.Length() > 0) {
|
| TypedData::Copy(new_digits, TypedData::data_offset(),
|
| old_digits, TypedData::data_offset(),
|
| old_digits.LengthInBytes());
|
| @@ -19635,6 +19640,20 @@
|
| }
|
|
|
|
|
| +RawTypedData* TypedData::EmptyUint32Array(Isolate* isolate) {
|
| + ASSERT(isolate != NULL);
|
| + ASSERT(isolate->object_store() != NULL);
|
| + if (isolate->object_store()->empty_uint32_array() != TypedData::null()) {
|
| + // Already created.
|
| + return isolate->object_store()->empty_uint32_array();
|
| + }
|
| + const TypedData& array = TypedData::Handle(isolate,
|
| + TypedData::New(kTypedDataUint32ArrayCid, 0, Heap::kOld));
|
| + isolate->object_store()->set_empty_uint32_array(array);
|
| + return array.raw();
|
| +}
|
| +
|
| +
|
| const char* TypedData::ToCString() const {
|
| return "TypedData";
|
| }
|
|
|