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

Side by Side Diff: src/parser.cc

Issue 11597007: Rename LookupSymbol calls to use Utf8 or OneByte in names. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years 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/objects.cc ('k') | src/runtime.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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 247
248 248
249 Handle<String> Parser::LookupSymbol(int symbol_id) { 249 Handle<String> Parser::LookupSymbol(int symbol_id) {
250 // Length of symbol cache is the number of identified symbols. 250 // Length of symbol cache is the number of identified symbols.
251 // If we are larger than that, or negative, it's not a cached symbol. 251 // If we are larger than that, or negative, it's not a cached symbol.
252 // This might also happen if there is no preparser symbol data, even 252 // This might also happen if there is no preparser symbol data, even
253 // if there is some preparser data. 253 // if there is some preparser data.
254 if (static_cast<unsigned>(symbol_id) 254 if (static_cast<unsigned>(symbol_id)
255 >= static_cast<unsigned>(symbol_cache_.length())) { 255 >= static_cast<unsigned>(symbol_cache_.length())) {
256 if (scanner().is_literal_ascii()) { 256 if (scanner().is_literal_ascii()) {
257 return isolate()->factory()->LookupAsciiSymbol( 257 return isolate()->factory()->LookupOneByteSymbol(
258 scanner().literal_ascii_string()); 258 scanner().literal_ascii_string());
259 } else { 259 } else {
260 return isolate()->factory()->LookupTwoByteSymbol( 260 return isolate()->factory()->LookupTwoByteSymbol(
261 scanner().literal_utf16_string()); 261 scanner().literal_utf16_string());
262 } 262 }
263 } 263 }
264 return LookupCachedSymbol(symbol_id); 264 return LookupCachedSymbol(symbol_id);
265 } 265 }
266 266
267 267
268 Handle<String> Parser::LookupCachedSymbol(int symbol_id) { 268 Handle<String> Parser::LookupCachedSymbol(int symbol_id) {
269 // Make sure the cache is large enough to hold the symbol identifier. 269 // Make sure the cache is large enough to hold the symbol identifier.
270 if (symbol_cache_.length() <= symbol_id) { 270 if (symbol_cache_.length() <= symbol_id) {
271 // Increase length to index + 1. 271 // Increase length to index + 1.
272 symbol_cache_.AddBlock(Handle<String>::null(), 272 symbol_cache_.AddBlock(Handle<String>::null(),
273 symbol_id + 1 - symbol_cache_.length(), zone()); 273 symbol_id + 1 - symbol_cache_.length(), zone());
274 } 274 }
275 Handle<String> result = symbol_cache_.at(symbol_id); 275 Handle<String> result = symbol_cache_.at(symbol_id);
276 if (result.is_null()) { 276 if (result.is_null()) {
277 if (scanner().is_literal_ascii()) { 277 if (scanner().is_literal_ascii()) {
278 result = isolate()->factory()->LookupAsciiSymbol( 278 result = isolate()->factory()->LookupOneByteSymbol(
279 scanner().literal_ascii_string()); 279 scanner().literal_ascii_string());
280 } else { 280 } else {
281 result = isolate()->factory()->LookupTwoByteSymbol( 281 result = isolate()->factory()->LookupTwoByteSymbol(
282 scanner().literal_utf16_string()); 282 scanner().literal_utf16_string());
283 } 283 }
284 symbol_cache_.at(symbol_id) = result; 284 symbol_cache_.at(symbol_id) = result;
285 return result; 285 return result;
286 } 286 }
287 isolate()->counters()->total_preparse_symbols_skipped()->Increment(); 287 isolate()->counters()->total_preparse_symbols_skipped()->Increment();
288 return result; 288 return result;
(...skipping 3692 matching lines...) Expand 10 before | Expand all | Expand 10 after
3981 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... } 3981 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... }
3982 // We have already read the "get" or "set" keyword. 3982 // We have already read the "get" or "set" keyword.
3983 Token::Value next = Next(); 3983 Token::Value next = Next();
3984 bool is_keyword = Token::IsKeyword(next); 3984 bool is_keyword = Token::IsKeyword(next);
3985 if (next == Token::IDENTIFIER || next == Token::NUMBER || 3985 if (next == Token::IDENTIFIER || next == Token::NUMBER ||
3986 next == Token::FUTURE_RESERVED_WORD || 3986 next == Token::FUTURE_RESERVED_WORD ||
3987 next == Token::FUTURE_STRICT_RESERVED_WORD || 3987 next == Token::FUTURE_STRICT_RESERVED_WORD ||
3988 next == Token::STRING || is_keyword) { 3988 next == Token::STRING || is_keyword) {
3989 Handle<String> name; 3989 Handle<String> name;
3990 if (is_keyword) { 3990 if (is_keyword) {
3991 name = isolate_->factory()->LookupAsciiSymbol(Token::String(next)); 3991 name = isolate_->factory()->LookupUtf8Symbol(Token::String(next));
3992 } else { 3992 } else {
3993 name = GetSymbol(CHECK_OK); 3993 name = GetSymbol(CHECK_OK);
3994 } 3994 }
3995 FunctionLiteral* value = 3995 FunctionLiteral* value =
3996 ParseFunctionLiteral(name, 3996 ParseFunctionLiteral(name,
3997 false, // reserved words are allowed here 3997 false, // reserved words are allowed here
3998 RelocInfo::kNoPosition, 3998 RelocInfo::kNoPosition,
3999 FunctionLiteral::ANONYMOUS_EXPRESSION, 3999 FunctionLiteral::ANONYMOUS_EXPRESSION,
4000 CHECK_OK); 4000 CHECK_OK);
4001 // Allow any number of parameters for compatibilty with JSC. 4001 // Allow any number of parameters for compatibilty with JSC.
(...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after
5928 ASSERT(info->isolate()->has_pending_exception()); 5928 ASSERT(info->isolate()->has_pending_exception());
5929 } else { 5929 } else {
5930 result = parser.ParseProgram(); 5930 result = parser.ParseProgram();
5931 } 5931 }
5932 } 5932 }
5933 info->SetFunction(result); 5933 info->SetFunction(result);
5934 return (result != NULL); 5934 return (result != NULL);
5935 } 5935 }
5936 5936
5937 } } // namespace v8::internal 5937 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698