Index: vm/object.cc |
=================================================================== |
--- vm/object.cc (revision 4598) |
+++ vm/object.cc (working copy) |
@@ -6269,32 +6269,17 @@ |
Bigint& other_bgi = Bigint::Handle(); |
other_bgi ^= other.raw(); |
- return BN_cmp(BNAddr(), other_bgi.BNAddr()) == 0; |
-} |
+ intptr_t len = this->Length(); |
+ if (len != other_bgi.Length()) { |
+ return false; |
+ } |
- |
-RawBigint* Bigint::New(const BIGNUM *bn, Heap::Space space) { |
- Isolate* isolate = Isolate::Current(); |
- const Class& cls = Class::Handle(isolate->object_store()->bigint_class()); |
- Bigint& result = Bigint::Handle(); |
- { |
- RawObject* raw = Object::Allocate(cls, |
- Bigint::InstanceSize(bn), |
- space); |
- NoGCScope no_gc; |
- result ^= raw; |
- // Danger Will Robinson! Use of OpenSSL internals! |
- // Copy the OpenSSL BIGNUM to our own heap. Don't fix up our d |
- // pointer, that'll get done for us. |
- BIGNUM* our_bn = result.MutableBNAddr(); |
- // memcpy would be sufficient. |
- memmove(our_bn, bn, sizeof *bn); |
- memmove(result.BNMemory(), bn->d, bn->top * sizeof(BN_ULONG)); |
- // We only allocated/copied the active part. |
- our_bn->dmax = our_bn->top; |
+ for (intptr_t i = 0; i < len; i++) { |
+ if (this->GetChunkAt(i) != other_bgi.GetChunkAt(i)) { |
+ return false; |
+ } |
} |
- |
- return result.raw(); |
+ return true; |
} |
@@ -6337,6 +6322,22 @@ |
} |
+RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) { |
+ ASSERT(length >= 0); |
+ Isolate* isolate = Isolate::Current(); |
+ const Class& cls = Class::Handle(isolate->object_store()->bigint_class()); |
+ Bigint& result = Bigint::Handle(); |
+ { |
+ RawObject* raw = Object::Allocate(cls, Bigint::InstanceSize(length), space); |
+ NoGCScope no_gc; |
+ result ^= raw; |
+ result.raw_ptr()->allocated_length_ = length; |
+ result.raw_ptr()->signed_length_ = length; |
+ } |
+ return result.raw(); |
+} |
+ |
+ |
static uword ZoneAllocator(intptr_t size) { |
Zone* zone = Isolate::Current()->current_zone(); |
return zone->Allocate(size); |
@@ -6344,7 +6345,7 @@ |
const char* Bigint::ToCString() const { |
- return BigintOperations::ToDecCString(*this, &ZoneAllocator); |
+ return BigintOperations::ToHexCString(*this, &ZoneAllocator); |
Ivan Posva
2012/02/28 01:38:34
Can you please add a TODO and file a bug to implem
siva
2012/02/28 18:22:18
Done.
|
} |