| Index: src/runtime.cc
|
| diff --git a/src/runtime.cc b/src/runtime.cc
|
| index 306042f4ea65601e0e4ed3c5fe57ee08937be87c..3596add429ee9335994c525ad946be41648d6842 100644
|
| --- a/src/runtime.cc
|
| +++ b/src/runtime.cc
|
| @@ -633,14 +633,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreatePrivateSymbol) {
|
| }
|
|
|
|
|
| -RUNTIME_FUNCTION(MaybeObject*, Runtime_NewSymbolWrapper) {
|
| - ASSERT(args.length() == 1);
|
| - CONVERT_ARG_CHECKED(Symbol, symbol, 0);
|
| - return symbol->ToObject(isolate);
|
| -}
|
| -
|
| -
|
| -RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolDescription) {
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolName) {
|
| SealHandleScope shs(isolate);
|
| ASSERT(args.length() == 1);
|
| CONVERT_ARG_CHECKED(Symbol, symbol, 0);
|
| @@ -6548,6 +6541,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToUpperCase) {
|
| }
|
|
|
|
|
| +static inline bool IsTrimWhiteSpace(unibrow::uchar c) {
|
| + return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff;
|
| +}
|
| +
|
| +
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) {
|
| HandleScope scope(isolate);
|
| ASSERT(args.length() == 3);
|
| @@ -6560,19 +6558,15 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) {
|
| int length = string->length();
|
|
|
| int left = 0;
|
| - UnicodeCache* unicode_cache = isolate->unicode_cache();
|
| if (trimLeft) {
|
| - while (left < length &&
|
| - unicode_cache->IsWhiteSpaceOrLineTerminator(string->Get(left))) {
|
| + while (left < length && IsTrimWhiteSpace(string->Get(left))) {
|
| left++;
|
| }
|
| }
|
|
|
| int right = length;
|
| if (trimRight) {
|
| - while (right > left &&
|
| - unicode_cache->IsWhiteSpaceOrLineTerminator(
|
| - string->Get(right - 1))) {
|
| + while (right > left && IsTrimWhiteSpace(string->Get(right - 1))) {
|
| right--;
|
| }
|
| }
|
| @@ -7654,110 +7648,33 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) {
|
| }
|
|
|
|
|
| -#define RUNTIME_UNARY_MATH(NAME) \
|
| -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_##NAME) { \
|
| - SealHandleScope shs(isolate); \
|
| - ASSERT(args.length() == 1); \
|
| - isolate->counters()->math_##NAME()->Increment(); \
|
| - CONVERT_DOUBLE_ARG_CHECKED(x, 0); \
|
| - return isolate->heap()->AllocateHeapNumber(std::NAME(x)); \
|
| -}
|
| -
|
| -RUNTIME_UNARY_MATH(acos)
|
| -RUNTIME_UNARY_MATH(asin)
|
| -RUNTIME_UNARY_MATH(atan)
|
| -RUNTIME_UNARY_MATH(log)
|
| -#undef RUNTIME_UNARY_MATH
|
| -
|
| -
|
| -// Cube root approximation, refer to: http://metamerist.com/cbrt/cbrt.htm
|
| -// Using initial approximation adapted from Kahan's cbrt and 4 iterations
|
| -// of Newton's method.
|
| -inline double CubeRootNewtonIteration(double approx, double x) {
|
| - return (1.0 / 3.0) * (x / (approx * approx) + 2 * approx);
|
| -}
|
| -
|
| -
|
| -inline double CubeRoot(double x) {
|
| - static const uint64_t magic = V8_2PART_UINT64_C(0x2A9F7893, 00000000);
|
| - uint64_t xhigh = double_to_uint64(x);
|
| - double approx = uint64_to_double(xhigh / 3 + magic);
|
| -
|
| - approx = CubeRootNewtonIteration(approx, x);
|
| - approx = CubeRootNewtonIteration(approx, x);
|
| - approx = CubeRootNewtonIteration(approx, x);
|
| - return CubeRootNewtonIteration(approx, x);
|
| -}
|
| -
|
| -
|
| -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cbrt) {
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) {
|
| SealHandleScope shs(isolate);
|
| ASSERT(args.length() == 1);
|
| + isolate->counters()->math_acos()->Increment();
|
| +
|
| CONVERT_DOUBLE_ARG_CHECKED(x, 0);
|
| - if (x == 0 || std::isinf(x)) return args[0];
|
| - double result = (x > 0) ? CubeRoot(x) : -CubeRoot(-x);
|
| - return isolate->heap()->AllocateHeapNumber(result);
|
| + return isolate->heap()->AllocateHeapNumber(std::acos(x));
|
| }
|
|
|
|
|
| -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log1p) {
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) {
|
| SealHandleScope shs(isolate);
|
| ASSERT(args.length() == 1);
|
| - CONVERT_DOUBLE_ARG_CHECKED(x, 0);
|
| + isolate->counters()->math_asin()->Increment();
|
|
|
| - double x_abs = std::fabs(x);
|
| - // Use Taylor series to approximate. With y = x + 1;
|
| - // log(y) at 1 == log(1) + log'(1)(y-1)/1! + log''(1)(y-1)^2/2! + ...
|
| - // == 0 + x - x^2/2 + x^3/3 ...
|
| - // The closer x is to 0, the fewer terms are required.
|
| - static const double threshold_2 = 1.0 / 0x00800000;
|
| - static const double threshold_3 = 1.0 / 0x00008000;
|
| - static const double threshold_7 = 1.0 / 0x00000080;
|
| -
|
| - double result;
|
| - if (x_abs < threshold_2) {
|
| - result = x * (1.0/1.0 - x * 1.0/2.0);
|
| - } else if (x_abs < threshold_3) {
|
| - result = x * (1.0/1.0 - x * (1.0/2.0 - x * (1.0/3.0)));
|
| - } else if (x_abs < threshold_7) {
|
| - result = x * (1.0/1.0 - x * (1.0/2.0 - x * (
|
| - 1.0/3.0 - x * (1.0/4.0 - x * (
|
| - 1.0/5.0 - x * (1.0/6.0 - x * (
|
| - 1.0/7.0)))))));
|
| - } else { // Use regular log if not close enough to 0.
|
| - result = std::log(1.0 + x);
|
| - }
|
| - return isolate->heap()->AllocateHeapNumber(result);
|
| + CONVERT_DOUBLE_ARG_CHECKED(x, 0);
|
| + return isolate->heap()->AllocateHeapNumber(std::asin(x));
|
| }
|
|
|
|
|
| -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_expm1) {
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) {
|
| SealHandleScope shs(isolate);
|
| ASSERT(args.length() == 1);
|
| - CONVERT_DOUBLE_ARG_CHECKED(x, 0);
|
| + isolate->counters()->math_atan()->Increment();
|
|
|
| - double x_abs = std::fabs(x);
|
| - // Use Taylor series to approximate.
|
| - // exp(x) - 1 at 0 == -1 + exp(0) + exp'(0)*x/1! + exp''(0)*x^2/2! + ...
|
| - // == x/1! + x^2/2! + x^3/3! + ...
|
| - // The closer x is to 0, the fewer terms are required.
|
| - static const double threshold_2 = 1.0 / 0x00400000;
|
| - static const double threshold_3 = 1.0 / 0x00004000;
|
| - static const double threshold_6 = 1.0 / 0x00000040;
|
| -
|
| - double result;
|
| - if (x_abs < threshold_2) {
|
| - result = x * (1.0/1.0 + x * (1.0/2.0));
|
| - } else if (x_abs < threshold_3) {
|
| - result = x * (1.0/1.0 + x * (1.0/2.0 + x * (1.0/6.0)));
|
| - } else if (x_abs < threshold_6) {
|
| - result = x * (1.0/1.0 + x * (1.0/2.0 + x * (
|
| - 1.0/6.0 + x * (1.0/24.0 + x * (
|
| - 1.0/120.0 + x * (1.0/720.0))))));
|
| - } else { // Use regular exp if not close enough to 0.
|
| - result = std::exp(x) - 1.0;
|
| - }
|
| - return isolate->heap()->AllocateHeapNumber(result);
|
| + CONVERT_DOUBLE_ARG_CHECKED(x, 0);
|
| + return isolate->heap()->AllocateHeapNumber(std::atan(x));
|
| }
|
|
|
|
|
| @@ -7808,6 +7725,16 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) {
|
| }
|
|
|
|
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) {
|
| + SealHandleScope shs(isolate);
|
| + ASSERT(args.length() == 1);
|
| + isolate->counters()->math_log()->Increment();
|
| +
|
| + CONVERT_DOUBLE_ARG_CHECKED(x, 0);
|
| + return isolate->heap()->AllocateHeapNumber(std::log(x));
|
| +}
|
| +
|
| +
|
| // Slow version of Math.pow. We check for fast paths for special cases.
|
| // Used if SSE2/VFP3 is not available.
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) {
|
| @@ -7903,16 +7830,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) {
|
| }
|
|
|
|
|
| -RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_fround) {
|
| - SealHandleScope shs(isolate);
|
| - ASSERT(args.length() == 1);
|
| -
|
| - CONVERT_DOUBLE_ARG_CHECKED(x, 0);
|
| - float xf = static_cast<float>(x);
|
| - return isolate->heap()->AllocateHeapNumber(xf);
|
| -}
|
| -
|
| -
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) {
|
| SealHandleScope shs(isolate);
|
| ASSERT(args.length() == 2);
|
| @@ -8558,7 +8475,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearFunctionTypeFeedback) {
|
| Code* unoptimized = function->shared()->code();
|
| if (unoptimized->kind() == Code::FUNCTION) {
|
| unoptimized->ClearInlineCaches();
|
| - unoptimized->ClearTypeFeedbackInfo(isolate->heap());
|
| + unoptimized->ClearTypeFeedbackCells(isolate->heap());
|
| }
|
| return isolate->heap()->undefined_value();
|
| }
|
| @@ -14349,11 +14266,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) {
|
|
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) {
|
| SealHandleScope shs(isolate);
|
| - ASSERT(args.length() == 1);
|
| - CONVERT_SMI_ARG_CHECKED(message_id, 0);
|
| - const char* message = GetBailoutReason(
|
| - static_cast<BailoutReason>(message_id));
|
| - OS::PrintError("abort: %s\n", message);
|
| + ASSERT(args.length() == 2);
|
| + OS::PrintError("abort: %s\n",
|
| + reinterpret_cast<char*>(args[0]) + args.smi_at(1));
|
| isolate->PrintStack(stderr);
|
| OS::Abort();
|
| UNREACHABLE();
|
| @@ -14682,21 +14597,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetMicrotaskPending) {
|
| }
|
|
|
|
|
| -RUNTIME_FUNCTION(MaybeObject*, Runtime_RunMicrotasks) {
|
| - HandleScope scope(isolate);
|
| - ASSERT(args.length() == 0);
|
| - Execution::RunMicrotasks(isolate);
|
| - return isolate->heap()->undefined_value();
|
| -}
|
| -
|
| -
|
| -RUNTIME_FUNCTION(MaybeObject*, Runtime_GetMicrotaskState) {
|
| - SealHandleScope shs(isolate);
|
| - ASSERT(args.length() == 0);
|
| - return isolate->heap()->microtask_state();
|
| -}
|
| -
|
| -
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_GetObservationState) {
|
| SealHandleScope shs(isolate);
|
| ASSERT(args.length() == 0);
|
|
|