Rename and retype Symbol name to description

Change-Id: I2a1ad1835b751237b350e56d64e3475459bfb7a6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1873715
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: Sathya Gunasekaran  <gsathya@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64636}
This commit is contained in:
Gus Caplan 2019-10-28 11:16:45 -07:00 committed by Commit Bot
parent 572f536a54
commit 7bd4068101
27 changed files with 95 additions and 85 deletions

View File

@ -3246,30 +3246,35 @@ class V8_EXPORT String : public Name {
class V8_EXPORT Symbol : public Name { class V8_EXPORT Symbol : public Name {
public: public:
/** /**
* Returns the print name string of the symbol, or undefined if none. * Returns the description string of the symbol, or undefined if none.
*/ */
Local<Value> Name() const; Local<Value> Description() const;
V8_DEPRECATE_SOON("Use Symbol::Description()")
Local<Value> Name() const { return Description(); }
/** /**
* Create a symbol. If name is not empty, it will be used as the description. * Create a symbol. If description is not empty, it will be used as the
* description.
*/ */
static Local<Symbol> New(Isolate* isolate, static Local<Symbol> New(Isolate* isolate,
Local<String> name = Local<String>()); Local<String> description = Local<String>());
/** /**
* Access global symbol registry. * Access global symbol registry.
* Note that symbols created this way are never collected, so * Note that symbols created this way are never collected, so
* they should only be used for statically fixed properties. * they should only be used for statically fixed properties.
* Also, there is only one global name space for the names used as keys. * Also, there is only one global name space for the descriptions used as
* keys.
* To minimize the potential for clashes, use qualified names as keys. * To minimize the potential for clashes, use qualified names as keys.
*/ */
static Local<Symbol> For(Isolate *isolate, Local<String> name); static Local<Symbol> For(Isolate* isolate, Local<String> description);
/** /**
* Retrieve a global symbol. Similar to |For|, but using a separate * Retrieve a global symbol. Similar to |For|, but using a separate
* registry that is not accessible by (and cannot clash with) JavaScript code. * registry that is not accessible by (and cannot clash with) JavaScript code.
*/ */
static Local<Symbol> ForApi(Isolate *isolate, Local<String> name); static Local<Symbol> ForApi(Isolate* isolate, Local<String> description);
// Well-known symbols // Well-known symbols
static Local<Symbol> GetAsyncIterator(Isolate* isolate); static Local<Symbol> GetAsyncIterator(Isolate* isolate);

View File

@ -5477,28 +5477,28 @@ v8::String::GetExternalOneByteStringResource() const {
return nullptr; return nullptr;
} }
Local<Value> Symbol::Name() const { Local<Value> Symbol::Description() const {
i::Handle<i::Symbol> sym = Utils::OpenHandle(this); i::Handle<i::Symbol> sym = Utils::OpenHandle(this);
i::Isolate* isolate; i::Isolate* isolate;
if (!i::GetIsolateFromHeapObject(*sym, &isolate)) { if (!i::GetIsolateFromHeapObject(*sym, &isolate)) {
// Symbol is in RO_SPACE, which means that its name is also in RO_SPACE. // Symbol is in RO_SPACE, which means that its description is also in
// Since RO_SPACE objects are immovable we can use the Handle(Address*) // RO_SPACE. Since RO_SPACE objects are immovable we can use the
// constructor with the address of the name field in the Symbol object // Handle(Address*) constructor with the address of the description
// without needing an isolate. // field in the Symbol object without needing an isolate.
DCHECK(!COMPRESS_POINTERS_BOOL); DCHECK(!COMPRESS_POINTERS_BOOL);
i::Handle<i::HeapObject> ro_name(reinterpret_cast<i::Address*>( i::Handle<i::HeapObject> ro_description(reinterpret_cast<i::Address*>(
sym->GetFieldAddress(i::Symbol::kNameOffset))); sym->GetFieldAddress(i::Symbol::kDescriptionOffset)));
return Utils::ToLocal(ro_name); return Utils::ToLocal(ro_description);
} }
i::Handle<i::Object> name(sym->name(), isolate); i::Handle<i::Object> description(sym->description(), isolate);
return Utils::ToLocal(name); return Utils::ToLocal(description);
} }
Local<Value> Private::Name() const { Local<Value> Private::Name() const {
return reinterpret_cast<const Symbol*>(this)->Name(); return reinterpret_cast<const Symbol*>(this)->Description();
} }
double Number::Value() const { double Number::Value() const {
@ -7860,7 +7860,7 @@ Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) {
LOG_API(i_isolate, Symbol, New); LOG_API(i_isolate, Symbol, New);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name)); if (!name.IsEmpty()) result->set_description(*Utils::OpenHandle(*name));
return Utils::ToLocal(result); return Utils::ToLocal(result);
} }
@ -7907,7 +7907,7 @@ Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
LOG_API(i_isolate, Private, New); LOG_API(i_isolate, Private, New);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol();
if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); if (!name.IsEmpty()) symbol->set_description(*Utils::OpenHandle(*name));
Local<Symbol> result = Utils::ToLocal(symbol); Local<Symbol> result = Utils::ToLocal(symbol);
return v8::Local<Private>(reinterpret_cast<Private*>(*result)); return v8::Local<Private>(reinterpret_cast<Private*>(*result));
} }

