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

Unified Diff: src/runtime/runtime-object.cc

Issue 1375943002: Add LookupIterator constructor for arbitrary Object keys (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 5 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/lookup.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-object.cc
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc
index 4782a3143056b155db1304af871a84e52cb1f78a..7aaf768ae1f02153fb272b5deec211b6bd67b393 100644
--- a/src/runtime/runtime-object.cc
+++ b/src/runtime/runtime-object.cc
@@ -26,26 +26,12 @@ MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
Object);
}
- // Check if the given key is an array index.
- uint32_t index = 0;
- if (key->ToArrayIndex(&index)) {
- return Object::GetElement(isolate, object, index, language_mode);
- }
+ bool success = false;
+ LookupIterator it =
+ LookupIterator::PropertyOrElement(isolate, object, key, &success);
+ if (!success) return MaybeHandle<Object>();
- // Convert the key to a name - possibly by calling back into JavaScript.
- Handle<Name> name;
- ASSIGN_RETURN_ON_EXCEPTION(isolate, name, Object::ToName(isolate, key),
- Object);
-
- // Check if the name is trivially convertible to an index and get
- // the element if so.
- // TODO(verwaest): Make sure GetProperty(LookupIterator*) can handle this, and
- // remove the special casing here.
- if (name->AsArrayIndex(&index)) {
- return Object::GetElement(isolate, object, index);
- } else {
- return Object::GetProperty(object, name, language_mode);
- }
+ return Object::GetProperty(&it, language_mode);
}
@@ -135,17 +121,12 @@ MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate,
Handle<JSReceiver> receiver,
Handle<Object> key,
LanguageMode language_mode) {
- // Check if the given key is an array index.
- uint32_t index = 0;
- if (key->ToArrayIndex(&index)) {
- return JSReceiver::DeleteElement(receiver, index, language_mode);
- }
-
- Handle<Name> name;
- ASSIGN_RETURN_ON_EXCEPTION(isolate, name, Object::ToName(isolate, key),
- Object);
+ bool success = false;
+ LookupIterator it = LookupIterator::PropertyOrElement(
+ isolate, receiver, key, &success, LookupIterator::HIDDEN);
+ if (!success) return MaybeHandle<Object>();
- return JSReceiver::DeletePropertyOrElement(receiver, name, language_mode);
+ return JSReceiver::DeleteProperty(&it, language_mode);
}
@@ -162,16 +143,11 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
}
// Check if the given key is an array index.
- uint32_t index = 0;
- if (key->ToArrayIndex(&index)) {
- return Object::SetElement(isolate, object, index, value, language_mode);
- }
-
- Handle<Name> name;
- ASSIGN_RETURN_ON_EXCEPTION(isolate, name, Object::ToName(isolate, key),
- Object);
+ bool success = false;
+ LookupIterator it =
+ LookupIterator::PropertyOrElement(isolate, object, key, &success);
+ if (!success) return MaybeHandle<Object>();
- LookupIterator it = LookupIterator::PropertyOrElement(isolate, object, name);
return Object::SetProperty(&it, value, language_mode,
Object::MAY_BE_STORE_FROM_KEYED);
}
« no previous file with comments | « src/lookup.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698