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

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

Issue 501323002: Replace our homegrown ARRAY_SIZE() with Chrome's arraysize(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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/once.h" 9 #include "src/base/once.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
(...skipping 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 ALLOCATE_MAP(FOREIGN_TYPE, Foreign::kSize, foreign) 2493 ALLOCATE_MAP(FOREIGN_TYPE, Foreign::kSize, foreign)
2494 2494
2495 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, the_hole); 2495 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, the_hole);
2496 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, boolean); 2496 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, boolean);
2497 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, uninitialized); 2497 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, uninitialized);
2498 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, arguments_marker); 2498 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, arguments_marker);
2499 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, no_interceptor_result_sentinel); 2499 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, no_interceptor_result_sentinel);
2500 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, exception); 2500 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, exception);
2501 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, termination_exception); 2501 ALLOCATE_MAP(ODDBALL_TYPE, Oddball::kSize, termination_exception);
2502 2502
2503 for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) { 2503 for (unsigned i = 0; i < arraysize(string_type_table); i++) {
2504 const StringTypeTable& entry = string_type_table[i]; 2504 const StringTypeTable& entry = string_type_table[i];
2505 { 2505 {
2506 AllocationResult allocation = AllocateMap(entry.type, entry.size); 2506 AllocationResult allocation = AllocateMap(entry.type, entry.size);
2507 if (!allocation.To(&obj)) return false; 2507 if (!allocation.To(&obj)) return false;
2508 } 2508 }
2509 // Mark cons string maps as unstable, because their objects can change 2509 // Mark cons string maps as unstable, because their objects can change
2510 // maps during GC. 2510 // maps during GC.
2511 Map* map = Map::cast(obj); 2511 Map* map = Map::cast(obj);
2512 if (StringShape(entry.type).IsCons()) map->mark_unstable(); 2512 if (StringShape(entry.type).IsCons()) map->mark_unstable();
2513 roots_[entry.index] = map; 2513 roots_[entry.index] = map;
(...skipping 25 matching lines...) Expand all
2539 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, sloppy_arguments_elements) 2539 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, sloppy_arguments_elements)
2540 2540
2541 ALLOCATE_VARSIZE_MAP(CODE_TYPE, code) 2541 ALLOCATE_VARSIZE_MAP(CODE_TYPE, code)
2542 2542
2543 ALLOCATE_MAP(CELL_TYPE, Cell::kSize, cell) 2543 ALLOCATE_MAP(CELL_TYPE, Cell::kSize, cell)
2544 ALLOCATE_MAP(PROPERTY_CELL_TYPE, PropertyCell::kSize, global_property_cell) 2544 ALLOCATE_MAP(PROPERTY_CELL_TYPE, PropertyCell::kSize, global_property_cell)
2545 ALLOCATE_MAP(FILLER_TYPE, kPointerSize, one_pointer_filler) 2545 ALLOCATE_MAP(FILLER_TYPE, kPointerSize, one_pointer_filler)
2546 ALLOCATE_MAP(FILLER_TYPE, 2 * kPointerSize, two_pointer_filler) 2546 ALLOCATE_MAP(FILLER_TYPE, 2 * kPointerSize, two_pointer_filler)
2547 2547
2548 2548
2549 for (unsigned i = 0; i < ARRAY_SIZE(struct_table); i++) { 2549 for (unsigned i = 0; i < arraysize(struct_table); i++) {
2550 const StructTable& entry = struct_table[i]; 2550 const StructTable& entry = struct_table[i];
2551 Map* map; 2551 Map* map;
2552 if (!AllocateMap(entry.type, entry.size).To(&map)) return false; 2552 if (!AllocateMap(entry.type, entry.size).To(&map)) return false;
2553 roots_[entry.index] = map; 2553 roots_[entry.index] = map;
2554 } 2554 }
2555 2555
2556 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, hash_table) 2556 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, hash_table)
2557 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, ordered_hash_table) 2557 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, ordered_hash_table)
2558 2558
2559 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, function_context) 2559 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, function_context)
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
2784 Oddball::kOther)); 2784 Oddball::kOther));
2785 2785
2786 set_termination_exception(*factory->NewOddball( 2786 set_termination_exception(*factory->NewOddball(
2787 factory->termination_exception_map(), "termination_exception", 2787 factory->termination_exception_map(), "termination_exception",
2788 handle(Smi::FromInt(-3), isolate()), Oddball::kOther)); 2788 handle(Smi::FromInt(-3), isolate()), Oddball::kOther));
2789 2789
2790 set_exception(*factory->NewOddball(factory->exception_map(), "exception", 2790 set_exception(*factory->NewOddball(factory->exception_map(), "exception",
2791 handle(Smi::FromInt(-5), isolate()), 2791 handle(Smi::FromInt(-5), isolate()),
2792 Oddball::kException)); 2792 Oddball::kException));
2793 2793
2794 for (unsigned i = 0; i < ARRAY_SIZE(constant_string_table); i++) { 2794 for (unsigned i = 0; i < arraysize(constant_string_table); i++) {
2795 Handle<String> str = 2795 Handle<String> str =
2796 factory->InternalizeUtf8String(constant_string_table[i].contents); 2796 factory->InternalizeUtf8String(constant_string_table[i].contents);
2797 roots_[constant_string_table[i].index] = *str; 2797 roots_[constant_string_table[i].index] = *str;
2798 } 2798 }
2799 2799
2800 // Allocate the hidden string which is used to identify the hidden properties 2800 // Allocate the hidden string which is used to identify the hidden properties
2801 // in JSObjects. The hash code has a special value so that it will not match 2801 // in JSObjects. The hash code has a special value so that it will not match
2802 // the empty string when searching for the property. It cannot be part of the 2802 // the empty string when searching for the property. It cannot be part of the
2803 // loop above because it needs to be allocated manually with the special 2803 // loop above because it needs to be allocated manually with the special
2804 // hash code in place. The hash code for the hidden_string is zero to ensure 2804 // hash code in place. The hash code for the hidden_string is zero to ensure
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2914 kLastScriptIdRootIndex, 2914 kLastScriptIdRootIndex,
2915 kEmptyScriptRootIndex, 2915 kEmptyScriptRootIndex,
2916 kRealStackLimitRootIndex, 2916 kRealStackLimitRootIndex,
2917 kArgumentsAdaptorDeoptPCOffsetRootIndex, 2917 kArgumentsAdaptorDeoptPCOffsetRootIndex,
2918 kConstructStubDeoptPCOffsetRootIndex, 2918 kConstructStubDeoptPCOffsetRootIndex,
2919 kGetterStubDeoptPCOffsetRootIndex, 2919 kGetterStubDeoptPCOffsetRootIndex,
2920 kSetterStubDeoptPCOffsetRootIndex, 2920 kSetterStubDeoptPCOffsetRootIndex,
2921 kStringTableRootIndex, 2921 kStringTableRootIndex,
2922 }; 2922 };
2923 2923
2924 for (unsigned int i = 0; i < ARRAY_SIZE(writable_roots); i++) { 2924 for (unsigned int i = 0; i < arraysize(writable_roots); i++) {
2925 if (root_index == writable_roots[i]) return true; 2925 if (root_index == writable_roots[i]) return true;
2926 } 2926 }
2927 return false; 2927 return false;
2928 } 2928 }
2929 2929
2930 2930
2931 bool Heap::RootCanBeTreatedAsConstant(RootListIndex root_index) { 2931 bool Heap::RootCanBeTreatedAsConstant(RootListIndex root_index) {
2932 return !RootCanBeWrittenAfterInitialization(root_index) && 2932 return !RootCanBeWrittenAfterInitialization(root_index) &&
2933 !InNewSpace(roots_array_start()[root_index]); 2933 !InNewSpace(roots_array_start()[root_index]);
2934 } 2934 }
(...skipping 3174 matching lines...) Expand 10 before | Expand all | Expand 10 after
6109 static_cast<int>(object_sizes_last_time_[index])); 6109 static_cast<int>(object_sizes_last_time_[index]));
6110 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6110 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6111 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6111 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6112 6112
6113 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6113 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6114 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6114 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6115 ClearObjectStats(); 6115 ClearObjectStats();
6116 } 6116 }
6117 } 6117 }
6118 } // namespace v8::internal 6118 } // namespace v8::internal
OLDNEW
« src/base/macros.h ('K') | « src/global-handles.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698