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

Side by Side Diff: src/objects.cc

Issue 173469: Handle pre-allocated properties when copying map (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 3 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/compiler.cc ('k') | src/objects-debug.cc » ('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 2905 matching lines...) Expand 10 before | Expand all | Expand 10 after
2916 Map::cast(result)->set_constructor(constructor()); 2916 Map::cast(result)->set_constructor(constructor());
2917 // Don't copy descriptors, so map transitions always remain a forest. 2917 // Don't copy descriptors, so map transitions always remain a forest.
2918 // If we retained the same descriptors we would have two maps 2918 // If we retained the same descriptors we would have two maps
2919 // pointing to the same transition which is bad because the garbage 2919 // pointing to the same transition which is bad because the garbage
2920 // collector relies on being able to reverse pointers from transitions 2920 // collector relies on being able to reverse pointers from transitions
2921 // to maps. If properties need to be retained use CopyDropTransitions. 2921 // to maps. If properties need to be retained use CopyDropTransitions.
2922 Map::cast(result)->set_instance_descriptors(Heap::empty_descriptor_array()); 2922 Map::cast(result)->set_instance_descriptors(Heap::empty_descriptor_array());
2923 // Please note instance_type and instance_size are set when allocated. 2923 // Please note instance_type and instance_size are set when allocated.
2924 Map::cast(result)->set_inobject_properties(inobject_properties()); 2924 Map::cast(result)->set_inobject_properties(inobject_properties());
2925 Map::cast(result)->set_unused_property_fields(unused_property_fields()); 2925 Map::cast(result)->set_unused_property_fields(unused_property_fields());
2926
2927 // If the map has pre-allocated properties always start out with a descriptor
2928 // array describing these properties.
2929 if (pre_allocated_property_fields() > 0) {
2930 ASSERT(constructor()->IsJSFunction());
2931 JSFunction* ctor = JSFunction::cast(constructor());
2932 Map::cast(result)->set_instance_descriptors(
2933 ctor->initial_map()->instance_descriptors());
2934 Map::cast(result)->set_pre_allocated_property_fields(
2935 pre_allocated_property_fields());
2936 }
2926 Map::cast(result)->set_bit_field(bit_field()); 2937 Map::cast(result)->set_bit_field(bit_field());
2927 Map::cast(result)->set_bit_field2(bit_field2()); 2938 Map::cast(result)->set_bit_field2(bit_field2());
2928 Map::cast(result)->ClearCodeCache(); 2939 Map::cast(result)->ClearCodeCache();
2929 return result; 2940 return result;
2930 } 2941 }
2931 2942
2932 2943
2933 Object* Map::CopyDropTransitions() { 2944 Object* Map::CopyDropTransitions() {
2934 Object* new_map = CopyDropDescriptors(); 2945 Object* new_map = CopyDropDescriptors();
2935 if (new_map->IsFailure()) return new_map; 2946 if (new_map->IsFailure()) return new_map;
(...skipping 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after
4793 4804
4794 int SharedFunctionInfo::CalculateInObjectProperties() { 4805 int SharedFunctionInfo::CalculateInObjectProperties() {
4795 return (CalculateInstanceSize() - JSObject::kHeaderSize) / kPointerSize; 4806 return (CalculateInstanceSize() - JSObject::kHeaderSize) / kPointerSize;
4796 } 4807 }
4797 4808
4798 4809
4799 void SharedFunctionInfo::SetThisPropertyAssignmentsInfo( 4810 void SharedFunctionInfo::SetThisPropertyAssignmentsInfo(
4800 bool only_this_property_assignments, 4811 bool only_this_property_assignments,
4801 bool only_simple_this_property_assignments, 4812 bool only_simple_this_property_assignments,
4802 FixedArray* assignments) { 4813 FixedArray* assignments) {
4803 ASSERT(this_property_assignments()->IsUndefined());
4804 set_compiler_hints(BooleanBit::set(compiler_hints(), 4814 set_compiler_hints(BooleanBit::set(compiler_hints(),
4805 kHasOnlyThisPropertyAssignments, 4815 kHasOnlyThisPropertyAssignments,
4806 only_this_property_assignments)); 4816 only_this_property_assignments));
4807 set_compiler_hints(BooleanBit::set(compiler_hints(), 4817 set_compiler_hints(BooleanBit::set(compiler_hints(),
4808 kHasOnlySimpleThisPropertyAssignments, 4818 kHasOnlySimpleThisPropertyAssignments,
4809 only_simple_this_property_assignments)); 4819 only_simple_this_property_assignments));
4810 set_this_property_assignments(assignments); 4820 set_this_property_assignments(assignments);
4811 set_this_property_assignments_count(assignments->length() / 3); 4821 set_this_property_assignments_count(assignments->length() / 3);
4812 } 4822 }
4813 4823
(...skipping 3134 matching lines...) Expand 10 before | Expand all | Expand 10 after
7948 if (break_point_objects()->IsUndefined()) return 0; 7958 if (break_point_objects()->IsUndefined()) return 0;
7949 // Single beak point. 7959 // Single beak point.
7950 if (!break_point_objects()->IsFixedArray()) return 1; 7960 if (!break_point_objects()->IsFixedArray()) return 1;
7951 // Multiple break points. 7961 // Multiple break points.
7952 return FixedArray::cast(break_point_objects())->length(); 7962 return FixedArray::cast(break_point_objects())->length();
7953 } 7963 }
7954 #endif 7964 #endif
7955 7965
7956 7966
7957 } } // namespace v8::internal 7967 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698