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

Side by Side Diff: src/heap.cc

Issue 249103002: StringTable::LookupKey() and all callers handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing review notes Created 6 years, 8 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/heap.h ('k') | src/mark-compact.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 3369 matching lines...) Expand 10 before | Expand all | Expand 10 after
3380 STATIC_ASSERT(Foreign::kSize <= Page::kMaxRegularHeapObjectSize); 3380 STATIC_ASSERT(Foreign::kSize <= Page::kMaxRegularHeapObjectSize);
3381 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; 3381 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE;
3382 Foreign* result; 3382 Foreign* result;
3383 MaybeObject* maybe_result = Allocate(foreign_map(), space); 3383 MaybeObject* maybe_result = Allocate(foreign_map(), space);
3384 if (!maybe_result->To(&result)) return maybe_result; 3384 if (!maybe_result->To(&result)) return maybe_result;
3385 result->set_foreign_address(address); 3385 result->set_foreign_address(address);
3386 return result; 3386 return result;
3387 } 3387 }
3388 3388
3389 3389
3390 MaybeObject* Heap::LookupSingleCharacterStringFromCode(uint16_t code) {
3391 if (code <= String::kMaxOneByteCharCode) {
3392 Object* value = single_character_string_cache()->get(code);
3393 if (value != undefined_value()) return value;
3394
3395 uint8_t buffer[1];
3396 buffer[0] = static_cast<uint8_t>(code);
3397 Object* result;
3398 OneByteStringKey key(Vector<const uint8_t>(buffer, 1), HashSeed());
3399 MaybeObject* maybe_result = InternalizeStringWithKey(&key);
3400
3401 if (!maybe_result->ToObject(&result)) return maybe_result;
3402 single_character_string_cache()->set(code, result);
3403 return result;
3404 }
3405
3406 SeqTwoByteString* result;
3407 { MaybeObject* maybe_result = AllocateRawTwoByteString(1, NOT_TENURED);
3408 if (!maybe_result->To<SeqTwoByteString>(&result)) return maybe_result;
3409 }
3410 result->SeqTwoByteStringSet(0, code);
3411 return result;
3412 }
3413
3414
3415 MaybeObject* Heap::AllocateByteArray(int length, PretenureFlag pretenure) { 3390 MaybeObject* Heap::AllocateByteArray(int length, PretenureFlag pretenure) {
3416 if (length < 0 || length > ByteArray::kMaxLength) { 3391 if (length < 0 || length > ByteArray::kMaxLength) {
3417 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); 3392 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true);
3418 } 3393 }
3419 int size = ByteArray::SizeFor(length); 3394 int size = ByteArray::SizeFor(length);
3420 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); 3395 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure);
3421 Object* result; 3396 Object* result;
3422 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE); 3397 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE);
3423 if (!maybe_result->ToObject(&result)) return maybe_result; 3398 if (!maybe_result->ToObject(&result)) return maybe_result;
3424 } 3399 }
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after
4868 old_data_space_->Verify(&no_dirty_regions_visitor); 4843 old_data_space_->Verify(&no_dirty_regions_visitor);
4869 code_space_->Verify(&no_dirty_regions_visitor); 4844 code_space_->Verify(&no_dirty_regions_visitor);
4870 cell_space_->Verify(&no_dirty_regions_visitor); 4845 cell_space_->Verify(&no_dirty_regions_visitor);
4871 property_cell_space_->Verify(&no_dirty_regions_visitor); 4846 property_cell_space_->Verify(&no_dirty_regions_visitor);
4872 4847
4873 lo_space_->Verify(); 4848 lo_space_->Verify();
4874 } 4849 }
4875 #endif 4850 #endif
4876 4851
4877 4852
4878 MaybeObject* Heap::InternalizeUtf8String(Vector<const char> string) {
4879 Utf8StringKey key(string, HashSeed());
4880 return InternalizeStringWithKey(&key);
4881 }
4882
4883
4884 MaybeObject* Heap::InternalizeString(String* string) {
4885 if (string->IsInternalizedString()) return string;
4886 Object* result = NULL;
4887 Object* new_table;
4888 { MaybeObject* maybe_new_table =
4889 string_table()->LookupString(string, &result);
4890 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table;
4891 }
4892 // Can't use set_string_table because StringTable::cast knows that
4893 // StringTable is a singleton and checks for identity.
4894 roots_[kStringTableRootIndex] = new_table;
4895 ASSERT(result != NULL);
4896 return result;
4897 }
4898
4899
4900 bool Heap::InternalizeStringIfExists(String* string, String** result) { 4853 bool Heap::InternalizeStringIfExists(String* string, String** result) {
4901 if (string->IsInternalizedString()) { 4854 if (string->IsInternalizedString()) {
4902 *result = string; 4855 *result = string;
4903 return true; 4856 return true;
4904 } 4857 }
4905 return string_table()->LookupStringIfExists(string, result); 4858 return string_table()->LookupStringIfExists(string, result);
4906 } 4859 }
4907 4860
4908 4861
4909 MaybeObject* Heap::InternalizeStringWithKey(HashTableKey* key) {
4910 Object* result = NULL;
4911 Object* new_table;
4912 { MaybeObject* maybe_new_table =
4913 string_table()->LookupKey(key, &result);
4914 if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table;
4915 }
4916 // Can't use set_string_table because StringTable::cast knows that
4917 // StringTable is a singleton and checks for identity.
4918 roots_[kStringTableRootIndex] = new_table;
4919 ASSERT(result != NULL);
4920 return result;
4921 }
4922
4923
4924 void Heap::ZapFromSpace() { 4862 void Heap::ZapFromSpace() {
4925 NewSpacePageIterator it(new_space_.FromSpaceStart(), 4863 NewSpacePageIterator it(new_space_.FromSpaceStart(),
4926 new_space_.FromSpaceEnd()); 4864 new_space_.FromSpaceEnd());
4927 while (it.has_next()) { 4865 while (it.has_next()) {
4928 NewSpacePage* page = it.next(); 4866 NewSpacePage* page = it.next();
4929 for (Address cursor = page->area_start(), limit = page->area_end(); 4867 for (Address cursor = page->area_start(), limit = page->area_end();
4930 cursor < limit; 4868 cursor < limit;
4931 cursor += kPointerSize) { 4869 cursor += kPointerSize) {
4932 Memory::Address_at(cursor) = kFromSpaceZapValue; 4870 Memory::Address_at(cursor) = kFromSpaceZapValue;
4933 } 4871 }
(...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after
6737 static_cast<int>(object_sizes_last_time_[index])); 6675 static_cast<int>(object_sizes_last_time_[index]));
6738 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6676 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6739 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6677 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6740 6678
6741 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6679 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6742 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6680 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6743 ClearObjectStats(); 6681 ClearObjectStats();
6744 } 6682 }
6745 6683
6746 } } // namespace v8::internal 6684 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698