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

Side by Side Diff: src/factory.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/factory.h ('k') | src/heap-symbols.h » ('j') | 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/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
11 #include "src/bootstrapper.h" 11 #include "src/bootstrapper.h"
12 #include "src/compiler.h" 12 #include "src/compiler.h"
13 #include "src/conversions.h" 13 #include "src/conversions.h"
14 #include "src/isolate-inl.h" 14 #include "src/isolate-inl.h"
15 #include "src/macro-assembler.h" 15 #include "src/macro-assembler.h"
16 #include "src/objects/frame-array-inl.h" 16 #include "src/objects/frame-array-inl.h"
17 #include "src/objects/module-info.h" 17 #include "src/objects/module-info.h"
18 #include "src/objects/scope-info.h" 18 #include "src/objects/scope-info.h"
19 #include "src/string-builder.h"
20 19
21 namespace v8 { 20 namespace v8 {
22 namespace internal { 21 namespace internal {
23 22
24 23
25 // Calls the FUNCTION_CALL function and retries it up to three times 24 // Calls the FUNCTION_CALL function and retries it up to three times
26 // to guarantee that any allocations performed during the call will 25 // to guarantee that any allocations performed during the call will
27 // succeed if there's enough memory. 26 // succeed if there's enough memory.
28 // 27 //
29 // Warning: Do not use the identifiers __object__, __maybe_object__, 28 // Warning: Do not use the identifiers __object__, __maybe_object__,
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 return iterator; 902 return iterator;
904 } 903 }
905 904
906 Handle<Symbol> Factory::NewSymbol() { 905 Handle<Symbol> Factory::NewSymbol() {
907 CALL_HEAP_FUNCTION( 906 CALL_HEAP_FUNCTION(
908 isolate(), 907 isolate(),
909 isolate()->heap()->AllocateSymbol(), 908 isolate()->heap()->AllocateSymbol(),
910 Symbol); 909 Symbol);
911 } 910 }
912 911
913 MaybeHandle<Symbol> Factory::NewSymbol(Handle<Object> name) {
914 DCHECK(name->IsString() || name->IsUndefined(isolate()));
915 Handle<Symbol> symbol = NewSymbol();
916 if (name->IsString()) {
917 // Compute the descriptive string for the {symbol}.
918 Handle<String> descriptive_string;
919 IncrementalStringBuilder builder(isolate());
920 builder.AppendCString("Symbol(");
921 builder.AppendString(Handle<String>::cast(name));
922 builder.AppendCharacter(')');
923 ASSIGN_RETURN_ON_EXCEPTION(isolate(), descriptive_string, builder.Finish(),
924 Symbol);
925
926 // Make sure those strings are flattened.
927 name = String::Flatten(Handle<String>::cast(name), TENURED);
928 descriptive_string = String::Flatten(descriptive_string, TENURED);
929
930 symbol->set_name(String::cast(*name));
931 symbol->set_descriptive_string(*descriptive_string);
932 }
933 return symbol;
934 }
935 912
936 Handle<Symbol> Factory::NewPrivateSymbol() { 913 Handle<Symbol> Factory::NewPrivateSymbol() {
937 Handle<Symbol> symbol = NewSymbol(); 914 Handle<Symbol> symbol = NewSymbol();
938 symbol->set_is_private(true); 915 symbol->set_is_private(true);
939 return symbol; 916 return symbol;
940 } 917 }
941
942 MaybeHandle<Symbol> Factory::NewPrivateSymbol(Handle<Object> name) {
943 Handle<Symbol> symbol;
944 ASSIGN_RETURN_ON_EXCEPTION(isolate(), symbol, NewSymbol(name), Symbol);
945 symbol->set_is_private(true);
946 return symbol;
947 }
948 918
949 Handle<JSPromise> Factory::NewJSPromise() { 919 Handle<JSPromise> Factory::NewJSPromise() {
950 Handle<JSFunction> constructor( 920 Handle<JSFunction> constructor(
951 isolate()->native_context()->promise_function(), isolate()); 921 isolate()->native_context()->promise_function(), isolate());
952 DCHECK(constructor->has_initial_map()); 922 DCHECK(constructor->has_initial_map());
953 Handle<Map> map(constructor->initial_map(), isolate()); 923 Handle<Map> map(constructor->initial_map(), isolate());
954 924
955 DCHECK(!map->is_prototype_map()); 925 DCHECK(!map->is_prototype_map());
956 Handle<JSObject> promise_obj = NewJSObjectFromMap(map); 926 Handle<JSObject> promise_obj = NewJSObjectFromMap(map);
957 Handle<JSPromise> promise = Handle<JSPromise>::cast(promise_obj); 927 Handle<JSPromise> promise = Handle<JSPromise>::cast(promise_obj);
(...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 Handle<AccessorInfo> prototype = 2952 Handle<AccessorInfo> prototype =
2983 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); 2953 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs);
2984 Descriptor d = Descriptor::AccessorConstant( 2954 Descriptor d = Descriptor::AccessorConstant(
2985 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); 2955 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs);
2986 map->AppendDescriptor(&d); 2956 map->AppendDescriptor(&d);
2987 } 2957 }
2988 } 2958 }
2989 2959
2990 } // namespace internal 2960 } // namespace internal
2991 } // namespace v8 2961 } // namespace v8
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/heap-symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698