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

Side by Side Diff: src/messages.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/mark-compact.cc ('k') | src/mips/code-stubs-mips.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 } 55 }
56 56
57 57
58 Handle<JSMessageObject> MessageHandler::MakeMessageObject( 58 Handle<JSMessageObject> MessageHandler::MakeMessageObject(
59 const char* type, 59 const char* type,
60 MessageLocation* loc, 60 MessageLocation* loc,
61 Vector< Handle<Object> > args, 61 Vector< Handle<Object> > args,
62 Handle<String> stack_trace, 62 Handle<String> stack_trace,
63 Handle<JSArray> stack_frames) { 63 Handle<JSArray> stack_frames) {
64 Handle<String> type_handle = FACTORY->LookupUtf8Symbol(type); 64 Handle<String> type_handle = FACTORY->InternalizeUtf8String(type);
65 Handle<FixedArray> arguments_elements = 65 Handle<FixedArray> arguments_elements =
66 FACTORY->NewFixedArray(args.length()); 66 FACTORY->NewFixedArray(args.length());
67 for (int i = 0; i < args.length(); i++) { 67 for (int i = 0; i < args.length(); i++) {
68 arguments_elements->set(i, *args[i]); 68 arguments_elements->set(i, *args[i]);
69 } 69 }
70 Handle<JSArray> arguments_handle = 70 Handle<JSArray> arguments_handle =
71 FACTORY->NewJSArrayWithElements(arguments_elements); 71 FACTORY->NewJSArrayWithElements(arguments_elements);
72 72
73 int start = 0; 73 int start = 0;
74 int end = 0; 74 int end = 0;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 if (isolate->has_scheduled_exception()) { 143 if (isolate->has_scheduled_exception()) {
144 isolate->clear_scheduled_exception(); 144 isolate->clear_scheduled_exception();
145 } 145 }
146 } 146 }
147 } 147 }
148 } 148 }
149 149
150 150
151 Handle<String> MessageHandler::GetMessage(Handle<Object> data) { 151 Handle<String> MessageHandler::GetMessage(Handle<Object> data) {
152 Handle<String> fmt_str = 152 Handle<String> fmt_str =
153 FACTORY->LookupOneByteSymbol(STATIC_ASCII_VECTOR("FormatMessage")); 153 FACTORY->InternalizeOneByteString(STATIC_ASCII_VECTOR("FormatMessage"));
154 Handle<JSFunction> fun = 154 Handle<JSFunction> fun =
155 Handle<JSFunction>( 155 Handle<JSFunction>(
156 JSFunction::cast( 156 JSFunction::cast(
157 Isolate::Current()->js_builtins_object()-> 157 Isolate::Current()->js_builtins_object()->
158 GetPropertyNoExceptionThrown(*fmt_str))); 158 GetPropertyNoExceptionThrown(*fmt_str)));
159 Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data); 159 Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data);
160 Handle<Object> argv[] = { Handle<Object>(message->type()), 160 Handle<Object> argv[] = { Handle<Object>(message->type()),
161 Handle<Object>(message->arguments()) }; 161 Handle<Object>(message->arguments()) };
162 162
163 bool caught_exception; 163 bool caught_exception;
164 Handle<Object> result = 164 Handle<Object> result =
165 Execution::TryCall(fun, 165 Execution::TryCall(fun,
166 Isolate::Current()->js_builtins_object(), 166 Isolate::Current()->js_builtins_object(),
167 ARRAY_SIZE(argv), 167 ARRAY_SIZE(argv),
168 argv, 168 argv,
169 &caught_exception); 169 &caught_exception);
170 170
171 if (caught_exception || !result->IsString()) { 171 if (caught_exception || !result->IsString()) {
172 return FACTORY->LookupOneByteSymbol(STATIC_ASCII_VECTOR("<error>")); 172 return FACTORY->InternalizeOneByteString(STATIC_ASCII_VECTOR("<error>"));
173 } 173 }
174 Handle<String> result_string = Handle<String>::cast(result); 174 Handle<String> result_string = Handle<String>::cast(result);
175 // A string that has been obtained from JS code in this way is 175 // A string that has been obtained from JS code in this way is
176 // likely to be a complicated ConsString of some sort. We flatten it 176 // likely to be a complicated ConsString of some sort. We flatten it
177 // here to improve the efficiency of converting it to a C string and 177 // here to improve the efficiency of converting it to a C string and
178 // other operations that are likely to take place (see GetLocalizedMessage 178 // other operations that are likely to take place (see GetLocalizedMessage
179 // for example). 179 // for example).
180 FlattenString(result_string); 180 FlattenString(result_string);
181 return result_string; 181 return result_string;
182 } 182 }
183 183
184 184
185 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage( 185 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage(
186 Handle<Object> data) { 186 Handle<Object> data) {
187 HandleScope scope; 187 HandleScope scope;
188 return GetMessage(data)->ToCString(DISALLOW_NULLS); 188 return GetMessage(data)->ToCString(DISALLOW_NULLS);
189 } 189 }
190 190
191 191
192 } } // namespace v8::internal 192 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mark-compact.cc ('k') | src/mips/code-stubs-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698