Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(881)

Unified Diff: vm/object.cc

Issue 9481019: Changes to get rid of dependency on openssl in the dart VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« vm/bigint_operations.cc ('K') | « vm/object.h ('k') | vm/object_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
}
« vm/bigint_operations.cc ('K') | « vm/object.h ('k') | vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698