Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(983)

Unified Diff: src/runtime/runtime-symbol.cc

Issue 2900703002: [es2015] Precompute the descriptive string for symbols. (Closed)
Patch Set: Address feedback. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-symbol.cc
diff --git a/src/runtime/runtime-symbol.cc b/src/runtime/runtime-symbol.cc
index 2eaef63bbf2bedb4e06df8b9ccae892505f13b00..35870fd5ac1d80d959beca229fa0222cf63c710b 100644
--- a/src/runtime/runtime-symbol.cc
+++ b/src/runtime/runtime-symbol.cc
@@ -7,7 +7,6 @@
#include "src/arguments.h"
#include "src/isolate-inl.h"
#include "src/objects-inl.h"
-#include "src/string-builder.h"
namespace v8 {
namespace internal {
@@ -16,24 +15,16 @@ RUNTIME_FUNCTION(Runtime_CreateSymbol) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
- CHECK(name->IsString() || name->IsUndefined(isolate));
- Handle<Symbol> symbol = isolate->factory()->NewSymbol();
- if (name->IsString()) symbol->set_name(*name);
- return *symbol;
+ RETURN_RESULT_OR_FAILURE(isolate, isolate->factory()->NewSymbol(name));
}
-
RUNTIME_FUNCTION(Runtime_CreatePrivateSymbol) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
- CHECK(name->IsString() || name->IsUndefined(isolate));
- Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol();
- if (name->IsString()) symbol->set_name(*name);
- return *symbol;
+ RETURN_RESULT_OR_FAILURE(isolate, isolate->factory()->NewPrivateSymbol(name));
}
-
RUNTIME_FUNCTION(Runtime_SymbolDescription) {
SealHandleScope shs(isolate);
DCHECK_EQ(1, args.length());
@@ -41,26 +32,19 @@ RUNTIME_FUNCTION(Runtime_SymbolDescription) {
return symbol->name();
}
-
RUNTIME_FUNCTION(Runtime_SymbolDescriptiveString) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0);
- IncrementalStringBuilder builder(isolate);
- builder.AppendCString("Symbol(");
- if (symbol->name()->IsString()) {
- builder.AppendString(handle(String::cast(symbol->name()), isolate));
- }
- builder.AppendCharacter(')');
- RETURN_RESULT_OR_FAILURE(isolate, builder.Finish());
+ return symbol->descriptive_string();
}
-
RUNTIME_FUNCTION(Runtime_SymbolIsPrivate) {
SealHandleScope shs(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_CHECKED(Symbol, symbol, 0);
return isolate->heap()->ToBoolean(symbol->is_private());
}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698