Commit 7cd573f4 authored by ishell's avatar ishell Committed by Commit bot

[runtime] Remove specific Descriptor subclasses and add respective factory methods instead.

This is a preliminary step for constant tracking.

BUG=v8:5495

Review-Url: https://codereview.chromium.org/2595893002
Cr-Commit-Position: refs/heads/master@{#41899}
parent 19aa7a20
......@@ -834,8 +834,8 @@ static void ReplaceAccessors(Handle<Map> map,
Handle<AccessorPair> accessor_pair) {
DescriptorArray* descriptors = map->instance_descriptors();
int idx = descriptors->SearchWithCache(map->GetIsolate(), *name, *map);
AccessorConstantDescriptor descriptor(name, accessor_pair, attributes);
descriptors->Replace(idx, &descriptor);
Descriptor d = Descriptor::AccessorConstant(name, accessor_pair, attributes);
descriptors->Replace(idx, &d);
}
void Genesis::AddRestrictedFunctionProperties(Handle<JSFunction> empty) {
......@@ -1107,8 +1107,8 @@ static void InstallError(Isolate* isolate, Handle<JSObject> global,
Handle<AccessorInfo> error_stack =
Accessors::ErrorStackInfo(isolate, attribs);
{
AccessorConstantDescriptor d(Handle<Name>(Name::cast(error_stack->name())),
error_stack, attribs);
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(error_stack->name())), error_stack, attribs);
initial_map->AppendDescriptor(&d);
}
}
......@@ -1318,7 +1318,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<AccessorInfo> array_length =
Accessors::ArrayLengthInfo(isolate, attribs);
{ // Add length.
AccessorConstantDescriptor d(
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(array_length->name())), array_length,
attribs);
initial_map->AppendDescriptor(&d);
......@@ -1542,8 +1542,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Accessors::StringLengthInfo(isolate, attribs));
{ // Add length.
AccessorConstantDescriptor d(factory->length_string(), string_length,
attribs);
Descriptor d = Descriptor::AccessorConstant(factory->length_string(),
string_length, attribs);
string_map->AppendDescriptor(&d);
}
......@@ -2146,10 +2146,10 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
// ECMA-262, section 15.10.7.5.
PropertyAttributes writable =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
DataDescriptor field(factory->lastIndex_string(),
JSRegExp::kLastIndexFieldIndex, writable,
Representation::Tagged());
initial_map->AppendDescriptor(&field);
Descriptor d = Descriptor::DataField(factory->lastIndex_string(),
JSRegExp::kLastIndexFieldIndex,
writable, Representation::Tagged());
initial_map->AppendDescriptor(&d);
static const int num_fields = JSRegExp::kInObjectFieldCount;
initial_map->SetInObjectProperties(num_fields);
......@@ -2491,9 +2491,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{ // Install @@toStringTag.
PropertyAttributes attribs =
static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);
DataConstantDescriptor d(factory->to_string_tag_symbol(),
factory->NewStringFromAsciiChecked("Module"),
attribs);
Descriptor d = Descriptor::DataConstant(
factory->to_string_tag_symbol(),
factory->NewStringFromAsciiChecked("Module"), attribs);
map->AppendDescriptor(&d);
}
}
......@@ -2505,14 +2505,16 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Map::EnsureDescriptorSlack(map, 2);
{ // value
DataDescriptor d(factory->value_string(), JSIteratorResult::kValueIndex,
NONE, Representation::Tagged());
Descriptor d = Descriptor::DataField(factory->value_string(),
JSIteratorResult::kValueIndex, NONE,
Representation::Tagged());
map->AppendDescriptor(&d);
}
{ // done
DataDescriptor d(factory->done_string(), JSIteratorResult::kDoneIndex,
NONE, Representation::Tagged());
Descriptor d = Descriptor::DataField(factory->done_string(),
JSIteratorResult::kDoneIndex, NONE,
Representation::Tagged());
map->AppendDescriptor(&d);
}
......@@ -2618,15 +2620,15 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<AccessorInfo> bound_length =
Accessors::BoundFunctionLengthInfo(isolate, roc_attribs);
{ // length
AccessorConstantDescriptor d(factory->length_string(), bound_length,
roc_attribs);
Descriptor d = Descriptor::AccessorConstant(factory->length_string(),
bound_length, roc_attribs);
map->AppendDescriptor(&d);
}
Handle<AccessorInfo> bound_name =
Accessors::BoundFunctionNameInfo(isolate, roc_attribs);
{ // length
AccessorConstantDescriptor d(factory->name_string(), bound_name,
roc_attribs);
{ // name
Descriptor d = Descriptor::AccessorConstant(factory->name_string(),
bound_name, roc_attribs);
map->AppendDescriptor(&d);
}
map->SetInObjectProperties(0);
......@@ -2653,15 +2655,15 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Map::EnsureDescriptorSlack(map, 2);
{ // length
DataDescriptor d(factory->length_string(),
JSSloppyArgumentsObject::kLengthIndex, DONT_ENUM,
Representation::Tagged());
Descriptor d = Descriptor::DataField(
factory->length_string(), JSSloppyArgumentsObject::kLengthIndex,
DONT_ENUM, Representation::Tagged());
map->AppendDescriptor(&d);
}
{ // callee
DataDescriptor d(factory->callee_string(),
JSSloppyArgumentsObject::kCalleeIndex, DONT_ENUM,
Representation::Tagged());
Descriptor d = Descriptor::DataField(
factory->callee_string(), JSSloppyArgumentsObject::kCalleeIndex,
DONT_ENUM, Representation::Tagged());
map->AppendDescriptor(&d);
}
// @@iterator method is added later.
......@@ -2710,14 +2712,14 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Map::EnsureDescriptorSlack(map, 2);
{ // length
DataDescriptor d(factory->length_string(),
JSStrictArgumentsObject::kLengthIndex, DONT_ENUM,
Representation::Tagged());
Descriptor d = Descriptor::DataField(
factory->length_string(), JSStrictArgumentsObject::kLengthIndex,
DONT_ENUM, Representation::Tagged());
map->AppendDescriptor(&d);
}
{ // callee
AccessorConstantDescriptor d(factory->callee_string(), callee,
attributes);
Descriptor d = Descriptor::AccessorConstant(factory->callee_string(),
callee, attributes);
map->AppendDescriptor(&d);
}
// @@iterator method is added later.
......@@ -3130,7 +3132,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<AccessorInfo> script_column =
Accessors::ScriptColumnOffsetInfo(isolate, attribs);
{
AccessorConstantDescriptor d(
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(script_column->name())), script_column,
attribs);
script_map->AppendDescriptor(&d);
......@@ -3138,8 +3140,8 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<AccessorInfo> script_id = Accessors::ScriptIdInfo(isolate, attribs);
{
AccessorConstantDescriptor d(Handle<Name>(Name::cast(script_id->name())),
script_id, attribs);
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(script_id->name())), script_id, attribs);
script_map->AppendDescriptor(&d);
}
......@@ -3147,7 +3149,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<AccessorInfo> script_name =
Accessors::ScriptNameInfo(isolate, attribs);
{
AccessorConstantDescriptor d(
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(script_name->name())), script_name, attribs);
script_map->AppendDescriptor(&d);
}
......@@ -3155,7 +3157,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<AccessorInfo> script_line =
Accessors::ScriptLineOffsetInfo(isolate, attribs);
{
AccessorConstantDescriptor d(
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(script_line->name())), script_line, attribs);
script_map->AppendDescriptor(&d);
}
......@@ -3163,7 +3165,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<AccessorInfo> script_source =
Accessors::ScriptSourceInfo(isolate, attribs);
{
AccessorConstantDescriptor d(
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(script_source->name())), script_source,
attribs);
script_map->AppendDescriptor(&d);
......@@ -3172,7 +3174,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<AccessorInfo> script_type =
Accessors::ScriptTypeInfo(isolate, attribs);
{
AccessorConstantDescriptor d(
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(script_type->name())), script_type, attribs);
script_map->AppendDescriptor(&d);
}
......@@ -3180,7 +3182,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<AccessorInfo> script_compilation_type =
Accessors::ScriptCompilationTypeInfo(isolate, attribs);
{
AccessorConstantDescriptor d(
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(script_compilation_type->name())),
script_compilation_type, attribs);
script_map->AppendDescriptor(&d);
......@@ -3189,7 +3191,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<AccessorInfo> script_context_data =
Accessors::ScriptContextDataInfo(isolate, attribs);
{
AccessorConstantDescriptor d(
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(script_context_data->name())),
script_context_data, attribs);
script_map->AppendDescriptor(&d);
......@@ -3198,7 +3200,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<AccessorInfo> script_eval_from_script =
Accessors::ScriptEvalFromScriptInfo(isolate, attribs);
{
AccessorConstantDescriptor d(
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(script_eval_from_script->name())),
script_eval_from_script, attribs);
script_map->AppendDescriptor(&d);
......@@ -3207,7 +3209,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<AccessorInfo> script_eval_from_script_position =
Accessors::ScriptEvalFromScriptPositionInfo(isolate, attribs);
{
AccessorConstantDescriptor d(
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(script_eval_from_script_position->name())),
script_eval_from_script_position, attribs);
script_map->AppendDescriptor(&d);
......@@ -3216,7 +3218,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<AccessorInfo> script_eval_from_function_name =
Accessors::ScriptEvalFromFunctionNameInfo(isolate, attribs);
{
AccessorConstantDescriptor d(
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(script_eval_from_function_name->name())),
script_eval_from_function_name, attribs);
script_map->AppendDescriptor(&d);
......@@ -3225,7 +3227,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<AccessorInfo> script_source_url =
Accessors::ScriptSourceUrlInfo(isolate, attribs);
{
AccessorConstantDescriptor d(
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(script_source_url->name())),
script_source_url, attribs);
script_map->AppendDescriptor(&d);
......@@ -3234,7 +3236,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<AccessorInfo> script_source_mapping_url =
Accessors::ScriptSourceMappingUrlInfo(isolate, attribs);
{
AccessorConstantDescriptor d(
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(script_source_mapping_url->name())),
script_source_mapping_url, attribs);
script_map->AppendDescriptor(&d);
......@@ -3537,8 +3539,8 @@ Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target,
Handle<AccessorInfo> array_length =
Accessors::ArrayLengthInfo(isolate(), attribs);
{ // Add length.
AccessorConstantDescriptor d(Handle<Name>(Name::cast(array_length->name())),
array_length, attribs);
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(array_length->name())), array_length, attribs);
initial_map->AppendDescriptor(&d);
}
......@@ -3733,27 +3735,29 @@ bool Genesis::InstallNatives(GlobalContextType context_type) {
Map::EnsureDescriptorSlack(map, 4);
{ // get
DataDescriptor d(factory()->get_string(),
JSAccessorPropertyDescriptor::kGetIndex, NONE,
Representation::Tagged());
Descriptor d = Descriptor::DataField(
factory()->get_string(), JSAccessorPropertyDescriptor::kGetIndex,
NONE, Representation::Tagged());
map->AppendDescriptor(&d);
}
{ // set
DataDescriptor d(factory()->set_string(),
JSAccessorPropertyDescriptor::kSetIndex, NONE,
Representation::Tagged());
Descriptor d = Descriptor::DataField(
factory()->set_string(), JSAccessorPropertyDescriptor::kSetIndex,
NONE, Representation::Tagged());
map->AppendDescriptor(&d);
}
{ // enumerable
DataDescriptor d(factory()->enumerable_string(),
JSAccessorPropertyDescriptor::kEnumerableIndex, NONE,
Representation::Tagged());
Descriptor d =
Descriptor::DataField(factory()->enumerable_string(),
JSAccessorPropertyDescriptor::kEnumerableIndex,
NONE, Representation::Tagged());
map->AppendDescriptor(&d);
}
{ // configurable
DataDescriptor d(factory()->configurable_string(),
JSAccessorPropertyDescriptor::kConfigurableIndex, NONE,
Representation::Tagged());
Descriptor d = Descriptor::DataField(
factory()->configurable_string(),
JSAccessorPropertyDescriptor::kConfigurableIndex, NONE,
Representation::Tagged());
map->AppendDescriptor(&d);
}
......@@ -3776,27 +3780,30 @@ bool Genesis::InstallNatives(GlobalContextType context_type) {
Map::EnsureDescriptorSlack(map, 4);
{ // value
DataDescriptor d(factory()->value_string(),
JSDataPropertyDescriptor::kValueIndex, NONE,
Representation::Tagged());
Descriptor d = Descriptor::DataField(
factory()->value_string(), JSDataPropertyDescriptor::kValueIndex,
NONE, Representation::Tagged());
map->AppendDescriptor(&d);
}
{ // writable
DataDescriptor d(factory()->writable_string(),
JSDataPropertyDescriptor::kWritableIndex, NONE,
Representation::Tagged());
Descriptor d =
Descriptor::DataField(factory()->writable_string(),
JSDataPropertyDescriptor::kWritableIndex, NONE,
Representation::Tagged());
map->AppendDescriptor(&d);
}
{ // enumerable
DataDescriptor d(factory()->enumerable_string(),
JSDataPropertyDescriptor::kEnumerableIndex, NONE,
Representation::Tagged());
Descriptor d =
Descriptor::DataField(factory()->enumerable_string(),
JSDataPropertyDescriptor::kEnumerableIndex,
NONE, Representation::Tagged());
map->AppendDescriptor(&d);
}
{ // configurable
DataDescriptor d(factory()->configurable_string(),
JSDataPropertyDescriptor::kConfigurableIndex, NONE,
Representation::Tagged());
Descriptor d =
Descriptor::DataField(factory()->configurable_string(),
JSDataPropertyDescriptor::kConfigurableIndex,
NONE, Representation::Tagged());
map->AppendDescriptor(&d);
}
......@@ -3838,23 +3845,23 @@ bool Genesis::InstallNatives(GlobalContextType context_type) {
int old = array_descriptors->SearchWithCache(
isolate(), *length, array_function->initial_map());
DCHECK(old != DescriptorArray::kNotFound);
AccessorConstantDescriptor desc(
Descriptor d = Descriptor::AccessorConstant(
length, handle(array_descriptors->GetValue(old), isolate()),
array_descriptors->GetDetails(old).attributes());
initial_map->AppendDescriptor(&desc);
initial_map->AppendDescriptor(&d);
}
{
DataDescriptor index_field(factory()->index_string(),
JSRegExpResult::kIndexIndex, NONE,
Representation::Tagged());
initial_map->AppendDescriptor(&index_field);
Descriptor d = Descriptor::DataField(factory()->index_string(),
JSRegExpResult::kIndexIndex, NONE,
Representation::Tagged());
initial_map->AppendDescriptor(&d);
}
{
DataDescriptor input_field(factory()->input_string(),
JSRegExpResult::kInputIndex, NONE,
Representation::Tagged());
initial_map->AppendDescriptor(&input_field);
Descriptor d = Descriptor::DataField(factory()->input_string(),
JSRegExpResult::kInputIndex, NONE,
Representation::Tagged());
initial_map->AppendDescriptor(&d);
}
initial_map->SetInObjectProperties(2);
......@@ -3869,29 +3876,29 @@ bool Genesis::InstallNatives(GlobalContextType context_type) {
Handle<AccessorInfo> arguments_iterator =
Accessors::ArgumentsIteratorInfo(isolate(), attribs);
{
AccessorConstantDescriptor d(factory()->iterator_symbol(),
arguments_iterator, attribs);
Descriptor d = Descriptor::AccessorConstant(factory()->iterator_symbol(),
arguments_iterator, attribs);
Handle<Map> map(native_context()->sloppy_arguments_map());
Map::EnsureDescriptorSlack(map, 1);
map->AppendDescriptor(&d);
}
{
AccessorConstantDescriptor d(factory()->iterator_symbol(),
arguments_iterator, attribs);
Descriptor d = Descriptor::AccessorConstant(factory()->iterator_symbol(),
arguments_iterator, attribs);
Handle<Map> map(native_context()->fast_aliased_arguments_map());
Map::EnsureDescriptorSlack(map, 1);
map->AppendDescriptor(&d);
}
{
AccessorConstantDescriptor d(factory()->iterator_symbol(),
arguments_iterator, attribs);
Descriptor d = Descriptor::AccessorConstant(factory()->iterator_symbol(),
arguments_iterator, attribs);
Handle<Map> map(native_context()->slow_aliased_arguments_map());
Map::EnsureDescriptorSlack(map, 1);
map->AppendDescriptor(&d);
}
{
AccessorConstantDescriptor d(factory()->iterator_symbol(),
arguments_iterator, attribs);
Descriptor d = Descriptor::AccessorConstant(factory()->iterator_symbol(),
arguments_iterator, attribs);
Handle<Map> map(native_context()->strict_arguments_map());
Map::EnsureDescriptorSlack(map, 1);
map->AppendDescriptor(&d);
......
......@@ -2686,8 +2686,8 @@ void Factory::SetFunctionInstanceDescriptor(Handle<Map> map,
Handle<AccessorInfo> length =
Accessors::FunctionLengthInfo(isolate(), roc_attribs);
{ // Add length.
AccessorConstantDescriptor d(Handle<Name>(Name::cast(length->name())),
length, roc_attribs);
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(length->name())), length, roc_attribs);
map->AppendDescriptor(&d);
}
......@@ -2695,22 +2695,22 @@ void Factory::SetFunctionInstanceDescriptor(Handle<Map> map,
Handle<AccessorInfo> name =
Accessors::FunctionNameInfo(isolate(), ro_attribs);
{ // Add name.
AccessorConstantDescriptor d(Handle<Name>(Name::cast(name->name())), name,
roc_attribs);
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(name->name())), name, roc_attribs);
map->AppendDescriptor(&d);
}
Handle<AccessorInfo> args =
Accessors::FunctionArgumentsInfo(isolate(), ro_attribs);
{ // Add arguments.
AccessorConstantDescriptor d(Handle<Name>(Name::cast(args->name())), args,
ro_attribs);
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(args->name())), args, ro_attribs);
map->AppendDescriptor(&d);
}
Handle<AccessorInfo> caller =
Accessors::FunctionCallerInfo(isolate(), ro_attribs);
{ // Add caller.
AccessorConstantDescriptor d(Handle<Name>(Name::cast(caller->name())),
caller, ro_attribs);
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(caller->name())), caller, ro_attribs);
map->AppendDescriptor(&d);
}
if (IsFunctionModeWithPrototype(function_mode)) {
......@@ -2719,8 +2719,8 @@ void Factory::SetFunctionInstanceDescriptor(Handle<Map> map,
}
Handle<AccessorInfo> prototype =
Accessors::FunctionPrototypeInfo(isolate(), ro_attribs);
AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())),
prototype, ro_attribs);
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(prototype->name())), prototype, ro_attribs);
map->AppendDescriptor(&d);
}
}
......@@ -2754,8 +2754,8 @@ void Factory::SetStrictFunctionInstanceDescriptor(Handle<Map> map,
{ // Add length.
Handle<AccessorInfo> length =
Accessors::FunctionLengthInfo(isolate(), roc_attribs);
AccessorConstantDescriptor d(handle(Name::cast(length->name())), length,
roc_attribs);
Descriptor d = Descriptor::AccessorConstant(
handle(Name::cast(length->name())), length, roc_attribs);
map->AppendDescriptor(&d);
}
......@@ -2763,8 +2763,8 @@ void Factory::SetStrictFunctionInstanceDescriptor(Handle<Map> map,
{ // Add name.
Handle<AccessorInfo> name =
Accessors::FunctionNameInfo(isolate(), roc_attribs);
AccessorConstantDescriptor d(handle(Name::cast(name->name())), name,
roc_attribs);
Descriptor d = Descriptor::AccessorConstant(
handle(Name::cast(name->name())), name, roc_attribs);
map->AppendDescriptor(&d);
}
if (IsFunctionModeWithPrototype(function_mode)) {
......@@ -2774,8 +2774,8 @@ void Factory::SetStrictFunctionInstanceDescriptor(Handle<Map> map,
: ro_attribs;
Handle<AccessorInfo> prototype =
Accessors::FunctionPrototypeInfo(isolate(), attribs);
AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())),
prototype, attribs);
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(prototype->name())), prototype, attribs);
map->AppendDescriptor(&d);
}
}
......@@ -2801,8 +2801,8 @@ void Factory::SetClassFunctionInstanceDescriptor(Handle<Map> map) {
{ // Add length.
Handle<AccessorInfo> length =
Accessors::FunctionLengthInfo(isolate(), roc_attribs);
AccessorConstantDescriptor d(handle(Name::cast(length->name())), length,
roc_attribs);
Descriptor d = Descriptor::AccessorConstant(
handle(Name::cast(length->name())), length, roc_attribs);
map->AppendDescriptor(&d);
}
......@@ -2810,8 +2810,8 @@ void Factory::SetClassFunctionInstanceDescriptor(Handle<Map> map) {
// Add prototype.
Handle<AccessorInfo> prototype =
Accessors::FunctionPrototypeInfo(isolate(), rw_attribs);
AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())),
prototype, rw_attribs);
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs);
map->AppendDescriptor(&d);
}
}
......
......@@ -3208,9 +3208,9 @@ MaybeHandle<Map> Map::CopyWithField(Handle<Map> map, Handle<Name> name,
Handle<Object> wrapped_type(WrapType(type));
DataDescriptor new_field_desc(name, index, wrapped_type, attributes,
representation);
Handle<Map> new_map = Map::CopyAddDescriptor(map, &new_field_desc, flag);
Descriptor d = Descriptor::DataField(name, index, wrapped_type, attributes,
representation);
Handle<Map> new_map = Map::CopyAddDescriptor(map, &d, flag);
int unused_property_fields = new_map->unused_property_fields() - 1;
if (unused_property_fields < 0) {
unused_property_fields += JSObject::kFieldsAdded;
......@@ -3231,8 +3231,8 @@ MaybeHandle<Map> Map::CopyWithConstant(Handle<Map> map,
}
// Allocate new instance descriptors with (name, constant) added.
DataConstantDescriptor new_constant_desc(name, constant, attributes);
return Map::CopyAddDescriptor(map, &new_constant_desc, flag);
Descriptor d = Descriptor::DataConstant(name, constant, attributes);
return Map::CopyAddDescriptor(map, &d, flag);
}
const char* Representation::Mnemonic() const {
......@@ -3771,8 +3771,9 @@ Handle<Map> Map::CopyGeneralizeAllRepresentations(
(details.type() != DATA || details.attributes() != attributes)) {
int field_index = details.type() == DATA ? details.field_index()
: new_map->NumberOfFields();
DataDescriptor d(handle(descriptors->GetKey(modify_index), isolate),
field_index, attributes, Representation::Tagged());
Descriptor d = Descriptor::DataField(
handle(descriptors->GetKey(modify_index), isolate), field_index,
attributes, Representation::Tagged());
descriptors->Replace(modify_index, &d);
if (details.type() != DATA) {
int unused_property_fields = new_map->unused_property_fields() - 1;
......@@ -3957,9 +3958,9 @@ void Map::UpdateFieldType(int descriptor, Handle<Name> name,
// Skip if already updated the shared descriptor.
if (descriptors->GetValue(descriptor) != *new_wrapped_type) {
DataDescriptor d(name, descriptors->GetFieldIndex(descriptor),
new_wrapped_type, details.attributes(),
new_representation);
Descriptor d = Descriptor::DataField(
name, descriptors->GetFieldIndex(descriptor), new_wrapped_type,
details.attributes(), new_representation);
descriptors->Replace(descriptor, &d);
}
}
......@@ -4432,8 +4433,9 @@ Handle<Map> Map::Reconfigure(Handle<Map> old_map,
target_field_type, isolate);
}
Handle<Object> wrapped_type(WrapType(next_field_type));
DataDescriptor d(target_key, current_offset, wrapped_type,
next_attributes, next_representation);
Descriptor d =
Descriptor::DataField(target_key, current_offset, wrapped_type,
next_attributes, next_representation);
current_offset += d.GetDetails().field_width_in_words();
new_descriptors->Set(i, &d);
} else {
......@@ -4503,8 +4505,9 @@ Handle<Map> Map::Reconfigure(Handle<Map> old_map,
Handle<Object> wrapped_type(WrapType(next_field_type));
DataDescriptor d(old_key, current_offset, wrapped_type, next_attributes,
next_representation);
Descriptor d =
Descriptor::DataField(old_key, current_offset, wrapped_type,
next_attributes, next_representation);
current_offset += d.GetDetails().field_width_in_words();
new_descriptors->Set(i, &d);
} else {
......@@ -5206,8 +5209,9 @@ struct DescriptorArrayAppender {
int valid_descriptors,
Handle<DescriptorArray> array) {
DisallowHeapAllocation no_gc;
AccessorConstantDescriptor desc(key, entry, entry->property_attributes());
array->Append(&desc);
Descriptor d =
Descriptor::AccessorConstant(key, entry, entry->property_attributes());
array->Append(&d);
}
};
......@@ -6173,8 +6177,8 @@ void JSObject::MigrateSlowToFast(Handle<JSObject> object,
PropertyType type = details.type();
if (value->IsJSFunction()) {
DataConstantDescriptor d(key, handle(value, isolate),
details.attributes());
Descriptor d = Descriptor::DataConstant(key, handle(value, isolate),
details.attributes());
descriptors->Set(enumeration_index - 1, &d);
} else if (type == DATA) {
if (current_offset < inobject_props) {
......@@ -6184,14 +6188,15 @@ void JSObject::MigrateSlowToFast(Handle<JSObject> object,
int offset = current_offset - inobject_props;
fields->set(offset, value);
}
DataDescriptor d(key, current_offset, details.attributes(),
// TODO(verwaest): value->OptimalRepresentation();
Representation::Tagged());
Descriptor d = Descriptor::DataField(
key, current_offset, details.attributes(),
// TODO(verwaest): value->OptimalRepresentation();
Representation::Tagged());
current_offset += d.GetDetails().field_width_in_words();
descriptors->Set(enumeration_index - 1, &d);
} else if (type == ACCESSOR_CONSTANT) {
AccessorConstantDescriptor d(key, handle(value, isolate),
details.attributes());
Descriptor d = Descriptor::AccessorConstant(key, handle(value, isolate),
details.attributes());
descriptors->Set(enumeration_index - 1, &d);
} else {
UNREACHABLE();
......@@ -9796,8 +9801,8 @@ Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map,
pair->SetComponents(*getter, *setter);
TransitionFlag flag = INSERT_TRANSITION;
AccessorConstantDescriptor new_desc(name, pair, attributes);
return Map::CopyInsertDescriptor(map, &new_desc, flag);
Descriptor d = Descriptor::AccessorConstant(name, pair, attributes);
return Map::CopyInsertDescriptor(map, &d, flag);
}
......
......@@ -21,11 +21,12 @@ std::ostream& operator<<(std::ostream& os,
return os;
}
DataDescriptor::DataDescriptor(Handle<Name> key, int field_index,
PropertyAttributes attributes,
Representation representation)
: Descriptor(key, FieldType::Any(key->GetIsolate()), attributes, DATA,
representation, field_index) {}
Descriptor Descriptor::DataField(Handle<Name> key, int field_index,
PropertyAttributes attributes,
Representation representation) {
return Descriptor(key, FieldType::Any(key->GetIsolate()), attributes, DATA,
representation, field_index);
}
struct FastPropertyDetails {
explicit FastPropertyDetails(const PropertyDetails& v) : details(v) {}
......
......@@ -18,7 +18,7 @@ namespace internal {
// Each descriptor has a key, property attributes, property type,
// property index (in the actual instance-descriptor array) and
// optionally a piece of data.
class Descriptor BASE_EMBEDDED {
class Descriptor final BASE_EMBEDDED {
public:
Handle<Name> GetKey() const { return key_; }
Handle<Object> GetValue() const { return value_; }
......@@ -26,6 +26,31 @@ class Descriptor BASE_EMBEDDED {
void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); }
static Descriptor DataField(Handle<Name> key, int field_index,
PropertyAttributes attributes,
Representation representation);
static Descriptor DataField(Handle<Name> key, int field_index,
Handle<Object> wrapped_field_type,
PropertyAttributes attributes,
Representation representation) {
DCHECK(wrapped_field_type->IsSmi() || wrapped_field_type->IsWeakCell());
return Descriptor(key, wrapped_field_type, attributes, DATA, representation,
field_index);
}
static Descriptor DataConstant(Handle<Name> key, Handle<Object> value,
PropertyAttributes attributes) {
return Descriptor(key, value, attributes, DATA_CONSTANT,
value->OptimalRepresentation());
}
static Descriptor AccessorConstant(Handle<Name> key, Handle<Object> foreign,
PropertyAttributes attributes) {
return Descriptor(key, foreign, attributes, ACCESSOR_CONSTANT,
Representation::Tagged());
}
private:
Handle<Name> key_;
Handle<Object> value_;
......@@ -62,43 +87,8 @@ class Descriptor BASE_EMBEDDED {
friend class Map;
};
std::ostream& operator<<(std::ostream& os, const Descriptor& d);
class DataDescriptor final : public Descriptor {
public:
DataDescriptor(Handle<Name> key, int field_index,
PropertyAttributes attributes, Representation representation);
// The field type is either a simple type or a map wrapped in a weak cell.
DataDescriptor(Handle<Name> key, int field_index,
Handle<Object> wrapped_field_type,
PropertyAttributes attributes, Representation representation)
: Descriptor(key, wrapped_field_type, attributes, DATA, representation,
field_index) {
DCHECK(wrapped_field_type->IsSmi() || wrapped_field_type->IsWeakCell());
}
};
class DataConstantDescriptor final : public Descriptor {
public:
DataConstantDescriptor(Handle<Name> key, Handle<Object> value,
PropertyAttributes attributes)
: Descriptor(key, value, attributes, DATA_CONSTANT,
value->OptimalRepresentation()) {}
};
class AccessorConstantDescriptor final : public Descriptor {
public:
AccessorConstantDescriptor(Handle<Name> key, Handle<Object> foreign,
PropertyAttributes attributes)
: Descriptor(key, foreign, attributes, ACCESSOR_CONSTANT,
Representation::Tagged()) {}
};
} // namespace internal
} // namespace v8
......
......@@ -154,8 +154,8 @@ TEST(StressJS) {
Handle<AccessorInfo> foreign = TestAccessorInfo(isolate, attrs);
Map::EnsureDescriptorSlack(map, 1);
AccessorConstantDescriptor d(Handle<Name>(Name::cast(foreign->name())),
foreign, attrs);
Descriptor d = Descriptor::AccessorConstant(
Handle<Name>(Name::cast(foreign->name())), foreign, attrs);
map->AppendDescriptor(&d);
// Add the Foo constructor the global object.
......
......@@ -376,8 +376,8 @@ class Expectations {
Handle<String> name = MakeName("prop", property_index);
AccessorConstantDescriptor new_desc(name, pair, attributes);
return Map::CopyInsertDescriptor(map, &new_desc, INSERT_TRANSITION);
Descriptor d = Descriptor::AccessorConstant(name, pair, attributes);
return Map::CopyInsertDescriptor(map, &d, INSERT_TRANSITION);
}
Handle<Map> AddAccessorConstant(Handle<Map> map,
......@@ -396,14 +396,14 @@ class Expectations {
if (!getter->IsNull(isolate_)) {
Handle<AccessorPair> pair = factory->NewAccessorPair();
pair->SetComponents(*getter, *factory->null_value());
AccessorConstantDescriptor new_desc(name, pair, attributes);
map = Map::CopyInsertDescriptor(map, &new_desc, INSERT_TRANSITION);
Descriptor d = Descriptor::AccessorConstant(name, pair, attributes);
map = Map::CopyInsertDescriptor(map, &d, INSERT_TRANSITION);
}
if (!setter->IsNull(isolate_)) {
Handle<AccessorPair> pair = factory->NewAccessorPair();
pair->SetComponents(*getter, *setter);
AccessorConstantDescriptor new_desc(name, pair, attributes);
map = Map::CopyInsertDescriptor(map, &new_desc, INSERT_TRANSITION);
Descriptor d = Descriptor::AccessorConstant(name, pair, attributes);
map = Map::CopyInsertDescriptor(map, &d, INSERT_TRANSITION);
}
return map;
}
......
......@@ -106,13 +106,14 @@ static Handle<DescriptorArray> CreateDescriptorArray(Isolate* isolate,
TestPropertyKind kind = props[i];
if (kind == PROP_CONSTANT) {
DataConstantDescriptor d(name, func, NONE);
Descriptor d = Descriptor::DataConstant(name, func, NONE);
descriptors->Append(&d);
} else {
DataDescriptor f(name, next_field_offset, NONE, representations[kind]);
next_field_offset += f.GetDetails().field_width_in_words();
descriptors->Append(&f);
Descriptor d = Descriptor::DataField(name, next_field_offset, NONE,
representations[kind]);
next_field_offset += d.GetDetails().field_width_in_words();
descriptors->Append(&d);
}
}
return descriptors;
......@@ -628,18 +629,19 @@ static Handle<LayoutDescriptor> TestLayoutDescriptorAppend(
Handle<LayoutDescriptor> layout_descriptor;
TestPropertyKind kind = props[i];
if (kind == PROP_CONSTANT) {
DataConstantDescriptor d(name, func, NONE);
Descriptor d = Descriptor::DataConstant(name, func, NONE);
layout_descriptor = LayoutDescriptor::ShareAppend(map, d.GetDetails());
descriptors->Append(&d);
} else {
DataDescriptor f(name, next_field_offset, NONE, representations[kind]);
int field_width_in_words = f.GetDetails().field_width_in_words();
Descriptor d = Descriptor::DataField(name, next_field_offset, NONE,
representations[kind]);
int field_width_in_words = d.GetDetails().field_width_in_words();
next_field_offset += field_width_in_words;
layout_descriptor = LayoutDescriptor::ShareAppend(map, f.GetDetails());
descriptors->Append(&f);
layout_descriptor = LayoutDescriptor::ShareAppend(map, d.GetDetails());
descriptors->Append(&d);
int field_index = f.GetDetails().field_index();
int field_index = d.GetDetails().field_index();
bool is_inobject = field_index < map->GetInObjectProperties();
for (int bit = 0; bit < field_width_in_words; bit++) {
CHECK_EQ(is_inobject && (kind == PROP_DOUBLE),
......
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