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

Side by Side Diff: src/heap.cc

Issue 10780031: Grouping all map creation code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments Created 8 years, 5 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/handles.cc ('k') | src/objects.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 3691 matching lines...) Expand 10 before | Expand all | Expand 10 after
3702 // from the function's context, since the function can be from a 3702 // from the function's context, since the function can be from a
3703 // different context. 3703 // different context.
3704 JSFunction* object_function = 3704 JSFunction* object_function =
3705 function->context()->global_context()->object_function(); 3705 function->context()->global_context()->object_function();
3706 3706
3707 // Each function prototype gets a copy of the object function map. 3707 // Each function prototype gets a copy of the object function map.
3708 // This avoid unwanted sharing of maps between prototypes of different 3708 // This avoid unwanted sharing of maps between prototypes of different
3709 // constructors. 3709 // constructors.
3710 Map* new_map; 3710 Map* new_map;
3711 ASSERT(object_function->has_initial_map()); 3711 ASSERT(object_function->has_initial_map());
3712 { MaybeObject* maybe_map = 3712 MaybeObject* maybe_map =
3713 object_function->initial_map()->CopyDropTransitions( 3713 object_function->initial_map()->Copy(DescriptorArray::MAY_BE_SHARED);
3714 DescriptorArray::MAY_BE_SHARED); 3714 if (!maybe_map->To(&new_map)) return maybe_map;
3715 if (!maybe_map->To<Map>(&new_map)) return maybe_map; 3715
3716 }
3717 Object* prototype; 3716 Object* prototype;
3718 { MaybeObject* maybe_prototype = AllocateJSObjectFromMap(new_map); 3717 MaybeObject* maybe_prototype = AllocateJSObjectFromMap(new_map);
3719 if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype; 3718 if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype;
3720 } 3719
3721 // When creating the prototype for the function we must set its 3720 // When creating the prototype for the function we must set its
3722 // constructor to the function. 3721 // constructor to the function.
3723 Object* result; 3722 MaybeObject* maybe_failure =
3724 { MaybeObject* maybe_result = 3723 JSObject::cast(prototype)->SetLocalPropertyIgnoreAttributes(
3725 JSObject::cast(prototype)->SetLocalPropertyIgnoreAttributes( 3724 constructor_symbol(), function, DONT_ENUM);
3726 constructor_symbol(), function, DONT_ENUM); 3725 if (maybe_failure->IsFailure()) return maybe_failure;
3727 if (!maybe_result->ToObject(&result)) return maybe_result; 3726
3728 }
3729 return prototype; 3727 return prototype;
3730 } 3728 }
3731 3729
3732 3730
3733 MaybeObject* Heap::AllocateFunction(Map* function_map, 3731 MaybeObject* Heap::AllocateFunction(Map* function_map,
3734 SharedFunctionInfo* shared, 3732 SharedFunctionInfo* shared,
3735 Object* prototype, 3733 Object* prototype,
3736 PretenureFlag pretenure) { 3734 PretenureFlag pretenure) {
3737 AllocationSpace space = 3735 AllocationSpace space =
3738 (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE; 3736 (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE;
(...skipping 3471 matching lines...) Expand 10 before | Expand all | Expand 10 after
7210 counters->size_of_##name()->Decrement( \ 7208 counters->size_of_##name()->Decrement( \
7211 static_cast<int>(object_sizes_last_time_[name])); 7209 static_cast<int>(object_sizes_last_time_[name]));
7212 INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) 7210 INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT)
7213 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7211 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7214 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7212 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7215 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7213 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7216 ClearObjectStats(); 7214 ClearObjectStats();
7217 } 7215 }
7218 7216
7219 } } // namespace v8::internal 7217 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/handles.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698