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

Unified Diff: src/heap.cc

Issue 7391001: Implement sealing, freezing, and related functions for proxies. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Oops, forgot to rebase branch. Created 9 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 side-by-side diff with in-line comments
Download patch
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index 98a2d3374b6949e3ab79d881f00a6d59b4871334..741947aa26a152225fafe1f8608c74f7e5eab7eb 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -3279,7 +3279,7 @@ MaybeObject* Heap::AllocateJSProxy(Object* handler, Object* prototype) {
}
-MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) {
+ MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) {
Mads Ager (chromium) 2011/07/17 10:43:47 Accidental edit. :-)
rossberg 2011/07/18 10:53:53 Done.
ASSERT(constructor->has_initial_map());
Map* map = constructor->initial_map();
@@ -3414,6 +3414,36 @@ MaybeObject* Heap::CopyJSObject(JSObject* source) {
}
+MaybeObject* Heap::ReinitializeJSReceiverAsJSObject(JSReceiver* object) {
+ // Allocate fresh map.
+ // TODO(rossberg): Once we optimize proxies, cache these maps.
+ Map* map;
+ MaybeObject* maybe_map_obj =
+ AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
+ if (!maybe_map_obj->To<Map>(&map)) return maybe_map_obj;
+
+ // Check that the receiver has the same size as a fresh object.
+ ASSERT(map->instance_size() == object->map()->instance_size());
+
+ map->set_prototype(object->map()->prototype());
+
+ // Allocate the backing storage for the properties.
+ int prop_size = map->unused_property_fields() - map->inobject_properties();
+ Object* properties;
+ { MaybeObject* maybe_properties = AllocateFixedArray(prop_size, TENURED);
+ if (!maybe_properties->ToObject(&properties)) return maybe_properties;
+ }
+
+ // Reset the map for the object.
+ object->set_map(map);
+
+ // Reinitialize the object from the constructor map.
+ InitializeJSObjectFromMap(JSObject::cast(object),
+ FixedArray::cast(properties), map);
+ return object;
+}
+
+
MaybeObject* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor,
JSGlobalProxy* object) {
ASSERT(constructor->has_initial_map());

Powered by Google App Engine
This is Rietveld 408576698