Commit 40d5a8c7 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[compiler] Make typer recognize calls of some standard constructors.

For instance, it now knows that Number(x) has type Number.

(In this particular case, we used to know that already due to
js-call-reduction of Number but that was recently disabled because
of BigInts.)

Bug: v8:6791
Change-Id: If5c57d46fc8448ca530a9ce7c9d14d63daa0f31c
Reviewed-on: https://chromium-review.googlesource.com/811264Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49909}
parent 42a7c0be
......@@ -1802,6 +1802,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> number_fun = InstallFunction(
global, "Number", JS_VALUE_TYPE, JSValue::kSize, 0,
isolate->initial_object_prototype(), Builtins::kNumberConstructor);
number_fun->shared()->set_builtin_function_id(kNumberConstructor);
number_fun->shared()->DontAdaptArguments();
number_fun->shared()->SetConstructStub(
*BUILTIN_CODE(isolate, NumberConstructor_ConstructStub));
......@@ -1946,6 +1947,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> string_fun = InstallFunction(
global, "String", JS_VALUE_TYPE, JSValue::kSize, 0,
isolate->initial_object_prototype(), Builtins::kStringConstructor);
string_fun->shared()->set_builtin_function_id(kStringConstructor);
string_fun->shared()->SetConstructStub(
*BUILTIN_CODE(isolate, StringConstructor_ConstructStub));
string_fun->shared()->DontAdaptArguments();
......@@ -2127,6 +2129,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> symbol_fun = InstallFunction(
global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, 0,
factory->the_hole_value(), Builtins::kSymbolConstructor);
symbol_fun->shared()->set_builtin_function_id(kSymbolConstructor);
symbol_fun->shared()->SetConstructStub(
*BUILTIN_CODE(isolate, SymbolConstructor_ConstructStub));
symbol_fun->shared()->set_length(0);
......@@ -4426,6 +4429,7 @@ void Genesis::InitializeGlobal_harmony_bigint() {
Handle<JSFunction> bigint_fun =
InstallFunction(global, "BigInt", JS_VALUE_TYPE, JSValue::kSize, 0,
factory->the_hole_value(), Builtins::kBigIntConstructor);
bigint_fun->shared()->set_builtin_function_id(kBigIntConstructor);
bigint_fun->shared()->DontAdaptArguments();
bigint_fun->shared()->SetConstructStub(
*BUILTIN_CODE(isolate(), BigIntConstructor_ConstructStub));
......
......@@ -1555,7 +1555,17 @@ Type* Typer::Visitor::JSCallTyper(Type* fun, Typer* t) {
case kDateGetTime:
return t->cache_.kJSDateValueType;
// Symbol functions.
case kSymbolConstructor:
return Type::Symbol();
// BigInt functions.
case kBigIntConstructor:
return Type::BigInt();
// Number functions.
case kNumberConstructor:
return Type::Number();
case kNumberIsFinite:
case kNumberIsInteger:
case kNumberIsNaN:
......@@ -1569,6 +1579,8 @@ Type* Typer::Visitor::JSCallTyper(Type* fun, Typer* t) {
return Type::String();
// String functions.
case kStringConstructor:
return Type::String();
case kStringCharCodeAt:
return Type::Union(Type::Range(0, kMaxUInt16, t->zone()), Type::NaN(),
t->zone());
......
......@@ -3201,6 +3201,7 @@ enum BuiltinFunctionId {
kArrayKeys,
kArrayValues,
kArrayIteratorNext,
kBigIntConstructor,
kMapSize,
kSetSize,
kMapIteratorNext,
......@@ -3217,6 +3218,8 @@ enum BuiltinFunctionId {
kGlobalUnescape,
kGlobalIsFinite,
kGlobalIsNaN,
kNumberConstructor,
kSymbolConstructor,
kTypedArrayByteLength,
kTypedArrayByteOffset,
kTypedArrayEntries,
......@@ -3225,6 +3228,7 @@ enum BuiltinFunctionId {
kTypedArrayToStringTag,
kTypedArrayValues,
kSharedArrayBufferByteLength,
kStringConstructor,
kStringIterator,
kStringIteratorNext,
kStringToLowerCaseIntl,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment