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

Issue 509153003: New bigint implementation in the vm. (Closed)

Created:
6 years, 3 months ago by regis
Modified:
6 years, 3 months ago
CC:
reviews_dartlang.org, vm-dev_dartlang.org, Ivan Posva
Visibility:
Public.

Description

New bigint implementation in the vm. R=srdjan@google.com Committed: https://code.google.com/p/dart/source/detail?r=40061

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Total comments: 16

Patch Set 4 : #

Total comments: 4

Patch Set 5 : #

Patch Set 6 : #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+2850 lines, -4854 lines) Patch
M runtime/bin/dartutils.h View 1 2 3 4 5 2 chunks +27 lines, -3 lines 0 comments Download
M runtime/bin/dartutils.cc View 1 2 3 4 5 2 chunks +140 lines, -0 lines 0 comments Download
M runtime/include/dart_native_api.h View 1 2 3 4 5 1 chunk +5 lines, -1 line 0 comments Download
M runtime/lib/array.cc View 1 2 3 4 5 1 chunk +0 lines, -1 line 0 comments Download
A runtime/lib/bigint.dart View 1 2 3 4 1 chunk +1206 lines, -0 lines 3 comments Download
M runtime/lib/bool.cc View 1 2 3 4 5 1 chunk +0 lines, -1 line 0 comments Download
M runtime/lib/corelib_sources.gypi View 1 2 3 4 5 2 chunks +7 lines, -6 lines 0 comments Download
M runtime/lib/date.cc View 1 2 3 4 5 1 chunk +0 lines, -1 line 0 comments Download
M runtime/lib/double.cc View 1 2 3 4 5 2 chunks +59 lines, -3 lines 0 comments Download
M runtime/lib/double.dart View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M runtime/lib/integers.cc View 1 2 3 4 5 16 chunks +65 lines, -47 lines 0 comments Download
M runtime/lib/integers.dart View 1 2 3 4 5 5 chunks +33 lines, -42 lines 0 comments Download
M runtime/lib/math.cc View 1 2 3 4 5 2 chunks +18 lines, -11 lines 0 comments Download
M runtime/lib/profiler.cc View 1 2 3 4 5 1 chunk +0 lines, -1 line 0 comments Download
M runtime/lib/typed_data.cc View 1 2 3 4 5 4 chunks +6 lines, -5 lines 0 comments Download
D runtime/vm/bigint_operations.h View 1 2 3 4 5 1 chunk +0 lines, -159 lines 0 comments Download
D runtime/vm/bigint_operations.cc View 1 2 3 4 5 1 chunk +0 lines, -1868 lines 0 comments Download
D runtime/vm/bigint_operations_test.cc View 1 2 3 4 5 1 chunk +0 lines, -2240 lines 0 comments Download
M runtime/vm/bootstrap_natives.h View 1 2 3 4 5 1 chunk +7 lines, -3 lines 0 comments Download
M runtime/vm/class_finalizer.cc View 1 2 3 4 5 1 chunk +0 lines, -2 lines 0 comments Download
M runtime/vm/code_generator.cc View 1 2 3 4 5 2 chunks +1 line, -2 lines 0 comments Download
M runtime/vm/dart_api_impl.cc View 1 2 3 4 5 10 chunks +16 lines, -18 lines 0 comments Download
M runtime/vm/dart_api_message.h View 1 2 3 4 5 1 chunk +2 lines, -2 lines 0 comments Download
M runtime/vm/dart_api_message.cc View 1 2 3 4 5 6 chunks +53 lines, -32 lines 0 comments Download
M runtime/vm/flow_graph_optimizer.cc View 1 2 3 4 5 3 chunks +13 lines, -1 line 0 comments Download
M runtime/vm/intermediate_language.cc View 1 2 3 4 5 2 chunks +2 lines, -5 lines 0 comments Download
M runtime/vm/intrinsifier_arm.cc View 1 2 3 4 5 1 chunk +45 lines, -0 lines 0 comments Download
M runtime/vm/intrinsifier_arm64.cc View 1 2 3 4 5 1 chunk +45 lines, -0 lines 0 comments Download
M runtime/vm/intrinsifier_ia32.cc View 1 2 3 4 5 1 chunk +46 lines, -0 lines 0 comments Download
M runtime/vm/intrinsifier_mips.cc View 1 2 3 4 5 1 chunk +45 lines, -0 lines 0 comments Download
M runtime/vm/intrinsifier_x64.cc View 1 2 3 4 5 1 chunk +46 lines, -0 lines 0 comments Download
M runtime/vm/method_recognizer.h View 1 2 3 4 5 3 chunks +15 lines, -9 lines 0 comments Download
M runtime/vm/object.h View 1 2 3 4 5 10 chunks +73 lines, -74 lines 0 comments Download
M runtime/vm/object.cc View 1 2 3 4 5 26 chunks +800 lines, -191 lines 0 comments Download
M runtime/vm/object_store.cc View 1 2 3 4 5 1 chunk +0 lines, -1 line 0 comments Download
M runtime/vm/object_test.cc View 1 2 3 4 5 4 chunks +9 lines, -11 lines 0 comments Download
M runtime/vm/raw_object.h View 1 2 3 4 5 2 chunks +5 lines, -16 lines 0 comments Download
M runtime/vm/raw_object.cc View 1 2 3 4 5 2 chunks +2 lines, -9 lines 0 comments Download
M runtime/vm/raw_object_snapshot.cc View 1 2 3 4 5 5 chunks +15 lines, -45 lines 0 comments Download
M runtime/vm/snapshot.h View 1 2 3 4 5 3 chunks +3 lines, -1 line 0 comments Download
M runtime/vm/snapshot.cc View 1 2 3 4 5 4 chunks +6 lines, -15 lines 0 comments Download
M runtime/vm/snapshot_test.cc View 1 2 3 4 5 8 chunks +26 lines, -24 lines 0 comments Download
M runtime/vm/symbols.h View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/unit_test.h View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M runtime/vm/unit_test.cc View 1 2 3 4 5 1 chunk +5 lines, -0 lines 0 comments Download
M runtime/vm/vm_sources.gypi View 1 2 3 4 5 1 chunk +0 lines, -3 lines 0 comments Download

