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

Unified Diff: src/heap.cc

Issue 7754015: Implement identity hashes for proxies. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap.h ('k') | src/objects.h » ('j') | src/objects.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index f0c37f2b9ecf2aa10c18d74d1bc972d428f5f433..bcb2168408b79065e19ef3a8a8fec7d447540c51 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -3290,6 +3290,7 @@ MaybeObject* Heap::AllocateJSProxy(Object* handler, Object* prototype) {
if (!maybe_result->To<JSProxy>(&result)) return maybe_result;
result->InitializeBody(map->instance_size(), Smi::FromInt(0));
result->set_handler(handler);
+ result->set_hash(undefined_value());
return result;
}
@@ -3313,6 +3314,7 @@ MaybeObject* Heap::AllocateJSFunctionProxy(Object* handler,
if (!maybe_result->To<JSFunctionProxy>(&result)) return maybe_result;
result->InitializeBody(map->instance_size(), Smi::FromInt(0));
result->set_handler(handler);
+ result->set_hash(undefined_value());
result->set_call_trap(call_trap);
result->set_construct_trap(construct_trap);
return result;
@@ -3463,6 +3465,9 @@ MaybeObject* Heap::ReinitializeJSReceiver(
JSReceiver* object, InstanceType type, int size) {
ASSERT(type >= FIRST_JS_RECEIVER_TYPE);
+ // Save identity hash.
+ MaybeObject* maybe_hash = object->GetIdentityHash(JSReceiver::OMIT_CREATION);
+
// Allocate fresh map.
// TODO(rossberg): Once we optimize proxies, cache these maps.
Map* map;
@@ -3511,6 +3516,18 @@ MaybeObject* Heap::ReinitializeJSReceiver(
object->address() + map->instance_size(), size_difference);
}
+ // Inherit identity, if it was present.
+ Object* hash;
+ if (maybe_hash->To<Object>(&hash) && hash->IsSmi()) {
+ JSObject* jsobj = JSObject::cast(object);
+ JSObject* hidden_props;
+ MaybeObject* maybe = jsobj->GetHiddenProperties(JSObject::ALLOW_CREATION);
Michael Starzinger 2011/09/09 09:40:00 Can we move that into a separate method JSObject::
rossberg 2011/09/12 10:50:08 Done.
+ if (!maybe->To<JSObject>(&hidden_props)) return maybe;
+ maybe = hidden_props->SetLocalPropertyIgnoreAttributes(
+ identity_hash_symbol(), hash, NONE);
+ if (maybe->IsFailure()) return maybe;
+ }
+
return object;
}
« no previous file with comments | « src/heap.h ('k') | src/objects.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698