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

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
« no previous file with comments | « 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 4707)
+++ vm/object.cc (working copy)
@@ -5952,8 +5952,8 @@
const Bigint& big = Bigint::Handle(Bigint::New(str));
if (BigintOperations::FitsIntoSmi(big)) {
return BigintOperations::ToSmi(big);
- } else if (BigintOperations::FitsIntoInt64(big)) {
- return Mint::New(BigintOperations::ToInt64(big));
+ } else if (BigintOperations::FitsIntoMint(big)) {
+ return Mint::New(BigintOperations::ToMint(big));
} else {
return big.raw();
}
@@ -6170,7 +6170,7 @@
if (other.IsBigint()) {
Bigint& bigi = Bigint::Handle();
bigi ^= other.raw();
- ASSERT(!BigintOperations::FitsIntoInt64(bigi));
+ ASSERT(!BigintOperations::FitsIntoMint(bigi));
if (this->IsNegative() == other.IsNegative()) {
return this->IsNegative() ? 1 : -1;
}
@@ -6329,32 +6329,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;
}
@@ -6374,17 +6359,17 @@
int64_t Bigint::AsInt64Value() const {
- if (!BigintOperations::FitsIntoInt64(*this)) {
+ if (!BigintOperations::FitsIntoMint(*this)) {
UNREACHABLE();
}
- return BigintOperations::ToInt64(*this);
+ return BigintOperations::ToMint(*this);
}
// For positive values: Smi < Mint < Bigint.
int Bigint::CompareWith(const Integer& other) const {
ASSERT(!FitsIntoSmi(*this));
- ASSERT(!BigintOperations::FitsIntoInt64(*this));
+ ASSERT(!BigintOperations::FitsIntoMint(*this));
if (other.IsBigint()) {
Bigint& big = Bigint::Handle();
big ^= other.raw();
@@ -6397,6 +6382,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);
@@ -6404,7 +6405,9 @@
const char* Bigint::ToCString() const {
- return BigintOperations::ToDecCString(*this, &ZoneAllocator);
+ // TODO(florian): Add a BigintOperations::ToDecCString method and use that
+ // here.
+ return BigintOperations::ToHexCString(*this, &ZoneAllocator);
}
« no previous file with comments | « vm/object.h ('k') | vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698