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

Side by Side Diff: src/heap/heap.cc

Issue 559913002: Rename ascii to one-byte where applicable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 2502 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 // Mark cons string maps as unstable, because their objects can change 2513 // Mark cons string maps as unstable, because their objects can change
2514 // maps during GC. 2514 // maps during GC.
2515 Map* map = Map::cast(obj); 2515 Map* map = Map::cast(obj);
2516 if (StringShape(entry.type).IsCons()) map->mark_unstable(); 2516 if (StringShape(entry.type).IsCons()) map->mark_unstable();
2517 roots_[entry.index] = map; 2517 roots_[entry.index] = map;
2518 } 2518 }
2519 2519
2520 ALLOCATE_VARSIZE_MAP(STRING_TYPE, undetectable_string) 2520 ALLOCATE_VARSIZE_MAP(STRING_TYPE, undetectable_string)
2521 undetectable_string_map()->set_is_undetectable(); 2521 undetectable_string_map()->set_is_undetectable();
2522 2522
2523 ALLOCATE_VARSIZE_MAP(ASCII_STRING_TYPE, undetectable_ascii_string); 2523 ALLOCATE_VARSIZE_MAP(ONE_BYTE_STRING_TYPE, undetectable_one_byte_string);
2524 undetectable_ascii_string_map()->set_is_undetectable(); 2524 undetectable_one_byte_string_map()->set_is_undetectable();
2525 2525
2526 ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array) 2526 ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array)
2527 ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array) 2527 ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array)
2528 ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space) 2528 ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space)
2529 2529
2530 #define ALLOCATE_EXTERNAL_ARRAY_MAP(Type, type, TYPE, ctype, size) \ 2530 #define ALLOCATE_EXTERNAL_ARRAY_MAP(Type, type, TYPE, ctype, size) \
2531 ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kAlignedSize, \ 2531 ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kAlignedSize, \
2532 external_##type##_array) 2532 external_##type##_array)
2533 2533
2534 TYPED_ARRAYS(ALLOCATE_EXTERNAL_ARRAY_MAP) 2534 TYPED_ARRAYS(ALLOCATE_EXTERNAL_ARRAY_MAP)
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
3758 } 3758 }
3759 JSObject::cast(clone)->set_properties(prop, wb_mode); 3759 JSObject::cast(clone)->set_properties(prop, wb_mode);
3760 } 3760 }
3761 // Return the new clone. 3761 // Return the new clone.
3762 return clone; 3762 return clone;
3763 } 3763 }
3764 3764
3765 3765
3766 static inline void WriteOneByteData(Vector<const char> vector, uint8_t* chars, 3766 static inline void WriteOneByteData(Vector<const char> vector, uint8_t* chars,
3767 int len) { 3767 int len) {
3768 // Only works for ascii. 3768 // Only works for one byte strings.
3769 DCHECK(vector.length() == len); 3769 DCHECK(vector.length() == len);
3770 MemCopy(chars, vector.start(), len); 3770 MemCopy(chars, vector.start(), len);
3771 } 3771 }
3772 3772
3773 static inline void WriteTwoByteData(Vector<const char> vector, uint16_t* chars, 3773 static inline void WriteTwoByteData(Vector<const char> vector, uint16_t* chars,
3774 int len) { 3774 int len) {
3775 const uint8_t* stream = reinterpret_cast<const uint8_t*>(vector.start()); 3775 const uint8_t* stream = reinterpret_cast<const uint8_t*>(vector.start());
3776 unsigned stream_length = vector.length(); 3776 unsigned stream_length = vector.length();
3777 while (stream_length != 0) { 3777 while (stream_length != 0) {
3778 unsigned consumed = 0; 3778 unsigned consumed = 0;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3813 AllocationResult Heap::AllocateInternalizedStringImpl(T t, int chars, 3813 AllocationResult Heap::AllocateInternalizedStringImpl(T t, int chars,
3814 uint32_t hash_field) { 3814 uint32_t hash_field) {
3815 DCHECK(chars >= 0); 3815 DCHECK(chars >= 0);
3816 // Compute map and object size. 3816 // Compute map and object size.
3817 int size; 3817 int size;
3818 Map* map; 3818 Map* map;
3819 3819
3820 DCHECK_LE(0, chars); 3820 DCHECK_LE(0, chars);
3821 DCHECK_GE(String::kMaxLength, chars); 3821 DCHECK_GE(String::kMaxLength, chars);
3822 if (is_one_byte) { 3822 if (is_one_byte) {
3823 map = ascii_internalized_string_map(); 3823 map = one_byte_internalized_string_map();
3824 size = SeqOneByteString::SizeFor(chars); 3824 size = SeqOneByteString::SizeFor(chars);
3825 } else { 3825 } else {
3826 map = internalized_string_map(); 3826 map = internalized_string_map();
3827 size = SeqTwoByteString::SizeFor(chars); 3827 size = SeqTwoByteString::SizeFor(chars);
3828 } 3828 }
3829 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, TENURED); 3829 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, TENURED);
3830 3830
3831 // Allocate string. 3831 // Allocate string.
3832 HeapObject* result; 3832 HeapObject* result;
3833 { 3833 {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3871 DCHECK(size <= SeqOneByteString::kMaxSize); 3871 DCHECK(size <= SeqOneByteString::kMaxSize);
3872 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); 3872 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure);
3873 3873
3874 HeapObject* result; 3874 HeapObject* result;
3875 { 3875 {
3876 AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); 3876 AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE);
3877 if (!allocation.To(&result)) return allocation; 3877 if (!allocation.To(&result)) return allocation;
3878 } 3878 }
3879 3879
3880 // Partially initialize the object. 3880 // Partially initialize the object.
3881 result->set_map_no_write_barrier(ascii_string_map()); 3881 result->set_map_no_write_barrier(one_byte_string_map());
3882 String::cast(result)->set_length(length); 3882 String::cast(result)->set_length(length);
3883 String::cast(result)->set_hash_field(String::kEmptyHashField); 3883 String::cast(result)->set_hash_field(String::kEmptyHashField);
3884 DCHECK_EQ(size, HeapObject::cast(result)->Size()); 3884 DCHECK_EQ(size, HeapObject::cast(result)->Size());
3885 3885
3886 return result; 3886 return result;
3887 } 3887 }
3888 3888
3889 3889
3890 AllocationResult Heap::AllocateRawTwoByteString(int length, 3890 AllocationResult Heap::AllocateRawTwoByteString(int length,
3891 PretenureFlag pretenure) { 3891 PretenureFlag pretenure) {
(...skipping 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after
6126 static_cast<int>(object_sizes_last_time_[index])); 6126 static_cast<int>(object_sizes_last_time_[index]));
6127 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6127 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6128 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6128 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6129 6129
6130 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6130 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6131 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6131 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6132 ClearObjectStats(); 6132 ClearObjectStats();
6133 } 6133 }
6134 } 6134 }
6135 } // namespace v8::internal 6135 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/heap-inl.h » ('j') | src/jsregexp.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698