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

Unified Diff: src/objects.cc

Issue 1768553002: [runtime] Clean up symbol access in identity hash code (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 765c2ec1424eb0fb79ffb7f3ff0d6aa678848eb1..e7f5e66f55d0ef7489eba3fddeed5bd2252af568 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -1401,8 +1401,11 @@ Object* Object::GetHash() {
Object* hash = GetSimpleHash();
if (hash->IsSmi()) return hash;
+ DisallowHeapAllocation no_gc;
DCHECK(IsJSReceiver());
- return JSReceiver::cast(this)->GetIdentityHash();
+ JSReceiver* receiver = JSReceiver::cast(this);
+ Isolate* isolate = receiver->GetIsolate();
+ return *JSReceiver::GetIdentityHash(isolate, handle(receiver, isolate));
}
@@ -5855,7 +5858,7 @@ static Smi* GenerateIdentityHash(Isolate* isolate) {
void JSObject::SetIdentityHash(Handle<JSObject> object, Handle<Smi> hash) {
DCHECK(!object->IsJSGlobalProxy());
Isolate* isolate = object->GetIsolate();
- Handle<Name> hash_code_symbol(isolate->heap()->hash_code_symbol());
+ Handle<Name> hash_code_symbol = isolate->factory()->hash_code_symbol();
JSObject::AddProperty(object, hash_code_symbol, hash, NONE);
}
@@ -5872,40 +5875,35 @@ static Handle<Smi> GetOrCreateIdentityHashHelper(Handle<ProxyType> proxy) {
return hash;
}
-
-Object* JSObject::GetIdentityHash() {
- DisallowHeapAllocation no_gc;
- Isolate* isolate = GetIsolate();
- if (IsJSGlobalProxy()) {
- return JSGlobalProxy::cast(this)->hash();
+// static
+Handle<Object> JSObject::GetIdentityHash(Isolate* isolate,
+ Handle<JSObject> object) {
+ if (object->IsJSGlobalProxy()) {
+ return handle(JSGlobalProxy::cast(*object)->hash(), isolate);
}
- Handle<Name> hash_code_symbol(isolate->heap()->hash_code_symbol());
- Handle<Object> stored_value =
- Object::GetPropertyOrElement(Handle<Object>(this, isolate),
- hash_code_symbol).ToHandleChecked();
- return stored_value->IsSmi() ? *stored_value
- : isolate->heap()->undefined_value();
+ Handle<Name> hash_code_symbol = isolate->factory()->hash_code_symbol();
+ return JSReceiver::GetDataProperty(object, hash_code_symbol);
}
-
+// static
Handle<Smi> JSObject::GetOrCreateIdentityHash(Handle<JSObject> object) {
if (object->IsJSGlobalProxy()) {
return GetOrCreateIdentityHashHelper(Handle<JSGlobalProxy>::cast(object));
}
Isolate* isolate = object->GetIsolate();
- Handle<Object> maybe_hash(object->GetIdentityHash(), isolate);
+ Handle<Object> maybe_hash = JSObject::GetIdentityHash(isolate, object);
if (maybe_hash->IsSmi()) return Handle<Smi>::cast(maybe_hash);
Handle<Smi> hash(GenerateIdentityHash(isolate), isolate);
- Handle<Name> hash_code_symbol(isolate->heap()->hash_code_symbol());
- JSObject::AddProperty(object, hash_code_symbol, hash, NONE);
+ SetIdentityHash(object, hash);
return hash;
}
-
-Object* JSProxy::GetIdentityHash() {
- return this->hash();
+// static
+Handle<Object> JSProxy::GetIdentityHash(Isolate* isolate,
+ Handle<JSProxy> proxy) {
+ return handle(proxy->hash(), isolate);
}
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698