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

Side by Side Diff: src/heap.cc

Issue 7521: Make one-ascii-character-string a symbol in its cache. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 if (result->IsFailure()) return result; 1481 if (result->IsFailure()) return result;
1482 1482
1483 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result); 1483 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result);
1484 external_string->set_length(length); 1484 external_string->set_length(length);
1485 external_string->set_resource(resource); 1485 external_string->set_resource(resource);
1486 1486
1487 return result; 1487 return result;
1488 } 1488 }
1489 1489
1490 1490
1491 Object* Heap:: LookupSingleCharacterStringFromCode(uint16_t code) { 1491 Object* Heap::LookupSingleCharacterStringFromCode(uint16_t code) {
1492 if (code <= String::kMaxAsciiCharCode) { 1492 if (code <= String::kMaxAsciiCharCode) {
1493 Object* value = Heap::single_character_string_cache()->get(code); 1493 Object* value = Heap::single_character_string_cache()->get(code);
1494 if (value != Heap::undefined_value()) return value; 1494 if (value != Heap::undefined_value()) return value;
1495 Object* result = Heap::AllocateRawAsciiString(1); 1495
1496 char buffer[1];
1497 buffer[0] = static_cast<char>(code);
1498 Object* result = LookupSymbol(Vector<const char>(buffer, 1));
1499
1496 if (result->IsFailure()) return result; 1500 if (result->IsFailure()) return result;
1497 String::cast(result)->Set(0, code);
1498 Heap::single_character_string_cache()->set(code, result); 1501 Heap::single_character_string_cache()->set(code, result);
1499 return result; 1502 return result;
1500 } 1503 }
1504
1501 Object* result = Heap::AllocateRawTwoByteString(1); 1505 Object* result = Heap::AllocateRawTwoByteString(1);
iposva 2008/10/21 04:33:46 Is there a reason we do not symbolize one characte
Feng Qian 2008/10/21 16:27:11 I viewed single_character_string_cache is a cache
1502 if (result->IsFailure()) return result; 1506 if (result->IsFailure()) return result;
1503 String::cast(result)->Set(0, code); 1507 String::cast(result)->Set(0, code);
1504 return result; 1508 return result;
1505 } 1509 }
1506 1510
1507 1511
1508 Object* Heap::AllocateByteArray(int length) { 1512 Object* Heap::AllocateByteArray(int length) {
1509 int size = ByteArray::SizeFor(length); 1513 int size = ByteArray::SizeFor(length);
1510 AllocationSpace space = 1514 AllocationSpace space =
1511 size > MaxHeapObjectSize() ? LO_SPACE : NEW_SPACE; 1515 size > MaxHeapObjectSize() ? LO_SPACE : NEW_SPACE;
(...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after
3109 #ifdef DEBUG 3113 #ifdef DEBUG
3110 bool Heap::GarbageCollectionGreedyCheck() { 3114 bool Heap::GarbageCollectionGreedyCheck() {
3111 ASSERT(FLAG_gc_greedy); 3115 ASSERT(FLAG_gc_greedy);
3112 if (Bootstrapper::IsActive()) return true; 3116 if (Bootstrapper::IsActive()) return true;
3113 if (disallow_allocation_failure()) return true; 3117 if (disallow_allocation_failure()) return true;
3114 return CollectGarbage(0, NEW_SPACE); 3118 return CollectGarbage(0, NEW_SPACE);
3115 } 3119 }
3116 #endif 3120 #endif
3117 3121
3118 } } // namespace v8::internal 3122 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698