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

Unified Diff: src/runtime.cc

Issue 359413007: Improve error reporting for duplicate object template properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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/runtime.h ('k') | test/mjsunit/runtime-gen/addpropertyfortemplate.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 888f665d21c8d8ab126a7d0ff9703d534094d5aa..1d10a8e222aecfa213e9a9ba1122e2a81494110b 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -5339,15 +5339,59 @@ RUNTIME_FUNCTION(Runtime_AddProperty) {
static_cast<PropertyAttributes>(unchecked_attributes);
#ifdef DEBUG
+ bool duplicate;
if (key->IsName()) {
LookupIterator it(object, Handle<Name>::cast(key),
LookupIterator::CHECK_OWN_REAL);
JSReceiver::GetPropertyAttributes(&it);
- RUNTIME_ASSERT(!it.IsFound());
+ duplicate = it.IsFound();
} else {
uint32_t index = 0;
RUNTIME_ASSERT(key->ToArrayIndex(&index));
- RUNTIME_ASSERT(!JSReceiver::HasOwnElement(object, index));
+ duplicate = JSReceiver::HasOwnElement(object, index);
+ }
+ RUNTIME_ASSERT(!duplicate);
+#endif
+
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ Runtime::DefineObjectProperty(object, key, value, attributes));
+ return *result;
+}
+
+
+RUNTIME_FUNCTION(Runtime_AddPropertyForTemplate) {
+ HandleScope scope(isolate);
+ RUNTIME_ASSERT(args.length() == 4);
+
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
+ CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3);
+ RUNTIME_ASSERT(
+ (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
+ // Compute attributes.
+ PropertyAttributes attributes =
+ static_cast<PropertyAttributes>(unchecked_attributes);
+
+#ifdef DEBUG
+ bool duplicate;
+ if (key->IsName()) {
+ LookupIterator it(object, Handle<Name>::cast(key),
+ LookupIterator::CHECK_OWN_REAL);
+ JSReceiver::GetPropertyAttributes(&it);
+ duplicate = it.IsFound();
+ } else {
+ uint32_t index = 0;
+ RUNTIME_ASSERT(key->ToArrayIndex(&index));
+ duplicate = JSReceiver::HasOwnElement(object, index);
+ }
+ if (duplicate) {
+ Handle<Object> args[1] = { key };
+ Handle<Object> error = isolate->factory()->NewTypeError(
+ "duplicate_template_property", HandleVector(args, 1));
+ return isolate->Throw(*error);
}
#endif
« no previous file with comments | « src/runtime.h ('k') | test/mjsunit/runtime-gen/addpropertyfortemplate.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698