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

Unified Diff: src/objects.cc

Issue 1765633004: Avoid duplicate lookups when Get+Creating identity hashes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: tweaks 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 5faa79ef646162a8e4cf71c41a0f4748fcd1ccec..8800b99e22300c06b4a8a21392b6c544ecb0aa8a 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -836,14 +836,6 @@ MaybeHandle<Object> JSProxy::GetProperty(Isolate* isolate,
}
-Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object,
- Handle<Name> name) {
- LookupIterator it(object, name,
- LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
- return GetDataProperty(&it);
-}
-
-
Handle<Object> JSReceiver::GetDataProperty(LookupIterator* it) {
for (; it->IsFound(); it->Next()) {
switch (it->state()) {
@@ -5856,14 +5848,6 @@ 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->factory()->hash_code_symbol();
- JSObject::AddProperty(object, hash_code_symbol, hash, NONE);
-}
-
-
template<typename ProxyType>
static Handle<Smi> GetOrCreateIdentityHashHelper(Handle<ProxyType> proxy) {
Isolate* isolate = proxy->GetIsolate();
@@ -5893,11 +5877,18 @@ Handle<Smi> JSObject::GetOrCreateIdentityHash(Handle<JSObject> object) {
}
Isolate* isolate = object->GetIsolate();
- Handle<Object> maybe_hash = JSObject::GetIdentityHash(isolate, object);
- if (maybe_hash->IsSmi()) return Handle<Smi>::cast(maybe_hash);
+ Handle<Name> hash_code_symbol = isolate->factory()->hash_code_symbol();
+ LookupIterator it(object, hash_code_symbol, LookupIterator::OWN);
+ if (it.IsFound()) {
+ DCHECK_EQ(LookupIterator::DATA, it.state());
+ Handle<Object> maybe_hash = it.GetDataValue();
+ if (maybe_hash->IsSmi()) return Handle<Smi>::cast(maybe_hash);
+ }
Handle<Smi> hash(GenerateIdentityHash(isolate), isolate);
- SetIdentityHash(object, hash);
+ CHECK(AddDataProperty(&it, hash, NONE, THROW_ON_ERROR,
+ CERTAINLY_NOT_STORE_FROM_KEYED)
+ .IsJust());
return hash;
}
« 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