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

Side by Side Diff: src/objects-inl.h

Issue 6723001: Some Isolate usage cleanups in objects.{h,cc}. (Closed)
Patch Set: Created 9 years, 9 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
« no previous file with comments | « src/objects.cc ('k') | 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 // During GC, the map pointer in HeapObject is used in various ways that 1127 // During GC, the map pointer in HeapObject is used in various ways that
1128 // prevent us from retrieving Heap from the map. 1128 // prevent us from retrieving Heap from the map.
1129 // Assert that we are not in GC, implement GC code in a way that it doesn't 1129 // Assert that we are not in GC, implement GC code in a way that it doesn't
1130 // pull heap from the map. 1130 // pull heap from the map.
1131 ASSERT(HEAP->is_safe_to_read_maps()); 1131 ASSERT(HEAP->is_safe_to_read_maps());
1132 return map()->heap(); 1132 return map()->heap();
1133 } 1133 }
1134 1134
1135 1135
1136 Isolate* HeapObject::GetIsolate() { 1136 Isolate* HeapObject::GetIsolate() {
1137 Isolate* i = GetHeap()->isolate(); 1137 return GetHeap()->isolate();
1138 ASSERT(i == Isolate::Current());
1139 return i;
1140 } 1138 }
1141 1139
1142 1140
1143 Map* HeapObject::map() { 1141 Map* HeapObject::map() {
1144 return map_word().ToMap(); 1142 return map_word().ToMap();
1145 } 1143 }
1146 1144
1147 1145
1148 void HeapObject::set_map(Map* value) { 1146 void HeapObject::set_map(Map* value) {
1149 set_map_word(MapWord::FromMap(value)); 1147 set_map_word(MapWord::FromMap(value));
(...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after
2808 HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize); 2806 HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize);
2809 // GetCodeFromTargetAddress might be called when marking objects during mark 2807 // GetCodeFromTargetAddress might be called when marking objects during mark
2810 // sweep. reinterpret_cast is therefore used instead of the more appropriate 2808 // sweep. reinterpret_cast is therefore used instead of the more appropriate
2811 // Code::cast. Code::cast does not work when the object's map is 2809 // Code::cast. Code::cast does not work when the object's map is
2812 // marked. 2810 // marked.
2813 Code* result = reinterpret_cast<Code*>(code); 2811 Code* result = reinterpret_cast<Code*>(code);
2814 return result; 2812 return result;
2815 } 2813 }
2816 2814
2817 2815
2816 Isolate* Map::isolate() {
2817 return heap()->isolate();
2818 }
2819
2820
2818 Heap* Map::heap() { 2821 Heap* Map::heap() {
2819 // NOTE: address() helper is not used to save one instruction. 2822 // NOTE: address() helper is not used to save one instruction.
2820 Heap* heap = Page::FromAddress(reinterpret_cast<Address>(this))->heap_; 2823 Heap* heap = Page::FromAddress(reinterpret_cast<Address>(this))->heap_;
2821 ASSERT(heap != NULL); 2824 ASSERT(heap != NULL);
2822 ASSERT(heap->isolate() == Isolate::Current()); 2825 ASSERT(heap->isolate() == Isolate::Current());
2823 return heap; 2826 return heap;
2824 } 2827 }
2825 2828
2826 2829
2827 Object* Code::GetObjectFromEntryAddress(Address location_of_address) { 2830 Object* Code::GetObjectFromEntryAddress(Address location_of_address) {
(...skipping 15 matching lines...) Expand all
2843 2846
2844 2847
2845 MaybeObject* Map::GetFastElementsMap() { 2848 MaybeObject* Map::GetFastElementsMap() {
2846 if (has_fast_elements()) return this; 2849 if (has_fast_elements()) return this;
2847 Object* obj; 2850 Object* obj;
2848 { MaybeObject* maybe_obj = CopyDropTransitions(); 2851 { MaybeObject* maybe_obj = CopyDropTransitions();
2849 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 2852 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2850 } 2853 }
2851 Map* new_map = Map::cast(obj); 2854 Map* new_map = Map::cast(obj);
2852 new_map->set_has_fast_elements(true); 2855 new_map->set_has_fast_elements(true);
2853 COUNTERS->map_slow_to_fast_elements()->Increment(); 2856 isolate()->counters()->map_slow_to_fast_elements()->Increment();
Mads Ager (chromium) 2011/03/22 19:05:37 Hey, that's part of my next change! ;-)
2854 return new_map; 2857 return new_map;
2855 } 2858 }
2856 2859
2857 2860
2858 MaybeObject* Map::GetSlowElementsMap() { 2861 MaybeObject* Map::GetSlowElementsMap() {
2859 if (!has_fast_elements()) return this; 2862 if (!has_fast_elements()) return this;
2860 Object* obj; 2863 Object* obj;
2861 { MaybeObject* maybe_obj = CopyDropTransitions(); 2864 { MaybeObject* maybe_obj = CopyDropTransitions();
2862 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 2865 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2863 } 2866 }
2864 Map* new_map = Map::cast(obj); 2867 Map* new_map = Map::cast(obj);
2865 new_map->set_has_fast_elements(false); 2868 new_map->set_has_fast_elements(false);
2866 COUNTERS->map_fast_to_slow_elements()->Increment(); 2869 isolate()->counters()->map_fast_to_slow_elements()->Increment();
2867 return new_map; 2870 return new_map;
2868 } 2871 }
2869 2872
2870 2873
2871 MaybeObject* Map::NewExternalArrayElementsMap() { 2874 MaybeObject* Map::NewExternalArrayElementsMap() {
2872 // TODO(danno): Special case empty object map (or most common case) 2875 // TODO(danno): Special case empty object map (or most common case)
2873 // to return a pre-canned pixel array map. 2876 // to return a pre-canned pixel array map.
2874 Object* obj; 2877 Object* obj;
2875 { MaybeObject* maybe_obj = CopyDropTransitions(); 2878 { MaybeObject* maybe_obj = CopyDropTransitions();
2876 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 2879 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2877 } 2880 }
2878 Map* new_map = Map::cast(obj); 2881 Map* new_map = Map::cast(obj);
2879 new_map->set_has_fast_elements(false); 2882 new_map->set_has_fast_elements(false);
2880 new_map->set_has_external_array_elements(true); 2883 new_map->set_has_external_array_elements(true);
2881 COUNTERS->map_to_external_array_elements()->Increment(); 2884 isolate()->counters()->map_to_external_array_elements()->Increment();
2882 return new_map; 2885 return new_map;
2883 } 2886 }
2884 2887
2885 2888
2886 ACCESSORS(Map, instance_descriptors, DescriptorArray, 2889 ACCESSORS(Map, instance_descriptors, DescriptorArray,
2887 kInstanceDescriptorsOffset) 2890 kInstanceDescriptorsOffset)
2888 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) 2891 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset)
2889 ACCESSORS(Map, constructor, Object, kConstructorOffset) 2892 ACCESSORS(Map, constructor, Object, kConstructorOffset)
2890 2893
2891 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) 2894 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after
4110 #undef WRITE_INT_FIELD 4113 #undef WRITE_INT_FIELD
4111 #undef READ_SHORT_FIELD 4114 #undef READ_SHORT_FIELD
4112 #undef WRITE_SHORT_FIELD 4115 #undef WRITE_SHORT_FIELD
4113 #undef READ_BYTE_FIELD 4116 #undef READ_BYTE_FIELD
4114 #undef WRITE_BYTE_FIELD 4117 #undef WRITE_BYTE_FIELD
4115 4118
4116 4119
4117 } } // namespace v8::internal 4120 } } // namespace v8::internal
4118 4121
4119 #endif // V8_OBJECTS_INL_H_ 4122 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698