Revision: 24471
Author: [email protected]
Date: Wed Oct 8 14:42:31 2014 UTC
Log: Remove premordial math functions from native context.
[email protected]
Review URL: https://codereview.chromium.org/635323002
https://code.google.com/p/v8/source/detail?r=24471
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/bootstrapper.cc
/branches/bleeding_edge/src/compiler/typer.cc
/branches/bleeding_edge/src/contexts.h
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/test/unittests/compiler/js-builtin-reducer-unittest.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Wed Oct 8 08:17:04 2014 UTC
+++ /branches/bleeding_edge/include/v8.h Wed Oct 8 14:42:31 2014 UTC
@@ -5909,7 +5909,7 @@
static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
static const int kContextHeaderSize = 2 * kApiPointerSize;
- static const int kContextEmbedderDataIndex = 95;
+ static const int kContextEmbedderDataIndex = 76;
static const int kFullStringRepresentationMask = 0x07;
static const int kStringEncodingMask = 0x4;
static const int kExternalTwoByteRepresentationTag = 0x02;
=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Wed Oct 8 09:01:43 2014 UTC
+++ /branches/bleeding_edge/src/bootstrapper.cc Wed Oct 8 14:42:31 2014 UTC
@@ -1505,12 +1505,6 @@
.ToHandleChecked();
\
native_context()->set_##var(Type::cast(*var##_native));
-#define INSTALL_NATIVE_MATH(name) \
- { \
- Handle<Object> fun = \
- ResolveBuiltinIdHolder(native_context(), "Math." #name); \
- native_context()->set_math_##name##_fun(JSFunction::cast(*fun)); \
- }
void Genesis::InstallNativeFunctions() {
HandleScope scope(isolate());
@@ -1557,26 +1551,6 @@
INSTALL_NATIVE(Symbol, "symbolIterator", iterator_symbol);
INSTALL_NATIVE(Symbol, "symbolUnscopables", unscopables_symbol);
INSTALL_NATIVE(JSFunction, "ArrayValues", array_values_iterator);
-
- INSTALL_NATIVE_MATH(abs)
- INSTALL_NATIVE_MATH(acos)
- INSTALL_NATIVE_MATH(asin)
- INSTALL_NATIVE_MATH(atan)
- INSTALL_NATIVE_MATH(atan2)
- INSTALL_NATIVE_MATH(ceil)
- INSTALL_NATIVE_MATH(cos)
- INSTALL_NATIVE_MATH(exp)
- INSTALL_NATIVE_MATH(floor)
- INSTALL_NATIVE_MATH(imul)
- INSTALL_NATIVE_MATH(log)
- INSTALL_NATIVE_MATH(max)
- INSTALL_NATIVE_MATH(min)
- INSTALL_NATIVE_MATH(pow)
- INSTALL_NATIVE_MATH(random)
- INSTALL_NATIVE_MATH(round)
- INSTALL_NATIVE_MATH(sin)
- INSTALL_NATIVE_MATH(sqrt)
- INSTALL_NATIVE_MATH(tan)
}
=======================================
--- /branches/bleeding_edge/src/compiler/typer.cc Wed Oct 1 11:08:37 2014
UTC
+++ /branches/bleeding_edge/src/compiler/typer.cc Wed Oct 8 14:42:31 2014
UTC
@@ -824,62 +824,69 @@
// Heap constants.
Type* Typer::Visitor::TypeConstant(Handle<Object> value) {
- if (value->IsJSFunction() && JSFunction::cast(*value)->IsBuiltin() &&
- !context().is_null()) {
- Handle<Context> native =
- handle(context().ToHandleChecked()->native_context(), isolate());
- if (*value == native->math_abs_fun()) {
- return typer_->number_fun1_; // TODO(rossberg): can't express
overloading
- } else if (*value == native->math_acos_fun()) {
- return typer_->number_fun1_;
- } else if (*value == native->math_asin_fun()) {
- return typer_->number_fun1_;
- } else if (*value == native->math_atan_fun()) {
- return typer_->number_fun1_;
- } else if (*value == native->math_atan2_fun()) {
- return typer_->number_fun2_;
- } else if (*value == native->math_ceil_fun()) {
- return typer_->weakint_fun1_;
- } else if (*value == native->math_cos_fun()) {
- return typer_->number_fun1_;
- } else if (*value == native->math_exp_fun()) {
- return typer_->number_fun1_;
- } else if (*value == native->math_floor_fun()) {
- return typer_->weakint_fun1_;
- } else if (*value == native->math_imul_fun()) {
- return typer_->imul_fun_;
- } else if (*value == native->math_log_fun()) {
- return typer_->number_fun1_;
- } else if (*value == native->math_pow_fun()) {
- return typer_->number_fun2_;
- } else if (*value == native->math_random_fun()) {
- return typer_->random_fun_;
- } else if (*value == native->math_round_fun()) {
- return typer_->weakint_fun1_;
- } else if (*value == native->math_sin_fun()) {
- return typer_->number_fun1_;
- } else if (*value == native->math_sqrt_fun()) {
- return typer_->number_fun1_;
- } else if (*value == native->math_tan_fun()) {
- return typer_->number_fun1_;
- } else if (*value == native->array_buffer_fun()) {
- return typer_->array_buffer_fun_;
- } else if (*value == native->int8_array_fun()) {
- return typer_->int8_array_fun_;
- } else if (*value == native->int16_array_fun()) {
- return typer_->int16_array_fun_;
- } else if (*value == native->int32_array_fun()) {
- return typer_->int32_array_fun_;
- } else if (*value == native->uint8_array_fun()) {
- return typer_->uint8_array_fun_;
- } else if (*value == native->uint16_array_fun()) {
- return typer_->uint16_array_fun_;
- } else if (*value == native->uint32_array_fun()) {
- return typer_->uint32_array_fun_;
- } else if (*value == native->float32_array_fun()) {
- return typer_->float32_array_fun_;
- } else if (*value == native->float64_array_fun()) {
- return typer_->float64_array_fun_;
+ if (value->IsJSFunction()) {
+ if (JSFunction::cast(*value)->shared()->HasBuiltinFunctionId()) {
+ switch (JSFunction::cast(*value)->shared()->builtin_function_id()) {
+ // TODO(rossberg): can't express overloading
+ case kMathAbs:
+ return typer_->number_fun1_;
+ case kMathAcos:
+ return typer_->number_fun1_;
+ case kMathAsin:
+ return typer_->number_fun1_;
+ case kMathAtan:
+ return typer_->number_fun1_;
+ case kMathAtan2:
+ return typer_->number_fun2_;
+ case kMathCeil:
+ return typer_->weakint_fun1_;
+ case kMathCos:
+ return typer_->number_fun1_;
+ case kMathExp:
+ return typer_->number_fun1_;
+ case kMathFloor:
+ return typer_->weakint_fun1_;
+ case kMathImul:
+ return typer_->imul_fun_;
+ case kMathLog:
+ return typer_->number_fun1_;
+ case kMathPow:
+ return typer_->number_fun2_;
+ case kMathRandom:
+ return typer_->random_fun_;
+ case kMathRound:
+ return typer_->weakint_fun1_;
+ case kMathSin:
+ return typer_->number_fun1_;
+ case kMathSqrt:
+ return typer_->number_fun1_;
+ case kMathTan:
+ return typer_->number_fun1_;
+ default:
+ break;
+ }
+ } else if (JSFunction::cast(*value)->IsBuiltin()
&& !context().is_null()) {
+ Handle<Context> native =
+ handle(context().ToHandleChecked()->native_context(), isolate());
+ if (*value == native->array_buffer_fun()) {
+ return typer_->array_buffer_fun_;
+ } else if (*value == native->int8_array_fun()) {
+ return typer_->int8_array_fun_;
+ } else if (*value == native->int16_array_fun()) {
+ return typer_->int16_array_fun_;
+ } else if (*value == native->int32_array_fun()) {
+ return typer_->int32_array_fun_;
+ } else if (*value == native->uint8_array_fun()) {
+ return typer_->uint8_array_fun_;
+ } else if (*value == native->uint16_array_fun()) {
+ return typer_->uint16_array_fun_;
+ } else if (*value == native->uint32_array_fun()) {
+ return typer_->uint32_array_fun_;
+ } else if (*value == native->float32_array_fun()) {
+ return typer_->float32_array_fun_;
+ } else if (*value == native->float64_array_fun()) {
+ return typer_->float64_array_fun_;
+ }
}
}
return Type::Constant(value, zone());
=======================================
--- /branches/bleeding_edge/src/contexts.h Tue Sep 30 15:40:08 2014 UTC
+++ /branches/bleeding_edge/src/contexts.h Wed Oct 8 14:42:31 2014 UTC
@@ -101,25 +101,6 @@
V(GLOBAL_EVAL_FUN_INDEX, JSFunction,
global_eval_fun) \
V(INSTANTIATE_FUN_INDEX, JSFunction,
instantiate_fun) \
V(CONFIGURE_INSTANCE_FUN_INDEX, JSFunction,
configure_instance_fun) \
- V(MATH_ABS_FUN_INDEX, JSFunction,
math_abs_fun) \
- V(MATH_ACOS_FUN_INDEX, JSFunction,
math_acos_fun) \
- V(MATH_ASIN_FUN_INDEX, JSFunction,
math_asin_fun) \
- V(MATH_ATAN_FUN_INDEX, JSFunction,
math_atan_fun) \
- V(MATH_ATAN2_FUN_INDEX, JSFunction,
math_atan2_fun) \
- V(MATH_CEIL_FUN_INDEX, JSFunction,
math_ceil_fun) \
- V(MATH_COS_FUN_INDEX, JSFunction,
math_cos_fun) \
- V(MATH_EXP_FUN_INDEX, JSFunction,
math_exp_fun) \
- V(MATH_FLOOR_FUN_INDEX, JSFunction,
math_floor_fun) \
- V(MATH_IMUL_FUN_INDEX, JSFunction,
math_imul_fun) \
- V(MATH_LOG_FUN_INDEX, JSFunction,
math_log_fun) \
- V(MATH_MAX_FUN_INDEX, JSFunction,
math_max_fun) \
- V(MATH_MIN_FUN_INDEX, JSFunction,
math_min_fun) \
- V(MATH_POW_FUN_INDEX, JSFunction,
math_pow_fun) \
- V(MATH_RANDOM_FUN_INDEX, JSFunction,
math_random_fun) \
- V(MATH_ROUND_FUN_INDEX, JSFunction,
math_round_fun) \
- V(MATH_SIN_FUN_INDEX, JSFunction,
math_sin_fun) \
- V(MATH_SQRT_FUN_INDEX, JSFunction,
math_sqrt_fun) \
- V(MATH_TAN_FUN_INDEX, JSFunction,
math_tan_fun) \
V(ARRAY_BUFFER_FUN_INDEX, JSFunction,
array_buffer_fun) \
V(UINT8_ARRAY_FUN_INDEX, JSFunction,
uint8_array_fun) \
V(INT8_ARRAY_FUN_INDEX, JSFunction,
int8_array_fun) \
@@ -312,25 +293,6 @@
GLOBAL_EVAL_FUN_INDEX,
INSTANTIATE_FUN_INDEX,
CONFIGURE_INSTANCE_FUN_INDEX,
- MATH_ABS_FUN_INDEX,
- MATH_ACOS_FUN_INDEX,
- MATH_ASIN_FUN_INDEX,
- MATH_ATAN_FUN_INDEX,
- MATH_ATAN2_FUN_INDEX,
- MATH_CEIL_FUN_INDEX,
- MATH_COS_FUN_INDEX,
- MATH_EXP_FUN_INDEX,
- MATH_FLOOR_FUN_INDEX,
- MATH_IMUL_FUN_INDEX,
- MATH_LOG_FUN_INDEX,
- MATH_MAX_FUN_INDEX,
- MATH_MIN_FUN_INDEX,
- MATH_POW_FUN_INDEX,
- MATH_RANDOM_FUN_INDEX,
- MATH_ROUND_FUN_INDEX,
- MATH_SIN_FUN_INDEX,
- MATH_SQRT_FUN_INDEX,
- MATH_TAN_FUN_INDEX,
ARRAY_BUFFER_FUN_INDEX,
UINT8_ARRAY_FUN_INDEX,
INT8_ARRAY_FUN_INDEX,
=======================================
--- /branches/bleeding_edge/src/objects.h Wed Oct 1 13:14:14 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Wed Oct 8 14:42:31 2014 UTC
@@ -6548,6 +6548,7 @@
V(String.prototype, charCodeAt, StringCharCodeAt) \
V(String.prototype, charAt, StringCharAt) \
V(String, fromCharCode, StringFromCharCode) \
+ V(Math, random, MathRandom) \
V(Math, floor, MathFloor) \
V(Math, round, MathRound) \
V(Math, ceil, MathCeil) \
@@ -6558,6 +6559,13 @@
V(Math, pow, MathPow) \
V(Math, max, MathMax) \
V(Math, min, MathMin) \
+ V(Math, cos, MathCos) \
+ V(Math, sin, MathSin) \
+ V(Math, tan, MathTan) \
+ V(Math, acos, MathAcos) \
+ V(Math, asin, MathAsin) \
+ V(Math, atan, MathAtan) \
+ V(Math, atan2, MathAtan2) \
V(Math, imul, MathImul) \
V(Math, clz32, MathClz32) \
V(Math, fround, MathFround)
=======================================
---
/branches/bleeding_edge/test/unittests/compiler/js-builtin-reducer-unittest.cc
Tue Oct 7 07:36:21 2014 UTC
+++
/branches/bleeding_edge/test/unittests/compiler/js-builtin-reducer-unittest.cc
Wed Oct 8 14:42:31 2014 UTC
@@ -34,6 +34,18 @@
NodeProperties::SetBounds(n, Bounds(Type::None(), t));
return n;
}
+
+ Handle<JSFunction> MathFunction(const char* name) {
+ Handle<Object> m =
+ JSObject::GetProperty(isolate()->global_object(),
+
isolate()->factory()->NewStringFromAsciiChecked(
+ "Math")).ToHandleChecked();
+ Handle<JSFunction> f = Handle<JSFunction>::cast(
+ JSObject::GetProperty(
+ m, isolate()->factory()->NewStringFromAsciiChecked(name))
+ .ToHandleChecked());
+ return f;
+ }
JSOperatorBuilder* javascript() { return &javascript_; }
@@ -60,7 +72,7 @@
TEST_F(JSBuiltinReducerTest, MathAbs) {
- Handle<JSFunction> f(isolate()->context()->math_abs_fun());
+ Handle<JSFunction> f = MathFunction("abs");
TRACED_FOREACH(Type*, t0, kNumberTypes) {
Node* p0 = Parameter(t0, 0);
@@ -94,7 +106,7 @@
TEST_F(JSBuiltinReducerTest, MathSqrt) {
- Handle<JSFunction> f(isolate()->context()->math_sqrt_fun());
+ Handle<JSFunction> f = MathFunction("sqrt");
TRACED_FOREACH(Type*, t0, kNumberTypes) {
Node* p0 = Parameter(t0, 0);
@@ -115,7 +127,7 @@
TEST_F(JSBuiltinReducerTest, MathMax0) {
- Handle<JSFunction> f(isolate()->context()->math_max_fun());
+ Handle<JSFunction> f = MathFunction("max");
Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f));
Node* call =
@@ -129,7 +141,7 @@
TEST_F(JSBuiltinReducerTest, MathMax1) {
- Handle<JSFunction> f(isolate()->context()->math_max_fun());
+ Handle<JSFunction> f = MathFunction("max");
TRACED_FOREACH(Type*, t0, kNumberTypes) {
Node* p0 = Parameter(t0, 0);
@@ -146,7 +158,7 @@
TEST_F(JSBuiltinReducerTest, MathMax2) {
- Handle<JSFunction> f(isolate()->context()->math_max_fun());
+ Handle<JSFunction> f = MathFunction("max");
TRACED_FOREACH(Type*, t0, kNumberTypes) {
TRACED_FOREACH(Type*, t1, kNumberTypes) {
@@ -182,7 +194,7 @@
TEST_F(JSBuiltinReducerTest, MathImul) {
- Handle<JSFunction> f(isolate()->context()->math_imul_fun());
+ Handle<JSFunction> f = MathFunction("imul");
TRACED_FOREACH(Type*, t0, kNumberTypes) {
TRACED_FOREACH(Type*, t1, kNumberTypes) {
@@ -211,13 +223,7 @@
TEST_F(JSBuiltinReducerTest, MathFround) {
- Handle<Object> m =
- JSObject::GetProperty(isolate()->global_object(),
-
isolate()->factory()->NewStringFromAsciiChecked(
- "Math")).ToHandleChecked();
- Handle<JSFunction> f = Handle<JSFunction>::cast(
- JSObject::GetProperty(m,
isolate()->factory()->NewStringFromAsciiChecked(
- "fround")).ToHandleChecked());
+ Handle<JSFunction> f = MathFunction("fround");
TRACED_FOREACH(Type*, t0, kNumberTypes) {
Node* p0 = Parameter(t0, 0);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.