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

Issue 9363023: Add support for big integers to the native message format (Closed)

Created:
8 years, 10 months ago by Søren Gjesse
Modified:
8 years, 10 months ago
Reviewers:
siva
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add support for big integers to the native message format Also fixed snapshotting of negative big integers. R=asiva@google.com BUG= TEST= Committed: https://code.google.com/p/dart/source/detail?r=4078

Patch Set 1 #

Total comments: 8

Patch Set 2 : Addressed review comments from asiva@ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+161 lines, -5 lines) Patch
M runtime/include/dart_api.h View 1 2 chunks +2 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_message.h View 1 1 chunk +2 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_message.cc View 1 2 chunks +25 lines, -0 lines 0 comments Download
M runtime/vm/raw_object_snapshot.cc View 1 1 chunk +12 lines, -1 line 0 comments Download
M runtime/vm/snapshot.h View 1 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/snapshot.cc View 1 1 chunk +14 lines, -0 lines 0 comments Download
M runtime/vm/snapshot_test.cc View 1 7 chunks +105 lines, -3 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
Søren Gjesse
8 years, 10 months ago (2012-02-08 14:23:00 UTC) #1
siva
LGTM once the openssl references in this code is removed and limited to the BigIntOperations ...
8 years, 10 months ago (2012-02-09 01:47:27 UTC) #2
Søren Gjesse
8 years, 10 months ago (2012-02-09 14:08:32 UTC) #3
Thank you for the review

https://chromiumcodereview.appspot.com/9363023/diff/1/runtime/vm/dart_api_mes...
File runtime/vm/dart_api_message.cc (right):

https://chromiumcodereview.appspot.com/9363023/diff/1/runtime/vm/dart_api_mes...
runtime/vm/dart_api_message.cc:199: char* hex_string =
reinterpret_cast<char*>(AllocateTemp(len + 1));
On 2012/02/09 01:47:27, asiva wrote:
> Why do you use this special temp Allocator and not the regular allocator
> registered with this reader object?

The idea was that temporary data should be freed before returning, but maybe
thats a bad idea.

As suggested we keep the hex string, so temporary allocation for conversion is
not required any more.

https://chromiumcodereview.appspot.com/9363023/diff/1/runtime/vm/dart_api_mes...
runtime/vm/dart_api_message.cc:209: char* dec_string = BN_bn2dec(bn);
On 2012/02/09 01:47:27, asiva wrote:
> What is the advantage of converting this into a decimal string and not leaving
> it as hex string?
> 
> Also ditto comment made elsewhere about exposing the OPENSSL stuff here and
not
> sticking to the BigIntOperations abstraction.

Keeping the hex string - no need for bigint operations here any more.

https://chromiumcodereview.appspot.com/9363023/diff/1/runtime/vm/raw_object_s...
File runtime/vm/raw_object_snapshot.cc (right):

https://chromiumcodereview.appspot.com/9363023/diff/1/runtime/vm/raw_object_s...
runtime/vm/raw_object_snapshot.cc:1188: if (neg) writer->Write<uint8_t>('-');
On 2012/02/09 01:47:27, asiva wrote:
> Could you restruct as follows to make it more clear:
> if (neg) {
>   writer->WriteIntptrValue(len - 1);  // Include '-' in length.
>   writer->Write<uint8_t>('-');
> } else {
>   writer->WriteIntptrValue(len - 2);
> }

Done.

https://chromiumcodereview.appspot.com/9363023/diff/1/runtime/vm/snapshot.cc
File runtime/vm/snapshot.cc (right):

https://chromiumcodereview.appspot.com/9363023/diff/1/runtime/vm/snapshot.cc#...
runtime/vm/snapshot.cc:551: char* hex_string = BN_bn2hex(bn);
On 2012/02/09 01:47:27, asiva wrote:
> Somebody came up with the BigintOperations class in the hope of hiding the
fact
> that we are using OPENSSL to do the bigint operations and be able to plug in
> some other implementation without changing much of the rest of the code.
> 
> This assumption is being violated here.

After changing to using the hex format for the data in the Dart_CObject
structure no bignum operations are needed any more.

Powered by Google App Engine
This is Rietveld 408576698