Revision: 22112
Author: [email protected]
Date: Tue Jul 1 10:00:19 2014 UTC
Log: Improve error reporting for duplicate object template properties.
BUG=
[email protected]
Review URL: https://codereview.chromium.org/359413007
http://code.google.com/p/v8/source/detail?r=22112
Added:
/branches/bleeding_edge/test/mjsunit/runtime-gen/addpropertyfortemplate.js
Modified:
/branches/bleeding_edge/src/apinatives.js
/branches/bleeding_edge/src/messages.js
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/src/runtime.h
/branches/bleeding_edge/tools/generate-runtime-tests.py
=======================================
--- /dev/null
+++
/branches/bleeding_edge/test/mjsunit/runtime-gen/addpropertyfortemplate.js
Tue Jul 1 10:00:19 2014 UTC
@@ -0,0 +1,8 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY
+// Flags: --allow-natives-syntax --harmony
+var _object = new Object();
+var arg1 = 10;
+var _value = new Object();
+var _unchecked_attributes = 1;
+%AddPropertyForTemplate(_object, arg1, _value, _unchecked_attributes);
=======================================
--- /branches/bleeding_edge/src/apinatives.js Fri Jun 27 13:48:37 2014 UTC
+++ /branches/bleeding_edge/src/apinatives.js Tue Jul 1 10:00:19 2014 UTC
@@ -99,7 +99,7 @@
var prop_data = properties[i + 2];
var attributes = properties[i + 3];
var value = Instantiate(prop_data, name);
- %AddProperty(obj, name, value, attributes);
+ %AddPropertyForTemplate(obj, name, value, attributes);
} else if (length == 4 || length == 5) {
// TODO(verwaest): The 5th value used to be access_control. Remove
once
// the bindings are updated.
=======================================
--- /branches/bleeding_edge/src/messages.js Mon Jun 30 13:16:42 2014 UTC
+++ /branches/bleeding_edge/src/messages.js Tue Jul 1 10:00:19 2014 UTC
@@ -26,6 +26,7 @@
newline_after_throw: ["Illegal newline after throw"],
label_redeclaration: ["Label '", "%0", "' has already been
declared"],
var_redeclaration: ["Identifier '", "%0", "' has already
been declared"],
+ duplicate_template_property: ["Object template has duplicate
property '", "%0", "'"],
no_catch_or_finally: ["Missing catch or finally after try"],
unknown_label: ["Undefined label '", "%0", "'"],
uncaught_exception: ["Uncaught ", "%0"],
=======================================
--- /branches/bleeding_edge/src/runtime.cc Tue Jul 1 09:49:25 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc Tue Jul 1 10:00:19 2014 UTC
@@ -5339,15 +5339,59 @@
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
=======================================
--- /branches/bleeding_edge/src/runtime.h Mon Jun 30 13:16:42 2014 UTC
+++ /branches/bleeding_edge/src/runtime.h Tue Jul 1 10:00:19 2014 UTC
@@ -225,6 +225,7 @@
F(IsAttachedGlobal, 1, 1) \
\
F(AddProperty, 4, 1) \
+ F(AddPropertyForTemplate, 4, 1) \
F(SetProperty, 4, 1) \
F(DefineDataPropertyUnchecked, 4, 1) \
F(DefineAccessorPropertyUnchecked, 5, 1) \
=======================================
--- /branches/bleeding_edge/tools/generate-runtime-tests.py Mon Jun 30
13:16:42 2014 UTC
+++ /branches/bleeding_edge/tools/generate-runtime-tests.py Tue Jul 1
10:00:19 2014 UTC
@@ -47,8 +47,8 @@
# that the parser doesn't bit-rot. Change the values as needed when you
add,
# remove or change runtime functions, but make sure we don't lose our
ability
# to parse them!
-EXPECTED_FUNCTION_COUNT = 416
-EXPECTED_FUZZABLE_COUNT = 331
+EXPECTED_FUNCTION_COUNT = 417
+EXPECTED_FUZZABLE_COUNT = 332
EXPECTED_CCTEST_COUNT = 6
EXPECTED_UNKNOWN_COUNT = 4
EXPECTED_BUILTINS_COUNT = 809
@@ -212,6 +212,7 @@
# None means "fall back to autodetected value".
CUSTOM_KNOWN_GOOD_INPUT = {
"AddProperty": [None, 10, None, None, None],
+ "AddPropertyForTemplate": [None, 10, None, None, None],
"Apply": ["function() {}", None, None, None, None, None],
"ArrayBufferSliceImpl": [None, None, 0, None],
"ArrayConcat": ["[1, 'a']", None],
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.