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

Unified Diff: src/heap/heap.cc

Issue 489833004: Harden CopyJSObject. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 1c966b350d2aee49a480e56c4f1c53b8619f25bf..cd61c17d71caa1d0fe071c67ddacc523492d6608 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -3684,12 +3684,14 @@ AllocationResult Heap::AllocateJSObject(JSFunction* constructor,
AllocationResult Heap::CopyJSObject(JSObject* source, AllocationSite* site) {
- // Never used to copy functions. If functions need to be copied we
- // have to be careful to clear the literals array.
- SLOW_DCHECK(!source->IsJSFunction());
-
// Make the clone.
Map* map = source->map();
+
+ // We can only clone normal objects or arrays. Copying anything else
+ // will break invariants.
+ CHECK(map->instance_type() == JS_OBJECT_TYPE ||
+ map->instance_type() == JS_ARRAY_TYPE);
+
int object_size = map->instance_size();
HeapObject* clone;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698