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

Side by Side Diff: src/runtime/runtime-symbol.cc

Issue 2903533002: Revert of [es2015] Precompute the descriptive string for symbols. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/isolate-inl.h" 8 #include "src/isolate-inl.h"
9 #include "src/objects-inl.h" 9 #include "src/objects-inl.h"
10 #include "src/string-builder.h"
10 11
11 namespace v8 { 12 namespace v8 {
12 namespace internal { 13 namespace internal {
13 14
14 RUNTIME_FUNCTION(Runtime_CreateSymbol) { 15 RUNTIME_FUNCTION(Runtime_CreateSymbol) {
15 HandleScope scope(isolate); 16 HandleScope scope(isolate);
16 DCHECK_EQ(1, args.length()); 17 DCHECK_EQ(1, args.length());
17 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); 18 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
18 RETURN_RESULT_OR_FAILURE(isolate, isolate->factory()->NewSymbol(name)); 19 CHECK(name->IsString() || name->IsUndefined(isolate));
20 Handle<Symbol> symbol = isolate->factory()->NewSymbol();
21 if (name->IsString()) symbol->set_name(*name);
22 return *symbol;
19 } 23 }
20 24
25
21 RUNTIME_FUNCTION(Runtime_CreatePrivateSymbol) { 26 RUNTIME_FUNCTION(Runtime_CreatePrivateSymbol) {
22 HandleScope scope(isolate); 27 HandleScope scope(isolate);
23 DCHECK_EQ(1, args.length()); 28 DCHECK_EQ(1, args.length());
24 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); 29 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
25 RETURN_RESULT_OR_FAILURE(isolate, isolate->factory()->NewPrivateSymbol(name)); 30 CHECK(name->IsString() || name->IsUndefined(isolate));
31 Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol();
32 if (name->IsString()) symbol->set_name(*name);
33 return *symbol;
26 } 34 }
27 35
36
28 RUNTIME_FUNCTION(Runtime_SymbolDescription) { 37 RUNTIME_FUNCTION(Runtime_SymbolDescription) {
29 SealHandleScope shs(isolate); 38 SealHandleScope shs(isolate);
30 DCHECK_EQ(1, args.length()); 39 DCHECK_EQ(1, args.length());
31 CONVERT_ARG_CHECKED(Symbol, symbol, 0); 40 CONVERT_ARG_CHECKED(Symbol, symbol, 0);
32 return symbol->name(); 41 return symbol->name();
33 } 42 }
34 43
44
35 RUNTIME_FUNCTION(Runtime_SymbolDescriptiveString) { 45 RUNTIME_FUNCTION(Runtime_SymbolDescriptiveString) {
36 HandleScope scope(isolate); 46 HandleScope scope(isolate);
37 DCHECK_EQ(1, args.length()); 47 DCHECK_EQ(1, args.length());
38 CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0); 48 CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0);
39 return symbol->descriptive_string(); 49 IncrementalStringBuilder builder(isolate);
50 builder.AppendCString("Symbol(");
51 if (symbol->name()->IsString()) {
52 builder.AppendString(handle(String::cast(symbol->name()), isolate));
53 }
54 builder.AppendCharacter(')');
55 RETURN_RESULT_OR_FAILURE(isolate, builder.Finish());
40 } 56 }
41 57
58
42 RUNTIME_FUNCTION(Runtime_SymbolIsPrivate) { 59 RUNTIME_FUNCTION(Runtime_SymbolIsPrivate) {
43 SealHandleScope shs(isolate); 60 SealHandleScope shs(isolate);
44 DCHECK_EQ(1, args.length()); 61 DCHECK_EQ(1, args.length());
45 CONVERT_ARG_CHECKED(Symbol, symbol, 0); 62 CONVERT_ARG_CHECKED(Symbol, symbol, 0);
46 return isolate->heap()->ToBoolean(symbol->is_private()); 63 return isolate->heap()->ToBoolean(symbol->is_private());
47 } 64 }
48
49 } // namespace internal 65 } // namespace internal
50 } // namespace v8 66 } // namespace v8
OLDNEW
« 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