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

Side by Side Diff: src/ast-value-factory.h

Issue 707483002: Revert "Parser & internalization fix: ensure no heap allocs during GetString(Handle<String>)." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | « no previous file | src/ast-value-factory.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 #define F(name, str) name##_string_ = NULL; 280 #define F(name, str) name##_string_ = NULL;
281 STRING_CONSTANTS(F) 281 STRING_CONSTANTS(F)
282 #undef F 282 #undef F
283 #define F(name) name##_ = NULL; 283 #define F(name) name##_ = NULL;
284 OTHER_CONSTANTS(F) 284 OTHER_CONSTANTS(F)
285 #undef F 285 #undef F
286 } 286 }
287 287
288 Zone* zone() const { return zone_; } 288 Zone* zone() const { return zone_; }
289 289
290 const AstRawString* GetOneByteString(Vector<const uint8_t> literal) { 290 const AstRawString* GetOneByteString(Vector<const uint8_t> literal);
291 return GetOneByteStringInternal(literal);
292 }
293 const AstRawString* GetOneByteString(const char* string) { 291 const AstRawString* GetOneByteString(const char* string) {
294 return GetOneByteString(Vector<const uint8_t>( 292 return GetOneByteString(Vector<const uint8_t>(
295 reinterpret_cast<const uint8_t*>(string), StrLength(string))); 293 reinterpret_cast<const uint8_t*>(string), StrLength(string)));
296 } 294 }
297 const AstRawString* GetTwoByteString(Vector<const uint16_t> literal) { 295 const AstRawString* GetTwoByteString(Vector<const uint16_t> literal);
298 return GetTwoByteStringInternal(literal);
299 }
300 const AstRawString* GetString(Handle<String> literal); 296 const AstRawString* GetString(Handle<String> literal);
301 const AstConsString* NewConsString(const AstString* left, 297 const AstConsString* NewConsString(const AstString* left,
302 const AstString* right); 298 const AstString* right);
303 299
304 void Internalize(Isolate* isolate); 300 void Internalize(Isolate* isolate);
305 bool IsInternalized() { 301 bool IsInternalized() {
306 return isolate_ != NULL; 302 return isolate_ != NULL;
307 } 303 }
308 304
309 #define F(name, str) \ 305 #define F(name, str) \
(...skipping 14 matching lines...) Expand all
324 const AstValue* NewSymbol(const char* name); 320 const AstValue* NewSymbol(const char* name);
325 const AstValue* NewNumber(double number); 321 const AstValue* NewNumber(double number);
326 const AstValue* NewSmi(int number); 322 const AstValue* NewSmi(int number);
327 const AstValue* NewBoolean(bool b); 323 const AstValue* NewBoolean(bool b);
328 const AstValue* NewStringList(ZoneList<const AstRawString*>* strings); 324 const AstValue* NewStringList(ZoneList<const AstRawString*>* strings);
329 const AstValue* NewNull(); 325 const AstValue* NewNull();
330 const AstValue* NewUndefined(); 326 const AstValue* NewUndefined();
331 const AstValue* NewTheHole(); 327 const AstValue* NewTheHole();
332 328
333 private: 329 private:
334 AstRawString* GetOneByteStringInternal(Vector<const uint8_t> literal); 330 const AstRawString* GetString(uint32_t hash, bool is_one_byte,
335 AstRawString* GetTwoByteStringInternal(Vector<const uint16_t> literal); 331 Vector<const byte> literal_bytes);
336 AstRawString* GetString(uint32_t hash, bool is_one_byte,
337 Vector<const byte> literal_bytes);
338 332
339 // All strings are copied here, one after another (no NULLs inbetween). 333 // All strings are copied here, one after another (no NULLs inbetween).
340 HashMap string_table_; 334 HashMap string_table_;
341 // For keeping track of all AstValues and AstRawStrings we've created (so that 335 // For keeping track of all AstValues and AstRawStrings we've created (so that
342 // they can be internalized later). 336 // they can be internalized later).
343 List<AstValue*> values_; 337 List<AstValue*> values_;
344 List<AstString*> strings_; 338 List<AstString*> strings_;
345 Zone* zone_; 339 Zone* zone_;
346 Isolate* isolate_; 340 Isolate* isolate_;
347 341
(...skipping 11 matching lines...) Expand all
359 353
360 bool AstRawString::IsArguments(AstValueFactory* ast_value_factory) const { 354 bool AstRawString::IsArguments(AstValueFactory* ast_value_factory) const {
361 return ast_value_factory->arguments_string() == this; 355 return ast_value_factory->arguments_string() == this;
362 } 356 }
363 } } // namespace v8::internal 357 } } // namespace v8::internal
364 358
365 #undef STRING_CONSTANTS 359 #undef STRING_CONSTANTS
366 #undef OTHER_CONSTANTS 360 #undef OTHER_CONSTANTS
367 361
368 #endif // V8_AST_VALUE_FACTORY_H_ 362 #endif // V8_AST_VALUE_FACTORY_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast-value-factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698