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

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

Issue 234783002: Handlify Map::CopyDropDescriptors(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some more refactoring. 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/objects.cc ('k') | src/transitions.h » ('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 2817 matching lines...) Expand 10 before | Expand all | Expand 10 after
2828 } 2828 }
2829 2829
2830 2830
2831 void DescriptorArray::SwapSortedKeys(int first, int second) { 2831 void DescriptorArray::SwapSortedKeys(int first, int second) {
2832 int first_key = GetSortedKeyIndex(first); 2832 int first_key = GetSortedKeyIndex(first);
2833 SetSortedKey(first, GetSortedKeyIndex(second)); 2833 SetSortedKey(first, GetSortedKeyIndex(second));
2834 SetSortedKey(second, first_key); 2834 SetSortedKey(second, first_key);
2835 } 2835 }
2836 2836
2837 2837
2838 DescriptorArray::WhitenessWitness::WhitenessWitness(FixedArray* array) 2838 DescriptorArray::WhitenessWitness::WhitenessWitness(DescriptorArray* array)
2839 : marking_(array->GetHeap()->incremental_marking()) { 2839 : marking_(array->GetHeap()->incremental_marking()) {
2840 marking_->EnterNoMarkingScope(); 2840 marking_->EnterNoMarkingScope();
2841 ASSERT(!marking_->IsMarking() || 2841 ASSERT(!marking_->IsMarking() ||
2842 Marking::Color(array) == Marking::WHITE_OBJECT); 2842 Marking::Color(array) == Marking::WHITE_OBJECT);
2843 } 2843 }
2844 2844
2845 2845
2846 DescriptorArray::WhitenessWitness::~WhitenessWitness() { 2846 DescriptorArray::WhitenessWitness::~WhitenessWitness() {
2847 marking_->LeaveNoMarkingScope(); 2847 marking_->LeaveNoMarkingScope();
2848 } 2848 }
(...skipping 2068 matching lines...) Expand 10 before | Expand all | Expand 10 after
4917 4917
4918 void Map::set_prototype(Object* value, WriteBarrierMode mode) { 4918 void Map::set_prototype(Object* value, WriteBarrierMode mode) {
4919 ASSERT(value->IsNull() || value->IsJSReceiver()); 4919 ASSERT(value->IsNull() || value->IsJSReceiver());
4920 WRITE_FIELD(this, kPrototypeOffset, value); 4920 WRITE_FIELD(this, kPrototypeOffset, value);
4921 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode); 4921 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode);
4922 } 4922 }
4923 4923
4924 4924
4925 // If the descriptor is using the empty transition array, install a new empty 4925 // If the descriptor is using the empty transition array, install a new empty
4926 // transition array that will have place for an element transition. 4926 // transition array that will have place for an element transition.
4927 static MaybeObject* EnsureHasTransitionArray(Map* map) { 4927 static void EnsureHasTransitionArray(Handle<Map> map) {
4928 TransitionArray* transitions; 4928 Handle<TransitionArray> transitions;
4929 MaybeObject* maybe_transitions;
4930 if (!map->HasTransitionArray()) { 4929 if (!map->HasTransitionArray()) {
4931 maybe_transitions = TransitionArray::Allocate(map->GetIsolate(), 0); 4930 transitions = TransitionArray::Allocate(map->GetIsolate(), 0);
4932 if (!maybe_transitions->To(&transitions)) return maybe_transitions;
4933 transitions->set_back_pointer_storage(map->GetBackPointer()); 4931 transitions->set_back_pointer_storage(map->GetBackPointer());
4934 } else if (!map->transitions()->IsFullTransitionArray()) { 4932 } else if (!map->transitions()->IsFullTransitionArray()) {
4935 maybe_transitions = map->transitions()->ExtendToFullTransitionArray(); 4933 transitions = TransitionArray::ExtendToFullTransitionArray(
4936 if (!maybe_transitions->To(&transitions)) return maybe_transitions; 4934 handle(map->transitions()));
4937 } else { 4935 } else {
4938 return map; 4936 return;
4939 } 4937 }
4940 map->set_transitions(transitions); 4938 map->set_transitions(*transitions);
4941 return transitions;
4942 } 4939 }
4943 4940
4944 4941
4945 void Map::InitializeDescriptors(DescriptorArray* descriptors) { 4942 void Map::InitializeDescriptors(DescriptorArray* descriptors) {
4946 int len = descriptors->number_of_descriptors(); 4943 int len = descriptors->number_of_descriptors();
4947 set_instance_descriptors(descriptors); 4944 set_instance_descriptors(descriptors);
4948 SetNumberOfOwnDescriptors(len); 4945 SetNumberOfOwnDescriptors(len);
4949 } 4946 }
4950 4947
4951 4948
(...skipping 20 matching lines...) Expand all
4972 if (Heap::ShouldZapGarbage() && HasTransitionArray()) { 4969 if (Heap::ShouldZapGarbage() && HasTransitionArray()) {
4973 ZapTransitions(); 4970 ZapTransitions();
4974 } 4971 }
4975 4972
4976 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, back_pointer); 4973 WRITE_FIELD(this, kTransitionsOrBackPointerOffset, back_pointer);
4977 CONDITIONAL_WRITE_BARRIER( 4974 CONDITIONAL_WRITE_BARRIER(
4978 heap, this, kTransitionsOrBackPointerOffset, back_pointer, mode); 4975 heap, this, kTransitionsOrBackPointerOffset, back_pointer, mode);
4979 } 4976 }
4980 4977
4981 4978
4982 void Map::AppendDescriptor(Descriptor* desc, 4979 void Map::AppendDescriptor(Descriptor* desc) {
4983 const DescriptorArray::WhitenessWitness& witness) {
4984 DescriptorArray* descriptors = instance_descriptors(); 4980 DescriptorArray* descriptors = instance_descriptors();
4985 int number_of_own_descriptors = NumberOfOwnDescriptors(); 4981 int number_of_own_descriptors = NumberOfOwnDescriptors();
4986 ASSERT(descriptors->number_of_descriptors() == number_of_own_descriptors); 4982 ASSERT(descriptors->number_of_descriptors() == number_of_own_descriptors);
4987 descriptors->Append(desc, witness); 4983 descriptors->Append(desc);
4988 SetNumberOfOwnDescriptors(number_of_own_descriptors + 1); 4984 SetNumberOfOwnDescriptors(number_of_own_descriptors + 1);
4989 } 4985 }
4990 4986
4991 4987
4992 Object* Map::GetBackPointer() { 4988 Object* Map::GetBackPointer() {
4993 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset); 4989 Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset);
4994 if (object->IsDescriptorArray()) { 4990 if (object->IsDescriptorArray()) {
4995 return TransitionArray::cast(object)->back_pointer_storage(); 4991 return TransitionArray::cast(object)->back_pointer_storage();
4996 } else { 4992 } else {
4997 ASSERT(object->IsMap() || object->IsUndefined()); 4993 ASSERT(object->IsMap() || object->IsUndefined());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
5043 5039
5044 FixedArray* Map::GetPrototypeTransitions() { 5040 FixedArray* Map::GetPrototypeTransitions() {
5045 if (!HasTransitionArray()) return GetHeap()->empty_fixed_array(); 5041 if (!HasTransitionArray()) return GetHeap()->empty_fixed_array();
5046 if (!transitions()->HasPrototypeTransitions()) { 5042 if (!transitions()->HasPrototypeTransitions()) {
5047 return GetHeap()->empty_fixed_array(); 5043 return GetHeap()->empty_fixed_array();
5048 } 5044 }
5049 return transitions()->GetPrototypeTransitions(); 5045 return transitions()->GetPrototypeTransitions();
5050 } 5046 }
5051 5047
5052 5048
5053 MaybeObject* Map::SetPrototypeTransitions(FixedArray* proto_transitions) { 5049 void Map::SetPrototypeTransitions(
5054 MaybeObject* allow_prototype = EnsureHasTransitionArray(this); 5050 Handle<Map> map, Handle<FixedArray> proto_transitions) {
5055 if (allow_prototype->IsFailure()) return allow_prototype; 5051 EnsureHasTransitionArray(map);
5056 int old_number_of_transitions = NumberOfProtoTransitions(); 5052 int old_number_of_transitions = map->NumberOfProtoTransitions();
5057 #ifdef DEBUG 5053 #ifdef DEBUG
5058 if (HasPrototypeTransitions()) { 5054 if (map->HasPrototypeTransitions()) {
5059 ASSERT(GetPrototypeTransitions() != proto_transitions); 5055 ASSERT(map->GetPrototypeTransitions() != *proto_transitions);
5060 ZapPrototypeTransitions(); 5056 map->ZapPrototypeTransitions();
5061 } 5057 }
5062 #endif 5058 #endif
5063 transitions()->SetPrototypeTransitions(proto_transitions); 5059 map->transitions()->SetPrototypeTransitions(*proto_transitions);
5064 SetNumberOfProtoTransitions(old_number_of_transitions); 5060 map->SetNumberOfProtoTransitions(old_number_of_transitions);
5065 return this;
5066 } 5061 }
5067 5062
5068 5063
5069 bool Map::HasPrototypeTransitions() { 5064 bool Map::HasPrototypeTransitions() {
5070 return HasTransitionArray() && transitions()->HasPrototypeTransitions(); 5065 return HasTransitionArray() && transitions()->HasPrototypeTransitions();
5071 } 5066 }
5072 5067
5073 5068
5074 TransitionArray* Map::transitions() { 5069 TransitionArray* Map::transitions() {
5075 ASSERT(HasTransitionArray()); 5070 ASSERT(HasTransitionArray());
(...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after
7049 #undef READ_SHORT_FIELD 7044 #undef READ_SHORT_FIELD
7050 #undef WRITE_SHORT_FIELD 7045 #undef WRITE_SHORT_FIELD
7051 #undef READ_BYTE_FIELD 7046 #undef READ_BYTE_FIELD
7052 #undef WRITE_BYTE_FIELD 7047 #undef WRITE_BYTE_FIELD
7053 #undef NOBARRIER_READ_BYTE_FIELD 7048 #undef NOBARRIER_READ_BYTE_FIELD
7054 #undef NOBARRIER_WRITE_BYTE_FIELD 7049 #undef NOBARRIER_WRITE_BYTE_FIELD
7055 7050
7056 } } // namespace v8::internal 7051 } } // namespace v8::internal
7057 7052
7058 #endif // V8_OBJECTS_INL_H_ 7053 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/transitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698