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

Side by Side Diff: src/heap.cc

Issue 211333002: Replace HeapNumber as doublebox with an explicit MutableHeapNumber. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
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 2822 matching lines...) Expand 10 before | Expand all | Expand 10 after
2833 } 2833 }
2834 2834
2835 #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \ 2835 #define ALLOCATE_VARSIZE_MAP(instance_type, field_name) \
2836 ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name) 2836 ALLOCATE_MAP(instance_type, kVariableSizeSentinel, field_name)
2837 2837
2838 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, fixed_cow_array) 2838 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, fixed_cow_array)
2839 ASSERT(fixed_array_map() != fixed_cow_array_map()); 2839 ASSERT(fixed_array_map() != fixed_cow_array_map());
2840 2840
2841 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, scope_info) 2841 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, scope_info)
2842 ALLOCATE_MAP(HEAP_NUMBER_TYPE, HeapNumber::kSize, heap_number) 2842 ALLOCATE_MAP(HEAP_NUMBER_TYPE, HeapNumber::kSize, heap_number)
2843 ALLOCATE_MAP(
2844 MUTABLE_HEAP_NUMBER_TYPE, HeapNumber::kSize, mutable_heap_number)
2843 ALLOCATE_MAP(SYMBOL_TYPE, Symbol::kSize, symbol) 2845 ALLOCATE_MAP(SYMBOL_TYPE, Symbol::kSize, symbol)
2844 ALLOCATE_MAP(FOREIGN_TYPE, Foreign::kSize, foreign) 2846 ALLOCATE_MAP(FOREIGN_TYPE, Foreign::kSize, foreign)
2845 2847
2846 for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) { 2848 for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) {
2847 const StringTypeTable& entry = string_type_table[i]; 2849 const StringTypeTable& entry = string_type_table[i];
2848 { MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size); 2850 { MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size);
2849 if (!maybe_obj->ToObject(&obj)) return false; 2851 if (!maybe_obj->ToObject(&obj)) return false;
2850 } 2852 }
2851 roots_[entry.index] = Map::cast(obj); 2853 roots_[entry.index] = Map::cast(obj);
2852 } 2854 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2952 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE); 2954 { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE);
2953 if (!maybe_result->ToObject(&result)) return maybe_result; 2955 if (!maybe_result->ToObject(&result)) return maybe_result;
2954 } 2956 }
2955 2957
2956 HeapObject::cast(result)->set_map_no_write_barrier(heap_number_map()); 2958 HeapObject::cast(result)->set_map_no_write_barrier(heap_number_map());
2957 HeapNumber::cast(result)->set_value(value); 2959 HeapNumber::cast(result)->set_value(value);
2958 return result; 2960 return result;
2959 } 2961 }
2960 2962
2961 2963
2964 MaybeObject* Heap::AllocateMutableHeapNumber(double value,
Igor Sheludko 2014/03/27 11:30:16 This code is the same as AllocateHeapNumber() exce
2965 PretenureFlag pretenure) {
2966 // Statically ensure that it is safe to allocate heap numbers in paged
2967 // spaces.
2968 int size = HeapNumber::kSize;
2969 STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxRegularHeapObjectSize);
2970
2971 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure);
2972
2973 Object* result;
2974 MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE);
2975 if (!maybe_result->ToObject(&result)) return maybe_result;
2976
2977 HeapObject::cast(result)->set_map_no_write_barrier(mutable_heap_number_map());
2978 HeapNumber::cast(result)->set_value(value);
2979 return result;
2980 }
2981
2982
2962 MaybeObject* Heap::AllocateCell(Object* value) { 2983 MaybeObject* Heap::AllocateCell(Object* value) {
2963 int size = Cell::kSize; 2984 int size = Cell::kSize;
2964 STATIC_ASSERT(Cell::kSize <= Page::kMaxRegularHeapObjectSize); 2985 STATIC_ASSERT(Cell::kSize <= Page::kMaxRegularHeapObjectSize);
2965 2986
2966 Object* result; 2987 Object* result;
2967 { MaybeObject* maybe_result = AllocateRaw(size, CELL_SPACE, CELL_SPACE); 2988 { MaybeObject* maybe_result = AllocateRaw(size, CELL_SPACE, CELL_SPACE);
2968 if (!maybe_result->ToObject(&result)) return maybe_result; 2989 if (!maybe_result->ToObject(&result)) return maybe_result;
2969 } 2990 }
2970 HeapObject::cast(result)->set_map_no_write_barrier(cell_map()); 2991 HeapObject::cast(result)->set_map_no_write_barrier(cell_map());
2971 Cell::cast(result)->set_value(value); 2992 Cell::cast(result)->set_value(value);
(...skipping 4839 matching lines...) Expand 10 before | Expand all | Expand 10 after
7811 static_cast<int>(object_sizes_last_time_[index])); 7832 static_cast<int>(object_sizes_last_time_[index]));
7812 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 7833 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
7813 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7834 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7814 7835
7815 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7836 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7816 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7837 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7817 ClearObjectStats(); 7838 ClearObjectStats();
7818 } 7839 }
7819 7840
7820 } } // namespace v8::internal 7841 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698