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