Messages

Total messages: 14 (3 generated)
regis
This is slower than the replaced version, because no intrinsics are implemented yet.
6 years, 3 months ago (2014-09-05 23:07:43 UTC) #2
Florian Schneider
dbc: https://codereview.chromium.org/509153003/diff/40001/runtime/lib/bigint.dart File runtime/lib/bigint.dart (right): https://codereview.chromium.org/509153003/diff/40001/runtime/lib/bigint.dart#newcode43 runtime/lib/bigint.dart:43: static const int DIGIT_BITS = 32; Ideally, this ...
6 years, 3 months ago (2014-09-08 09:10:20 UTC) #4
srdjan
https://codereview.chromium.org/509153003/diff/40001/runtime/bin/dartutils.cc File runtime/bin/dartutils.cc (right): https://codereview.chromium.org/509153003/diff/40001/runtime/bin/dartutils.cc#newcode877 runtime/bin/dartutils.cc:877: two lines https://codereview.chromium.org/509153003/diff/40001/runtime/lib/bigint.dart File runtime/lib/bigint.dart (right): https://codereview.chromium.org/509153003/diff/40001/runtime/lib/bigint.dart#newcode80 runtime/lib/bigint.dart:80: */ ...
6 years, 3 months ago (2014-09-08 19:19:49 UTC) #5
regis
Thanks. I've cleaned up a few more TODOs and added intrinsics for bigint field accessors. ...
6 years, 3 months ago (2014-09-09 19:18:14 UTC) #6
srdjan
https://codereview.chromium.org/509153003/diff/40001/runtime/lib/bigint.dart File runtime/lib/bigint.dart (right): https://codereview.chromium.org/509153003/diff/40001/runtime/lib/bigint.dart#newcode233 runtime/lib/bigint.dart:233: void _copyTo(r) { Please add type to arguments (here ...
6 years, 3 months ago (2014-09-09 19:31:44 UTC) #7
srdjan
LGTM https://codereview.chromium.org/509153003/diff/60001/runtime/vm/bigint_operations_test.cc File runtime/vm/bigint_operations_test.cc (left): https://codereview.chromium.org/509153003/diff/60001/runtime/vm/bigint_operations_test.cc#oldcode2237 runtime/vm/bigint_operations_test.cc:2237: "01234567890ABCDEE"); Can we move these tests to Dart ...
6 years, 3 months ago (2014-09-09 20:22:01 UTC) #8
regis
Thanks! https://codereview.chromium.org/509153003/diff/40001/runtime/lib/bigint.dart File runtime/lib/bigint.dart (right): https://codereview.chromium.org/509153003/diff/40001/runtime/lib/bigint.dart#newcode233 runtime/lib/bigint.dart:233: void _copyTo(r) { On 2014/09/09 19:31:44, srdjan wrote: ...
6 years, 3 months ago (2014-09-09 21:19:38 UTC) #9
regis
Committed patchset #6 (id:100001) manually as r40061 (presubmit successful).
6 years, 3 months ago (2014-09-09 21:48:06 UTC) #10
Vyacheslav Egorov (Google)
https://codereview.chromium.org/509153003/diff/100001/runtime/lib/bigint.dart File runtime/lib/bigint.dart (right): https://codereview.chromium.org/509153003/diff/100001/runtime/lib/bigint.dart#newcode79 runtime/lib/bigint.dart:79: Uint32List get _digits native "Bigint_getDigits"; Any reason why is ...
6 years, 3 months ago (2014-09-10 11:44:12 UTC) #12
regis
https://codereview.chromium.org/509153003/diff/100001/runtime/lib/bigint.dart File runtime/lib/bigint.dart (right): https://codereview.chromium.org/509153003/diff/100001/runtime/lib/bigint.dart#newcode79 runtime/lib/bigint.dart:79: Uint32List get _digits native "Bigint_getDigits"; On 2014/09/10 11:44:12, Vyacheslav ...
6 years, 3 months ago (2014-09-10 17:34:17 UTC) #13
Vyacheslav Egorov (Google)
6 years, 3 months ago (2014-09-10 17:40:44 UTC) #14
Message was sent while issue was closed.
https://codereview.chromium.org/509153003/diff/100001/runtime/lib/bigint.dart
File runtime/lib/bigint.dart (right):

