Commit 5af460f5 authored by Z Duong Nguyen-Huu's avatar Z Duong Nguyen-Huu Committed by Commit Bot

Reland Remove builtin-function-id in SFI

This is the reland of https://chromium-review.googlesource.com/c/v8/v8/+/1495898

builtin_function_id corresponded to BuiltinFunctionId (a manually maintained list of 'interesting' functionsmainly used during optimization). With this change, we nuke builtin-function-id in favor of builtin-id and 8 bits is freed up in SFI.

Bug: v8:6993
Change-Id: I7e1681cc2a95864c71ce8bdda075481310607166
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1506445Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#60131}
parent 1952508e
......@@ -2278,7 +2278,6 @@ v8_source_set("v8_base") {
"src/objects/arguments.h",
"src/objects/bigint.cc",
"src/objects/bigint.h",
"src/objects/builtin-function-id.h",
"src/objects/cell-inl.h",
"src/objects/cell.h",
"src/objects/code-inl.h",
......
......@@ -24,7 +24,6 @@
#include "src/microtask-queue.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/arguments.h"
#include "src/objects/builtin-function-id.h"
#include "src/objects/hash-table-inl.h"
#ifdef V8_INTL_SUPPORT
#include "src/objects/intl-objects.h"
......@@ -229,7 +228,6 @@ class Genesis {
Handle<JSFunction> InstallTypedArray(const char* name,
ElementsKind elements_kind);
bool InstallExtraNatives();
void InstallBuiltinFunctionIds();
void InitializeNormalizedMapCaches();
enum ExtensionTraversalState {
......@@ -454,13 +452,11 @@ V8_NOINLINE Handle<JSFunction> SimpleCreateFunction(Isolate* isolate,
V8_NOINLINE Handle<JSFunction> InstallFunctionWithBuiltinId(
Isolate* isolate, Handle<JSObject> base, const char* name,
Builtins::Name call, int len, bool adapt, BuiltinFunctionId id) {
DCHECK_NE(BuiltinFunctionId::kInvalidBuiltinFunctionId, id);
Builtins::Name call, int len, bool adapt) {
Handle<String> internalized_name =
isolate->factory()->InternalizeUtf8String(name);
Handle<JSFunction> fun =
SimpleCreateFunction(isolate, internalized_name, call, len, adapt);
fun->shared()->set_builtin_function_id(id);
JSObject::AddProperty(isolate, base, internalized_name, fun, DONT_ENUM);
return fun;
}
......@@ -482,15 +478,11 @@ V8_NOINLINE Handle<JSFunction> SimpleInstallFunction(
V8_NOINLINE Handle<JSFunction> InstallFunctionAtSymbol(
Isolate* isolate, Handle<JSObject> base, Handle<Symbol> symbol,
const char* symbol_string, Builtins::Name call, int len, bool adapt,
PropertyAttributes attrs = DONT_ENUM,
BuiltinFunctionId id = BuiltinFunctionId::kInvalidBuiltinFunctionId) {
PropertyAttributes attrs = DONT_ENUM) {
Handle<String> internalized_symbol =
isolate->factory()->InternalizeUtf8String(symbol_string);
Handle<JSFunction> fun =
SimpleCreateFunction(isolate, internalized_symbol, call, len, adapt);
if (id != BuiltinFunctionId::kInvalidBuiltinFunctionId) {
fun->shared()->set_builtin_function_id(id);
}
JSObject::AddProperty(isolate, base, symbol, fun, attrs);
return fun;
}
......@@ -548,15 +540,6 @@ V8_NOINLINE Handle<JSFunction> SimpleInstallGetter(Isolate* isolate,
return SimpleInstallGetter(isolate, base, name, name, call, adapt);
}
V8_NOINLINE Handle<JSFunction> SimpleInstallGetter(
Isolate* isolate, Handle<JSObject> base, Handle<Name> name,
Builtins::Name call, bool adapt, BuiltinFunctionId id) {
Handle<JSFunction> fun =
SimpleInstallGetter(isolate, base, name, call, adapt);
fun->shared()->set_builtin_function_id(id);
return fun;
}
V8_NOINLINE void InstallConstant(Isolate* isolate, Handle<JSObject> holder,
const char* name, Handle<Object> value) {
JSObject::AddProperty(
......@@ -1557,8 +1540,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
isolate_, prototype, factory->has_instance_symbol(),
"[Symbol.hasInstance]", Builtins::kFunctionPrototypeHasInstance, 1,
true,
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY),
BuiltinFunctionId::kFunctionHasInstance);
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY));
native_context()->set_function_has_instance(*has_instance);
// Complete setting up function maps.
......@@ -1627,8 +1609,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
isolate_, global, "Array", JS_ARRAY_TYPE, JSArray::kSize, 0,
isolate_->initial_object_prototype(), Builtins::kArrayConstructor);
array_function->shared()->DontAdaptArguments();
array_function->shared()->set_builtin_function_id(
BuiltinFunctionId::kArrayConstructor);
// This seems a bit hackish, but we need to make sure Array.length
// is 1.
......@@ -1716,18 +1696,16 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{ // Set up iterator-related properties.
Handle<JSFunction> keys = InstallFunctionWithBuiltinId(
isolate_, proto, "keys", Builtins::kArrayPrototypeKeys, 0, true,
BuiltinFunctionId::kArrayKeys);
isolate_, proto, "keys", Builtins::kArrayPrototypeKeys, 0, true);
native_context()->set_array_keys_iterator(*keys);
Handle<JSFunction> entries = InstallFunctionWithBuiltinId(
isolate_, proto, "entries", Builtins::kArrayPrototypeEntries, 0, true,
BuiltinFunctionId::kArrayEntries);
isolate_, proto, "entries", Builtins::kArrayPrototypeEntries, 0,
true);
native_context()->set_array_entries_iterator(*entries);
Handle<JSFunction> values = InstallFunctionWithBuiltinId(
isolate_, proto, "values", Builtins::kArrayPrototypeValues, 0, true,
BuiltinFunctionId::kArrayValues);
isolate_, proto, "values", Builtins::kArrayPrototypeValues, 0, true);
JSObject::AddProperty(isolate_, proto, factory->iterator_symbol(), values,
DONT_ENUM);
native_context()->set_array_values_iterator(*values);
......@@ -1790,8 +1768,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
factory->ArrayIterator_string());
InstallFunctionWithBuiltinId(isolate_, array_iterator_prototype, "next",
Builtins::kArrayIteratorPrototypeNext, 0, true,
BuiltinFunctionId::kArrayIteratorNext);
Builtins::kArrayIteratorPrototypeNext, 0,
true);
Handle<JSFunction> array_iterator_function =
CreateFunction(isolate_, factory->ArrayIterator_string(),
......@@ -1809,8 +1787,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> number_fun = InstallFunction(
isolate_, global, "Number", JS_VALUE_TYPE, JSValue::kSize, 0,
isolate_->initial_object_prototype(), Builtins::kNumberConstructor);
number_fun->shared()->set_builtin_function_id(
BuiltinFunctionId::kNumberConstructor);
number_fun->shared()->DontAdaptArguments();
number_fun->shared()->set_length(1);
InstallWithIntrinsicDefaultProto(isolate_, number_fun,
......@@ -1920,8 +1896,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> string_fun = InstallFunction(
isolate_, global, "String", JS_VALUE_TYPE, JSValue::kSize, 0,
isolate_->initial_object_prototype(), Builtins::kStringConstructor);
string_fun->shared()->set_builtin_function_id(
BuiltinFunctionId::kStringConstructor);
string_fun->shared()->DontAdaptArguments();
string_fun->shared()->set_length(1);
InstallWithIntrinsicDefaultProto(isolate_, string_fun,
......@@ -2082,10 +2056,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
SimpleInstallFunction(isolate_, prototype, "valueOf",
Builtins::kStringPrototypeValueOf, 0, true);
InstallFunctionAtSymbol(isolate_, prototype, factory->iterator_symbol(),
"[Symbol.iterator]",
Builtins::kStringPrototypeIterator, 0, true,
DONT_ENUM, BuiltinFunctionId::kStringIterator);
InstallFunctionAtSymbol(
isolate_, prototype, factory->iterator_symbol(), "[Symbol.iterator]",
Builtins::kStringPrototypeIterator, 0, true, DONT_ENUM);
}
{ // --- S t r i n g I t e r a t o r ---
......@@ -2100,7 +2073,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
InstallFunctionWithBuiltinId(isolate_, string_iterator_prototype, "next",
Builtins::kStringIteratorPrototypeNext, 0,
true, BuiltinFunctionId::kStringIteratorNext);
true);
Handle<JSFunction> string_iterator_function = CreateFunction(
isolate_, factory->InternalizeUtf8String("StringIterator"),
......@@ -2117,8 +2090,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> symbol_fun = InstallFunction(
isolate_, global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, 0,
factory->the_hole_value(), Builtins::kSymbolConstructor);
symbol_fun->shared()->set_builtin_function_id(
BuiltinFunctionId::kSymbolConstructor);
symbol_fun->shared()->set_length(0);
symbol_fun->shared()->DontAdaptArguments();
native_context()->set_symbol_function(*symbol_fun);
......@@ -2158,11 +2129,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
// Install the Symbol.prototype methods.
InstallFunctionWithBuiltinId(isolate_, prototype, "toString",
Builtins::kSymbolPrototypeToString, 0, true,
BuiltinFunctionId::kSymbolPrototypeToString);
Builtins::kSymbolPrototypeToString, 0, true);
InstallFunctionWithBuiltinId(isolate_, prototype, "valueOf",
Builtins::kSymbolPrototypeValueOf, 0, true,
BuiltinFunctionId::kSymbolPrototypeValueOf);
Builtins::kSymbolPrototypeValueOf, 0, true);
// Install the Symbol.prototype.description getter.
SimpleInstallGetter(isolate_, prototype,
......@@ -2332,21 +2301,17 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
InstallSpeciesGetter(isolate_, promise_fun);
Handle<JSFunction> promise_all = InstallFunctionWithBuiltinId(
isolate_, promise_fun, "all", Builtins::kPromiseAll, 1, true,
BuiltinFunctionId::kPromiseAll);
isolate_, promise_fun, "all", Builtins::kPromiseAll, 1, true);
native_context()->set_promise_all(*promise_all);
InstallFunctionWithBuiltinId(isolate_, promise_fun, "race",
Builtins::kPromiseRace, 1, true,
BuiltinFunctionId::kPromiseRace);
Builtins::kPromiseRace, 1, true);
InstallFunctionWithBuiltinId(isolate_, promise_fun, "resolve",
Builtins::kPromiseResolveTrampoline, 1, true,
BuiltinFunctionId::kPromiseResolve);
Builtins::kPromiseResolveTrampoline, 1, true);
InstallFunctionWithBuiltinId(isolate_, promise_fun, "reject",
Builtins::kPromiseReject, 1, true,
BuiltinFunctionId::kPromiseReject);
Builtins::kPromiseReject, 1, true);
// Setup %PromisePrototype%.
Handle<JSObject> prototype(
......@@ -2356,18 +2321,16 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
InstallToStringTag(isolate_, prototype, factory->Promise_string());
Handle<JSFunction> promise_then = InstallFunctionWithBuiltinId(
isolate_, prototype, "then", Builtins::kPromisePrototypeThen, 2, true,
BuiltinFunctionId::kPromisePrototypeThen);
isolate_, prototype, "then", Builtins::kPromisePrototypeThen, 2, true);
native_context()->set_promise_then(*promise_then);
Handle<JSFunction> promise_catch = InstallFunctionWithBuiltinId(
isolate_, prototype, "catch", Builtins::kPromisePrototypeCatch, 1, true,
BuiltinFunctionId::kPromisePrototypeCatch);
Handle<JSFunction> promise_catch =
InstallFunctionWithBuiltinId(isolate_, prototype, "catch",
Builtins::kPromisePrototypeCatch, 1, true);
native_context()->set_promise_catch(*promise_catch);
InstallFunctionWithBuiltinId(isolate_, prototype, "finally",
Builtins::kPromisePrototypeFinally, 1, true,
BuiltinFunctionId::kPromisePrototypeFinally);
Builtins::kPromisePrototypeFinally, 1, true);
{
Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
......@@ -3148,30 +3111,25 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
SimpleInstallGetter(isolate_, prototype, factory->buffer_string(),
Builtins::kTypedArrayPrototypeBuffer, false);
SimpleInstallGetter(isolate_, prototype, factory->byte_length_string(),
Builtins::kTypedArrayPrototypeByteLength, true,
BuiltinFunctionId::kTypedArrayByteLength);
Builtins::kTypedArrayPrototypeByteLength, true);
SimpleInstallGetter(isolate_, prototype, factory->byte_offset_string(),
Builtins::kTypedArrayPrototypeByteOffset, true,
BuiltinFunctionId::kTypedArrayByteOffset);
Builtins::kTypedArrayPrototypeByteOffset, true);
SimpleInstallGetter(isolate_, prototype, factory->length_string(),
Builtins::kTypedArrayPrototypeLength, true,
BuiltinFunctionId::kTypedArrayLength);
Builtins::kTypedArrayPrototypeLength, true);
SimpleInstallGetter(isolate_, prototype, factory->to_string_tag_symbol(),
Builtins::kTypedArrayPrototypeToStringTag, true,
BuiltinFunctionId::kTypedArrayToStringTag);
Builtins::kTypedArrayPrototypeToStringTag, true);
// Install "keys", "values" and "entries" methods on the {prototype}.
InstallFunctionWithBuiltinId(isolate_, prototype, "entries",
Builtins::kTypedArrayPrototypeEntries, 0, true,
BuiltinFunctionId::kTypedArrayEntries);
Builtins::kTypedArrayPrototypeEntries, 0,
true);
InstallFunctionWithBuiltinId(isolate_, prototype, "keys",
Builtins::kTypedArrayPrototypeKeys, 0, true,
BuiltinFunctionId::kTypedArrayKeys);
Builtins::kTypedArrayPrototypeKeys, 0, true);
Handle<JSFunction> values = InstallFunctionWithBuiltinId(
isolate_, prototype, "values", Builtins::kTypedArrayPrototypeValues, 0,
true, BuiltinFunctionId::kTypedArrayValues);
true);
JSObject::AddProperty(isolate_, prototype, factory->iterator_symbol(),
values, DONT_ENUM);
......@@ -3254,14 +3212,11 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
// Install the "buffer", "byteOffset" and "byteLength" getters
// on the {prototype}.
SimpleInstallGetter(isolate_, prototype, factory->buffer_string(),
Builtins::kDataViewPrototypeGetBuffer, false,
BuiltinFunctionId::kDataViewBuffer);
Builtins::kDataViewPrototypeGetBuffer, false);
SimpleInstallGetter(isolate_, prototype, factory->byte_length_string(),
Builtins::kDataViewPrototypeGetByteLength, false,
BuiltinFunctionId::kDataViewByteLength);
Builtins::kDataViewPrototypeGetByteLength, false);
SimpleInstallGetter(isolate_, prototype, factory->byte_offset_string(),
Builtins::kDataViewPrototypeGetByteOffset, false,
BuiltinFunctionId::kDataViewByteOffset);
Builtins::kDataViewPrototypeGetByteOffset, false);
SimpleInstallFunction(isolate_, prototype, "getInt8",
Builtins::kDataViewPrototypeGetInt8, 1, false);
......@@ -3352,9 +3307,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kMapPrototypeForEach, 1, false);
SimpleInstallFunction(isolate_, prototype, "keys",
Builtins::kMapPrototypeKeys, 0, true);
SimpleInstallGetter(
isolate_, prototype, factory->InternalizeUtf8String("size"),
Builtins::kMapPrototypeGetSize, true, BuiltinFunctionId::kMapSize);
SimpleInstallGetter(isolate_, prototype,
factory->InternalizeUtf8String("size"),
Builtins::kMapPrototypeGetSize, true);
SimpleInstallFunction(isolate_, prototype, "values",
Builtins::kMapPrototypeValues, 0, true);
......@@ -3367,8 +3322,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> bigint_fun = InstallFunction(
isolate_, global, "BigInt", JS_VALUE_TYPE, JSValue::kSize, 0,
factory->the_hole_value(), Builtins::kBigIntConstructor);
bigint_fun->shared()->set_builtin_function_id(
BuiltinFunctionId::kBigIntConstructor);
bigint_fun->shared()->DontAdaptArguments();
bigint_fun->shared()->set_length(1);
InstallWithIntrinsicDefaultProto(isolate_, bigint_fun,
......@@ -3440,9 +3393,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kSetPrototypeEntries, 0, true);
SimpleInstallFunction(isolate_, prototype, "forEach",
Builtins::kSetPrototypeForEach, 1, false);
SimpleInstallGetter(
isolate_, prototype, factory->InternalizeUtf8String("size"),
Builtins::kSetPrototypeGetSize, true, BuiltinFunctionId::kSetSize);
SimpleInstallGetter(isolate_, prototype,
factory->InternalizeUtf8String("size"),
Builtins::kSetPrototypeGetSize, true);
Handle<JSFunction> values = SimpleInstallFunction(
isolate_, prototype, "values", Builtins::kSetPrototypeValues, 0, true);
JSObject::AddProperty(isolate_, prototype, factory->keys_string(), values,
......@@ -3527,8 +3480,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
prototype->map()->LastAdded());
native_context()->set_weakmap_set(*weakmap_set);
SimpleInstallFunction(isolate_, prototype, "has", Builtins::kWeakMapHas, 1,
true);
SimpleInstallFunction(isolate_, prototype, "has",
Builtins::kWeakMapPrototypeHas, 1, true);
InstallToStringTag(isolate_, prototype, "WeakMap");
......@@ -3552,8 +3505,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
SimpleInstallFunction(isolate_, prototype, "delete",
Builtins::kWeakSetPrototypeDelete, 1, true);
SimpleInstallFunction(isolate_, prototype, "has", Builtins::kWeakSetHas, 1,
true);
SimpleInstallFunction(isolate_, prototype, "has",
Builtins::kWeakSetPrototypeHas, 1, true);
Handle<JSFunction> weakset_add = SimpleInstallFunction(
isolate_, prototype, "add", Builtins::kWeakSetPrototypeAdd, 1, true);
......@@ -3945,38 +3898,6 @@ bool Genesis::CompileExtension(Isolate* isolate, v8::Extension* extension) {
.is_null();
}
static Handle<JSObject> ResolveBuiltinIdHolder(Isolate* isolate,
Handle<Context> native_context,
const char* holder_expr) {
Factory* factory = isolate->factory();
Handle<JSGlobalObject> global(native_context->global_object(), isolate);
const char* period_pos = strchr(holder_expr, '.');
if (period_pos == nullptr) {
return Handle<JSObject>::cast(
Object::GetPropertyOrElement(
isolate, global, factory->InternalizeUtf8String(holder_expr))
.ToHandleChecked());
}
const char* inner = period_pos + 1;
DCHECK(!strchr(inner, '.'));
Vector<const char> property(holder_expr,
static_cast<int>(period_pos - holder_expr));
Handle<String> property_string = factory->InternalizeUtf8String(property);
DCHECK(!property_string.is_null());
Handle<JSObject> object = Handle<JSObject>::cast(
JSReceiver::GetProperty(isolate, global, property_string)
.ToHandleChecked());
if (strcmp("prototype", inner) == 0) {
Handle<JSFunction> function = Handle<JSFunction>::cast(object);
return Handle<JSObject>(JSObject::cast(function->prototype()), isolate);
}
Handle<String> inner_string = factory->InternalizeUtf8String(inner);
DCHECK(!inner_string.is_null());
Handle<Object> value =
JSReceiver::GetProperty(isolate, object, inner_string).ToHandleChecked();
return Handle<JSObject>::cast(value);
}
void Genesis::ConfigureUtilsObject() {
// We still need the utils object after deserialization.
if (isolate()->serializer_enabled()) return;
......@@ -4061,8 +3982,7 @@ void Genesis::InitializeIteratorFunctions() {
// Install the next function on the {prototype}.
InstallFunctionWithBuiltinId(isolate, prototype, "next",
Builtins::kSetIteratorPrototypeNext, 0, true,
BuiltinFunctionId::kSetIteratorNext);
Builtins::kSetIteratorPrototypeNext, 0, true);
native_context->set_initial_set_iterator_prototype(*prototype);
// Setup SetIterator constructor.
......@@ -4092,8 +4012,7 @@ void Genesis::InitializeIteratorFunctions() {
// Install the next function on the {prototype}.
InstallFunctionWithBuiltinId(isolate, prototype, "next",
Builtins::kMapIteratorPrototypeNext, 0, true,
BuiltinFunctionId::kMapIteratorNext);
Builtins::kMapIteratorPrototypeNext, 0, true);
native_context->set_initial_map_iterator_prototype(*prototype);
// Setup MapIterator constructor.
......@@ -4616,13 +4535,11 @@ Handle<JSFunction> Genesis::CreateArrayBuffer(
switch (array_buffer_kind) {
case ARRAY_BUFFER:
InstallFunctionWithBuiltinId(isolate(), array_buffer_fun, "isView",
Builtins::kArrayBufferIsView, 1, true,
BuiltinFunctionId::kArrayBufferIsView);
Builtins::kArrayBufferIsView, 1, true);
// Install the "byteLength" getter on the {prototype}.
SimpleInstallGetter(isolate(), prototype, factory()->byte_length_string(),
Builtins::kArrayBufferPrototypeGetByteLength, false,
BuiltinFunctionId::kArrayBufferByteLength);
Builtins::kArrayBufferPrototypeGetByteLength, false);
SimpleInstallFunction(isolate(), prototype, "slice",
Builtins::kArrayBufferPrototypeSlice, 2, true);
......@@ -4632,8 +4549,7 @@ Handle<JSFunction> Genesis::CreateArrayBuffer(
// Install the "byteLength" getter on the {prototype}.
SimpleInstallGetter(isolate(), prototype, factory()->byte_length_string(),
Builtins::kSharedArrayBufferPrototypeGetByteLength,
false,
BuiltinFunctionId::kSharedArrayBufferByteLength);
false);
SimpleInstallFunction(isolate(), prototype, "slice",
Builtins::kSharedArrayBufferPrototypeSlice, 2,
......@@ -4820,33 +4736,27 @@ bool Genesis::InstallNatives() {
// Install Global.decodeURI.
InstallFunctionWithBuiltinId(isolate(), global_object, "decodeURI",
Builtins::kGlobalDecodeURI, 1, false,
BuiltinFunctionId::kGlobalDecodeURI);
Builtins::kGlobalDecodeURI, 1, false);
// Install Global.decodeURIComponent.
InstallFunctionWithBuiltinId(isolate(), global_object, "decodeURIComponent",
Builtins::kGlobalDecodeURIComponent, 1, false,
BuiltinFunctionId::kGlobalDecodeURIComponent);
Builtins::kGlobalDecodeURIComponent, 1, false);
// Install Global.encodeURI.
InstallFunctionWithBuiltinId(isolate(), global_object, "encodeURI",
Builtins::kGlobalEncodeURI, 1, false,
BuiltinFunctionId::kGlobalEncodeURI);
Builtins::kGlobalEncodeURI, 1, false);
// Install Global.encodeURIComponent.
InstallFunctionWithBuiltinId(isolate(), global_object, "encodeURIComponent",
Builtins::kGlobalEncodeURIComponent, 1, false,
BuiltinFunctionId::kGlobalEncodeURIComponent);
Builtins::kGlobalEncodeURIComponent, 1, false);
// Install Global.escape.
InstallFunctionWithBuiltinId(isolate(), global_object, "escape",
Builtins::kGlobalEscape, 1, false,
BuiltinFunctionId::kGlobalEscape);
Builtins::kGlobalEscape, 1, false);
// Install Global.unescape.
InstallFunctionWithBuiltinId(isolate(), global_object, "unescape",
Builtins::kGlobalUnescape, 1, false,
BuiltinFunctionId::kGlobalUnescape);
Builtins::kGlobalUnescape, 1, false);
// Install Global.eval.
{
......@@ -4857,13 +4767,11 @@ bool Genesis::InstallNatives() {
// Install Global.isFinite
InstallFunctionWithBuiltinId(isolate(), global_object, "isFinite",
Builtins::kGlobalIsFinite, 1, true,
BuiltinFunctionId::kGlobalIsFinite);
Builtins::kGlobalIsFinite, 1, true);
// Install Global.isNaN
InstallFunctionWithBuiltinId(isolate(), global_object, "isNaN",
Builtins::kGlobalIsNaN, 1, true,
BuiltinFunctionId::kGlobalIsNaN);
Builtins::kGlobalIsNaN, 1, true);
// Install Array builtin functions.
{
......@@ -4882,8 +4790,6 @@ bool Genesis::InstallNatives() {
proto->set_elements(ReadOnlyRoots(heap()).empty_fixed_array());
}
InstallBuiltinFunctionIds();
// Create a map for accessor property descriptors (a variant of JSObject
// that predefines four properties get, set, configurable and enumerable).
{
......@@ -5105,40 +5011,6 @@ bool Genesis::InstallExtraNatives() {
return true;
}
static void InstallBuiltinFunctionId(Isolate* isolate, Handle<JSObject> holder,
const char* function_name,
BuiltinFunctionId id) {
Handle<Object> function_object =
JSReceiver::GetProperty(isolate, holder, function_name).ToHandleChecked();
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
function->shared()->set_builtin_function_id(id);
}
#define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
{#holder_expr, #fun_name, BuiltinFunctionId::k##name},
void Genesis::InstallBuiltinFunctionIds() {
HandleScope scope(isolate());
struct BuiltinFunctionIds {
const char* holder_expr;
const char* fun_name;
BuiltinFunctionId id;
};
const BuiltinFunctionIds builtins[] = {
FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)};
for (const BuiltinFunctionIds& builtin : builtins) {
Handle<JSObject> holder = ResolveBuiltinIdHolder(
isolate(), native_context(), builtin.holder_expr);
InstallBuiltinFunctionId(isolate(), holder, builtin.fun_name, builtin.id);
}
}
#undef INSTALL_BUILTIN_ID
void Genesis::InitializeNormalizedMapCaches() {
Handle<NormalizedMapCache> cache = NormalizedMapCache::New(isolate());
native_context()->set_normalized_map_cache(*cache);
......
......@@ -184,8 +184,8 @@ extern class SharedFunctionInfo extends HeapObject {
script_or_debug_info: Script | DebugInfo;
length: int16;
formal_parameter_count: uint16;
expected_nof_properties: int8;
builtin_function_id: int8;
// Currently set to uint16, can be set to uint8 to save space.
expected_nof_properties: uint16;
function_token_offset: int16;
flags: int32;
}
......
......@@ -2611,7 +2611,7 @@ TF_BUILTIN(WeakMapGet, WeakCollectionsBuiltinsAssembler) {
Return(UndefinedConstant());
}
TF_BUILTIN(WeakMapHas, WeakCollectionsBuiltinsAssembler) {
TF_BUILTIN(WeakMapPrototypeHas, WeakCollectionsBuiltinsAssembler) {
Node* const receiver = Parameter(Descriptor::kReceiver);
Node* const key = Parameter(Descriptor::kKey);
Node* const context = Parameter(Descriptor::kContext);
......@@ -2775,7 +2775,7 @@ TF_BUILTIN(WeakSetPrototypeDelete, CodeStubAssembler) {
CallBuiltin(Builtins::kWeakCollectionDelete, context, receiver, value));
}
TF_BUILTIN(WeakSetHas, WeakCollectionsBuiltinsAssembler) {
TF_BUILTIN(WeakSetPrototypeHas, WeakCollectionsBuiltinsAssembler) {
Node* const receiver = Parameter(Descriptor::kReceiver);
Node* const key = Parameter(Descriptor::kKey);
Node* const context = Parameter(Descriptor::kContext);
......
......@@ -1171,13 +1171,13 @@ namespace internal {
TFJ(WeakMapConstructor, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
TFS(WeakMapLookupHashIndex, kTable, kKey) \
TFJ(WeakMapGet, 1, kReceiver, kKey) \
TFJ(WeakMapHas, 1, kReceiver, kKey) \
TFJ(WeakMapPrototypeHas, 1, kReceiver, kKey) \
TFJ(WeakMapPrototypeSet, 2, kReceiver, kKey, kValue) \
TFJ(WeakMapPrototypeDelete, 1, kReceiver, kKey) \
\
/* WeakSet */ \
TFJ(WeakSetConstructor, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
TFJ(WeakSetHas, 1, kReceiver, kKey) \
TFJ(WeakSetPrototypeHas, 1, kReceiver, kKey) \
TFJ(WeakSetPrototypeAdd, 1, kReceiver, kValue) \
TFJ(WeakSetPrototypeDelete, 1, kReceiver, kValue) \
\
......
......@@ -13,7 +13,6 @@
#include "src/globals.h"
#include "src/handles.h"
#include "src/objects.h"
#include "src/objects/builtin-function-id.h"
#include "src/objects/instance-type.h"
#include "src/ostreams.h"
#include "src/zone/zone-containers.h"
......@@ -529,9 +528,7 @@ class ScopeInfoRef : public HeapObjectRef {
V(LanguageMode, language_mode) \
V(bool, native) \
V(bool, HasBreakInfo) \
V(bool, HasBuiltinFunctionId) \
V(bool, HasBuiltinId) \
V(BuiltinFunctionId, builtin_function_id) \
V(bool, construct_as_builtin) \
V(bool, HasBytecodeArray) \
V(bool, is_safe_to_skip_arguments_adaptor)
......
......@@ -19,7 +19,6 @@
#include "src/compiler/simplified-operator.h"
#include "src/compiler/type-cache.h"
#include "src/objects-inl.h"
#include "src/objects/builtin-function-id.h"
namespace v8 {
namespace internal {
......@@ -1490,285 +1489,290 @@ Type Typer::Visitor::JSCallTyper(Type fun, Typer* t) {
return Type::NonInternal();
}
JSFunctionRef function = fun.AsHeapConstant()->Ref().AsJSFunction();
if (!function.shared().HasBuiltinFunctionId()) {
if (!function.shared().HasBuiltinId()) {
return Type::NonInternal();
}
switch (function.shared().builtin_function_id()) {
case BuiltinFunctionId::kMathRandom:
switch (function.shared().builtin_id()) {
case Builtins::kMathRandom:
return Type::PlainNumber();
case BuiltinFunctionId::kMathFloor:
case BuiltinFunctionId::kMathCeil:
case BuiltinFunctionId::kMathRound:
case BuiltinFunctionId::kMathTrunc:
case Builtins::kMathFloor:
case Builtins::kMathCeil:
case Builtins::kMathRound:
case Builtins::kMathTrunc:
return t->cache_->kIntegerOrMinusZeroOrNaN;
// Unary math functions.
case BuiltinFunctionId::kMathAbs:
case BuiltinFunctionId::kMathExp:
case Builtins::kMathAbs:
case Builtins::kMathExp:
return Type::Union(Type::PlainNumber(), Type::NaN(), t->zone());
case BuiltinFunctionId::kMathAcos:
case BuiltinFunctionId::kMathAcosh:
case BuiltinFunctionId::kMathAsin:
case BuiltinFunctionId::kMathAsinh:
case BuiltinFunctionId::kMathAtan:
case BuiltinFunctionId::kMathAtanh:
case BuiltinFunctionId::kMathCbrt:
case BuiltinFunctionId::kMathCos:
case BuiltinFunctionId::kMathExpm1:
case BuiltinFunctionId::kMathFround:
case BuiltinFunctionId::kMathLog:
case BuiltinFunctionId::kMathLog1p:
case BuiltinFunctionId::kMathLog10:
case BuiltinFunctionId::kMathLog2:
case BuiltinFunctionId::kMathSin:
case BuiltinFunctionId::kMathSqrt:
case BuiltinFunctionId::kMathTan:
case Builtins::kMathAcos:
case Builtins::kMathAcosh:
case Builtins::kMathAsin:
case Builtins::kMathAsinh:
case Builtins::kMathAtan:
case Builtins::kMathAtanh:
case Builtins::kMathCbrt:
case Builtins::kMathCos:
case Builtins::kMathExpm1:
case Builtins::kMathFround:
case Builtins::kMathLog:
case Builtins::kMathLog1p:
case Builtins::kMathLog10:
case Builtins::kMathLog2:
case Builtins::kMathSin:
case Builtins::kMathSqrt:
case Builtins::kMathTan:
return Type::Number();
case BuiltinFunctionId::kMathSign:
case Builtins::kMathSign:
return t->cache_->kMinusOneToOneOrMinusZeroOrNaN;
// Binary math functions.
case BuiltinFunctionId::kMathAtan2:
case BuiltinFunctionId::kMathPow:
case BuiltinFunctionId::kMathMax:
case BuiltinFunctionId::kMathMin:
case Builtins::kMathAtan2:
case Builtins::kMathPow:
case Builtins::kMathMax:
case Builtins::kMathMin:
return Type::Number();
case BuiltinFunctionId::kMathImul:
case Builtins::kMathImul:
return Type::Signed32();
case BuiltinFunctionId::kMathClz32:
case Builtins::kMathClz32:
return t->cache_->kZeroToThirtyTwo;
// Date functions.
case BuiltinFunctionId::kDateNow:
case Builtins::kDateNow:
return t->cache_->kTimeValueType;
case BuiltinFunctionId::kDateGetDate:
case Builtins::kDatePrototypeGetDate:
return t->cache_->kJSDateDayType;
case BuiltinFunctionId::kDateGetDay:
case Builtins::kDatePrototypeGetDay:
return t->cache_->kJSDateWeekdayType;
case BuiltinFunctionId::kDateGetFullYear:
case Builtins::kDatePrototypeGetFullYear:
return t->cache_->kJSDateYearType;
case BuiltinFunctionId::kDateGetHours:
case Builtins::kDatePrototypeGetHours:
return t->cache_->kJSDateHourType;
case BuiltinFunctionId::kDateGetMilliseconds:
case Builtins::kDatePrototypeGetMilliseconds:
return Type::Union(Type::Range(0.0, 999.0, t->zone()), Type::NaN(),
t->zone());
case BuiltinFunctionId::kDateGetMinutes:
case Builtins::kDatePrototypeGetMinutes:
return t->cache_->kJSDateMinuteType;
case BuiltinFunctionId::kDateGetMonth:
case Builtins::kDatePrototypeGetMonth:
return t->cache_->kJSDateMonthType;
case BuiltinFunctionId::kDateGetSeconds:
case Builtins::kDatePrototypeGetSeconds:
return t->cache_->kJSDateSecondType;
case BuiltinFunctionId::kDateGetTime:
case Builtins::kDatePrototypeGetTime:
return t->cache_->kJSDateValueType;
// Symbol functions.
case BuiltinFunctionId::kSymbolConstructor:
case Builtins::kSymbolConstructor:
return Type::Symbol();
case BuiltinFunctionId::kSymbolPrototypeToString:
case Builtins::kSymbolPrototypeToString:
return Type::String();
case BuiltinFunctionId::kSymbolPrototypeValueOf:
case Builtins::kSymbolPrototypeValueOf:
return Type::Symbol();
// BigInt functions.
case BuiltinFunctionId::kBigIntConstructor:
case Builtins::kBigIntConstructor:
return Type::BigInt();
// Number functions.
case BuiltinFunctionId::kNumberConstructor:
case Builtins::kNumberConstructor:
return Type::Number();
case BuiltinFunctionId::kNumberIsFinite:
case BuiltinFunctionId::kNumberIsInteger:
case BuiltinFunctionId::kNumberIsNaN:
case BuiltinFunctionId::kNumberIsSafeInteger:
case Builtins::kNumberIsFinite:
case Builtins::kNumberIsInteger:
case Builtins::kNumberIsNaN:
case Builtins::kNumberIsSafeInteger:
return Type::Boolean();
case BuiltinFunctionId::kNumberParseFloat:
case Builtins::kNumberParseFloat:
return Type::Number();
case BuiltinFunctionId::kNumberParseInt:
case Builtins::kNumberParseInt:
return t->cache_->kIntegerOrMinusZeroOrNaN;
case BuiltinFunctionId::kNumberToString:
case Builtins::kNumberToString:
return Type::String();
// String functions.
case BuiltinFunctionId::kStringConstructor:
case Builtins::kStringConstructor:
return Type::String();
case BuiltinFunctionId::kStringCharCodeAt:
case Builtins::kStringPrototypeCharCodeAt:
return Type::Union(Type::Range(0, kMaxUInt16, t->zone()), Type::NaN(),
t->zone());
case BuiltinFunctionId::kStringCharAt:
case Builtins::kStringCharAt:
return Type::String();
case BuiltinFunctionId::kStringCodePointAt:
case Builtins::kStringPrototypeCodePointAt:
return Type::Union(Type::Range(0.0, String::kMaxCodePoint, t->zone()),
Type::Undefined(), t->zone());
case BuiltinFunctionId::kStringConcat:
case BuiltinFunctionId::kStringFromCharCode:
case BuiltinFunctionId::kStringFromCodePoint:
case Builtins::kStringPrototypeConcat:
case Builtins::kStringFromCharCode:
case Builtins::kStringFromCodePoint:
return Type::String();
case BuiltinFunctionId::kStringIndexOf:
case BuiltinFunctionId::kStringLastIndexOf:
case Builtins::kStringPrototypeIndexOf:
case Builtins::kStringPrototypeLastIndexOf:
return Type::Range(-1.0, String::kMaxLength, t->zone());
case BuiltinFunctionId::kStringEndsWith:
case BuiltinFunctionId::kStringIncludes:
case Builtins::kStringPrototypeEndsWith:
case Builtins::kStringPrototypeIncludes:
return Type::Boolean();
case BuiltinFunctionId::kStringRaw:
case BuiltinFunctionId::kStringRepeat:
case BuiltinFunctionId::kStringSlice:
case Builtins::kStringRaw:
case Builtins::kStringRepeat:
case Builtins::kStringPrototypeSlice:
return Type::String();
case BuiltinFunctionId::kStringStartsWith:
case Builtins::kStringPrototypeStartsWith:
return Type::Boolean();
case BuiltinFunctionId::kStringSubstr:
case BuiltinFunctionId::kStringSubstring:
case BuiltinFunctionId::kStringToLowerCase:
case BuiltinFunctionId::kStringToString:
case BuiltinFunctionId::kStringToUpperCase:
case BuiltinFunctionId::kStringTrim:
case BuiltinFunctionId::kStringTrimEnd:
case BuiltinFunctionId::kStringTrimStart:
case BuiltinFunctionId::kStringValueOf:
case Builtins::kStringPrototypeSubstr:
case Builtins::kStringSubstring:
case Builtins::kStringPrototypeToString:
#ifdef V8_INTL_SUPPORT
case Builtins::kStringPrototypeToLowerCaseIntl:
case Builtins::kStringPrototypeToUpperCaseIntl:
#else
case Builtins::kStringPrototypeToLowerCase:
case Builtins::kStringPrototypeToUpperCase:
#endif
case Builtins::kStringPrototypeTrim:
case Builtins::kStringPrototypeTrimEnd:
case Builtins::kStringPrototypeTrimStart:
case Builtins::kStringPrototypeValueOf:
return Type::String();
case BuiltinFunctionId::kStringIterator:
case BuiltinFunctionId::kStringIteratorNext:
case Builtins::kStringPrototypeIterator:
case Builtins::kStringIteratorPrototypeNext:
return Type::OtherObject();
case BuiltinFunctionId::kArrayEntries:
case BuiltinFunctionId::kArrayKeys:
case BuiltinFunctionId::kArrayValues:
case BuiltinFunctionId::kTypedArrayEntries:
case BuiltinFunctionId::kTypedArrayKeys:
case BuiltinFunctionId::kTypedArrayValues:
case BuiltinFunctionId::kArrayIteratorNext:
case BuiltinFunctionId::kMapIteratorNext:
case BuiltinFunctionId::kSetIteratorNext:
case Builtins::kArrayPrototypeEntries:
case Builtins::kArrayPrototypeKeys:
case Builtins::kArrayPrototypeValues:
case Builtins::kTypedArrayPrototypeEntries:
case Builtins::kTypedArrayPrototypeKeys:
case Builtins::kTypedArrayPrototypeValues:
case Builtins::kArrayIteratorPrototypeNext:
case Builtins::kMapIteratorPrototypeNext:
case Builtins::kSetIteratorPrototypeNext:
return Type::OtherObject();
case BuiltinFunctionId::kTypedArrayToStringTag:
case Builtins::kTypedArrayPrototypeToStringTag:
return Type::Union(Type::InternalizedString(), Type::Undefined(),
t->zone());
// Array functions.
case BuiltinFunctionId::kArrayIsArray:
case Builtins::kArrayIsArray:
return Type::Boolean();
case BuiltinFunctionId::kArrayConcat:
case Builtins::kArrayConcat:
return Type::Receiver();
case BuiltinFunctionId::kArrayEvery:
case Builtins::kArrayEvery:
return Type::Boolean();
case BuiltinFunctionId::kArrayFill:
case BuiltinFunctionId::kArrayFilter:
case Builtins::kArrayPrototypeFill:
case Builtins::kArrayFilter:
return Type::Receiver();
case BuiltinFunctionId::kArrayFindIndex:
case Builtins::kArrayPrototypeFindIndex:
return Type::Range(-1, kMaxSafeInteger, t->zone());
case BuiltinFunctionId::kArrayForEach:
case Builtins::kArrayForEach:
return Type::Undefined();
case BuiltinFunctionId::kArrayIncludes:
case Builtins::kArrayIncludes:
return Type::Boolean();
case BuiltinFunctionId::kArrayIndexOf:
case Builtins::kArrayIndexOf:
return Type::Range(-1, kMaxSafeInteger, t->zone());
case BuiltinFunctionId::kArrayJoin:
case Builtins::kArrayPrototypeJoin:
return Type::String();
case BuiltinFunctionId::kArrayLastIndexOf:
case Builtins::kArrayPrototypeLastIndexOf:
return Type::Range(-1, kMaxSafeInteger, t->zone());
case BuiltinFunctionId::kArrayMap:
case Builtins::kArrayMap:
return Type::Receiver();
case BuiltinFunctionId::kArrayPush:
case Builtins::kArrayPush:
return t->cache_->kPositiveSafeInteger;
case BuiltinFunctionId::kArrayReverse:
case BuiltinFunctionId::kArraySlice:
case Builtins::kArrayPrototypeReverse:
case Builtins::kArrayPrototypeSlice:
return Type::Receiver();
case BuiltinFunctionId::kArraySome:
case Builtins::kArraySome:
return Type::Boolean();
case BuiltinFunctionId::kArraySplice:
case Builtins::kArrayPrototypeSplice:
return Type::Receiver();
case BuiltinFunctionId::kArrayUnshift:
case Builtins::kArrayUnshift:
return t->cache_->kPositiveSafeInteger;
// ArrayBuffer functions.
case BuiltinFunctionId::kArrayBufferIsView:
case Builtins::kArrayBufferIsView:
return Type::Boolean();
// Object functions.
case BuiltinFunctionId::kObjectAssign:
case Builtins::kObjectAssign:
return Type::Receiver();
case BuiltinFunctionId::kObjectCreate:
case Builtins::kObjectCreate:
return Type::OtherObject();
case BuiltinFunctionId::kObjectIs:
case BuiltinFunctionId::kObjectHasOwnProperty:
case BuiltinFunctionId::kObjectIsPrototypeOf:
case Builtins::kObjectIs:
case Builtins::kObjectPrototypeHasOwnProperty:
case Builtins::kObjectPrototypeIsPrototypeOf:
return Type::Boolean();
case BuiltinFunctionId::kObjectToString:
case Builtins::kObjectToString:
return Type::String();
case BuiltinFunctionId::kPromiseAll:
case Builtins::kPromiseAll:
return Type::Receiver();
case BuiltinFunctionId::kPromisePrototypeThen:
case Builtins::kPromisePrototypeThen:
return Type::Receiver();
case BuiltinFunctionId::kPromiseRace:
case Builtins::kPromiseRace:
return Type::Receiver();
case BuiltinFunctionId::kPromiseReject:
case Builtins::kPromiseReject:
return Type::Receiver();
case BuiltinFunctionId::kPromiseResolve:
case Builtins::kPromiseResolveTrampoline:
return Type::Receiver();
// RegExp functions.
case BuiltinFunctionId::kRegExpCompile:
case Builtins::kRegExpPrototypeCompile:
return Type::OtherObject();
case BuiltinFunctionId::kRegExpExec:
case Builtins::kRegExpPrototypeExec:
return Type::Union(Type::Array(), Type::Null(), t->zone());
case BuiltinFunctionId::kRegExpTest:
case Builtins::kRegExpPrototypeTest:
return Type::Boolean();
case BuiltinFunctionId::kRegExpToString:
case Builtins::kRegExpPrototypeToString:
return Type::String();
// Function functions.
case BuiltinFunctionId::kFunctionBind:
case Builtins::kFunctionPrototypeBind:
return Type::BoundFunction();
case BuiltinFunctionId::kFunctionHasInstance:
case Builtins::kFunctionPrototypeHasInstance:
return Type::Boolean();
// Global functions.
case BuiltinFunctionId::kGlobalDecodeURI:
case BuiltinFunctionId::kGlobalDecodeURIComponent:
case BuiltinFunctionId::kGlobalEncodeURI:
case BuiltinFunctionId::kGlobalEncodeURIComponent:
case BuiltinFunctionId::kGlobalEscape:
case BuiltinFunctionId::kGlobalUnescape:
case Builtins::kGlobalDecodeURI:
case Builtins::kGlobalDecodeURIComponent:
case Builtins::kGlobalEncodeURI:
case Builtins::kGlobalEncodeURIComponent:
case Builtins::kGlobalEscape:
case Builtins::kGlobalUnescape:
return Type::String();
case BuiltinFunctionId::kGlobalIsFinite:
case BuiltinFunctionId::kGlobalIsNaN:
case Builtins::kGlobalIsFinite:
case Builtins::kGlobalIsNaN:
return Type::Boolean();
// Map functions.
case BuiltinFunctionId::kMapClear:
case BuiltinFunctionId::kMapForEach:
case Builtins::kMapPrototypeClear:
case Builtins::kMapPrototypeForEach:
return Type::Undefined();
case BuiltinFunctionId::kMapDelete:
case BuiltinFunctionId::kMapHas:
case Builtins::kMapPrototypeDelete:
case Builtins::kMapPrototypeHas:
return Type::Boolean();
case BuiltinFunctionId::kMapEntries:
case BuiltinFunctionId::kMapKeys:
case BuiltinFunctionId::kMapSet:
case BuiltinFunctionId::kMapValues:
case Builtins::kMapPrototypeEntries:
case Builtins::kMapPrototypeKeys:
case Builtins::kMapPrototypeSet:
case Builtins::kMapPrototypeValues:
return Type::OtherObject();
// Set functions.
case BuiltinFunctionId::kSetAdd:
case BuiltinFunctionId::kSetEntries:
case BuiltinFunctionId::kSetValues:
case Builtins::kSetPrototypeAdd:
case Builtins::kSetPrototypeEntries:
case Builtins::kSetPrototypeValues:
return Type::OtherObject();
case BuiltinFunctionId::kSetClear:
case BuiltinFunctionId::kSetForEach:
case Builtins::kSetPrototypeClear:
case Builtins::kSetPrototypeForEach:
return Type::Undefined();
case BuiltinFunctionId::kSetDelete:
case BuiltinFunctionId::kSetHas:
case Builtins::kSetPrototypeDelete:
case Builtins::kSetPrototypeHas:
return Type::Boolean();
// WeakMap functions.
case BuiltinFunctionId::kWeakMapDelete:
case BuiltinFunctionId::kWeakMapHas:
case Builtins::kWeakMapPrototypeDelete:
case Builtins::kWeakMapPrototypeHas:
return Type::Boolean();
case BuiltinFunctionId::kWeakMapSet:
case Builtins::kWeakMapPrototypeSet:
return Type::OtherObject();
// WeakSet functions.
case BuiltinFunctionId::kWeakSetAdd:
case Builtins::kWeakSetPrototypeAdd:
return Type::OtherObject();
case BuiltinFunctionId::kWeakSetDelete:
case BuiltinFunctionId::kWeakSetHas:
case Builtins::kWeakSetPrototypeDelete:
case Builtins::kWeakSetPrototypeHas:
return Type::Boolean();
default:
return Type::NonInternal();
......
......@@ -625,7 +625,7 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtins::Name id) {
// WeakMap builtins.
case Builtins::kWeakMapConstructor:
case Builtins::kWeakMapGet:
case Builtins::kWeakMapHas:
case Builtins::kWeakMapPrototypeHas:
// Math builtins.
case Builtins::kMathAbs:
case Builtins::kMathAcos:
......@@ -690,7 +690,7 @@ DebugInfo::SideEffectState BuiltinGetSideEffectState(Builtins::Name id) {
case Builtins::kSetPrototypeValues:
// WeakSet builtins.
case Builtins::kWeakSetConstructor:
case Builtins::kWeakSetHas:
case Builtins::kWeakSetPrototypeHas:
// String builtins. Strings are immutable.
case Builtins::kStringFromCharCode:
case Builtins::kStringFromCodePoint:
......
......@@ -3661,8 +3661,6 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
share->set_length(0);
share->set_internal_formal_parameter_count(0);
share->set_expected_nof_properties(0);
share->set_builtin_function_id(
BuiltinFunctionId::kInvalidBuiltinFunctionId);
share->set_raw_function_token_offset(0);
// All flags default to false or 0.
share->set_flags(0);
......
......@@ -5228,7 +5228,7 @@ bool SharedFunctionInfo::IsInlineable() {
}
// Built-in functions are handled by the JSCallReducer.
if (HasBuiltinFunctionId()) {
if (HasBuiltinId()) {
TraceInlining(*this, "false (is a builtin)");
return false;
}
......
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_OBJECTS_BUILTIN_FUNCTION_ID_H_
#define V8_OBJECTS_BUILTIN_FUNCTION_ID_H_
#include <stdint.h>
namespace v8 {
namespace internal {
// List of builtin functions we want to identify to improve code
// generation.
//
// Each entry has a name of a global object property holding an object
// optionally followed by ".prototype", a name of a builtin function
// on the object (the one the id is set for), and a label.
//
// Installation of ids for the selected builtin functions is handled
// by the bootstrapper.
#define FUNCTIONS_WITH_ID_LIST(V) \
V(Array, isArray, ArrayIsArray) \
V(Array.prototype, concat, ArrayConcat) \
V(Array.prototype, every, ArrayEvery) \
V(Array.prototype, fill, ArrayFill) \
V(Array.prototype, filter, ArrayFilter) \
V(Array.prototype, findIndex, ArrayFindIndex) \
V(Array.prototype, forEach, ArrayForEach) \
V(Array.prototype, includes, ArrayIncludes) \
V(Array.prototype, indexOf, ArrayIndexOf) \
V(Array.prototype, join, ArrayJoin) \
V(Array.prototype, lastIndexOf, ArrayLastIndexOf) \
V(Array.prototype, map, ArrayMap) \
V(Array.prototype, pop, ArrayPop) \
V(Array.prototype, push, ArrayPush) \
V(Array.prototype, reverse, ArrayReverse) \
V(Array.prototype, shift, ArrayShift) \
V(Array.prototype, slice, ArraySlice) \
V(Array.prototype, some, ArraySome) \
V(Array.prototype, splice, ArraySplice) \
V(Array.prototype, unshift, ArrayUnshift) \
V(Date, now, DateNow) \
V(Date.prototype, getDate, DateGetDate) \
V(Date.prototype, getDay, DateGetDay) \
V(Date.prototype, getFullYear, DateGetFullYear) \
V(Date.prototype, getHours, DateGetHours) \
V(Date.prototype, getMilliseconds, DateGetMilliseconds) \
V(Date.prototype, getMinutes, DateGetMinutes) \
V(Date.prototype, getMonth, DateGetMonth) \
V(Date.prototype, getSeconds, DateGetSeconds) \
V(Date.prototype, getTime, DateGetTime) \
V(Function.prototype, apply, FunctionApply) \
V(Function.prototype, bind, FunctionBind) \
V(Function.prototype, call, FunctionCall) \
V(Object, assign, ObjectAssign) \
V(Object, create, ObjectCreate) \
V(Object, is, ObjectIs) \
V(Object.prototype, hasOwnProperty, ObjectHasOwnProperty) \
V(Object.prototype, isPrototypeOf, ObjectIsPrototypeOf) \
V(Object.prototype, toString, ObjectToString) \
V(RegExp.prototype, compile, RegExpCompile) \
V(RegExp.prototype, exec, RegExpExec) \
V(RegExp.prototype, test, RegExpTest) \
V(RegExp.prototype, toString, RegExpToString) \
V(String.prototype, charCodeAt, StringCharCodeAt) \
V(String.prototype, charAt, StringCharAt) \
V(String.prototype, codePointAt, StringCodePointAt) \
V(String.prototype, concat, StringConcat) \
V(String.prototype, endsWith, StringEndsWith) \
V(String.prototype, includes, StringIncludes) \
V(String.prototype, indexOf, StringIndexOf) \
V(String.prototype, lastIndexOf, StringLastIndexOf) \
V(String.prototype, repeat, StringRepeat) \
V(String.prototype, slice, StringSlice) \
V(String.prototype, startsWith, StringStartsWith) \
V(String.prototype, substr, StringSubstr) \
V(String.prototype, substring, StringSubstring) \
V(String.prototype, toLowerCase, StringToLowerCase) \
V(String.prototype, toString, StringToString) \
V(String.prototype, toUpperCase, StringToUpperCase) \
V(String.prototype, trim, StringTrim) \
V(String.prototype, trimLeft, StringTrimStart) \
V(String.prototype, trimRight, StringTrimEnd) \
V(String.prototype, valueOf, StringValueOf) \
V(String, fromCharCode, StringFromCharCode) \
V(String, fromCodePoint, StringFromCodePoint) \
V(String, raw, StringRaw) \
V(Math, random, MathRandom) \
V(Math, floor, MathFloor) \
V(Math, round, MathRound) \
V(Math, ceil, MathCeil) \
V(Math, abs, MathAbs) \
V(Math, log, MathLog) \
V(Math, log1p, MathLog1p) \
V(Math, log2, MathLog2) \
V(Math, log10, MathLog10) \
V(Math, cbrt, MathCbrt) \
V(Math, exp, MathExp) \
V(Math, expm1, MathExpm1) \
V(Math, sqrt, MathSqrt) \
V(Math, pow, MathPow) \
V(Math, max, MathMax) \
V(Math, min, MathMin) \
V(Math, cos, MathCos) \
V(Math, cosh, MathCosh) \
V(Math, sign, MathSign) \
V(Math, sin, MathSin) \
V(Math, sinh, MathSinh) \
V(Math, tan, MathTan) \
V(Math, tanh, MathTanh) \
V(Math, acos, MathAcos) \
V(Math, acosh, MathAcosh) \
V(Math, asin, MathAsin) \
V(Math, asinh, MathAsinh) \
V(Math, atan, MathAtan) \
V(Math, atan2, MathAtan2) \
V(Math, atanh, MathAtanh) \
V(Math, imul, MathImul) \
V(Math, clz32, MathClz32) \
V(Math, fround, MathFround) \
V(Math, trunc, MathTrunc) \
V(Number, isFinite, NumberIsFinite) \
V(Number, isInteger, NumberIsInteger) \
V(Number, isNaN, NumberIsNaN) \
V(Number, isSafeInteger, NumberIsSafeInteger) \
V(Number, parseFloat, NumberParseFloat) \
V(Number, parseInt, NumberParseInt) \
V(Number.prototype, toString, NumberToString) \
V(Map.prototype, clear, MapClear) \
V(Map.prototype, delete, MapDelete) \
V(Map.prototype, entries, MapEntries) \
V(Map.prototype, forEach, MapForEach) \
V(Map.prototype, has, MapHas) \
V(Map.prototype, keys, MapKeys) \
V(Map.prototype, get, MapGet) \
V(Map.prototype, set, MapSet) \
V(Map.prototype, values, MapValues) \
V(Set.prototype, add, SetAdd) \
V(Set.prototype, clear, SetClear) \
V(Set.prototype, delete, SetDelete) \
V(Set.prototype, entries, SetEntries) \
V(Set.prototype, forEach, SetForEach) \
V(Set.prototype, has, SetHas) \
V(Set.prototype, values, SetValues) \
V(WeakMap.prototype, delete, WeakMapDelete) \
V(WeakMap.prototype, has, WeakMapHas) \
V(WeakMap.prototype, set, WeakMapSet) \
V(WeakSet.prototype, add, WeakSetAdd) \
V(WeakSet.prototype, delete, WeakSetDelete) \
V(WeakSet.prototype, has, WeakSetHas)
#define ATOMIC_FUNCTIONS_WITH_ID_LIST(V) \
V(Atomics, load, AtomicsLoad) \
V(Atomics, store, AtomicsStore) \
V(Atomics, exchange, AtomicsExchange) \
V(Atomics, compareExchange, AtomicsCompareExchange) \
V(Atomics, add, AtomicsAdd) \
V(Atomics, sub, AtomicsSub) \
V(Atomics, and, AtomicsAnd) \
V(Atomics, or, AtomicsOr) \
V(Atomics, xor, AtomicsXor)
enum class BuiltinFunctionId : uint8_t {
kArrayConstructor,
#define DECL_FUNCTION_ID(ignored1, ignore2, name) k##name,
FUNCTIONS_WITH_ID_LIST(DECL_FUNCTION_ID)
ATOMIC_FUNCTIONS_WITH_ID_LIST(DECL_FUNCTION_ID)
#undef DECL_FUNCTION_ID
// These are manually assigned to special getters during bootstrapping.
kArrayBufferByteLength,
kArrayBufferIsView,
kArrayEntries,
kArrayKeys,
kArrayValues,
kArrayIteratorNext,
kBigIntConstructor,
kMapSize,
kSetSize,
kMapIteratorNext,
kSetIteratorNext,
kDataViewBuffer,
kDataViewByteLength,
kDataViewByteOffset,
kFunctionHasInstance,
kGlobalDecodeURI,
kGlobalDecodeURIComponent,
kGlobalEncodeURI,
kGlobalEncodeURIComponent,
kGlobalEscape,
kGlobalUnescape,
kGlobalIsFinite,
kGlobalIsNaN,
kNumberConstructor,
kPromiseAll,
kPromisePrototypeCatch,
kPromisePrototypeFinally,
kPromisePrototypeThen,
kPromiseRace,
kPromiseReject,
kPromiseResolve,
kSymbolConstructor,
kSymbolPrototypeToString,
kSymbolPrototypeValueOf,
kTypedArrayByteLength,
kTypedArrayByteOffset,
kTypedArrayEntries,
kTypedArrayKeys,
kTypedArrayLength,
kTypedArrayToStringTag,
kTypedArrayValues,
kSharedArrayBufferByteLength,
kStringConstructor,
kStringIterator,
kStringIteratorNext,
kStringToLowerCaseIntl,
kStringToUpperCaseIntl,
kInvalidBuiltinFunctionId = static_cast<uint8_t>(-1),
};
} // namespace internal
} // namespace v8
#endif // V8_OBJECTS_BUILTIN_FUNCTION_ID_H_
......@@ -131,10 +131,8 @@ ACCESSORS(SharedFunctionInfo, script_or_debug_info, Object,
UINT16_ACCESSORS(SharedFunctionInfo, length, kLengthOffset)
UINT16_ACCESSORS(SharedFunctionInfo, internal_formal_parameter_count,
kFormalParameterCountOffset)
UINT8_ACCESSORS(SharedFunctionInfo, expected_nof_properties,
kExpectedNofPropertiesOffset)
UINT8_ACCESSORS(SharedFunctionInfo, raw_builtin_function_id,
kBuiltinFunctionIdOffset)
UINT16_ACCESSORS(SharedFunctionInfo, expected_nof_properties,
kExpectedNofPropertiesOffset)
UINT16_ACCESSORS(SharedFunctionInfo, raw_function_token_offset,
kFunctionTokenOffsetOffset)
RELAXED_INT32_ACCESSORS(SharedFunctionInfo, flags, kFlagsOffset)
......@@ -708,18 +706,6 @@ void SharedFunctionInfo::SetDebugInfo(DebugInfo debug_info) {
set_script_or_debug_info(debug_info);
}
bool SharedFunctionInfo::HasBuiltinFunctionId() {
return builtin_function_id() != BuiltinFunctionId::kInvalidBuiltinFunctionId;
}
BuiltinFunctionId SharedFunctionInfo::builtin_function_id() {
return static_cast<BuiltinFunctionId>(raw_builtin_function_id());
}
void SharedFunctionInfo::set_builtin_function_id(BuiltinFunctionId id) {
set_raw_builtin_function_id(static_cast<uint8_t>(id));
}
bool SharedFunctionInfo::HasInferredName() {
Object scope_info = name_or_scope_info();
if (scope_info->IsScopeInfo()) {
......
......@@ -8,7 +8,6 @@
#include "src/bailout-reason.h"
#include "src/function-kind.h"
#include "src/objects.h"
#include "src/objects/builtin-function-id.h"
#include "src/objects/compressed-slots.h"
#include "src/objects/script.h"
#include "src/objects/slots.h"
......@@ -324,7 +323,7 @@ class SharedFunctionInfo : public HeapObject {
// [expected_nof_properties]: Expected number of properties for the
// function. The value is only reliable when the function has been compiled.
DECL_UINT8_ACCESSORS(expected_nof_properties)
DECL_UINT16_ACCESSORS(expected_nof_properties)
// [function data]: This field holds some additional data for function.
// Currently it has one of:
......@@ -357,11 +356,7 @@ class SharedFunctionInfo : public HeapObject {
inline AsmWasmData asm_wasm_data() const;
inline void set_asm_wasm_data(AsmWasmData data);
// A brief note to clear up possible confusion:
// builtin_id corresponds to the auto-generated
// Builtins::Name id, while builtin_function_id corresponds to
// BuiltinFunctionId (a manually maintained list of 'interesting' functions
// mainly used during optimization).
// builtin_id corresponds to the auto-generated Builtins::Name id.
inline bool HasBuiltinId() const;
inline int builtin_id() const;
inline void set_builtin_id(int builtin_id);
......@@ -381,18 +376,6 @@ class SharedFunctionInfo : public HeapObject {
// turning it into UncompiledDataWithoutPreparseData.
inline void ClearPreparseData();
// [raw_builtin_function_id]: The id of the built-in function this function
// represents, used during optimization to improve code generation.
// TODO(leszeks): Once there are no more JS builtins, this can be replaced
// by BuiltinId.
DECL_UINT8_ACCESSORS(raw_builtin_function_id)
inline bool HasBuiltinFunctionId();
inline BuiltinFunctionId builtin_function_id();
inline void set_builtin_function_id(BuiltinFunctionId id);
// Make sure BuiltinFunctionIds fit in a uint8_t
STATIC_ASSERT((std::is_same<std::underlying_type<BuiltinFunctionId>::type,
uint8_t>::value));
// The inferred_name is inferred from variable or property assignment of this
// function. It is used to facilitate debugging and profiling of JavaScript
// code written in OO style, where almost all functions are anonymous but are
......
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