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

Side by Side Diff: src/objects.cc

Issue 3089005: [Isolates] Add a pointer to Heap to a meta map. (Closed)
Patch Set: review feedback Created 10 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
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 3064 matching lines...) Expand 10 before | Expand all | Expand 10 after
3075 } 3075 }
3076 } 3076 }
3077 return HEAP->undefined_value(); 3077 return HEAP->undefined_value();
3078 } else { 3078 } else {
3079 return property_dictionary()->SlowReverseLookup(value); 3079 return property_dictionary()->SlowReverseLookup(value);
3080 } 3080 }
3081 } 3081 }
3082 3082
3083 3083
3084 Object* Map::CopyDropDescriptors() { 3084 Object* Map::CopyDropDescriptors() {
3085 Object* result = HEAP->AllocateMap(instance_type(), instance_size()); 3085 Object* result = GetHeap()->AllocateMap(instance_type(), instance_size());
3086 if (result->IsFailure()) return result; 3086 if (result->IsFailure()) return result;
3087 Map::cast(result)->set_prototype(prototype()); 3087 Map::cast(result)->set_prototype(prototype());
3088 Map::cast(result)->set_constructor(constructor()); 3088 Map::cast(result)->set_constructor(constructor());
3089 // Don't copy descriptors, so map transitions always remain a forest. 3089 // Don't copy descriptors, so map transitions always remain a forest.
3090 // If we retained the same descriptors we would have two maps 3090 // If we retained the same descriptors we would have two maps
3091 // pointing to the same transition which is bad because the garbage 3091 // pointing to the same transition which is bad because the garbage
3092 // collector relies on being able to reverse pointers from transitions 3092 // collector relies on being able to reverse pointers from transitions
3093 // to maps. If properties need to be retained use CopyDropTransitions. 3093 // to maps. If properties need to be retained use CopyDropTransitions.
3094 Map::cast(result)->set_instance_descriptors(HEAP->empty_descriptor_array()); 3094 Map::cast(result)->set_instance_descriptors(
3095 GetHeap()->empty_descriptor_array());
3095 // Please note instance_type and instance_size are set when allocated. 3096 // Please note instance_type and instance_size are set when allocated.
3096 Map::cast(result)->set_inobject_properties(inobject_properties()); 3097 Map::cast(result)->set_inobject_properties(inobject_properties());
3097 Map::cast(result)->set_unused_property_fields(unused_property_fields()); 3098 Map::cast(result)->set_unused_property_fields(unused_property_fields());
3098 3099
3099 // If the map has pre-allocated properties always start out with a descriptor 3100 // If the map has pre-allocated properties always start out with a descriptor
3100 // array describing these properties. 3101 // array describing these properties.
3101 if (pre_allocated_property_fields() > 0) { 3102 if (pre_allocated_property_fields() > 0) {
3102 ASSERT(constructor()->IsJSFunction()); 3103 ASSERT(constructor()->IsJSFunction());
3103 JSFunction* ctor = JSFunction::cast(constructor()); 3104 JSFunction* ctor = JSFunction::cast(constructor());
3104 Object* descriptors = 3105 Object* descriptors =
3105 ctor->initial_map()->instance_descriptors()->RemoveTransitions(); 3106 ctor->initial_map()->instance_descriptors()->RemoveTransitions();
3106 if (descriptors->IsFailure()) return descriptors; 3107 if (descriptors->IsFailure()) return descriptors;
3107 Map::cast(result)->set_instance_descriptors( 3108 Map::cast(result)->set_instance_descriptors(
3108 DescriptorArray::cast(descriptors)); 3109 DescriptorArray::cast(descriptors));
3109 Map::cast(result)->set_pre_allocated_property_fields( 3110 Map::cast(result)->set_pre_allocated_property_fields(
3110 pre_allocated_property_fields()); 3111 pre_allocated_property_fields());
3111 } 3112 }
3112 Map::cast(result)->set_bit_field(bit_field()); 3113 Map::cast(result)->set_bit_field(bit_field());
3113 Map::cast(result)->set_bit_field2(bit_field2()); 3114 Map::cast(result)->set_bit_field2(bit_field2());
3114 Map::cast(result)->ClearCodeCache(); 3115 Map::cast(result)->ClearCodeCache(GetHeap());
3115 return result; 3116 return result;
3116 } 3117 }
3117 3118
3118 3119
3119 Object* Map::CopyDropTransitions() { 3120 Object* Map::CopyDropTransitions() {
3120 Object* new_map = CopyDropDescriptors(); 3121 Object* new_map = CopyDropDescriptors();
3121 if (new_map->IsFailure()) return new_map; 3122 if (new_map->IsFailure()) return new_map;
3122 Object* descriptors = instance_descriptors()->RemoveTransitions(); 3123 Object* descriptors = instance_descriptors()->RemoveTransitions();
3123 if (descriptors->IsFailure()) return descriptors; 3124 if (descriptors->IsFailure()) return descriptors;
3124 cast(new_map)->set_instance_descriptors(DescriptorArray::cast(descriptors)); 3125 cast(new_map)->set_instance_descriptors(DescriptorArray::cast(descriptors));
(...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after
5016 source_prototype == target_prototype); 5017 source_prototype == target_prototype);
5017 #endif 5018 #endif
5018 // Point target back to source. set_prototype() will not let us set 5019 // Point target back to source. set_prototype() will not let us set
5019 // the prototype to a map, as we do here. 5020 // the prototype to a map, as we do here.
5020 *RawField(target, kPrototypeOffset) = this; 5021 *RawField(target, kPrototypeOffset) = this;
5021 } 5022 }
5022 } 5023 }
5023 } 5024 }
5024 5025
5025 5026
5026 void Map::ClearNonLiveTransitions(Object* real_prototype) { 5027 void Map::ClearNonLiveTransitions(Heap* heap, Object* real_prototype) {
5027 // Live DescriptorArray objects will be marked, so we must use 5028 // Live DescriptorArray objects will be marked, so we must use
5028 // low-level accessors to get and modify their data. 5029 // low-level accessors to get and modify their data.
5029 DescriptorArray* d = reinterpret_cast<DescriptorArray*>( 5030 DescriptorArray* d = reinterpret_cast<DescriptorArray*>(
5030 *RawField(this, Map::kInstanceDescriptorsOffset)); 5031 *RawField(this, Map::kInstanceDescriptorsOffset));
5031 if (d == HEAP->raw_unchecked_empty_descriptor_array()) return; 5032 if (d == heap->raw_unchecked_empty_descriptor_array()) return;
5032 Smi* NullDescriptorDetails = 5033 Smi* NullDescriptorDetails =
5033 PropertyDetails(NONE, NULL_DESCRIPTOR).AsSmi(); 5034 PropertyDetails(NONE, NULL_DESCRIPTOR).AsSmi();
5034 FixedArray* contents = reinterpret_cast<FixedArray*>( 5035 FixedArray* contents = reinterpret_cast<FixedArray*>(
5035 d->get(DescriptorArray::kContentArrayIndex)); 5036 d->get(DescriptorArray::kContentArrayIndex));
5036 ASSERT(contents->length() >= 2); 5037 ASSERT(contents->length() >= 2);
5037 for (int i = 0; i < contents->length(); i += 2) { 5038 for (int i = 0; i < contents->length(); i += 2) {
5038 // If the pair (value, details) is a map transition, 5039 // If the pair (value, details) is a map transition,
5039 // check if the target is live. If not, null the descriptor. 5040 // check if the target is live. If not, null the descriptor.
5040 // Also drop the back pointer for that map transition, so that this 5041 // Also drop the back pointer for that map transition, so that this
5041 // map is not reached again by following a back pointer from a 5042 // map is not reached again by following a back pointer from a
5042 // non-live object. 5043 // non-live object.
5043 PropertyDetails details(Smi::cast(contents->get(i + 1))); 5044 PropertyDetails details(Smi::cast(contents->get(i + 1)));
5044 if (details.type() == MAP_TRANSITION) { 5045 if (details.type() == MAP_TRANSITION) {
5045 Map* target = reinterpret_cast<Map*>(contents->get(i)); 5046 Map* target = reinterpret_cast<Map*>(contents->get(i));
5046 ASSERT(target->IsHeapObject()); 5047 ASSERT(target->IsHeapObject());
5047 if (!target->IsMarked()) { 5048 if (!target->IsMarked()) {
5048 ASSERT(target->IsMap()); 5049 ASSERT(target->IsMap());
5049 contents->set(i + 1, NullDescriptorDetails); 5050 contents->set(i + 1, NullDescriptorDetails);
5050 contents->set_null(i); 5051 contents->set_null(heap, i);
5051 ASSERT(target->prototype() == this || 5052 ASSERT(target->prototype() == this ||
5052 target->prototype() == real_prototype); 5053 target->prototype() == real_prototype);
5053 // Getter prototype() is read-only, set_prototype() has side effects. 5054 // Getter prototype() is read-only, set_prototype() has side effects.
5054 *RawField(target, Map::kPrototypeOffset) = real_prototype; 5055 *RawField(target, Map::kPrototypeOffset) = real_prototype;
5055 } 5056 }
5056 } 5057 }
5057 } 5058 }
5058 } 5059 }
5059 5060
5060 5061
(...skipping 3742 matching lines...) Expand 10 before | Expand all | Expand 10 after
8803 if (break_point_objects()->IsUndefined()) return 0; 8804 if (break_point_objects()->IsUndefined()) return 0;
8804 // Single beak point. 8805 // Single beak point.
8805 if (!break_point_objects()->IsFixedArray()) return 1; 8806 if (!break_point_objects()->IsFixedArray()) return 1;
8806 // Multiple break points. 8807 // Multiple break points.
8807 return FixedArray::cast(break_point_objects())->length(); 8808 return FixedArray::cast(break_point_objects())->length();
8808 } 8809 }
8809 #endif 8810 #endif
8810 8811
8811 8812
8812 } } // namespace v8::internal 8813 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698