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

Unified Diff: src/api-natives.cc

Issue 1181733002: Revert of Replace SetObjectProperty / DefineObjectProperty with less powerful alternatives where relevant. (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 | « src/api.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api-natives.cc
diff --git a/src/api-natives.cc b/src/api-natives.cc
index 74518447ea329a61a703cd66fa459d5ca2b1ee4f..71a039f35ea8d4d312e43a398392630190618163 100644
--- a/src/api-natives.cc
+++ b/src/api-natives.cc
@@ -80,24 +80,32 @@
ASSIGN_RETURN_ON_EXCEPTION(isolate, value,
Instantiate(isolate, prop_data, key), Object);
- uint32_t index = 0;
- LookupIterator::Configuration c = LookupIterator::OWN_SKIP_INTERCEPTOR;
- LookupIterator it = key->AsArrayIndex(&index)
- ? LookupIterator(isolate, object, index, c)
- : LookupIterator(object, key, c);
-
#ifdef DEBUG
- Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
- DCHECK(maybe.IsJust());
- if (it.IsFound()) {
+ bool duplicate;
+ if (key->IsName()) {
+ LookupIterator it(object, Handle<Name>::cast(key),
+ LookupIterator::OWN_SKIP_INTERCEPTOR);
+ Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
+ DCHECK(maybe.IsJust());
+ duplicate = it.IsFound();
+ } else {
+ uint32_t index = 0;
+ key->ToArrayIndex(&index);
+ Maybe<bool> maybe = JSReceiver::HasOwnElement(object, index);
+ if (!maybe.IsJust()) return MaybeHandle<Object>();
+ duplicate = maybe.FromJust();
+ }
+ if (duplicate) {
THROW_NEW_ERROR(
isolate, NewTypeError(MessageTemplate::kDuplicateTemplateProperty, key),
Object);
}
#endif
- return Object::AddDataProperty(&it, value, attributes, STRICT,
- Object::CERTAINLY_NOT_STORE_FROM_KEYED);
+ RETURN_ON_EXCEPTION(
+ isolate, Runtime::DefineObjectProperty(object, key, value, attributes),
+ Object);
+ return object;
}
« no previous file with comments | « src/api.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698