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

Side by Side Diff: src/heap.cc

Issue 7427: - Fix instance size calculation to ensure that the object cannot... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 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 | « no previous file | 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 return result; 1659 return result;
1660 } 1660 }
1661 1661
1662 1662
1663 Object* Heap::AllocateInitialMap(JSFunction* fun) { 1663 Object* Heap::AllocateInitialMap(JSFunction* fun) {
1664 ASSERT(!fun->has_initial_map()); 1664 ASSERT(!fun->has_initial_map());
1665 1665
1666 // First create a new map with the expected number of properties being 1666 // First create a new map with the expected number of properties being
1667 // allocated in-object. 1667 // allocated in-object.
1668 int expected_nof_properties = fun->shared()->expected_nof_properties(); 1668 int expected_nof_properties = fun->shared()->expected_nof_properties();
1669 Object* map_obj = Heap::AllocateMap(JS_OBJECT_TYPE, 1669 int instance_size = JSObject::kHeaderSize +
1670 JSObject::kHeaderSize + expected_nof_properties * kPointerSize); 1670 expected_nof_properties * kPointerSize;
1671 if (instance_size > JSObject::kMaxInstanceSize) {
1672 instance_size = JSObject::kMaxInstanceSize;
1673 expected_nof_properties = (instance_size - JSObject::kHeaderSize) /
1674 kPointerSize;
1675 }
1676 Object* map_obj = Heap::AllocateMap(JS_OBJECT_TYPE, instance_size);
1671 if (map_obj->IsFailure()) return map_obj; 1677 if (map_obj->IsFailure()) return map_obj;
1672 1678
1673 // Fetch or allocate prototype. 1679 // Fetch or allocate prototype.
1674 Object* prototype; 1680 Object* prototype;
1675 if (fun->has_instance_prototype()) { 1681 if (fun->has_instance_prototype()) {
1676 prototype = fun->instance_prototype(); 1682 prototype = fun->instance_prototype();
1677 } else { 1683 } else {
1678 prototype = AllocateFunctionPrototype(fun); 1684 prototype = AllocateFunctionPrototype(fun);
1679 if (prototype->IsFailure()) return prototype; 1685 if (prototype->IsFailure()) return prototype;
1680 } 1686 }
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 return "Scavenge"; 3084 return "Scavenge";
3079 case MARK_COMPACTOR: 3085 case MARK_COMPACTOR:
3080 return MarkCompactCollector::HasCompacted() ? "Mark-compact" 3086 return MarkCompactCollector::HasCompacted() ? "Mark-compact"
3081 : "Mark-sweep"; 3087 : "Mark-sweep";
3082 } 3088 }
3083 return "Unknown GC"; 3089 return "Unknown GC";
3084 } 3090 }
3085 3091
3086 3092
3087 } } // namespace v8::internal 3093 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698