Revert "Remove builtin-function-id in SFI"
This reverts commit f8a676707d
.
Reason for revert: https://ci.chromium.org/p/v8/builders/ci/V8%20Linux%20-%20arm64%20-%20sim%20-%20MSAN/25576
I don't think I've seen MSAN being flaky. Chances are that the change to SFI's object layout indeed left some field uninitialized.
Original change's description:
> Remove builtin-function-id in SFI
>
> 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: Iee9b539475bc6531c9aa65b1904d1402a9ef30db
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1495898
> Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#60017}
TBR=ulan@chromium.org,jgruber@chromium.org,leszeks@chromium.org,bmeurer@chromium.org,duongn@microsoft.com
Change-Id: Ic3964ce182ddbd7ef529ddb8b78b9bdfb1be7887
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:6993
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1499500
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60018}
This commit is contained in:
parent
f8a676707d
commit
6eb66e1cbd
1
BUILD.gn
1
BUILD.gn
@ -2264,6 +2264,7 @@ 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,6 +24,7 @@
|
||||
#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"
|
||||
@ -228,6 +229,7 @@ class Genesis {
|
||||
Handle<JSFunction> InstallTypedArray(const char* name,
|
||||
ElementsKind elements_kind);
|
||||
bool InstallExtraNatives();
|
||||
void InstallBuiltinFunctionIds();
|
||||
void InitializeNormalizedMapCaches();
|
||||
|
||||
enum ExtensionTraversalState {
|
||||
@ -453,11 +455,13 @@ 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) {
|
||||
Builtins::Name call, int len, bool adapt, BuiltinFunctionId id) {
|
||||
DCHECK_NE(BuiltinFunctionId::kInvalidBuiltinFunctionId, id);
|
||||
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;
|
||||
}
|
||||
@ -479,11 +483,15 @@ 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) {
|
||||
PropertyAttributes attrs = DONT_ENUM,
|
||||
BuiltinFunctionId id = BuiltinFunctionId::kInvalidBuiltinFunctionId) {
|
||||
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;
|
||||
}
|
||||
@ -541,6 +549,15 @@ 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(
|
||||
@ -1541,7 +1558,8 @@ 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));
|
||||
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY),
|
||||
BuiltinFunctionId::kFunctionHasInstance);
|
||||
native_context()->set_function_has_instance(*has_instance);
|
||||
|
||||
// Complete setting up function maps.
|
||||
@ -1610,6 +1628,8 @@ 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.
|
||||
@ -1697,16 +1717,18 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
|
||||
|
||||
{ // Set up iterator-related properties.
|
||||
Handle<JSFunction> keys = InstallFunctionWithBuiltinId(
|
||||
isolate_, proto, "keys", Builtins::kArrayPrototypeKeys, 0, true);
|
||||
isolate_, proto, "keys", Builtins::kArrayPrototypeKeys, 0, true,
|
||||
BuiltinFunctionId::kArrayKeys);
|
||||
native_context()->set_array_keys_iterator(*keys);
|
||||
|
||||
Handle<JSFunction> entries = InstallFunctionWithBuiltinId(
|
||||
isolate_, proto, "entries", Builtins::kArrayPrototypeEntries, 0,
|
||||
true);
|
||||
isolate_, proto, "entries", Builtins::kArrayPrototypeEntries, 0, true,
|
||||
BuiltinFunctionId::kArrayEntries);
|
||||
native_context()->set_array_entries_iterator(*entries);
|
||||
|
||||
Handle<JSFunction> values = InstallFunctionWithBuiltinId(
|
||||
isolate_, proto, "values", Builtins::kArrayPrototypeValues, 0, true);
|
||||
isolate_, proto, "values", Builtins::kArrayPrototypeValues, 0, true,
|
||||
BuiltinFunctionId::kArrayValues);
|
||||
JSObject::AddProperty(isolate_, proto, factory->iterator_symbol(), values,
|
||||
DONT_ENUM);
|
||||
native_context()->set_array_values_iterator(*values);
|
||||
@ -1769,8 +1791,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
|
||||
factory->ArrayIterator_string());
|
||||
|
||||
InstallFunctionWithBuiltinId(isolate_, array_iterator_prototype, "next",
|
||||
Builtins::kArrayIteratorPrototypeNext, 0,
|
||||
true);
|
||||
Builtins::kArrayIteratorPrototypeNext, 0, true,
|
||||
BuiltinFunctionId::kArrayIteratorNext);
|
||||
|
||||
Handle<JSFunction> array_iterator_function =
|
||||
CreateFunction(isolate_, factory->ArrayIterator_string(),
|
||||
@ -1788,6 +1810,8 @@ 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,
|
||||
@ -1897,6 +1921,8 @@ 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,
|
||||
@ -2057,9 +2083,10 @@ 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);
|
||||
InstallFunctionAtSymbol(isolate_, prototype, factory->iterator_symbol(),
|
||||
"[Symbol.iterator]",
|
||||
Builtins::kStringPrototypeIterator, 0, true,
|
||||
DONT_ENUM, BuiltinFunctionId::kStringIterator);
|
||||
}
|
||||
|
||||
{ // --- S t r i n g I t e r a t o r ---
|
||||
@ -2074,7 +2101,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
|
||||
|
||||
InstallFunctionWithBuiltinId(isolate_, string_iterator_prototype, "next",
|
||||
Builtins::kStringIteratorPrototypeNext, 0,
|
||||
true);
|
||||
true, BuiltinFunctionId::kStringIteratorNext);
|
||||
|
||||
Handle<JSFunction> string_iterator_function = CreateFunction(
|
||||
isolate_, factory->InternalizeUtf8String("StringIterator"),
|
||||
@ -2091,6 +2118,8 @@ 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);
|
||||
@ -2130,9 +2159,11 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
|
||||
|
||||
// Install the Symbol.prototype methods.
|
||||
InstallFunctionWithBuiltinId(isolate_, prototype, "toString",
|
||||
Builtins::kSymbolPrototypeToString, 0, true);
|
||||
Builtins::kSymbolPrototypeToString, 0, true,
|
||||
BuiltinFunctionId::kSymbolPrototypeToString);
|
||||
InstallFunctionWithBuiltinId(isolate_, prototype, "valueOf",
|
||||
Builtins::kSymbolPrototypeValueOf, 0, true);
|
||||
Builtins::kSymbolPrototypeValueOf, 0, true,
|
||||
BuiltinFunctionId::kSymbolPrototypeValueOf);
|
||||
|
||||
// Install the Symbol.prototype.description getter.
|
||||
SimpleInstallGetter(isolate_, prototype,
|
||||
@ -2302,17 +2333,21 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
|
||||
InstallSpeciesGetter(isolate_, promise_fun);
|
||||
|
||||
Handle<JSFunction> promise_all = InstallFunctionWithBuiltinId(
|
||||
isolate_, promise_fun, "all", Builtins::kPromiseAll, 1, true);
|
||||
isolate_, promise_fun, "all", Builtins::kPromiseAll, 1, true,
|
||||
BuiltinFunctionId::kPromiseAll);
|
||||
native_context()->set_promise_all(*promise_all);
|
||||
|
||||
InstallFunctionWithBuiltinId(isolate_, promise_fun, "race",
|
||||
Builtins::kPromiseRace, 1, true);
|
||||
Builtins::kPromiseRace, 1, true,
|
||||
BuiltinFunctionId::kPromiseRace);
|
||||
|
||||
InstallFunctionWithBuiltinId(isolate_, promise_fun, "resolve",
|
||||
Builtins::kPromiseResolveTrampoline, 1, true);
|
||||
Builtins::kPromiseResolveTrampoline, 1, true,
|
||||
BuiltinFunctionId::kPromiseResolve);
|
||||
|
||||
InstallFunctionWithBuiltinId(isolate_, promise_fun, "reject",
|
||||
Builtins::kPromiseReject, 1, true);
|
||||
Builtins::kPromiseReject, 1, true,
|
||||
BuiltinFunctionId::kPromiseReject);
|
||||
|
||||
// Setup %PromisePrototype%.
|
||||
Handle<JSObject> prototype(
|
||||
@ -2322,16 +2357,18 @@ 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);
|
||||
isolate_, prototype, "then", Builtins::kPromisePrototypeThen, 2, true,
|
||||
BuiltinFunctionId::kPromisePrototypeThen);
|
||||
native_context()->set_promise_then(*promise_then);
|
||||
|
||||
Handle<JSFunction> promise_catch =
|
||||
InstallFunctionWithBuiltinId(isolate_, prototype, "catch",
|
||||
Builtins::kPromisePrototypeCatch, 1, true);
|
||||
Handle<JSFunction> promise_catch = InstallFunctionWithBuiltinId(
|
||||
isolate_, prototype, "catch", Builtins::kPromisePrototypeCatch, 1, true,
|
||||
BuiltinFunctionId::kPromisePrototypeCatch);
|
||||
native_context()->set_promise_catch(*promise_catch);
|
||||
|
||||
InstallFunctionWithBuiltinId(isolate_, prototype, "finally",
|
||||
Builtins::kPromisePrototypeFinally, 1, true);
|
||||
Builtins::kPromisePrototypeFinally, 1, true,
|
||||
BuiltinFunctionId::kPromisePrototypeFinally);
|
||||
|
||||
{
|
||||
Handle<SharedFunctionInfo> info = SimpleCreateSharedFunctionInfo(
|
||||
@ -3112,25 +3149,30 @@ 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);
|
||||
Builtins::kTypedArrayPrototypeByteLength, true,
|
||||
BuiltinFunctionId::kTypedArrayByteLength);
|
||||
SimpleInstallGetter(isolate_, prototype, factory->byte_offset_string(),
|
||||
Builtins::kTypedArrayPrototypeByteOffset, true);
|
||||
Builtins::kTypedArrayPrototypeByteOffset, true,
|
||||
BuiltinFunctionId::kTypedArrayByteOffset);
|
||||
SimpleInstallGetter(isolate_, prototype, factory->length_string(),
|
||||
Builtins::kTypedArrayPrototypeLength, true);
|
||||
Builtins::kTypedArrayPrototypeLength, true,
|
||||
BuiltinFunctionId::kTypedArrayLength);
|
||||
SimpleInstallGetter(isolate_, prototype, factory->to_string_tag_symbol(),
|
||||
Builtins::kTypedArrayPrototypeToStringTag, true);
|
||||
Builtins::kTypedArrayPrototypeToStringTag, true,
|
||||
BuiltinFunctionId::kTypedArrayToStringTag);
|
||||
|
||||
// Install "keys", "values" and "entries" methods on the {prototype}.
|
||||
InstallFunctionWithBuiltinId(isolate_, prototype, "entries",
|
||||
Builtins::kTypedArrayPrototypeEntries, 0,
|
||||
true);
|
||||
Builtins::kTypedArrayPrototypeEntries, 0, true,
|
||||
BuiltinFunctionId::kTypedArrayEntries);
|
||||
|
||||
InstallFunctionWithBuiltinId(isolate_, prototype, "keys",
|
||||
Builtins::kTypedArrayPrototypeKeys, 0, true);
|
||||
Builtins::kTypedArrayPrototypeKeys, 0, true,
|
||||
BuiltinFunctionId::kTypedArrayKeys);
|
||||
|
||||
Handle<JSFunction> values = InstallFunctionWithBuiltinId(
|
||||
isolate_, prototype, "values", Builtins::kTypedArrayPrototypeValues, 0,
|
||||
true);
|
||||
true, BuiltinFunctionId::kTypedArrayValues);
|
||||
JSObject::AddProperty(isolate_, prototype, factory->iterator_symbol(),
|
||||
values, DONT_ENUM);
|
||||
|
||||
@ -3213,11 +3255,14 @@ 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);
|
||||
Builtins::kDataViewPrototypeGetBuffer, false,
|
||||
BuiltinFunctionId::kDataViewBuffer);
|
||||
SimpleInstallGetter(isolate_, prototype, factory->byte_length_string(),
|
||||
Builtins::kDataViewPrototypeGetByteLength, false);
|
||||
Builtins::kDataViewPrototypeGetByteLength, false,
|
||||
BuiltinFunctionId::kDataViewByteLength);
|
||||
SimpleInstallGetter(isolate_, prototype, factory->byte_offset_string(),
|
||||
Builtins::kDataViewPrototypeGetByteOffset, false);
|
||||
Builtins::kDataViewPrototypeGetByteOffset, false,
|
||||
BuiltinFunctionId::kDataViewByteOffset);
|
||||
|
||||
SimpleInstallFunction(isolate_, prototype, "getInt8",
|
||||
Builtins::kDataViewPrototypeGetInt8, 1, false);
|
||||
@ -3308,9 +3353,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);
|
||||
SimpleInstallGetter(
|
||||
isolate_, prototype, factory->InternalizeUtf8String("size"),
|
||||
Builtins::kMapPrototypeGetSize, true, BuiltinFunctionId::kMapSize);
|
||||
SimpleInstallFunction(isolate_, prototype, "values",
|
||||
Builtins::kMapPrototypeValues, 0, true);
|
||||
|
||||
@ -3323,6 +3368,8 @@ 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,
|
||||
@ -3394,9 +3441,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);
|
||||
SimpleInstallGetter(
|
||||
isolate_, prototype, factory->InternalizeUtf8String("size"),
|
||||
Builtins::kSetPrototypeGetSize, true, BuiltinFunctionId::kSetSize);
|
||||
Handle<JSFunction> values = SimpleInstallFunction(
|
||||
isolate_, prototype, "values", Builtins::kSetPrototypeValues, 0, true);
|
||||
JSObject::AddProperty(isolate_, prototype, factory->keys_string(), values,
|
||||
@ -3481,8 +3528,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
|
||||
prototype->map()->LastAdded());
|
||||
|
||||
native_context()->set_weakmap_set(*weakmap_set);
|
||||
SimpleInstallFunction(isolate_, prototype, "has",
|
||||
Builtins::kWeakMapPrototypeHas, 1, true);
|
||||
SimpleInstallFunction(isolate_, prototype, "has", Builtins::kWeakMapHas, 1,
|
||||
true);
|
||||
|
||||
InstallToStringTag(isolate_, prototype, "WeakMap");
|
||||
|
||||
@ -3506,8 +3553,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
|
||||
|
||||
SimpleInstallFunction(isolate_, prototype, "delete",
|
||||
Builtins::kWeakSetPrototypeDelete, 1, true);
|
||||
SimpleInstallFunction(isolate_, prototype, "has",
|
||||
Builtins::kWeakSetPrototypeHas, 1, true);
|
||||
SimpleInstallFunction(isolate_, prototype, "has", Builtins::kWeakSetHas, 1,
|
||||
true);
|
||||
|
||||
Handle<JSFunction> weakset_add = SimpleInstallFunction(
|
||||
isolate_, prototype, "add", Builtins::kWeakSetPrototypeAdd, 1, true);
|
||||
@ -3899,6 +3946,38 @@ 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;
|
||||
@ -3983,7 +4062,8 @@ void Genesis::InitializeIteratorFunctions() {
|
||||
|
||||
// Install the next function on the {prototype}.
|
||||
InstallFunctionWithBuiltinId(isolate, prototype, "next",
|
||||
Builtins::kSetIteratorPrototypeNext, 0, true);
|
||||
Builtins::kSetIteratorPrototypeNext, 0, true,
|
||||
BuiltinFunctionId::kSetIteratorNext);
|
||||
native_context->set_initial_set_iterator_prototype(*prototype);
|
||||
|
||||
// Setup SetIterator constructor.
|
||||
@ -4013,7 +4093,8 @@ void Genesis::InitializeIteratorFunctions() {
|
||||
|
||||
// Install the next function on the {prototype}.
|
||||
InstallFunctionWithBuiltinId(isolate, prototype, "next",
|
||||
Builtins::kMapIteratorPrototypeNext, 0, true);
|
||||
Builtins::kMapIteratorPrototypeNext, 0, true,
|
||||
BuiltinFunctionId::kMapIteratorNext);
|
||||
native_context->set_initial_map_iterator_prototype(*prototype);
|
||||
|
||||
// Setup MapIterator constructor.
|
||||
@ -4536,11 +4617,13 @@ Handle<JSFunction> Genesis::CreateArrayBuffer(
|
||||
switch (array_buffer_kind) {
|
||||
case ARRAY_BUFFER:
|
||||
InstallFunctionWithBuiltinId(isolate(), array_buffer_fun, "isView",
|
||||
Builtins::kArrayBufferIsView, 1, true);
|
||||
Builtins::kArrayBufferIsView, 1, true,
|
||||
BuiltinFunctionId::kArrayBufferIsView);
|
||||
|
||||
// Install the "byteLength" getter on the {prototype}.
|
||||
SimpleInstallGetter(isolate(), prototype, factory()->byte_length_string(),
|
||||
Builtins::kArrayBufferPrototypeGetByteLength, false);
|
||||
Builtins::kArrayBufferPrototypeGetByteLength, false,
|
||||
BuiltinFunctionId::kArrayBufferByteLength);
|
||||
|
||||
SimpleInstallFunction(isolate(), prototype, "slice",
|
||||
Builtins::kArrayBufferPrototypeSlice, 2, true);
|
||||
@ -4550,7 +4633,8 @@ Handle<JSFunction> Genesis::CreateArrayBuffer(
|
||||
// Install the "byteLength" getter on the {prototype}.
|
||||
SimpleInstallGetter(isolate(), prototype, factory()->byte_length_string(),
|
||||
Builtins::kSharedArrayBufferPrototypeGetByteLength,
|
||||
false);
|
||||
false,
|
||||
BuiltinFunctionId::kSharedArrayBufferByteLength);
|
||||
|
||||
SimpleInstallFunction(isolate(), prototype, "slice",
|
||||
Builtins::kSharedArrayBufferPrototypeSlice, 2,
|
||||
@ -4737,27 +4821,33 @@ bool Genesis::InstallNatives() {
|
||||
|
||||
// Install Global.decodeURI.
|
||||
InstallFunctionWithBuiltinId(isolate(), global_object, "decodeURI",
|
||||
Builtins::kGlobalDecodeURI, 1, false);
|
||||
Builtins::kGlobalDecodeURI, 1, false,
|
||||
BuiltinFunctionId::kGlobalDecodeURI);
|
||||
|
||||
// Install Global.decodeURIComponent.
|
||||
InstallFunctionWithBuiltinId(isolate(), global_object, "decodeURIComponent",
|
||||
Builtins::kGlobalDecodeURIComponent, 1, false);
|
||||
Builtins::kGlobalDecodeURIComponent, 1, false,
|
||||
BuiltinFunctionId::kGlobalDecodeURIComponent);
|
||||
|
||||
// Install Global.encodeURI.
|
||||
InstallFunctionWithBuiltinId(isolate(), global_object, "encodeURI",
|
||||
Builtins::kGlobalEncodeURI, 1, false);
|
||||
Builtins::kGlobalEncodeURI, 1, false,
|
||||
BuiltinFunctionId::kGlobalEncodeURI);
|
||||
|
||||
// Install Global.encodeURIComponent.
|
||||
InstallFunctionWithBuiltinId(isolate(), global_object, "encodeURIComponent",
|
||||
Builtins::kGlobalEncodeURIComponent, 1, false);
|
||||
Builtins::kGlobalEncodeURIComponent, 1, false,
|
||||
BuiltinFunctionId::kGlobalEncodeURIComponent);
|
||||
|
||||
// Install Global.escape.
|
||||
InstallFunctionWithBuiltinId(isolate(), global_object, "escape",
|
||||
Builtins::kGlobalEscape, 1, false);
|
||||
Builtins::kGlobalEscape, 1, false,
|
||||
BuiltinFunctionId::kGlobalEscape);
|
||||
|
||||
// Install Global.unescape.
|
||||
InstallFunctionWithBuiltinId(isolate(), global_object, "unescape",
|
||||
Builtins::kGlobalUnescape, 1, false);
|
||||
Builtins::kGlobalUnescape, 1, false,
|
||||
BuiltinFunctionId::kGlobalUnescape);
|
||||
|
||||
// Install Global.eval.
|
||||
{
|
||||
@ -4768,11 +4858,13 @@ bool Genesis::InstallNatives() {
|
||||
|
||||
// Install Global.isFinite
|
||||
InstallFunctionWithBuiltinId(isolate(), global_object, "isFinite",
|
||||
Builtins::kGlobalIsFinite, 1, true);
|
||||
Builtins::kGlobalIsFinite, 1, true,
|
||||
BuiltinFunctionId::kGlobalIsFinite);
|
||||
|
||||
// Install Global.isNaN
|
||||
InstallFunctionWithBuiltinId(isolate(), global_object, "isNaN",
|
||||
Builtins::kGlobalIsNaN, 1, true);
|
||||
Builtins::kGlobalIsNaN, 1, true,
|
||||
BuiltinFunctionId::kGlobalIsNaN);
|
||||
|
||||
// Install Array builtin functions.
|
||||
{
|
||||
@ -4791,6 +4883,8 @@ 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).
|
||||
{
|
||||
@ -5012,6 +5106,40 @@ 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);
|
||||
|
@ -178,8 +178,8 @@ extern class SharedFunctionInfo extends HeapObject {
|
||||
script_or_debug_info: Script | DebugInfo;
|
||||
length: int16;
|
||||
formal_parameter_count: uint16;
|
||||
// Currently set to int16, can be set to int8 to save space.
|
||||
expected_nof_properties: int16;
|
||||
expected_nof_properties: int8;
|
||||
builtin_function_id: int8;
|
||||
function_token_offset: int16;
|
||||
flags: int32;
|
||||
}
|
||||
|
@ -2611,7 +2611,7 @@ TF_BUILTIN(WeakMapGet, WeakCollectionsBuiltinsAssembler) {
|
||||
Return(UndefinedConstant());
|
||||
}
|
||||
|
||||
TF_BUILTIN(WeakMapPrototypeHas, WeakCollectionsBuiltinsAssembler) {
|
||||
TF_BUILTIN(WeakMapHas, 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(WeakSetPrototypeHas, WeakCollectionsBuiltinsAssembler) {
|
||||
TF_BUILTIN(WeakSetHas, WeakCollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const key = Parameter(Descriptor::kKey);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
|
@ -1187,13 +1187,13 @@ namespace internal {
|
||||
TFJ(WeakMapConstructor, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
|
||||
TFS(WeakMapLookupHashIndex, kTable, kKey) \
|
||||
TFJ(WeakMapGet, 1, kReceiver, kKey) \
|
||||
TFJ(WeakMapPrototypeHas, 1, kReceiver, kKey) \
|
||||
TFJ(WeakMapHas, 1, kReceiver, kKey) \
|
||||
TFJ(WeakMapPrototypeSet, 2, kReceiver, kKey, kValue) \
|
||||
TFJ(WeakMapPrototypeDelete, 1, kReceiver, kKey) \
|
||||
\
|
||||
/* WeakSet */ \
|
||||
TFJ(WeakSetConstructor, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
|
||||
TFJ(WeakSetPrototypeHas, 1, kReceiver, kKey) \
|
||||
TFJ(WeakSetHas, 1, kReceiver, kKey) \
|
||||
TFJ(WeakSetPrototypeAdd, 1, kReceiver, kValue) \
|
||||
TFJ(WeakSetPrototypeDelete, 1, kReceiver, kValue) \
|
||||
\
|
||||
|
@ -13,6 +13,7 @@
|
||||
#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"
|
||||
@ -522,7 +523,9 @@ 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,6 +19,7 @@
|
||||
#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 {
|
||||
@ -1489,290 +1490,285 @@ Type Typer::Visitor::JSCallTyper(Type fun, Typer* t) {
|
||||
return Type::NonInternal();
|
||||
}
|
||||
JSFunctionRef function = fun.AsHeapConstant()->Ref().AsJSFunction();
|
||||
if (!function.shared().HasBuiltinId()) {
|
||||
if (!function.shared().HasBuiltinFunctionId()) {
|
||||
return Type::NonInternal();
|
||||
}
|
||||
switch (function.shared().builtin_id()) {
|
||||
case Builtins::kMathRandom:
|
||||
switch (function.shared().builtin_function_id()) {
|
||||
case BuiltinFunctionId::kMathRandom:
|
||||
return Type::PlainNumber();
|
||||
case Builtins::kMathFloor:
|
||||
case Builtins::kMathCeil:
|
||||
case Builtins::kMathRound:
|
||||
case Builtins::kMathTrunc:
|
||||
case BuiltinFunctionId::kMathFloor:
|
||||
case BuiltinFunctionId::kMathCeil:
|
||||
case BuiltinFunctionId::kMathRound:
|
||||
case BuiltinFunctionId::kMathTrunc:
|
||||
return t->cache_->kIntegerOrMinusZeroOrNaN;
|
||||
// Unary math functions.
|
||||
case Builtins::kMathAbs:
|
||||
case Builtins::kMathExp:
|
||||
case BuiltinFunctionId::kMathAbs:
|
||||
case BuiltinFunctionId::kMathExp:
|
||||
return Type::Union(Type::PlainNumber(), Type::NaN(), t->zone());
|
||||
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:
|
||||
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:
|
||||
return Type::Number();
|
||||
case Builtins::kMathSign:
|
||||
case BuiltinFunctionId::kMathSign:
|
||||
return t->cache_->kMinusOneToOneOrMinusZeroOrNaN;
|
||||
// Binary math functions.
|
||||
case Builtins::kMathAtan2:
|
||||
case Builtins::kMathPow:
|
||||
case Builtins::kMathMax:
|
||||
case Builtins::kMathMin:
|
||||
case BuiltinFunctionId::kMathAtan2:
|
||||
case BuiltinFunctionId::kMathPow:
|
||||
case BuiltinFunctionId::kMathMax:
|
||||
case BuiltinFunctionId::kMathMin:
|
||||
return Type::Number();
|
||||
case Builtins::kMathImul:
|
||||
case BuiltinFunctionId::kMathImul:
|
||||
return Type::Signed32();
|
||||
case Builtins::kMathClz32:
|
||||
case BuiltinFunctionId::kMathClz32:
|
||||
return t->cache_->kZeroToThirtyTwo;
|
||||
// Date functions.
|
||||
case Builtins::kDateNow:
|
||||
case BuiltinFunctionId::kDateNow:
|
||||
return t->cache_->kTimeValueType;
|
||||
case Builtins::kDatePrototypeGetDate:
|
||||
case BuiltinFunctionId::kDateGetDate:
|
||||
return t->cache_->kJSDateDayType;
|
||||
case Builtins::kDatePrototypeGetDay:
|
||||
case BuiltinFunctionId::kDateGetDay:
|
||||
return t->cache_->kJSDateWeekdayType;
|
||||
case Builtins::kDatePrototypeGetFullYear:
|
||||
case BuiltinFunctionId::kDateGetFullYear:
|
||||
return t->cache_->kJSDateYearType;
|
||||
case Builtins::kDatePrototypeGetHours:
|
||||
case BuiltinFunctionId::kDateGetHours:
|
||||
return t->cache_->kJSDateHourType;
|
||||
case Builtins::kDatePrototypeGetMilliseconds:
|
||||
case BuiltinFunctionId::kDateGetMilliseconds:
|
||||
return Type::Union(Type::Range(0.0, 999.0, t->zone()), Type::NaN(),
|
||||
t->zone());
|
||||
case Builtins::kDatePrototypeGetMinutes:
|
||||
case BuiltinFunctionId::kDateGetMinutes:
|
||||
return t->cache_->kJSDateMinuteType;
|
||||
case Builtins::kDatePrototypeGetMonth:
|
||||
case BuiltinFunctionId::kDateGetMonth:
|
||||
return t->cache_->kJSDateMonthType;
|
||||
case Builtins::kDatePrototypeGetSeconds:
|
||||
case BuiltinFunctionId::kDateGetSeconds:
|
||||
return t->cache_->kJSDateSecondType;
|
||||
case Builtins::kDatePrototypeGetTime:
|
||||
case BuiltinFunctionId::kDateGetTime:
|
||||
return t->cache_->kJSDateValueType;
|
||||
|
||||
// Symbol functions.
|
||||
case Builtins::kSymbolConstructor:
|
||||
case BuiltinFunctionId::kSymbolConstructor:
|
||||
return Type::Symbol();
|
||||
case Builtins::kSymbolPrototypeToString:
|
||||
case BuiltinFunctionId::kSymbolPrototypeToString:
|
||||
return Type::String();
|
||||
case Builtins::kSymbolPrototypeValueOf:
|
||||
case BuiltinFunctionId::kSymbolPrototypeValueOf:
|
||||
return Type::Symbol();
|
||||
|
||||
// BigInt functions.
|
||||
case Builtins::kBigIntConstructor:
|
||||
case BuiltinFunctionId::kBigIntConstructor:
|
||||
return Type::BigInt();
|
||||
|
||||
// Number functions.
|
||||
case Builtins::kNumberConstructor:
|
||||
case BuiltinFunctionId::kNumberConstructor:
|
||||
return Type::Number();
|
||||
case Builtins::kNumberIsFinite:
|
||||
case Builtins::kNumberIsInteger:
|
||||
case Builtins::kNumberIsNaN:
|
||||
case Builtins::kNumberIsSafeInteger:
|
||||
case BuiltinFunctionId::kNumberIsFinite:
|
||||
case BuiltinFunctionId::kNumberIsInteger:
|
||||
case BuiltinFunctionId::kNumberIsNaN:
|
||||
case BuiltinFunctionId::kNumberIsSafeInteger:
|
||||
return Type::Boolean();
|
||||
case Builtins::kNumberParseFloat:
|
||||
case BuiltinFunctionId::kNumberParseFloat:
|
||||
return Type::Number();
|
||||
case Builtins::kNumberParseInt:
|
||||
case BuiltinFunctionId::kNumberParseInt:
|
||||
return t->cache_->kIntegerOrMinusZeroOrNaN;
|
||||
case Builtins::kNumberToString:
|
||||
case BuiltinFunctionId::kNumberToString:
|
||||
return Type::String();
|
||||
|
||||
// String functions.
|
||||
case Builtins::kStringConstructor:
|
||||
case BuiltinFunctionId::kStringConstructor:
|
||||
return Type::String();
|
||||
case Builtins::kStringPrototypeCharCodeAt:
|
||||
case BuiltinFunctionId::kStringCharCodeAt:
|
||||
return Type::Union(Type::Range(0, kMaxUInt16, t->zone()), Type::NaN(),
|
||||
t->zone());
|
||||
case Builtins::kStringCharAt:
|
||||
case BuiltinFunctionId::kStringCharAt:
|
||||
return Type::String();
|
||||
case Builtins::kStringPrototypeCodePointAt:
|
||||
case BuiltinFunctionId::kStringCodePointAt:
|
||||
return Type::Union(Type::Range(0.0, String::kMaxCodePoint, t->zone()),
|
||||
Type::Undefined(), t->zone());
|
||||
case Builtins::kStringPrototypeConcat:
|
||||
case Builtins::kStringFromCharCode:
|
||||
case Builtins::kStringFromCodePoint:
|
||||
case BuiltinFunctionId::kStringConcat:
|
||||
case BuiltinFunctionId::kStringFromCharCode:
|
||||
case BuiltinFunctionId::kStringFromCodePoint:
|
||||
return Type::String();
|
||||
case Builtins::kStringPrototypeIndexOf:
|
||||
case Builtins::kStringPrototypeLastIndexOf:
|
||||
case BuiltinFunctionId::kStringIndexOf:
|
||||
case BuiltinFunctionId::kStringLastIndexOf:
|
||||
return Type::Range(-1.0, String::kMaxLength, t->zone());
|
||||
case Builtins::kStringPrototypeEndsWith:
|
||||
case Builtins::kStringPrototypeIncludes:
|
||||
case BuiltinFunctionId::kStringEndsWith:
|
||||
case BuiltinFunctionId::kStringIncludes:
|
||||
return Type::Boolean();
|
||||
case Builtins::kStringRaw:
|
||||
case Builtins::kStringRepeat:
|
||||
case Builtins::kStringPrototypeSlice:
|
||||
case BuiltinFunctionId::kStringRaw:
|
||||
case BuiltinFunctionId::kStringRepeat:
|
||||
case BuiltinFunctionId::kStringSlice:
|
||||
return Type::String();
|
||||
case Builtins::kStringPrototypeStartsWith:
|
||||
case BuiltinFunctionId::kStringStartsWith:
|
||||
return Type::Boolean();
|
||||
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:
|
||||
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:
|
||||
return Type::String();
|
||||
|
||||
case Builtins::kStringPrototypeIterator:
|
||||
case Builtins::kStringIteratorPrototypeNext:
|
||||
case BuiltinFunctionId::kStringIterator:
|
||||
case BuiltinFunctionId::kStringIteratorNext:
|
||||
return Type::OtherObject();
|
||||
|
||||
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:
|
||||
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:
|
||||
return Type::OtherObject();
|
||||
case Builtins::kTypedArrayPrototypeToStringTag:
|
||||
case BuiltinFunctionId::kTypedArrayToStringTag:
|
||||
return Type::Union(Type::InternalizedString(), Type::Undefined(),
|
||||
t->zone());
|
||||
|
||||
// Array functions.
|
||||
case Builtins::kArrayIsArray:
|
||||
case BuiltinFunctionId::kArrayIsArray:
|
||||
return Type::Boolean();
|
||||
case Builtins::kArrayConcat:
|
||||
case BuiltinFunctionId::kArrayConcat:
|
||||
return Type::Receiver();
|
||||
case Builtins::kArrayEvery:
|
||||
case BuiltinFunctionId::kArrayEvery:
|
||||
return Type::Boolean();
|
||||
case Builtins::kArrayPrototypeFill:
|
||||
case Builtins::kArrayFilter:
|
||||
case BuiltinFunctionId::kArrayFill:
|
||||
case BuiltinFunctionId::kArrayFilter:
|
||||
return Type::Receiver();
|
||||
case Builtins::kArrayPrototypeFindIndex:
|
||||
case BuiltinFunctionId::kArrayFindIndex:
|
||||
return Type::Range(-1, kMaxSafeInteger, t->zone());
|
||||
case Builtins::kArrayForEach:
|
||||
case BuiltinFunctionId::kArrayForEach:
|
||||
return Type::Undefined();
|
||||
case Builtins::kArrayIncludes:
|
||||
case BuiltinFunctionId::kArrayIncludes:
|
||||
return Type::Boolean();
|
||||
case Builtins::kArrayIndexOf:
|
||||
case BuiltinFunctionId::kArrayIndexOf:
|
||||
return Type::Range(-1, kMaxSafeInteger, t->zone());
|
||||
case Builtins::kArrayPrototypeJoin:
|
||||
case BuiltinFunctionId::kArrayJoin:
|
||||
return Type::String();
|
||||
case Builtins::kArrayPrototypeLastIndexOf:
|
||||
case BuiltinFunctionId::kArrayLastIndexOf:
|
||||
return Type::Range(-1, kMaxSafeInteger, t->zone());
|
||||
case Builtins::kArrayMap:
|
||||
case BuiltinFunctionId::kArrayMap:
|
||||
return Type::Receiver();
|
||||
case Builtins::kArrayPush:
|
||||
case BuiltinFunctionId::kArrayPush:
|
||||
return t->cache_->kPositiveSafeInteger;
|
||||
case Builtins::kArrayPrototypeReverse:
|
||||
case Builtins::kArrayPrototypeSlice:
|
||||
case BuiltinFunctionId::kArrayReverse:
|
||||
case BuiltinFunctionId::kArraySlice:
|
||||
return Type::Receiver();
|
||||
case Builtins::kArraySome:
|
||||
case BuiltinFunctionId::kArraySome:
|
||||
return Type::Boolean();
|
||||
case Builtins::kArrayPrototypeSplice:
|
||||
case BuiltinFunctionId::kArraySplice:
|
||||
return Type::Receiver();
|
||||
case Builtins::kArrayUnshift:
|
||||
case BuiltinFunctionId::kArrayUnshift:
|
||||
return t->cache_->kPositiveSafeInteger;
|
||||
|
||||
// ArrayBuffer functions.
|
||||
case Builtins::kArrayBufferIsView:
|
||||
case BuiltinFunctionId::kArrayBufferIsView:
|
||||
return Type::Boolean();
|
||||
|
||||
// Object functions.
|
||||
case Builtins::kObjectAssign:
|
||||
case BuiltinFunctionId::kObjectAssign:
|
||||
return Type::Receiver();
|
||||
case Builtins::kObjectCreate:
|
||||
case BuiltinFunctionId::kObjectCreate:
|
||||
return Type::OtherObject();
|
||||
case Builtins::kObjectIs:
|
||||
case Builtins::kObjectPrototypeHasOwnProperty:
|
||||
case Builtins::kObjectPrototypeIsPrototypeOf:
|
||||
case BuiltinFunctionId::kObjectIs:
|
||||
case BuiltinFunctionId::kObjectHasOwnProperty:
|
||||
case BuiltinFunctionId::kObjectIsPrototypeOf:
|
||||
return Type::Boolean();
|
||||
case Builtins::kObjectToString:
|
||||
case BuiltinFunctionId::kObjectToString:
|
||||
return Type::String();
|
||||
|
||||
case Builtins::kPromiseAll:
|
||||
case BuiltinFunctionId::kPromiseAll:
|
||||
return Type::Receiver();
|
||||
case Builtins::kPromisePrototypeThen:
|
||||
case BuiltinFunctionId::kPromisePrototypeThen:
|
||||
return Type::Receiver();
|
||||
case Builtins::kPromiseRace:
|
||||
case BuiltinFunctionId::kPromiseRace:
|
||||
return Type::Receiver();
|
||||
case Builtins::kPromiseReject:
|
||||
case BuiltinFunctionId::kPromiseReject:
|
||||
return Type::Receiver();
|
||||
case Builtins::kPromiseResolveTrampoline:
|
||||
case BuiltinFunctionId::kPromiseResolve:
|
||||
return Type::Receiver();
|
||||
|
||||
// RegExp functions.
|
||||
case Builtins::kRegExpPrototypeCompile:
|
||||
case BuiltinFunctionId::kRegExpCompile:
|
||||
return Type::OtherObject();
|
||||
case Builtins::kRegExpPrototypeExec:
|
||||
case BuiltinFunctionId::kRegExpExec:
|
||||
return Type::Union(Type::Array(), Type::Null(), t->zone());
|
||||
case Builtins::kRegExpPrototypeTest:
|
||||
case BuiltinFunctionId::kRegExpTest:
|
||||
return Type::Boolean();
|
||||
case Builtins::kRegExpPrototypeToString:
|
||||
case BuiltinFunctionId::kRegExpToString:
|
||||
return Type::String();
|
||||
|
||||
// Function functions.
|
||||
case Builtins::kFunctionPrototypeBind:
|
||||
case BuiltinFunctionId::kFunctionBind:
|
||||
return Type::BoundFunction();
|
||||
case Builtins::kFunctionPrototypeHasInstance:
|
||||
case BuiltinFunctionId::kFunctionHasInstance:
|
||||
return Type::Boolean();
|
||||
|
||||
// Global functions.
|
||||
case Builtins::kGlobalDecodeURI:
|
||||
case Builtins::kGlobalDecodeURIComponent:
|
||||
case Builtins::kGlobalEncodeURI:
|
||||
case Builtins::kGlobalEncodeURIComponent:
|
||||
case Builtins::kGlobalEscape:
|
||||
case Builtins::kGlobalUnescape:
|
||||
case BuiltinFunctionId::kGlobalDecodeURI:
|
||||
case BuiltinFunctionId::kGlobalDecodeURIComponent:
|
||||
case BuiltinFunctionId::kGlobalEncodeURI:
|
||||
case BuiltinFunctionId::kGlobalEncodeURIComponent:
|
||||
case BuiltinFunctionId::kGlobalEscape:
|
||||
case BuiltinFunctionId::kGlobalUnescape:
|
||||
return Type::String();
|
||||
case Builtins::kGlobalIsFinite:
|
||||
case Builtins::kGlobalIsNaN:
|
||||
case BuiltinFunctionId::kGlobalIsFinite:
|
||||
case BuiltinFunctionId::kGlobalIsNaN:
|
||||
return Type::Boolean();
|
||||
|
||||
// Map functions.
|
||||
case Builtins::kMapPrototypeClear:
|
||||
case Builtins::kMapPrototypeForEach:
|
||||
case BuiltinFunctionId::kMapClear:
|
||||
case BuiltinFunctionId::kMapForEach:
|
||||
return Type::Undefined();
|
||||
case Builtins::kMapPrototypeDelete:
|
||||
case Builtins::kMapPrototypeHas:
|
||||
case BuiltinFunctionId::kMapDelete:
|
||||
case BuiltinFunctionId::kMapHas:
|
||||
return Type::Boolean();
|
||||
case Builtins::kMapPrototypeEntries:
|
||||
case Builtins::kMapPrototypeKeys:
|
||||
case Builtins::kMapPrototypeSet:
|
||||
case Builtins::kMapPrototypeValues:
|
||||
case BuiltinFunctionId::kMapEntries:
|
||||
case BuiltinFunctionId::kMapKeys:
|
||||
case BuiltinFunctionId::kMapSet:
|
||||
case BuiltinFunctionId::kMapValues:
|
||||
return Type::OtherObject();
|
||||
|
||||
// Set functions.
|
||||
case Builtins::kSetPrototypeAdd:
|
||||
case Builtins::kSetPrototypeEntries:
|
||||
case Builtins::kSetPrototypeValues:
|
||||
case BuiltinFunctionId::kSetAdd:
|
||||
case BuiltinFunctionId::kSetEntries:
|
||||
case BuiltinFunctionId::kSetValues:
|
||||
return Type::OtherObject();
|
||||
case Builtins::kSetPrototypeClear:
|
||||
case Builtins::kSetPrototypeForEach:
|
||||
case BuiltinFunctionId::kSetClear:
|
||||
case BuiltinFunctionId::kSetForEach:
|
||||
return Type::Undefined();
|
||||
case Builtins::kSetPrototypeDelete:
|
||||
case Builtins::kSetPrototypeHas:
|
||||
case BuiltinFunctionId::kSetDelete:
|
||||
case BuiltinFunctionId::kSetHas:
|
||||
return Type::Boolean();
|
||||
|
||||
// WeakMap functions.
|
||||
case Builtins::kWeakMapPrototypeDelete:
|
||||
case Builtins::kWeakMapPrototypeHas:
|
||||
case BuiltinFunctionId::kWeakMapDelete:
|
||||
case BuiltinFunctionId::kWeakMapHas:
|
||||
return Type::Boolean();
|
||||
case Builtins::kWeakMapPrototypeSet:
|
||||
case BuiltinFunctionId::kWeakMapSet:
|
||||
return Type::OtherObject();
|
||||
|
||||
// WeakSet functions.
|
||||
case Builtins::kWeakSetPrototypeAdd:
|
||||
case BuiltinFunctionId::kWeakSetAdd:
|
||||
return Type::OtherObject();
|
||||
case Builtins::kWeakSetPrototypeDelete:
|
||||
case Builtins::kWeakSetPrototypeHas:
|
||||
case BuiltinFunctionId::kWeakSetDelete:
|
||||
case BuiltinFunctionId::kWeakSetHas:
|
||||
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::kWeakMapPrototypeHas:
|
||||
case Builtins::kWeakMapHas:
|
||||
// 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::kWeakSetPrototypeHas:
|
||||
case Builtins::kWeakSetHas:
|
||||
// String builtins. Strings are immutable.
|
||||
case Builtins::kStringFromCharCode:
|
||||
case Builtins::kStringFromCodePoint:
|
||||
|
@ -3664,6 +3664,8 @@ 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 (HasBuiltinId()) {
|
||||
if (HasBuiltinFunctionId()) {
|
||||
TraceInlining(*this, "false (is a builtin)");
|
||||
return false;
|
||||
}
|
||||
|
224
src/objects/builtin-function-id.h
Normal file
224
src/objects/builtin-function-id.h
Normal file
@ -0,0 +1,224 @@
|
||||
// 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_
|
@ -133,6 +133,8 @@ 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, raw_function_token_offset,
|
||||
kFunctionTokenOffsetOffset)
|
||||
RELAXED_INT32_ACCESSORS(SharedFunctionInfo, flags, kFlagsOffset)
|
||||
@ -706,6 +708,18 @@ 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,6 +8,7 @@
|
||||
#include "src/bailout-reason.h"
|
||||
#include "src/function-kind.h"
|
||||
#include "src/objects.h"
|
||||
#include "src/objects/builtin-function-id.h"
|
||||
#include "src/objects/script.h"
|
||||
#include "src/objects/smi.h"
|
||||
#include "src/objects/struct.h"
|
||||
@ -353,7 +354,11 @@ class SharedFunctionInfo : public HeapObject {
|
||||
inline AsmWasmData asm_wasm_data() const;
|
||||
inline void set_asm_wasm_data(AsmWasmData data);
|
||||
|
||||
// builtin_id corresponds to the auto-generated Builtins::Name id.
|
||||
// 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).
|
||||
inline bool HasBuiltinId() const;
|
||||
inline int builtin_id() const;
|
||||
inline void set_builtin_id(int builtin_id);
|
||||
@ -373,6 +378,18 @@ 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
|
||||
|
Loading…
Reference in New Issue
Block a user