dart-sdk/runtime/vm/double_conversion.h
Alexander Markov 307bc3ef2c [vm] Faster double.toInt() in AOT mode
double.toInt() micro-benchmark on AOT/x64:
Before: BenchToInt(RunTime): 438.67258771929824 us.
After:  BenchToInt(RunTime): 118.8603434955726 us.

double.floor() micro-benchmark on AOT/x64:
Before: BenchFloor(RunTime): 537.2132688691916 us.
After:  BenchFloor(RunTime): 321.2052352657781 us.

TEST=ci
Issue https://github.com/dart-lang/sdk/issues/46876
Issue https://github.com/dart-lang/sdk/issues/46650

Change-Id: Id37c827bceb7f374ae5b91b36871ccf0d9e92441
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211620
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-09-01 16:57:59 +00:00

31 lines
1,009 B
C++

// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_VM_DOUBLE_CONVERSION_H_
#define RUNTIME_VM_DOUBLE_CONVERSION_H_
#include "vm/allocation.h"
#include "vm/globals.h"
#include "vm/object.h"
namespace dart {
struct DoubleToStringConstants : AllStatic {
static char const kExponentChar;
static const char* const kInfinitySymbol;
static const char* const kNaNSymbol;
};
void DoubleToCString(double d, char* buffer, int buffer_size);
StringPtr DoubleToStringAsFixed(double d, int fraction_digits);
StringPtr DoubleToStringAsExponential(double d, int fraction_digits);
StringPtr DoubleToStringAsPrecision(double d, int precision);
bool CStringToDouble(const char* str, intptr_t length, double* result);
IntegerPtr DoubleToInteger(Zone* zone, double val);
} // namespace dart
#endif // RUNTIME_VM_DOUBLE_CONVERSION_H_