Commit 84ff61d3 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[runtime] Share V8-internal AccessorInfo objects via rootset.

This should avoid changes in code serializer in a follow-up class literals
improvement CL.

Bug: v8:5799
Change-Id: I4e4386333bcc7abb30399d4e9abba4eee80ca932
Reviewed-on: https://chromium-review.googlesource.com/733037
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48996}
parent 6d1522d5
......@@ -134,7 +134,7 @@ void Accessors::ArgumentsIteratorGetter(
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate)));
}
Handle<AccessorInfo> Accessors::ArgumentsIteratorInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeArgumentsIteratorInfo(Isolate* isolate) {
Handle<Name> name = isolate->factory()->iterator_symbol();
return MakeAccessor(isolate, name, &ArgumentsIteratorGetter, nullptr);
}
......@@ -216,7 +216,7 @@ void Accessors::ArrayLengthSetter(
}
}
Handle<AccessorInfo> Accessors::ArrayLengthInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeArrayLengthInfo(Isolate* isolate) {
return MakeAccessor(isolate, isolate->factory()->length_string(),
&ArrayLengthGetter, &ArrayLengthSetter);
}
......@@ -259,8 +259,8 @@ void Accessors::ModuleNamespaceEntrySetter(
}
}
Handle<AccessorInfo> Accessors::ModuleNamespaceEntryInfo(Isolate* isolate,
Handle<String> name) {
Handle<AccessorInfo> Accessors::MakeModuleNamespaceEntryInfo(
Isolate* isolate, Handle<String> name) {
return MakeAccessor(isolate, name, &ModuleNamespaceEntryGetter,
&ModuleNamespaceEntrySetter);
}
......@@ -293,7 +293,7 @@ void Accessors::StringLengthGetter(
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate)));
}
Handle<AccessorInfo> Accessors::StringLengthInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeStringLengthInfo(Isolate* isolate) {
return MakeAccessor(isolate, isolate->factory()->length_string(),
&StringLengthGetter, nullptr);
}
......@@ -316,7 +316,7 @@ void Accessors::ScriptColumnOffsetGetter(
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate)));
}
Handle<AccessorInfo> Accessors::ScriptColumnOffsetInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeScriptColumnOffsetInfo(Isolate* isolate) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("column_offset")));
return MakeAccessor(isolate, name, &ScriptColumnOffsetGetter, nullptr);
......@@ -339,7 +339,7 @@ void Accessors::ScriptIdGetter(
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(id, isolate)));
}
Handle<AccessorInfo> Accessors::ScriptIdInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeScriptIdInfo(Isolate* isolate) {
Handle<String> name(
isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("id")));
return MakeAccessor(isolate, name, &ScriptIdGetter, nullptr);
......@@ -362,7 +362,7 @@ void Accessors::ScriptNameGetter(
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate)));
}
Handle<AccessorInfo> Accessors::ScriptNameInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeScriptNameInfo(Isolate* isolate) {
return MakeAccessor(isolate, isolate->factory()->name_string(),
&ScriptNameGetter, nullptr);
}
......@@ -384,7 +384,7 @@ void Accessors::ScriptSourceGetter(
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate)));
}
Handle<AccessorInfo> Accessors::ScriptSourceInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeScriptSourceInfo(Isolate* isolate) {
return MakeAccessor(isolate, isolate->factory()->source_string(),
&ScriptSourceGetter, nullptr);
}
......@@ -407,7 +407,7 @@ void Accessors::ScriptLineOffsetGetter(
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate)));
}
Handle<AccessorInfo> Accessors::ScriptLineOffsetInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeScriptLineOffsetInfo(Isolate* isolate) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("line_offset")));
return MakeAccessor(isolate, name, &ScriptLineOffsetGetter, nullptr);
......@@ -431,7 +431,7 @@ void Accessors::ScriptTypeGetter(
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate)));
}
Handle<AccessorInfo> Accessors::ScriptTypeInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeScriptTypeInfo(Isolate* isolate) {
Handle<String> name(
isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("type")));
return MakeAccessor(isolate, name, &ScriptTypeGetter, nullptr);
......@@ -455,7 +455,8 @@ void Accessors::ScriptCompilationTypeGetter(
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate)));
}
Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeScriptCompilationTypeInfo(
Isolate* isolate) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("compilation_type")));
return MakeAccessor(isolate, name, &ScriptCompilationTypeGetter, nullptr);
......@@ -478,7 +479,7 @@ void Accessors::ScriptSourceUrlGetter(
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate)));
}
Handle<AccessorInfo> Accessors::ScriptSourceUrlInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeScriptSourceUrlInfo(Isolate* isolate) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("source_url")));
return MakeAccessor(isolate, name, &ScriptSourceUrlGetter, nullptr);
......@@ -502,7 +503,8 @@ void Accessors::ScriptSourceMappingUrlGetter(
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate)));
}
Handle<AccessorInfo> Accessors::ScriptSourceMappingUrlInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeScriptSourceMappingUrlInfo(
Isolate* isolate) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("source_mapping_url")));
return MakeAccessor(isolate, name, &ScriptSourceMappingUrlGetter, nullptr);
......@@ -525,7 +527,7 @@ void Accessors::ScriptContextDataGetter(
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate)));
}
Handle<AccessorInfo> Accessors::ScriptContextDataInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeScriptContextDataInfo(Isolate* isolate) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("context_data")));
return MakeAccessor(isolate, name, &ScriptContextDataGetter, nullptr);
......@@ -558,7 +560,7 @@ void Accessors::ScriptEvalFromScriptGetter(
info.GetReturnValue().Set(Utils::ToLocal(result));
}
Handle<AccessorInfo> Accessors::ScriptEvalFromScriptInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeScriptEvalFromScriptInfo(Isolate* isolate) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("eval_from_script")));
return MakeAccessor(isolate, name, &ScriptEvalFromScriptGetter, nullptr);
......@@ -585,7 +587,7 @@ void Accessors::ScriptEvalFromScriptPositionGetter(
info.GetReturnValue().Set(Utils::ToLocal(result));
}
Handle<AccessorInfo> Accessors::ScriptEvalFromScriptPositionInfo(
Handle<AccessorInfo> Accessors::MakeScriptEvalFromScriptPositionInfo(
Isolate* isolate) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("eval_from_script_position")));
......@@ -617,7 +619,7 @@ void Accessors::ScriptEvalFromFunctionNameGetter(
info.GetReturnValue().Set(Utils::ToLocal(result));
}
Handle<AccessorInfo> Accessors::ScriptEvalFromFunctionNameInfo(
Handle<AccessorInfo> Accessors::MakeScriptEvalFromFunctionNameInfo(
Isolate* isolate) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("eval_from_function_name")));
......@@ -666,7 +668,7 @@ void Accessors::FunctionPrototypeSetter(
info.GetReturnValue().Set(true);
}
Handle<AccessorInfo> Accessors::FunctionPrototypeInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeFunctionPrototypeInfo(Isolate* isolate) {
return MakeAccessor(isolate, isolate->factory()->prototype_string(),
&FunctionPrototypeGetter, &FunctionPrototypeSetter);
}
......@@ -692,7 +694,7 @@ void Accessors::FunctionLengthGetter(
info.GetReturnValue().Set(Utils::ToLocal(result));
}
Handle<AccessorInfo> Accessors::FunctionLengthInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeFunctionLengthInfo(Isolate* isolate) {
return MakeAccessor(isolate, isolate->factory()->length_string(),
&FunctionLengthGetter, &ReconfigureToDataProperty);
}
......@@ -714,7 +716,7 @@ void Accessors::FunctionNameGetter(
info.GetReturnValue().Set(Utils::ToLocal(result));
}
Handle<AccessorInfo> Accessors::FunctionNameInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeFunctionNameInfo(Isolate* isolate) {
return MakeAccessor(isolate, isolate->factory()->name_string(),
&FunctionNameGetter, &ReconfigureToDataProperty);
}
......@@ -863,7 +865,7 @@ void Accessors::FunctionArgumentsGetter(
info.GetReturnValue().Set(Utils::ToLocal(result));
}
Handle<AccessorInfo> Accessors::FunctionArgumentsInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeFunctionArgumentsInfo(Isolate* isolate) {
return MakeAccessor(isolate, isolate->factory()->arguments_string(),
&FunctionArgumentsGetter, nullptr);
}
......@@ -1039,7 +1041,7 @@ void Accessors::FunctionCallerGetter(
info.GetReturnValue().Set(Utils::ToLocal(result));
}
Handle<AccessorInfo> Accessors::FunctionCallerInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeFunctionCallerInfo(Isolate* isolate) {
return MakeAccessor(isolate, isolate->factory()->caller_string(),
&FunctionCallerGetter, nullptr);
}
......@@ -1067,7 +1069,7 @@ void Accessors::BoundFunctionLengthGetter(
info.GetReturnValue().Set(Utils::ToLocal(result));
}
Handle<AccessorInfo> Accessors::BoundFunctionLengthInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeBoundFunctionLengthInfo(Isolate* isolate) {
return MakeAccessor(isolate, isolate->factory()->length_string(),
&BoundFunctionLengthGetter, &ReconfigureToDataProperty);
}
......@@ -1092,7 +1094,7 @@ void Accessors::BoundFunctionNameGetter(
info.GetReturnValue().Set(Utils::ToLocal(result));
}
Handle<AccessorInfo> Accessors::BoundFunctionNameInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeBoundFunctionNameInfo(Isolate* isolate) {
return MakeAccessor(isolate, isolate->factory()->name_string(),
&BoundFunctionNameGetter, &ReconfigureToDataProperty);
}
......@@ -1207,7 +1209,7 @@ void Accessors::ErrorStackSetter(
Accessors::ReconfigureToDataProperty(name, val, info);
}
Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate) {
Handle<AccessorInfo> Accessors::MakeErrorStackInfo(Isolate* isolate) {
return MakeAccessor(isolate, isolate->factory()->stack_string(),
&ErrorStackGetter, &ErrorStackSetter);
}
......
......@@ -20,31 +20,31 @@ class Handle;
// The list of accessor descriptors. This is a second-order macro
// taking a macro to be applied to all accessor descriptor names.
#define ACCESSOR_INFO_LIST(V) \
V(ArgumentsIterator) \
V(ArrayLength) \
V(BoundFunctionLength) \
V(BoundFunctionName) \
V(ErrorStack) \
V(FunctionArguments) \
V(FunctionCaller) \
V(FunctionName) \
V(FunctionLength) \
V(FunctionPrototype) \
V(ScriptColumnOffset) \
V(ScriptCompilationType) \
V(ScriptContextData) \
V(ScriptEvalFromScript) \
V(ScriptEvalFromScriptPosition) \
V(ScriptEvalFromFunctionName) \
V(ScriptId) \
V(ScriptLineOffset) \
V(ScriptName) \
V(ScriptSource) \
V(ScriptType) \
V(ScriptSourceUrl) \
V(ScriptSourceMappingUrl) \
V(StringLength)
#define ACCESSOR_INFO_LIST(V) \
V(arguments_iterator, ArgumentsIterator) \
V(array_length, ArrayLength) \
V(bound_function_length, BoundFunctionLength) \
V(bound_function_name, BoundFunctionName) \
V(error_stack, ErrorStack) \
V(function_arguments, FunctionArguments) \
V(function_caller, FunctionCaller) \
V(function_name, FunctionName) \
V(function_length, FunctionLength) \
V(function_prototype, FunctionPrototype) \
V(script_column_offset, ScriptColumnOffset) \
V(script_compilation_type, ScriptCompilationType) \
V(script_context_data, ScriptContextData) \
V(script_eval_from_script, ScriptEvalFromScript) \
V(script_eval_from_script_position, ScriptEvalFromScriptPosition) \
V(script_eval_from_function_name, ScriptEvalFromFunctionName) \
V(script_id, ScriptId) \
V(script_line_offset, ScriptLineOffset) \
V(script_name, ScriptName) \
V(script_source, ScriptSource) \
V(script_type, ScriptType) \
V(script_source_url, ScriptSourceUrl) \
V(script_source_mapping_url, ScriptSourceMappingUrl) \
V(string_length, StringLength)
#define ACCESSOR_SETTER_LIST(V) \
V(ArrayLengthSetter) \
......@@ -57,34 +57,25 @@ class Handle;
class Accessors : public AllStatic {
public:
// Accessor descriptors.
#define ACCESSOR_INFO_DECLARATION(name) \
static void name##Getter(v8::Local<v8::Name> name, \
const v8::PropertyCallbackInfo<v8::Value>& info); \
static Handle<AccessorInfo> name##Info(Isolate* isolate);
ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
#undef ACCESSOR_INFO_DECLARATION
#define ACCESSOR_GETTER_DECLARATION(accessor_name, AccessorName) \
static void AccessorName##Getter( \
v8::Local<v8::Name> name, \
const v8::PropertyCallbackInfo<v8::Value>& info);
ACCESSOR_INFO_LIST(ACCESSOR_GETTER_DECLARATION)
#undef ACCESSOR_GETTER_DECLARATION
#define ACCESSOR_SETTER_DECLARATION(name) \
static void name(v8::Local<v8::Name> name, v8::Local<v8::Value> value, \
const v8::PropertyCallbackInfo<v8::Boolean>& info);
#define ACCESSOR_SETTER_DECLARATION(accessor_name) \
static void accessor_name( \
v8::Local<v8::Name> name, v8::Local<v8::Value> value, \
const v8::PropertyCallbackInfo<v8::Boolean>& info);
ACCESSOR_SETTER_LIST(ACCESSOR_SETTER_DECLARATION)
#undef ACCESSOR_SETTER_DECLARATION
static void ModuleNamespaceEntryGetter(
v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info);
static Handle<AccessorInfo> ModuleNamespaceEntryInfo(Isolate* isolate,
Handle<String> name);
enum DescriptorId {
#define ACCESSOR_INFO_DECLARATION(name) \
k##name##Getter, \
k##name##Setter,
ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
#undef ACCESSOR_INFO_DECLARATION
descriptorCount
};
static Handle<AccessorInfo> MakeModuleNamespaceEntryInfo(Isolate* isolate,
Handle<String> name);
// Accessor functions called directly from the runtime system.
static Handle<JSObject> FunctionGetArguments(Handle<JSFunction> object);
......@@ -109,6 +100,14 @@ class Accessors : public AllStatic {
static Handle<AccessorInfo> MakeAccessor(
Isolate* isolate, Handle<Name> name, AccessorNameGetterCallback getter,
AccessorNameBooleanSetterCallback setter);
private:
#define ACCESSOR_INFO_DECLARATION(accessor_name, AccessorName) \
static Handle<AccessorInfo> Make##AccessorName##Info(Isolate* isolate);
ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
#undef ACCESSOR_INFO_DECLARATION
friend class Heap;
};
} // namespace internal
......
......@@ -1342,7 +1342,7 @@ static void InstallError(Isolate* isolate, Handle<JSObject> global,
Map::EnsureDescriptorSlack(initial_map, 1);
{
Handle<AccessorInfo> info = Accessors::ErrorStackInfo(isolate);
Handle<AccessorInfo> info = factory->error_stack_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, DONT_ENUM);
initial_map->AppendDescriptor(&d);
......@@ -1617,9 +1617,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
DONT_ENUM | DONT_DELETE);
{ // Add length.
Handle<AccessorInfo> info = Accessors::ArrayLengthInfo(isolate);
Descriptor d =
Descriptor::AccessorConstant(factory->length_string(), info, attribs);
Descriptor d = Descriptor::AccessorConstant(
factory->length_string(), factory->array_length_accessor(), attribs);
initial_map->AppendDescriptor(&d);
}
......@@ -1927,9 +1926,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
DONT_ENUM | DONT_DELETE | READ_ONLY);
{ // Add length.
Handle<AccessorInfo> info = Accessors::StringLengthInfo(isolate);
Descriptor d =
Descriptor::AccessorConstant(factory->length_string(), info, attribs);
Descriptor d = Descriptor::AccessorConstant(
factory->length_string(), factory->string_length_accessor(), attribs);
string_map->AppendDescriptor(&d);
}
......@@ -3409,16 +3407,16 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Map::EnsureDescriptorSlack(map, 2);
{ // length
Handle<AccessorInfo> info = Accessors::BoundFunctionLengthInfo(isolate);
Descriptor d = Descriptor::AccessorConstant(factory->length_string(),
info, roc_attribs);
Descriptor d = Descriptor::AccessorConstant(
factory->length_string(), factory->bound_function_length_accessor(),
roc_attribs);
map->AppendDescriptor(&d);
}
{ // name
Handle<AccessorInfo> info = Accessors::BoundFunctionNameInfo(isolate);
Descriptor d = Descriptor::AccessorConstant(factory->name_string(), info,
roc_attribs);
Descriptor d = Descriptor::AccessorConstant(
factory->name_string(), factory->bound_function_name_accessor(),
roc_attribs);
map->AppendDescriptor(&d);
}
native_context()->set_bound_function_without_constructor_map(*map);
......@@ -3983,63 +3981,63 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
{ // column_offset
Handle<AccessorInfo> info = Accessors::ScriptColumnOffsetInfo(isolate);
Handle<AccessorInfo> info = factory->script_column_offset_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, attribs);
script_map->AppendDescriptor(&d);
}
{ // id
Handle<AccessorInfo> info = Accessors::ScriptIdInfo(isolate);
Handle<AccessorInfo> info = factory->script_id_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, attribs);
script_map->AppendDescriptor(&d);
}
{ // name
Handle<AccessorInfo> info = Accessors::ScriptNameInfo(isolate);
Handle<AccessorInfo> info = factory->script_name_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, attribs);
script_map->AppendDescriptor(&d);
}
{ // line_offset
Handle<AccessorInfo> info = Accessors::ScriptLineOffsetInfo(isolate);
Handle<AccessorInfo> info = factory->script_line_offset_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, attribs);
script_map->AppendDescriptor(&d);
}
{ // source
Handle<AccessorInfo> info = Accessors::ScriptSourceInfo(isolate);
Handle<AccessorInfo> info = factory->script_source_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, attribs);
script_map->AppendDescriptor(&d);
}
{ // type
Handle<AccessorInfo> info = Accessors::ScriptTypeInfo(isolate);
Handle<AccessorInfo> info = factory->script_type_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, attribs);
script_map->AppendDescriptor(&d);
}
{ // compilation_type
Handle<AccessorInfo> info = Accessors::ScriptCompilationTypeInfo(isolate);
Handle<AccessorInfo> info = factory->script_compilation_type_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, attribs);
script_map->AppendDescriptor(&d);
}
{ // context_data
Handle<AccessorInfo> info = Accessors::ScriptContextDataInfo(isolate);
Handle<AccessorInfo> info = factory->script_context_data_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, attribs);
script_map->AppendDescriptor(&d);
}
{ // eval_from_script
Handle<AccessorInfo> info = Accessors::ScriptEvalFromScriptInfo(isolate);
Handle<AccessorInfo> info = factory->script_eval_from_script_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, attribs);
script_map->AppendDescriptor(&d);
......@@ -4047,7 +4045,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
{ // eval_from_script_position
Handle<AccessorInfo> info =
Accessors::ScriptEvalFromScriptPositionInfo(isolate);
factory->script_eval_from_script_position_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, attribs);
script_map->AppendDescriptor(&d);
......@@ -4055,22 +4053,21 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
{ // eval_from_function_name
Handle<AccessorInfo> info =
Accessors::ScriptEvalFromFunctionNameInfo(isolate);
factory->script_eval_from_function_name_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, attribs);
script_map->AppendDescriptor(&d);
}
{ // source_url
Handle<AccessorInfo> info = Accessors::ScriptSourceUrlInfo(isolate);
Handle<AccessorInfo> info = factory->script_source_url_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, attribs);
script_map->AppendDescriptor(&d);
}
{ // source_mapping_url
Handle<AccessorInfo> info =
Accessors::ScriptSourceMappingUrlInfo(isolate);
Handle<AccessorInfo> info = factory->script_source_mapping_url_accessor();
Descriptor d = Descriptor::AccessorConstant(handle(info->name(), isolate),
info, attribs);
script_map->AppendDescriptor(&d);
......@@ -4510,9 +4507,9 @@ Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target,
DONT_ENUM | DONT_DELETE);
{ // Add length.
Handle<AccessorInfo> info = Accessors::ArrayLengthInfo(isolate());
Descriptor d =
Descriptor::AccessorConstant(factory()->length_string(), info, attribs);
Descriptor d = Descriptor::AccessorConstant(
factory()->length_string(), factory()->array_length_accessor(),
attribs);
initial_map->AppendDescriptor(&d);
}
......@@ -4823,7 +4820,7 @@ bool Genesis::InstallNatives(GlobalContextType context_type) {
{
PropertyAttributes attribs = DONT_ENUM;
Handle<AccessorInfo> arguments_iterator =
Accessors::ArgumentsIteratorInfo(isolate());
factory()->arguments_iterator_accessor();
{
Descriptor d = Descriptor::AccessorConstant(factory()->iterator_symbol(),
arguments_iterator, attribs);
......
......@@ -60,7 +60,7 @@ BUILTIN(ErrorCaptureStackTrace) {
// Add the stack accessors.
Handle<AccessorInfo> error_stack = Accessors::ErrorStackInfo(isolate);
Handle<AccessorInfo> error_stack = isolate->factory()->error_stack_accessor();
Handle<Name> name(Name::cast(error_stack->name()), isolate);
// Explicitly check for frozen objects. Other access checks are performed by
......
......@@ -392,8 +392,9 @@ void ExternalReferenceTable::AddAccessors(Isolate* isolate) {
};
static const AccessorRefTable getters[] = {
#define ACCESSOR_INFO_DECLARATION(name) \
{FUNCTION_ADDR(&Accessors::name##Getter), "Accessors::" #name "Getter"},
#define ACCESSOR_INFO_DECLARATION(accessor_name, AccessorName) \
{FUNCTION_ADDR(&Accessors::AccessorName##Getter), \
"Accessors::" #AccessorName "Getter"}, /* NOLINT(whitespace/indent) */
ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
#undef ACCESSOR_INFO_DECLARATION
};
......@@ -401,7 +402,7 @@ void ExternalReferenceTable::AddAccessors(Isolate* isolate) {
#define ACCESSOR_SETTER_DECLARATION(name) \
{ FUNCTION_ADDR(&Accessors::name), "Accessors::" #name},
ACCESSOR_SETTER_LIST(ACCESSOR_SETTER_DECLARATION)
#undef ACCESSOR_INFO_DECLARATION
#undef ACCESSOR_SETTER_DECLARATION
};
for (unsigned i = 0; i < arraysize(getters); ++i) {
......@@ -449,3 +450,5 @@ void ExternalReferenceTable::AddStubCache(Isolate* isolate) {
} // namespace internal
} // namespace v8
#undef SYMBOLIZE_FUNCTION
......@@ -54,6 +54,16 @@ PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
#define ACCESSOR_INFO_ACCESSOR(accessor_name, AccessorName) \
Handle<AccessorInfo> Factory::accessor_name##_accessor() { \
return Handle<AccessorInfo>(bit_cast<AccessorInfo**>( \
&isolate() \
->heap() \
->roots_[Heap::k##AccessorName##AccessorRootIndex])); \
}
ACCESSOR_INFO_LIST(ACCESSOR_INFO_ACCESSOR)
#undef ACCESSOR_INFO_ACCESSOR
Handle<String> Factory::InternalizeString(Handle<String> string) {
if (string->IsInternalizedString()) return string;
return StringTable::LookupString(isolate(), string);
......
......@@ -3012,9 +3012,8 @@ Handle<Map> Factory::CreateSloppyFunctionMap(
int field_index = 0;
STATIC_ASSERT(JSFunction::kLengthDescriptorIndex == 0);
{ // Add length accessor.
Handle<AccessorInfo> info = Accessors::FunctionLengthInfo(isolate());
Descriptor d =
Descriptor::AccessorConstant(length_string(), info, roc_attribs);
Descriptor d = Descriptor::AccessorConstant(
length_string(), function_length_accessor(), roc_attribs);
map->AppendDescriptor(&d);
}
......@@ -3028,21 +3027,18 @@ Handle<Map> Factory::CreateSloppyFunctionMap(
} else {
// Add name accessor.
Handle<AccessorInfo> info = Accessors::FunctionNameInfo(isolate());
Descriptor d =
Descriptor::AccessorConstant(name_string(), info, roc_attribs);
Descriptor d = Descriptor::AccessorConstant(
name_string(), function_name_accessor(), roc_attribs);
map->AppendDescriptor(&d);
}
{ // Add arguments accessor.
Handle<AccessorInfo> info = Accessors::FunctionArgumentsInfo(isolate());
Descriptor d =
Descriptor::AccessorConstant(arguments_string(), info, ro_attribs);
Descriptor d = Descriptor::AccessorConstant(
arguments_string(), function_arguments_accessor(), ro_attribs);
map->AppendDescriptor(&d);
}
{ // Add caller accessor.
Handle<AccessorInfo> info = Accessors::FunctionCallerInfo(isolate());
Descriptor d =
Descriptor::AccessorConstant(caller_string(), info, ro_attribs);
Descriptor d = Descriptor::AccessorConstant(
caller_string(), function_caller_accessor(), ro_attribs);
map->AppendDescriptor(&d);
}
if (IsFunctionModeWithPrototype(function_mode)) {
......@@ -3050,9 +3046,8 @@ Handle<Map> Factory::CreateSloppyFunctionMap(
PropertyAttributes attribs =
IsFunctionModeWithWritablePrototype(function_mode) ? rw_attribs
: ro_attribs;
Handle<AccessorInfo> info = Accessors::FunctionPrototypeInfo(isolate());
Descriptor d =
Descriptor::AccessorConstant(prototype_string(), info, attribs);
Descriptor d = Descriptor::AccessorConstant(
prototype_string(), function_prototype_accessor(), attribs);
map->AppendDescriptor(&d);
}
DCHECK_EQ(inobject_properties_count, field_index);
......@@ -3093,9 +3088,8 @@ Handle<Map> Factory::CreateStrictFunctionMap(
int field_index = 0;
STATIC_ASSERT(JSFunction::kLengthDescriptorIndex == 0);
{ // Add length accessor.
Handle<AccessorInfo> info = Accessors::FunctionLengthInfo(isolate());
Descriptor d =
Descriptor::AccessorConstant(length_string(), info, roc_attribs);
Descriptor d = Descriptor::AccessorConstant(
length_string(), function_length_accessor(), roc_attribs);
map->AppendDescriptor(&d);
}
......@@ -3109,9 +3103,8 @@ Handle<Map> Factory::CreateStrictFunctionMap(
} else {
// Add name accessor.
Handle<AccessorInfo> info = Accessors::FunctionNameInfo(isolate());
Descriptor d =
Descriptor::AccessorConstant(name_string(), info, roc_attribs);
Descriptor d = Descriptor::AccessorConstant(
name_string(), function_name_accessor(), roc_attribs);
map->AppendDescriptor(&d);
}
......@@ -3120,9 +3113,8 @@ Handle<Map> Factory::CreateStrictFunctionMap(
PropertyAttributes attribs =
IsFunctionModeWithWritablePrototype(function_mode) ? rw_attribs
: ro_attribs;
Handle<AccessorInfo> info = Accessors::FunctionPrototypeInfo(isolate());
Descriptor d =
Descriptor::AccessorConstant(prototype_string(), info, attribs);
Descriptor d = Descriptor::AccessorConstant(
prototype_string(), function_prototype_accessor(), attribs);
map->AppendDescriptor(&d);
}
......@@ -3156,17 +3148,15 @@ Handle<Map> Factory::CreateClassFunctionMap(Handle<JSFunction> empty_function) {
STATIC_ASSERT(JSFunction::kLengthDescriptorIndex == 0);
{ // Add length accessor.
Handle<AccessorInfo> info = Accessors::FunctionLengthInfo(isolate());
Descriptor d =
Descriptor::AccessorConstant(length_string(), info, roc_attribs);
Descriptor d = Descriptor::AccessorConstant(
length_string(), function_length_accessor(), roc_attribs);
map->AppendDescriptor(&d);
}
{
// Add prototype accessor.
Handle<AccessorInfo> info = Accessors::FunctionPrototypeInfo(isolate());
Descriptor d =
Descriptor::AccessorConstant(prototype_string(), info, rw_attribs);
Descriptor d = Descriptor::AccessorConstant(
prototype_string(), function_prototype_accessor(), rw_attribs);
map->AppendDescriptor(&d);
}
return map;
......
......@@ -757,6 +757,11 @@ class V8_EXPORT_PRIVATE Factory final {
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
#define ACCESSOR_INFO_ACCESSOR(accessor_name, AccessorName) \
inline Handle<AccessorInfo> accessor_name##_accessor();
ACCESSOR_INFO_LIST(ACCESSOR_INFO_ACCESSOR)
#undef ACCESSOR_INFO_ACCESSOR
// Allocates a new SharedFunctionInfo object.
Handle<SharedFunctionInfo> NewSharedFunctionInfo(
MaybeHandle<String> name, FunctionKind kind, Handle<Code> code,
......
......@@ -66,6 +66,13 @@ PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
#define ACCESSOR_INFO_ACCESSOR(accessor_name, AccessorName) \
AccessorInfo* Heap::accessor_name##_accessor() { \
return AccessorInfo::cast(roots_[k##AccessorName##AccessorRootIndex]); \
}
ACCESSOR_INFO_LIST(ACCESSOR_INFO_ACCESSOR)
#undef ACCESSOR_INFO_ACCESSOR
#define ROOT_ACCESSOR(type, name, camel_name) \
void Heap::set_##name(type* value) { \
/* The deserializer makes use of the fact that these common roots are */ \
......
......@@ -13,6 +13,7 @@
// Clients of this interface shouldn't depend on lots of heap internals.
// Do not include anything from src/heap here!
#include "include/v8.h"
#include "src/accessors.h"
#include "src/allocation.h"
#include "src/assert-scope.h"
#include "src/base/atomic-utils.h"
......@@ -551,11 +552,16 @@ class Heap {
WELL_KNOWN_SYMBOL_LIST(SYMBOL_INDEX_DECLARATION)
#undef SYMBOL_INDEX_DECLARATION
#define ACCESSOR_INDEX_DECLARATION(accessor_name, AccessorName) \
k##AccessorName##AccessorRootIndex,
ACCESSOR_INFO_LIST(ACCESSOR_INDEX_DECLARATION)
#undef ACCESSOR_INDEX_DECLARATION
// Utility type maps
#define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex,
STRUCT_LIST(DECLARE_STRUCT_MAP)
STRUCT_LIST(DECLARE_STRUCT_MAP)
#undef DECLARE_STRUCT_MAP
kStringTableRootIndex,
kStringTableRootIndex,
#define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex,
SMI_ROOT_LIST(ROOT_INDEX_DECLARATION)
......@@ -797,7 +803,7 @@ class Heap {
// Support for the API.
//
bool CreateApiObjects();
void CreateApiObjects();
// Implements the corresponding V8 API function.
bool IdleNotification(double deadline_in_seconds);
......@@ -1020,6 +1026,11 @@ class Heap {
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
#undef SYMBOL_ACCESSOR
#define ACCESSOR_INFO_ACCESSOR(accessor_name, AccessorName) \
inline AccessorInfo* accessor_name##_accessor();
ACCESSOR_INFO_LIST(ACCESSOR_INFO_ACCESSOR)
#undef ACCESSOR_INFO_ACCESSOR
Object* root(RootListIndex index) { return roots_[index]; }
Handle<Object> root_handle(RootListIndex index) {
return Handle<Object>(&roots_[index]);
......@@ -1726,6 +1737,7 @@ class Heap {
AllocationSite* allocation_site);
bool CreateInitialMaps();
void CreateInternalAccessorInfoObjects();
void CreateInitialObjects();
// These five Create*EntryStub functions are here and forced to not be inlined
......
......@@ -4,6 +4,7 @@
#include "src/setup-isolate.h"
#include "src/accessors.h"
#include "src/ast/context-slot-cache.h"
#include "src/compilation-cache.h"
#include "src/contexts.h"
......@@ -35,10 +36,11 @@ bool SetupIsolateDelegate::SetupHeapInternal(Heap* heap) {
bool Heap::CreateHeapObjects() {
// Create initial maps.
if (!CreateInitialMaps()) return false;
if (!CreateApiObjects()) return false;
CreateApiObjects();
// Create initial objects
CreateInitialObjects();
CreateInternalAccessorInfoObjects();
CHECK_EQ(0u, gc_count_);
set_native_contexts_list(undefined_value());
......@@ -363,18 +365,16 @@ bool Heap::CreateInitialMaps() {
return true;
}
bool Heap::CreateApiObjects() {
HandleScope scope(isolate());
set_message_listeners(*TemplateList::New(isolate(), 2));
HeapObject* obj = nullptr;
{
AllocationResult allocation = AllocateStruct(INTERCEPTOR_INFO_TYPE);
if (!allocation.To(&obj)) return false;
}
InterceptorInfo* info = InterceptorInfo::cast(obj);
void Heap::CreateApiObjects() {
Isolate* isolate = this->isolate();
HandleScope scope(isolate);
set_message_listeners(*TemplateList::New(isolate, 2));
Handle<InterceptorInfo> info = Handle<InterceptorInfo>::cast(
isolate->factory()->NewStruct(INTERCEPTOR_INFO_TYPE, TENURED));
info->set_flags(0);
set_noop_interceptor_info(info);
return true;
set_noop_interceptor_info(*info);
}
void Heap::CreateInitialObjects() {
......@@ -630,5 +630,17 @@ void Heap::CreateInitialObjects() {
isolate_->compilation_cache()->Clear();
}
void Heap::CreateInternalAccessorInfoObjects() {
Isolate* isolate = this->isolate();
HandleScope scope(isolate);
Handle<AccessorInfo> acessor_info;
#define INIT_ACCESSOR_INFO(accessor_name, AccessorName) \
acessor_info = Accessors::Make##AccessorName##Info(isolate); \
roots_[k##AccessorName##AccessorRootIndex] = *acessor_info;
ACCESSOR_INFO_LIST(INIT_ACCESSOR_INFO)
#undef INIT_ACCESSOR_INFO
}
} // namespace internal
} // namespace v8
......@@ -848,7 +848,7 @@ Handle<JSModuleNamespace> Module::GetModuleNamespace(Handle<Module> module) {
"JSModuleNamespace");
for (const auto& name : names) {
JSObject::SetNormalizedProperty(
ns, name, Accessors::ModuleNamespaceEntryInfo(isolate, name),
ns, name, Accessors::MakeModuleNamespaceEntryInfo(isolate, name),
PropertyDetails(kAccessor, attr, PropertyCellType::kMutable));
}
JSObject::PreventExtensions(ns, kThrowOnError).ToChecked();
......
......@@ -1919,6 +1919,10 @@ const char* V8HeapExplorer::GetStrongGcSubrootName(Object* object) {
PUBLIC_SYMBOL_LIST(SYMBOL_NAME)
WELL_KNOWN_SYMBOL_LIST(SYMBOL_NAME)
#undef SYMBOL_NAME
#define ACCESSOR_NAME(accessor_name, AccessorName) \
NAME_ENTRY(accessor_name##_accessor)
ACCESSOR_INFO_LIST(ACCESSOR_NAME)
#undef ACCESSOR_NAME
#undef NAME_ENTRY
CHECK(!strong_gc_subroot_names_.is_empty());
}
......
......@@ -205,8 +205,7 @@ void InstallClassNameAccessor(Isolate* isolate, Handle<JSObject> object) {
// Cannot fail since this should only be called when creating an object
// literal.
CHECK(!JSObject::SetAccessor(
object, name, Accessors::FunctionNameInfo(object->GetIsolate()),
attrs)
object, name, isolate->factory()->function_name_accessor(), attrs)
.is_null());
}
} // anonymous namespace
......
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