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 |