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

Side by Side Diff: src/factory.cc

Issue 12210083: Renamed "symbols" to "internalized strings" throughout the code base, (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Yang's comments Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/factory.h ('k') | src/func-name-inferrer.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 151
152 152
153 Handle<TypeFeedbackInfo> Factory::NewTypeFeedbackInfo() { 153 Handle<TypeFeedbackInfo> Factory::NewTypeFeedbackInfo() {
154 CALL_HEAP_FUNCTION(isolate(), 154 CALL_HEAP_FUNCTION(isolate(),
155 isolate()->heap()->AllocateTypeFeedbackInfo(), 155 isolate()->heap()->AllocateTypeFeedbackInfo(),
156 TypeFeedbackInfo); 156 TypeFeedbackInfo);
157 } 157 }
158 158
159 159
160 // Symbols are created in the old generation (data space). 160 // Internalized strings are created in the old generation (data space).
161 Handle<String> Factory::LookupUtf8Symbol(Vector<const char> string) { 161 Handle<String> Factory::InternalizeUtf8String(Vector<const char> string) {
162 CALL_HEAP_FUNCTION(isolate(), 162 CALL_HEAP_FUNCTION(isolate(),
163 isolate()->heap()->LookupUtf8Symbol(string), 163 isolate()->heap()->InternalizeUtf8String(string),
164 String); 164 String);
165 } 165 }
166 166
167 // Symbols are created in the old generation (data space). 167 // Internalized strings are created in the old generation (data space).
168 Handle<String> Factory::LookupSymbol(Handle<String> string) { 168 Handle<String> Factory::InternalizeString(Handle<String> string) {
169 CALL_HEAP_FUNCTION(isolate(), 169 CALL_HEAP_FUNCTION(isolate(),
170 isolate()->heap()->LookupSymbol(*string), 170 isolate()->heap()->InternalizeString(*string),
171 String); 171 String);
172 } 172 }
173 173
174 Handle<String> Factory::LookupOneByteSymbol(Vector<const uint8_t> string) { 174 Handle<String> Factory::InternalizeOneByteString(Vector<const uint8_t> string) {
175 CALL_HEAP_FUNCTION(isolate(), 175 CALL_HEAP_FUNCTION(isolate(),
176 isolate()->heap()->LookupOneByteSymbol(string), 176 isolate()->heap()->InternalizeOneByteString(string),
177 String); 177 String);
178 } 178 }
179 179
180 180
181 Handle<String> Factory::LookupOneByteSymbol(Handle<SeqOneByteString> string, 181 Handle<String> Factory::InternalizeOneByteString(
182 int from, 182 Handle<SeqOneByteString> string, int from, int length) {
183 int length) {
184 CALL_HEAP_FUNCTION(isolate(), 183 CALL_HEAP_FUNCTION(isolate(),
185 isolate()->heap()->LookupOneByteSymbol(string, 184 isolate()->heap()->InternalizeOneByteString(
186 from, 185 string, from, length),
187 length),
188 String); 186 String);
189 } 187 }
190 188
191 189
192 Handle<String> Factory::LookupTwoByteSymbol(Vector<const uc16> string) { 190 Handle<String> Factory::InternalizeTwoByteString(Vector<const uc16> string) {
193 CALL_HEAP_FUNCTION(isolate(), 191 CALL_HEAP_FUNCTION(isolate(),
194 isolate()->heap()->LookupTwoByteSymbol(string), 192 isolate()->heap()->InternalizeTwoByteString(string),
195 String); 193 String);
196 } 194 }
197 195
198 196
199 Handle<String> Factory::NewStringFromOneByte(Vector<const uint8_t> string, 197 Handle<String> Factory::NewStringFromOneByte(Vector<const uint8_t> string,
200 PretenureFlag pretenure) { 198 PretenureFlag pretenure) {
201 CALL_HEAP_FUNCTION( 199 CALL_HEAP_FUNCTION(
202 isolate(), 200 isolate(),
203 isolate()->heap()->AllocateStringFromOneByte(string, pretenure), 201 isolate()->heap()->AllocateStringFromOneByte(string, pretenure),
204 String); 202 String);
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 buffer[kBufferSize - 1] = '\0'; 732 buffer[kBufferSize - 1] = '\0';
735 } 733 }
736 Handle<String> error_string = NewStringFromUtf8(CStrVector(buffer), TENURED); 734 Handle<String> error_string = NewStringFromUtf8(CStrVector(buffer), TENURED);
737 return error_string; 735 return error_string;
738 } 736 }
739 737
740 738
741 Handle<Object> Factory::NewError(const char* maker, 739 Handle<Object> Factory::NewError(const char* maker,
742 const char* type, 740 const char* type,
743 Handle<JSArray> args) { 741 Handle<JSArray> args) {
744 Handle<String> make_str = LookupUtf8Symbol(maker); 742 Handle<String> make_str = InternalizeUtf8String(maker);
745 Handle<Object> fun_obj( 743 Handle<Object> fun_obj(
746 isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str)); 744 isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str));
747 // If the builtins haven't been properly configured yet this error 745 // If the builtins haven't been properly configured yet this error
748 // constructor may not have been defined. Bail out. 746 // constructor may not have been defined. Bail out.
749 if (!fun_obj->IsJSFunction()) { 747 if (!fun_obj->IsJSFunction()) {
750 return EmergencyNewError(type, args); 748 return EmergencyNewError(type, args);
751 } 749 }
752 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj); 750 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj);
753 Handle<Object> type_obj = LookupUtf8Symbol(type); 751 Handle<Object> type_obj = InternalizeUtf8String(type);
754 Handle<Object> argv[] = { type_obj, args }; 752 Handle<Object> argv[] = { type_obj, args };
755 753
756 // Invoke the JavaScript factory method. If an exception is thrown while 754 // Invoke the JavaScript factory method. If an exception is thrown while
757 // running the factory method, use the exception as the result. 755 // running the factory method, use the exception as the result.
758 bool caught_exception; 756 bool caught_exception;
759 Handle<Object> result = Execution::TryCall(fun, 757 Handle<Object> result = Execution::TryCall(fun,
760 isolate()->js_builtins_object(), 758 isolate()->js_builtins_object(),
761 ARRAY_SIZE(argv), 759 ARRAY_SIZE(argv),
762 argv, 760 argv,
763 &caught_exception); 761 &caught_exception);
764 return result; 762 return result;
765 } 763 }
766 764
767 765
768 Handle<Object> Factory::NewError(Handle<String> message) { 766 Handle<Object> Factory::NewError(Handle<String> message) {
769 return NewError("$Error", message); 767 return NewError("$Error", message);
770 } 768 }
771 769
772 770
773 Handle<Object> Factory::NewError(const char* constructor, 771 Handle<Object> Factory::NewError(const char* constructor,
774 Handle<String> message) { 772 Handle<String> message) {
775 Handle<String> constr = LookupUtf8Symbol(constructor); 773 Handle<String> constr = InternalizeUtf8String(constructor);
776 Handle<JSFunction> fun = Handle<JSFunction>( 774 Handle<JSFunction> fun = Handle<JSFunction>(
777 JSFunction::cast(isolate()->js_builtins_object()-> 775 JSFunction::cast(isolate()->js_builtins_object()->
778 GetPropertyNoExceptionThrown(*constr))); 776 GetPropertyNoExceptionThrown(*constr)));
779 Handle<Object> argv[] = { message }; 777 Handle<Object> argv[] = { message };
780 778
781 // Invoke the JavaScript factory method. If an exception is thrown while 779 // Invoke the JavaScript factory method. If an exception is thrown while
782 // running the factory method, use the exception as the result. 780 // running the factory method, use the exception as the result.
783 bool caught_exception; 781 bool caught_exception;
784 Handle<Object> result = Execution::TryCall(fun, 782 Handle<Object> result = Execution::TryCall(fun,
785 isolate()->js_builtins_object(), 783 isolate()->js_builtins_object(),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 function->set_initial_map(*initial_map); 841 function->set_initial_map(*initial_map);
844 initial_map->set_constructor(*function); 842 initial_map->set_constructor(*function);
845 } 843 }
846 844
847 // Set function.prototype and give the prototype a constructor 845 // Set function.prototype and give the prototype a constructor
848 // property that refers to the function. 846 // property that refers to the function.
849 SetPrototypeProperty(function, prototype); 847 SetPrototypeProperty(function, prototype);
850 // Currently safe because it is only invoked from Genesis. 848 // Currently safe because it is only invoked from Genesis.
851 CHECK_NOT_EMPTY_HANDLE(isolate(), 849 CHECK_NOT_EMPTY_HANDLE(isolate(),
852 JSObject::SetLocalPropertyIgnoreAttributes( 850 JSObject::SetLocalPropertyIgnoreAttributes(
853 prototype, constructor_symbol(), 851 prototype, constructor_string(),
854 function, DONT_ENUM)); 852 function, DONT_ENUM));
855 return function; 853 return function;
856 } 854 }
857 855
858 856
859 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, 857 Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name,
860 Handle<Code> code) { 858 Handle<Code> code) {
861 Handle<JSFunction> function = NewFunctionWithoutPrototype(name, 859 Handle<JSFunction> function = NewFunctionWithoutPrototype(name,
862 CLASSIC_MODE); 860 CLASSIC_MODE);
863 function->shared()->set_code(*code); 861 function->shared()->set_code(*code);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 } 899 }
902 900
903 901
904 Handle<Code> Factory::CopyCode(Handle<Code> code, Vector<byte> reloc_info) { 902 Handle<Code> Factory::CopyCode(Handle<Code> code, Vector<byte> reloc_info) {
905 CALL_HEAP_FUNCTION(isolate(), 903 CALL_HEAP_FUNCTION(isolate(),
906 isolate()->heap()->CopyCode(*code, reloc_info), 904 isolate()->heap()->CopyCode(*code, reloc_info),
907 Code); 905 Code);
908 } 906 }
909 907
910 908
911 Handle<String> Factory::SymbolFromString(Handle<String> value) { 909 Handle<String> Factory::InternalizedStringFromString(Handle<String> value) {
912 CALL_HEAP_FUNCTION(isolate(), 910 CALL_HEAP_FUNCTION(isolate(),
913 isolate()->heap()->LookupSymbol(*value), String); 911 isolate()->heap()->InternalizeString(*value), String);
914 } 912 }
915 913
916 914
917 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor, 915 Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor,
918 PretenureFlag pretenure) { 916 PretenureFlag pretenure) {
919 CALL_HEAP_FUNCTION( 917 CALL_HEAP_FUNCTION(
920 isolate(), 918 isolate(),
921 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject); 919 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject);
922 } 920 }
923 921
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 case OuterGlobalObject: 1246 case OuterGlobalObject:
1249 type = JS_GLOBAL_PROXY_TYPE; 1247 type = JS_GLOBAL_PROXY_TYPE;
1250 instance_size += JSGlobalProxy::kSize; 1248 instance_size += JSGlobalProxy::kSize;
1251 break; 1249 break;
1252 default: 1250 default:
1253 break; 1251 break;
1254 } 1252 }
1255 ASSERT(type != INVALID_TYPE); 1253 ASSERT(type != INVALID_TYPE);
1256 1254
1257 Handle<JSFunction> result = 1255 Handle<JSFunction> result =
1258 NewFunction(Factory::empty_symbol(), 1256 NewFunction(Factory::empty_string(),
1259 type, 1257 type,
1260 instance_size, 1258 instance_size,
1261 code, 1259 code,
1262 true); 1260 true);
1263 1261
1264 // Set length. 1262 // Set length.
1265 result->shared()->set_length(obj->length()); 1263 result->shared()->set_length(obj->length());
1266 1264
1267 // Set class name. 1265 // Set class name.
1268 Handle<Object> class_name = Handle<Object>(obj->class_name()); 1266 Handle<Object> class_name = Handle<Object>(obj->class_name());
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 instance_template, 1430 instance_template,
1433 pending_exception); 1431 pending_exception);
1434 } else { 1432 } else {
1435 *pending_exception = false; 1433 *pending_exception = false;
1436 } 1434 }
1437 } 1435 }
1438 1436
1439 1437
1440 Handle<Object> Factory::GlobalConstantFor(Handle<String> name) { 1438 Handle<Object> Factory::GlobalConstantFor(Handle<String> name) {
1441 Heap* h = isolate()->heap(); 1439 Heap* h = isolate()->heap();
1442 if (name->Equals(h->undefined_symbol())) return undefined_value(); 1440 if (name->Equals(h->undefined_string())) return undefined_value();
1443 if (name->Equals(h->nan_symbol())) return nan_value(); 1441 if (name->Equals(h->nan_string())) return nan_value();
1444 if (name->Equals(h->infinity_symbol())) return infinity_value(); 1442 if (name->Equals(h->infinity_string())) return infinity_value();
1445 return Handle<Object>::null(); 1443 return Handle<Object>::null();
1446 } 1444 }
1447 1445
1448 1446
1449 Handle<Object> Factory::ToBoolean(bool value) { 1447 Handle<Object> Factory::ToBoolean(bool value) {
1450 return Handle<Object>(value 1448 return Handle<Object>(value
1451 ? isolate()->heap()->true_value() 1449 ? isolate()->heap()->true_value()
1452 : isolate()->heap()->false_value()); 1450 : isolate()->heap()->false_value());
1453 } 1451 }
1454 1452
1455 1453
1456 } } // namespace v8::internal 1454 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/func-name-inferrer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698