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

Unified Diff: src/api.cc

Issue 1226473003: Cleanup API property handling (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 0dbebc14e564aa93c441a0eb7d38bacea217de02..be8c200cac35788638863bdcf1c1346d49fdd767 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3568,16 +3568,9 @@ static i::MaybeHandle<i::Object> DefineObjectProperty(
}
i::Handle<i::Name> name;
- if (key->IsName()) {
- name = i::Handle<i::Name>::cast(key);
- } else {
- // Call-back into JavaScript to convert the key to a string.
- i::Handle<i::Object> converted;
- ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, converted,
- i::Execution::ToString(isolate, key),
- i::MaybeHandle<i::Object>());
- name = i::Handle<i::String>::cast(converted);
- }
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, name,
+ i::Runtime::ToName(isolate, key),
+ i::MaybeHandle<i::Object>());
return i::JSObject::DefinePropertyOrElementIgnoreAttributes(js_object, name,
value, attrs);
@@ -3616,44 +3609,24 @@ bool v8::Object::ForceSet(v8::Handle<Value> key, v8::Handle<Value> value,
}
-namespace {
-
-i::MaybeHandle<i::Object> DeleteObjectProperty(
+MUST_USE_RESULT
+static i::MaybeHandle<i::Object> DeleteObjectProperty(
i::Isolate* isolate, i::Handle<i::JSReceiver> receiver,
i::Handle<i::Object> key, i::LanguageMode language_mode) {
// Check if the given key is an array index.
uint32_t index = 0;
if (key->ToArrayIndex(&index)) {
- // In Firefox/SpiderMonkey, Safari and Opera you can access the
- // characters of a string using [] notation. In the case of a
- // String object we just need to redirect the deletion to the
- // underlying string if the index is in range. Since the
- // underlying string does nothing with the deletion, we can ignore
- // such deletions.
- if (receiver->IsStringObjectWithCharacterAt(index)) {
- return isolate->factory()->false_value();
- }
-
return i::JSReceiver::DeleteElement(receiver, index, language_mode);
}
i::Handle<i::Name> name;
- if (key->IsName()) {
- name = i::Handle<i::Name>::cast(key);
- } else {
- // Call-back into JavaScript to convert the key to a string.
- i::Handle<i::Object> converted;
- if (!i::Execution::ToString(isolate, key).ToHandle(&converted)) {
- return i::MaybeHandle<i::Object>();
- }
- name = i::Handle<i::String>::cast(converted);
- }
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, name,
+ i::Runtime::ToName(isolate, key),
+ i::MaybeHandle<i::Object>());
- return i::JSReceiver::DeleteProperty(receiver, name, language_mode);
+ return i::JSReceiver::DeletePropertyOrElement(receiver, name, language_mode);
}
-} // namespace
-
MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context,
Local<Value> key) {
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698