View File

@ -582,7 +582,8 @@ void CallPrinter::PrintLiteral(Handle<Object> value, bool quote) {
Print(isolate_->factory()->NumberToString(value)); Print(isolate_->factory()->NumberToString(value));
} else if (value->IsSymbol()) { } else if (value->IsSymbol()) {
// Symbols can only occur as literals if they were inserted by the parser. // Symbols can only occur as literals if they were inserted by the parser.
PrintLiteral(handle(Handle<Symbol>::cast(value)->name(), isolate_), false); PrintLiteral(handle(Handle<Symbol>::cast(value)->description(), isolate_),
false);
} }
} }

View File

@ -158,7 +158,7 @@ type AnyName = PrivateSymbol|PublicSymbol|String;
@generateCppClass @generateCppClass
extern class Symbol extends Name { extern class Symbol extends Name {
flags: int32; flags: int32;
name: Object; // The print name of a symbol, or undefined if none. description: String|Undefined;
} }
type PublicSymbol extends Symbol; type PublicSymbol extends Symbol;

View File

@ -28,7 +28,7 @@ BUILTIN(SymbolConstructor) {
if (!description->IsUndefined(isolate)) { if (!description->IsUndefined(isolate)) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, description, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, description,
Object::ToString(isolate, description)); Object::ToString(isolate, description));
result->set_name(*description); result->set_description(String::cast(*description));
} }
return *result; return *result;
} }
@ -55,7 +55,7 @@ BUILTIN(SymbolKeyFor) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
Object result; Object result;
if (symbol->is_in_public_symbol_table()) { if (symbol->is_in_public_symbol_table()) {
result = symbol->name(); result = symbol->description();
DCHECK(result.IsString()); DCHECK(result.IsString());
} else { } else {
result = ReadOnlyRoots(isolate).undefined_value(); result = ReadOnlyRoots(isolate).undefined_value();

View File

@ -13,13 +13,13 @@ namespace symbol {
// ES #sec-symbol.prototype.description // ES #sec-symbol.prototype.description
transitioning javascript builtin SymbolPrototypeDescriptionGetter( transitioning javascript builtin SymbolPrototypeDescriptionGetter(
js-implicit context: Context, receiver: JSAny)(): JSAny { js-implicit context: Context, receiver: JSAny)(): String|Undefined {
// 1. Let s be the this value. // 1. Let s be the this value.
// 2. Let sym be ? thisSymbolValue(s). // 2. Let sym be ? thisSymbolValue(s).
const sym: Symbol = const sym: Symbol =
ThisSymbolValue(receiver, 'Symbol.prototype.description'); ThisSymbolValue(receiver, 'Symbol.prototype.description');
// 3. Return sym.[[Description]]. // 3. Return sym.[[Description]].
return Cast<JSAny>(sym.name) otherwise unreachable; return sym.description;
} }
// ES6 #sec-symbol.prototype-@@toprimitive // ES6 #sec-symbol.prototype-@@toprimitive

View File

@ -19,7 +19,7 @@ void WriteToFile(const char* prefix, FILE* file, Isolate* isolate,
Local<Value> arg = args[i]; Local<Value> arg = args[i];
Local<String> str_obj; Local<String> str_obj;
if (arg->IsSymbol()) arg = Local<Symbol>::Cast(arg)->Name(); if (arg->IsSymbol()) arg = Local<Symbol>::Cast(arg)->Description();
if (!arg->ToString(isolate->GetCurrentContext()).ToLocal(&str_obj)) return; if (!arg->ToString(isolate->GetCurrentContext()).ToLocal(&str_obj)) return;
v8::String::Utf8Value str(isolate, str_obj); v8::String::Utf8Value str(isolate, str_obj);

View File

@ -1366,7 +1366,7 @@ void WriteToFile(FILE* file, const v8::FunctionCallbackInfo<v8::Value>& args) {
Local<String> str_obj; Local<String> str_obj;
if (arg->IsSymbol()) { if (arg->IsSymbol()) {
arg = Local<Symbol>::Cast(arg)->Name(); arg = Local<Symbol>::Cast(arg)->Description();
} }
if (!arg->ToString(args.GetIsolate()->GetCurrentContext()) if (!arg->ToString(args.GetIsolate()->GetCurrentContext())
.ToLocal(&str_obj)) { .ToLocal(&str_obj)) {

View File

@ -275,7 +275,7 @@ void Symbol::SymbolVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::SymbolVerify(*this, isolate); TorqueGeneratedClassVerifiers::SymbolVerify(*this, isolate);
CHECK(HasHashCode()); CHECK(HasHashCode());
CHECK_GT(Hash(), 0); CHECK_GT(Hash(), 0);
CHECK(name().IsUndefined(isolate) || name().IsString()); CHECK(description().IsUndefined(isolate) || description().IsString());
CHECK_IMPLIES(IsPrivateName(), IsPrivate()); CHECK_IMPLIES(IsPrivateName(), IsPrivate());
} }

View File

@ -678,8 +678,8 @@ void JSRegExpStringIterator::JSRegExpStringIteratorPrint(
void Symbol::SymbolPrint(std::ostream& os) { // NOLINT void Symbol::SymbolPrint(std::ostream& os) { // NOLINT
PrintHeader(os, "Symbol"); PrintHeader(os, "Symbol");
os << "\n - hash: " << Hash(); os << "\n - hash: " << Hash();
os << "\n - name: " << Brief(name()); os << "\n - description: " << Brief(description());
if (name().IsUndefined()) { if (description().IsUndefined()) {
os << " (" << PrivateSymbolToName() << ")"; os << " (" << PrivateSymbolToName() << ")";
} }
os << "\n - private: " << is_private(); os << "\n - private: " << is_private();
@ -2333,10 +2333,10 @@ void Name::NameShortPrint() {
} else { } else {
DCHECK(this->IsSymbol()); DCHECK(this->IsSymbol());
Symbol s = Symbol::cast(*this); Symbol s = Symbol::cast(*this);
if (s.name().IsUndefined()) { if (s.description().IsUndefined()) {
PrintF("#<%s>", s.PrivateSymbolToName()); PrintF("#<%s>", s.PrivateSymbolToName());
} else { } else {
PrintF("<%s>", String::cast(s.name()).ToCString().get()); PrintF("<%s>", String::cast(s.description()).ToCString().get());
} }
} }
} }
@ -2348,10 +2348,11 @@ int Name::NameShortPrint(Vector<char> str) {
} else { } else {
DCHECK(this->IsSymbol()); DCHECK(this->IsSymbol());
Symbol s = Symbol::cast(*this); Symbol s = Symbol::cast(*this);
if (s.name().IsUndefined()) { if (s.description().IsUndefined()) {
return SNPrintF(str, "#<%s>", s.PrivateSymbolToName()); return SNPrintF(str, "#<%s>", s.PrivateSymbolToName());
} else { } else {
return SNPrintF(str, "<%s>", String::cast(s.name()).ToCString().get()); return SNPrintF(str, "<%s>",
String::cast(s.description()).ToCString().get());
} }
} }
} }

View File

@ -3871,7 +3871,7 @@ Handle<Symbol> Isolate::SymbolFor(RootIndex dictionary_index,
if (entry.is_not_found()) { if (entry.is_not_found()) {
symbol = symbol =
private_symbol ? factory()->NewPrivateSymbol() : factory()->NewSymbol(); private_symbol ? factory()->NewPrivateSymbol() : factory()->NewSymbol();
symbol->set_name(*key); symbol->set_description(*key);
dictionary = NameDictionary::Add(this, dictionary, key, symbol, dictionary = NameDictionary::Add(this, dictionary, key, symbol,
PropertyDetails::Empty(), &entry); PropertyDetails::Empty(), &entry);
switch (dictionary_index) { switch (dictionary_index) {

View File

@ -1378,7 +1378,7 @@ Handle<Symbol> Factory::NewSymbol(AllocationType allocation) {
Handle<Symbol> symbol(Symbol::cast(result), isolate()); Handle<Symbol> symbol(Symbol::cast(result), isolate());
symbol->set_hash_field(Name::kIsNotArrayIndexMask | symbol->set_hash_field(Name::kIsNotArrayIndexMask |
(hash << Name::kHashShift)); (hash << Name::kHashShift));
symbol->set_name(*undefined_value()); symbol->set_description(*undefined_value());
symbol->set_flags(0); symbol->set_flags(0);
DCHECK(!symbol->is_private()); DCHECK(!symbol->is_private());
return symbol; return symbol;
@ -1394,7 +1394,7 @@ Handle<Symbol> Factory::NewPrivateSymbol(AllocationType allocation) {
Handle<Symbol> Factory::NewPrivateNameSymbol(Handle<String> name) { Handle<Symbol> Factory::NewPrivateNameSymbol(Handle<String> name) {
Handle<Symbol> symbol = NewSymbol(); Handle<Symbol> symbol = NewSymbol();
symbol->set_is_private_name(); symbol->set_is_private_name();
symbol->set_name(*name); symbol->set_description(*name);
return symbol; return symbol;
} }

View File

@ -706,7 +706,7 @@ void Heap::CreateInitialObjects() {
#define SYMBOL_INIT(_, name, description) \ #define SYMBOL_INIT(_, name, description) \
Handle<Symbol> name = factory->NewSymbol(AllocationType::kReadOnly); \ Handle<Symbol> name = factory->NewSymbol(AllocationType::kReadOnly); \
Handle<String> name##d = factory->InternalizeUtf8String(#description); \ Handle<String> name##d = factory->InternalizeUtf8String(#description); \
name->set_name(*name##d); \ name->set_description(*name##d); \
roots_table()[RootIndex::k##name] = name->ptr(); roots_table()[RootIndex::k##name] = name->ptr();
PUBLIC_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */) PUBLIC_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */)
#undef SYMBOL_INIT #undef SYMBOL_INIT
@ -715,7 +715,7 @@ void Heap::CreateInitialObjects() {
Handle<Symbol> name = factory->NewSymbol(AllocationType::kReadOnly); \ Handle<Symbol> name = factory->NewSymbol(AllocationType::kReadOnly); \
Handle<String> name##d = factory->InternalizeUtf8String(#description); \ Handle<String> name##d = factory->InternalizeUtf8String(#description); \
name->set_is_well_known_symbol(true); \ name->set_is_well_known_symbol(true); \
name->set_name(*name##d); \ name->set_description(*name##d); \
roots_table()[RootIndex::k##name] = name->ptr(); roots_table()[RootIndex::k##name] = name->ptr();
WELL_KNOWN_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */) WELL_KNOWN_SYMBOL_LIST_GENERATOR(SYMBOL_INIT, /* not used */)
#undef SYMBOL_INIT #undef SYMBOL_INIT

View File

@ -412,8 +412,8 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name,
if (name->IsPrivate()) { if (name->IsPrivate()) {
if (name->IsPrivateName() && !it.IsFound()) { if (name->IsPrivateName() && !it.IsFound()) {
Handle<String> name_string(String::cast(Symbol::cast(*name).name()), Handle<String> name_string(
isolate()); String::cast(Symbol::cast(*name).description()), isolate());
return TypeError(MessageTemplate::kInvalidPrivateMemberRead, object, return TypeError(MessageTemplate::kInvalidPrivateMemberRead, object,
name_string); name_string);
} }
@ -1451,8 +1451,8 @@ MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name,
if (name->IsPrivate()) { if (name->IsPrivate()) {
if (name->IsPrivateName() && !it.IsFound()) { if (name->IsPrivateName() && !it.IsFound()) {
Handle<String> name_string(String::cast(Symbol::cast(*name).name()), Handle<String> name_string(
isolate()); String::cast(Symbol::cast(*name).description()), isolate());
return TypeError(MessageTemplate::kInvalidPrivateMemberWrite, object, return TypeError(MessageTemplate::kInvalidPrivateMemberWrite, object,
name_string); name_string);
} }

View File

@ -153,7 +153,7 @@ class V8ValueStringBuilder {
bool append(v8::Local<v8::Symbol> symbol) { bool append(v8::Local<v8::Symbol> symbol) {
m_builder.append("Symbol("); m_builder.append("Symbol(");
bool result = append(symbol->Name(), IgnoreUndefined); bool result = append(symbol->Description(), IgnoreUndefined);
m_builder.append(')'); m_builder.append(')');
return result; return result;
} }

View File

@ -153,10 +153,10 @@ String16 abbreviateString(const String16& value, AbbreviateMode mode) {
String16 descriptionForSymbol(v8::Local<v8::Context> context, String16 descriptionForSymbol(v8::Local<v8::Context> context,
v8::Local<v8::Symbol> symbol) { v8::Local<v8::Symbol> symbol) {
return String16::concat( return String16::concat("Symbol(",
"Symbol(", toProtocolStringWithTypeCheck(context->GetIsolate(),
toProtocolStringWithTypeCheck(context->GetIsolate(), symbol->Name()), symbol->Description()),
")"); ")");
} }
String16 descriptionForBigInt(v8::Local<v8::Context> context, String16 descriptionForBigInt(v8::Local<v8::Context> context,

View File

@ -157,9 +157,9 @@ void Log::MessageBuilder::AppendSymbolName(Symbol symbol) {
DCHECK(!symbol.is_null()); DCHECK(!symbol.is_null());
OFStream& os = log_->os_; OFStream& os = log_->os_;
os << "symbol("; os << "symbol(";
if (!symbol.name().IsUndefined()) { if (!symbol.description().IsUndefined()) {
os << "\""; os << "\"";
AppendSymbolNameDetails(String::cast(symbol.name()), false); AppendSymbolNameDetails(String::cast(symbol.description()), false);
os << "\" "; os << "\" ";
} }
os << "hash " << std::hex << symbol.Hash() << std::dec << ")"; os << "hash " << std::hex << symbol.Hash() << std::dec << ")";

View File

@ -112,9 +112,9 @@ class CodeEventLogger::NameBuffer {
} else { } else {
Symbol symbol = Symbol::cast(name); Symbol symbol = Symbol::cast(name);
AppendBytes("symbol("); AppendBytes("symbol(");
if (!symbol.name().IsUndefined()) { if (!symbol.description().IsUndefined()) {
AppendBytes("\""); AppendBytes("\"");
AppendString(String::cast(symbol.name())); AppendString(String::cast(symbol.description()));
AppendBytes("\" "); AppendBytes("\" ");
} }
AppendBytes("hash "); AppendBytes("hash ");

View File

@ -183,7 +183,7 @@ class Symbol : public TorqueGeneratedSymbol<Symbol, Name> {
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS) DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS #undef FLAGS_BIT_FIELDS
using BodyDescriptor = FixedBodyDescriptor<kNameOffset, kSize, kSize>; using BodyDescriptor = FixedBodyDescriptor<kDescriptionOffset, kSize, kSize>;
void SymbolShortPrint(std::ostream& os); void SymbolShortPrint(std::ostream& os);

View File

@ -469,13 +469,14 @@ Handle<String> Object::NoSideEffectsToString(Isolate* isolate,
Handle<Symbol> symbol = Handle<Symbol>::cast(input); Handle<Symbol> symbol = Handle<Symbol>::cast(input);
if (symbol->is_private_name()) { if (symbol->is_private_name()) {
return Handle<String>(String::cast(symbol->name()), isolate); return Handle<String>(String::cast(symbol->description()), isolate);
} }
IncrementalStringBuilder builder(isolate); IncrementalStringBuilder builder(isolate);
builder.AppendCString("Symbol("); builder.AppendCString("Symbol(");
if (symbol->name().IsString()) { if (symbol->description().IsString()) {
builder.AppendString(handle(String::cast(symbol->name()), isolate)); builder.AppendString(
handle(String::cast(symbol->description()), isolate));
} }
builder.AppendCharacter(')'); builder.AppendCharacter(')');
@ -4352,7 +4353,8 @@ bool DescriptorArray::IsEqualTo(DescriptorArray other) {
MaybeHandle<String> Name::ToFunctionName(Isolate* isolate, Handle<Name> name) { MaybeHandle<String> Name::ToFunctionName(Isolate* isolate, Handle<Name> name) {
if (name->IsString()) return Handle<String>::cast(name); if (name->IsString()) return Handle<String>::cast(name);
// ES6 section 9.2.11 SetFunctionName, step 4. // ES6 section 9.2.11 SetFunctionName, step 4.
Handle<Object> description(Handle<Symbol>::cast(name)->name(), isolate); Handle<Object> description(Handle<Symbol>::cast(name)->description(),
isolate);
if (description->IsUndefined(isolate)) { if (description->IsUndefined(isolate)) {
return isolate->factory()->empty_string(); return isolate->factory()->empty_string();
} }
@ -5725,11 +5727,11 @@ const char* Symbol::PrivateSymbolToName() const {
void Symbol::SymbolShortPrint(std::ostream& os) { void Symbol::SymbolShortPrint(std::ostream& os) {
os << "<Symbol:"; os << "<Symbol:";
if (!name().IsUndefined()) { if (!description().IsUndefined()) {
os << " "; os << " ";
HeapStringAllocator allocator; HeapStringAllocator allocator;
StringStream accumulator(&allocator); StringStream accumulator(&allocator);
String::cast(name()).StringShortPrint(&accumulator, false); String::cast(description()).StringShortPrint(&accumulator, false);
os << accumulator.ToCString().get(); os << accumulator.ToCString().get();
} else { } else {
os << " (" << PrivateSymbolToName() << ")"; os << " (" << PrivateSymbolToName() << ")";

View File

@ -913,7 +913,8 @@ void V8HeapExplorer::ExtractStringReferences(HeapEntry* entry, String string) {
} }
void V8HeapExplorer::ExtractSymbolReferences(HeapEntry* entry, Symbol symbol) { void V8HeapExplorer::ExtractSymbolReferences(HeapEntry* entry, Symbol symbol) {
SetInternalReference(entry, "name", symbol.name(), Symbol::kNameOffset); SetInternalReference(entry, "name", symbol.description(),
Symbol::kDescriptionOffset);
} }
void V8HeapExplorer::ExtractJSCollectionReferences(HeapEntry* entry, void V8HeapExplorer::ExtractJSCollectionReferences(HeapEntry* entry,

View File

@ -41,7 +41,7 @@ MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
if (!it.IsFound() && key->IsSymbol() && if (!it.IsFound() && key->IsSymbol() &&
Symbol::cast(*key).is_private_name()) { Symbol::cast(*key).is_private_name()) {
Handle<Object> name_string(Symbol::cast(*key).name(), isolate); Handle<Object> name_string(Symbol::cast(*key).description(), isolate);
DCHECK(name_string->IsString()); DCHECK(name_string->IsString());
THROW_NEW_ERROR(isolate, THROW_NEW_ERROR(isolate,
NewTypeError(MessageTemplate::kInvalidPrivateMemberRead, NewTypeError(MessageTemplate::kInvalidPrivateMemberRead,
@ -417,7 +417,7 @@ MaybeHandle<Object> Runtime::SetObjectProperty(
if (!it.IsFound() && key->IsSymbol() && if (!it.IsFound() && key->IsSymbol() &&
Symbol::cast(*key).is_private_name()) { Symbol::cast(*key).is_private_name()) {
Handle<Object> name_string(Symbol::cast(*key).name(), isolate); Handle<Object> name_string(Symbol::cast(*key).description(), isolate);
DCHECK(name_string->IsString()); DCHECK(name_string->IsString());
THROW_NEW_ERROR(isolate, THROW_NEW_ERROR(isolate,
NewTypeError(MessageTemplate::kInvalidPrivateMemberWrite, NewTypeError(MessageTemplate::kInvalidPrivateMemberWrite,

View File

@ -18,9 +18,10 @@ RUNTIME_FUNCTION(Runtime_CreatePrivateSymbol) {
DCHECK_GE(1, args.length()); DCHECK_GE(1, args.length());
Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol(); Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol();
if (args.length() == 1) { if (args.length() == 1) {
CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); CONVERT_ARG_HANDLE_CHECKED(Object, description, 0);
CHECK(name->IsString() || name->IsUndefined(isolate)); CHECK(description->IsString() || description->IsUndefined(isolate));
if (name->IsString()) symbol->set_name(*name); if (description->IsString())
symbol->set_description(String::cast(*description));
} }
return *symbol; return *symbol;
} }
@ -39,8 +40,8 @@ RUNTIME_FUNCTION(Runtime_SymbolDescriptiveString) {
CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0); CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0);
IncrementalStringBuilder builder(isolate); IncrementalStringBuilder builder(isolate);
builder.AppendCString("Symbol("); builder.AppendCString("Symbol(");
if (symbol->name().IsString()) { if (symbol->description().IsString()) {
builder.AppendString(handle(String::cast(symbol->name()), isolate)); builder.AppendString(handle(String::cast(symbol->description()), isolate));
} }
builder.AppendCharacter(')'); builder.AppendCharacter(')');
RETURN_RESULT_OR_FAILURE(isolate, builder.Finish()); RETURN_RESULT_OR_FAILURE(isolate, builder.Finish());

View File

@ -95,16 +95,16 @@ void SymbolAccessorGetter(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) { const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK(name->IsSymbol()); CHECK(name->IsSymbol());
Local<Symbol> sym = Local<Symbol>::Cast(name); Local<Symbol> sym = Local<Symbol>::Cast(name);
if (sym->Name()->IsUndefined()) return; if (sym->Description()->IsUndefined()) return;
SimpleAccessorGetter(Local<String>::Cast(sym->Name()), info); SimpleAccessorGetter(Local<String>::Cast(sym->Description()), info);
} }
void SymbolAccessorSetter(Local<Name> name, Local<Value> value, void SymbolAccessorSetter(Local<Name> name, Local<Value> value,
const v8::PropertyCallbackInfo<void>& info) { const v8::PropertyCallbackInfo<void>& info) {
CHECK(name->IsSymbol()); CHECK(name->IsSymbol());
Local<Symbol> sym = Local<Symbol>::Cast(name); Local<Symbol> sym = Local<Symbol>::Cast(name);
if (sym->Name()->IsUndefined()) return; if (sym->Description()->IsUndefined()) return;
SimpleAccessorSetter(Local<String>::Cast(sym->Name()), value, info); SimpleAccessorSetter(Local<String>::Cast(sym->Description()), value, info);
} }
void InterceptorGetter(Local<Name> generic_name, void InterceptorGetter(Local<Name> generic_name,
@ -154,7 +154,7 @@ void GenericInterceptorGetter(Local<Name> generic_name,
const v8::PropertyCallbackInfo<v8::Value>& info) { const v8::PropertyCallbackInfo<v8::Value>& info) {
Local<String> str; Local<String> str;
if (generic_name->IsSymbol()) { if (generic_name->IsSymbol()) {
Local<Value> name = Local<Symbol>::Cast(generic_name)->Name(); Local<Value> name = Local<Symbol>::Cast(generic_name)->Description();
if (name->IsUndefined()) return; if (name->IsUndefined()) return;
str = String::Concat(info.GetIsolate(), v8_str("_sym_"), str = String::Concat(info.GetIsolate(), v8_str("_sym_"),
Local<String>::Cast(name)); Local<String>::Cast(name));
@ -175,7 +175,7 @@ void GenericInterceptorSetter(Local<Name> generic_name, Local<Value> value,
const v8::PropertyCallbackInfo<v8::Value>& info) { const v8::PropertyCallbackInfo<v8::Value>& info) {
Local<String> str; Local<String> str;
if (generic_name->IsSymbol()) { if (generic_name->IsSymbol()) {
Local<Value> name = Local<Symbol>::Cast(generic_name)->Name(); Local<Value> name = Local<Symbol>::Cast(generic_name)->Description();
if (name->IsUndefined()) return; if (name->IsUndefined()) return;
str = String::Concat(info.GetIsolate(), v8_str("_sym_"), str = String::Concat(info.GetIsolate(), v8_str("_sym_"),
Local<String>::Cast(name)); Local<String>::Cast(name));

View File

@ -2554,25 +2554,23 @@ void SymbolAccessorGetter(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) { const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK(name->IsSymbol()); CHECK(name->IsSymbol());
Local<Symbol> sym = Local<Symbol>::Cast(name); Local<Symbol> sym = Local<Symbol>::Cast(name);
if (sym->Name()->IsUndefined()) if (sym->Description()->IsUndefined()) return;
return; SimpleAccessorGetter(Local<String>::Cast(sym->Description()), info);
SimpleAccessorGetter(Local<String>::Cast(sym->Name()), info);
} }
void SymbolAccessorSetter(Local<Name> name, Local<Value> value, void SymbolAccessorSetter(Local<Name> name, Local<Value> value,
const v8::PropertyCallbackInfo<void>& info) { const v8::PropertyCallbackInfo<void>& info) {
CHECK(name->IsSymbol()); CHECK(name->IsSymbol());
Local<Symbol> sym = Local<Symbol>::Cast(name); Local<Symbol> sym = Local<Symbol>::Cast(name);
if (sym->Name()->IsUndefined()) if (sym->Description()->IsUndefined()) return;
return; SimpleAccessorSetter(Local<String>::Cast(sym->Description()), value, info);
SimpleAccessorSetter(Local<String>::Cast(sym->Name()), value, info);
} }
void SymbolAccessorGetterReturnsDefault( void SymbolAccessorGetterReturnsDefault(
Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK(name->IsSymbol()); CHECK(name->IsSymbol());
Local<Symbol> sym = Local<Symbol>::Cast(name); Local<Symbol> sym = Local<Symbol>::Cast(name);
if (sym->Name()->IsUndefined()) return; if (sym->Description()->IsUndefined()) return;
info.GetReturnValue().Set(info.Data()); info.GetReturnValue().Set(info.Data());
} }
@ -3201,7 +3199,8 @@ THREADED_TEST(SymbolProperties) {
CHECK(!sym1->StrictEquals(sym2)); CHECK(!sym1->StrictEquals(sym2));
CHECK(!sym2->StrictEquals(sym1)); CHECK(!sym2->StrictEquals(sym1));
CHECK(sym2->Name()->Equals(env.local(), v8_str("my-symbol")).FromJust()); CHECK(
sym2->Description()->Equals(env.local(), v8_str("my-symbol")).FromJust());
v8::Local<v8::Value> sym_val = sym2; v8::Local<v8::Value> sym_val = sym2;
CHECK(sym_val->IsSymbol()); CHECK(sym_val->IsSymbol());
@ -14027,7 +14026,7 @@ void CheckIsSymbolAt(v8::Isolate* isolate, v8::Local<v8::Array> properties,
.ToLocalChecked(); .ToLocalChecked();
CHECK(value->IsSymbol()); CHECK(value->IsSymbol());
v8::String::Utf8Value symbol_name(isolate, v8::String::Utf8Value symbol_name(isolate,
Local<Symbol>::Cast(value)->Name()); Local<Symbol>::Cast(value)->Description());
if (strcmp(name, *symbol_name) != 0) { if (strcmp(name, *symbol_name) != 0) {
FATAL("properties[%u] was Symbol('%s') instead of Symbol('%s').", index, FATAL("properties[%u] was Symbol('%s') instead of Symbol('%s').", index,
name, *symbol_name); name, *symbol_name);

View File

@ -378,7 +378,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
v8::Local<v8::String> str_obj; v8::Local<v8::String> str_obj;
if (arg->IsSymbol()) { if (arg->IsSymbol()) {
arg = v8::Local<v8::Symbol>::Cast(arg)->Name(); arg = v8::Local<v8::Symbol>::Cast(arg)->Description();
} }
if (!arg->ToString(args.GetIsolate()->GetCurrentContext()) if (!arg->ToString(args.GetIsolate()->GetCurrentContext())
.ToLocal(&str_obj)) { .ToLocal(&str_obj)) {

View File

@ -277,7 +277,7 @@ extras_accessors = [
'ConsString, second, String, kSecondOffset', 'ConsString, second, String, kSecondOffset',
'SlicedString, offset, SMI, kOffsetOffset', 'SlicedString, offset, SMI, kOffsetOffset',
'ThinString, actual, String, kActualOffset', 'ThinString, actual, String, kActualOffset',
'Symbol, name, Object, kNameOffset', 'Symbol, name, Object, kDescriptionOffset',
]; ];
# #