https://codereview.chromium.org/509153003/diff/100001/runtime/lib/bigint.dart...
runtime/lib/bigint.dart:79: Uint32List get _digits native "Bigint_getDigits";
On 2014/09/10 17:34:17, regis wrote:
> On 2014/09/10 11:44:12, Vyacheslav Egorov (Google) wrote:
> > Any reason why is this not a real field?
> > 
> > This is completely nontransparent for the optimizer. 
> > 
> > Even if you recognize and inline this as LoadField with an offset it will
> still
> > be worse because optimizer can't used Field based aliasing for fields that
we
> > refer by offsets.
> > 
> 
> Class _Bigint being part of the integer class hierarchy, we need handles for
it.
> It is also used early in bootstrapping the system (e.g. bigint literals in
> source), so we need to be able to allocate and initialize a bigint instance
from
> C++ without calling into Dart.
> 
> So either we declare the fields in Dart and make access from C++ somewhat
> complicated, or we declare them in C++ (RawBigint) and provide native
accessors.
> 
> Ivan and Srdjan recommended the second approach and suggested to handle the 3
> required fields like the length field of Array.
> 
> I am opened to either way, as long as it is efficient.
> 
> I do not expect field accesses to be the bottleneck anyway. The fields neg and
> used are typically accessed once in each method and I plan to introduce local
> variables to cache the digits field.
> 

But we can force fields declared in the dart code into offsets "expected
offsets" known to C++ code, e.g. we deal with offsetInBytes in TypedData in this
manner.

I think is totally preferable to having a getter like this that does nothing but
marshall a field from C++ side and then having intrinsic for it.

Powered by Google App Engine
This is Rietveld 408576698