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

Side by Side Diff: src/builtins.cc

Issue 1731543004: [builtins] Migrate a bunch of Math builtins to C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins.h ('k') | src/compiler/typer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/builtins.h" 5 #include "src/builtins.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 CompileString(handle(target->native_context(), isolate), 1937 CompileString(handle(target->native_context(), isolate),
1938 Handle<String>::cast(x), NO_PARSE_RESTRICTION)); 1938 Handle<String>::cast(x), NO_PARSE_RESTRICTION));
1939 Handle<Object> result; 1939 Handle<Object> result;
1940 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1940 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1941 isolate, result, 1941 isolate, result,
1942 Execution::Call(isolate, function, target_global_proxy, 0, nullptr)); 1942 Execution::Call(isolate, function, target_global_proxy, 0, nullptr));
1943 return *result; 1943 return *result;
1944 } 1944 }
1945 1945
1946 1946
1947 // -----------------------------------------------------------------------------
1948 // ES6 section 20.2.2 Function Properties of the Math Object
1949
1950
1951 // ES6 section 20.2.2.2 Math.acos ( x )
1952 BUILTIN(MathAcos) {
1953 HandleScope scope(isolate);
1954 DCHECK_EQ(2, args.length());
1955 Handle<Object> x = args.at<Object>(1);
1956 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, x, Object::ToNumber(x));
1957 return *isolate->factory()->NewHeapNumber(std::acos(x->Number()));
1958 }
1959
1960
1961 // ES6 section 20.2.2.4 Math.asin ( x )
1962 BUILTIN(MathAsin) {
1963 HandleScope scope(isolate);
1964 DCHECK_EQ(2, args.length());
1965 Handle<Object> x = args.at<Object>(1);
1966 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, x, Object::ToNumber(x));
1967 return *isolate->factory()->NewHeapNumber(std::asin(x->Number()));
1968 }
1969
1970
1971 // ES6 section 20.2.2.6 Math.atan ( x )
1972 BUILTIN(MathAtan) {
1973 HandleScope scope(isolate);
1974 DCHECK_EQ(2, args.length());
1975 Handle<Object> x = args.at<Object>(1);
1976 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, x, Object::ToNumber(x));
1977 return *isolate->factory()->NewHeapNumber(std::atan(x->Number()));
1978 }
1979
1980
1981 // ES6 section 20.2.2.17 Math.fround ( x )
1982 BUILTIN(MathFround) {
1983 HandleScope scope(isolate);
1984 DCHECK_EQ(2, args.length());
1985 Handle<Object> x = args.at<Object>(1);
1986 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, x, Object::ToNumber(x));
1987 float x32 = DoubleToFloat32(x->Number());
1988 return *isolate->factory()->NewNumber(x32);
1989 }
1990
1991
1992 // ES6 section 20.2.2.19 Math.imul ( x, y )
1993 BUILTIN(MathImul) {
1994 HandleScope scope(isolate);
1995 DCHECK_EQ(3, args.length());
1996 Handle<Object> x = args.at<Object>(1);
1997 Handle<Object> y = args.at<Object>(2);
1998 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, x, Object::ToNumber(x));
1999 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, y, Object::ToNumber(y));
2000 int product = static_cast<int>(NumberToUint32(*x) * NumberToUint32(*y));
2001 return *isolate->factory()->NewNumberFromInt(product);
2002 }
2003
2004
2005 // -----------------------------------------------------------------------------
2006 // ES6 section 26.1 The Reflect Object
2007
2008
1947 // ES6 section 26.1.3 Reflect.defineProperty 2009 // ES6 section 26.1.3 Reflect.defineProperty
1948 BUILTIN(ReflectDefineProperty) { 2010 BUILTIN(ReflectDefineProperty) {
1949 HandleScope scope(isolate); 2011 HandleScope scope(isolate);
1950 DCHECK_EQ(4, args.length()); 2012 DCHECK_EQ(4, args.length());
1951 Handle<Object> target = args.at<Object>(1); 2013 Handle<Object> target = args.at<Object>(1);
1952 Handle<Object> key = args.at<Object>(2); 2014 Handle<Object> key = args.at<Object>(2);
1953 Handle<Object> attributes = args.at<Object>(3); 2015 Handle<Object> attributes = args.at<Object>(3);
1954 2016
1955 if (!target->IsJSReceiver()) { 2017 if (!target->IsJSReceiver()) {
1956 THROW_NEW_ERROR_RETURN_FAILURE( 2018 THROW_NEW_ERROR_RETURN_FAILURE(
(...skipping 2493 matching lines...) Expand 10 before | Expand all | Expand 10 after
4450 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 4512 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
4451 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 4513 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
4452 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 4514 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
4453 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 4515 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
4454 #undef DEFINE_BUILTIN_ACCESSOR_C 4516 #undef DEFINE_BUILTIN_ACCESSOR_C
4455 #undef DEFINE_BUILTIN_ACCESSOR_A 4517 #undef DEFINE_BUILTIN_ACCESSOR_A
4456 4518
4457 4519
4458 } // namespace internal 4520 } // namespace internal
4459 } // namespace v8 4521 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/compiler/typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698