6 ms·
What's wrong with the following code? https://github.com/dart-lang/bleeding_edge/blob/master/dart/runtime/lib/integers.dart https://github.com/dart-lang/bleedi
by mezoni 12y ago
What's wrong with the following code?
https://github.com/dart-lang/bleeding_edge/blob/master/dart/runtime/lib/integers.dart https://github.com/dart-lang/bleeding_edge/blob/master/dart/...
===============================
class _IntegerImplementation extends _Num {
@inline(INLINE.INTRINSICS) // <============================
int _bitAndFromInteger(int other) native "Integer_bitAndFromInteger";
}
===============================
The same method in CORE_INTEGER_LIB_INTRINSIC_LIST
https://github.com/dart-lang/bleeding_edge/blob/master/dart/runtime/vm/method_recognizer.h https://github.com/dart-lang/bleeding_edge/blob/master/dart/...
===============================
V(_IntegerImplementation, _bitAndFromInteger, \
Integer_bitAndFromInteger, 504496713)
===============================
If Dart VM can use "patch class" declarations then why this "@inline" should be considered as a bad?
Maybe your answer in that the "Dart VM ignored all kind of annotations (including type annotations) why it should use this approach".
P.S.
This is a not a direct problem of dynamism (ignore annotations even if they hard coded in source).
Problem in that the Dart VM does not want rely on annotations (dynamism is better, determine everything at runtime or from magic lists).
- mraleph 12y ago> If Dart VM can use "patch class" declarations then why this "@inline" should be considered as a bad? Annotation like that is not enough for intrinsics. You would still need to provide some way of detecting in the compilation pipeline and intrinsifier that method you are looking at is indeed `Integer_bitAndFromInteger`. In this particular case you could look at the name of the native, but that does not work with those intrinsified methods that have Dart bodies. In those cases it would have to be @intrinsic("name of the intrinsic"). Right now we can write C++ code like this: switch (recognized_kind()) { case MethodRecognizer::kSmth: case MethodRecognizer::kSmthElse: break; } If we start to relying on strings - this code will become less readable (or alternatively you would have to map strings into C++ enumeration which would require a list quite list one of the above). To be honest aesthetically I like annotations, so I would like to use them to replace these lists, but that does not really solve anything or improve much. Even more: there is really no fundamental difference between having an annotation and a list like that, so I don't really understand what bothers you about these lists. > (dynamism is better, determine everything at runtime or from magic lists) Annotation would be no less magic (and not available to the user code anyways).
- mezoni 12y ago>> so I don't really understand what bothers you about these lists. This approach does not allow me to use annotations (or other way) for specifying that my own "native" methods in "native extension" are required some attention. You use for such attention these lists. Eg. I have the following methods (via macro defs) in my "native extension": ========================= UNSAFE_READ_INT(8, int8_t) UNSAFE_READ_INT(16, int16_t) UNSAFE_READ_INT(32, int32_t) UNSAFE_READ_INT(64, int64_t) // Skipped UNSAFE_READ_FLOAT(32, float) UNSAFE_READ_FLOAT(64, double) // Skipped ========================= These methods are very fast (in C++) but in fact Dart VM executes them (native methods) very SLOOOOOOOOOOOWWWWWWWWWWWW... See my question on stack overflow: ========================= Why native wrapped functions in Dart are such heavyweight in comparison with “DEFINE NATIVE ENTRY” functions that are very lightweight? http://stackoverflow.com/questions/21363429/why-native-wrapped-functions-in-dart-are-such-heavyweight-in-comparison-with-de http://stackoverflow.com/questions/21363429/why-native-wrapp... ========================= - Dart developers does not like annotation - Dart VM does not uses annotation - Dart VM does not uses type annotation - Dart VM executes custom "native (which in fact are very fast)" methods very slow This is what is means for me that Dart VM is not a very well balanced for high performance. P.S. This is why "I bothers you about these lists". Because they are in some cases the only way to improve performance.
- mraleph 12y ago> I have the following methods (via macro defs) in my "native extension": Can't you just expose the data you are reading as an external typed data array to the Dart code? That would remove any need for those methods. > - Dart developers does not like annotation I like annotations! > - Dart VM executes custom "native (which in fact are very fast)" methods very slow This concern is very valid: it is true that transition between Dart code and native methods is too heavyweight and as a developer you have no way to fix it yourself. We had plans to fix it eventually - but they never been very high on the list of things. Did you file a bug for the slowness of your native extension?
- mezoni 12y ago