Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 3cb6fe20a20b752b42e042f33585459df27ef8aa..b0af9e77e3b44ab1c12619e027f0f2b40234abd3 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -2105,7 +2105,7 @@ static Handle<Object> InstantiateAccessorComponent(Isolate* isolate, |
} |
-RUNTIME_FUNCTION(Runtime_SetAccessorProperty) { |
+RUNTIME_FUNCTION(Runtime_DefineAccessorProperty) { |
HandleScope scope(isolate); |
ASSERT(args.length() == 5); |
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
@@ -5145,10 +5145,8 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
Handle<Object> object, |
Handle<Object> key, |
Handle<Object> value, |
- PropertyAttributes attr, |
- StrictMode strict_mode) { |
- SetPropertyMode set_mode = attr == NONE ? SET_PROPERTY : DEFINE_PROPERTY; |
- |
+ StrictMode strict_mode, |
+ PropertyAttributes attrs) { |
if (object->IsUndefined() || object->IsNull()) { |
Handle<Object> args[2] = { key, object }; |
Handle<Object> error = |
@@ -5167,8 +5165,7 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
} |
Handle<Name> name = Handle<Name>::cast(name_object); |
return JSReceiver::SetProperty(Handle<JSProxy>::cast(object), name, value, |
- attr, |
- strict_mode); |
+ attrs, strict_mode); |
} |
// If the object isn't a JavaScript object, we ignore the store. |
@@ -5200,7 +5197,7 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
} |
MaybeHandle<Object> result = JSObject::SetElement( |
- js_object, index, value, attr, strict_mode, true, set_mode); |
+ js_object, index, value, attrs, strict_mode, true, SET_PROPERTY); |
JSObject::ValidateElements(js_object); |
return result.is_null() ? result : value; |
@@ -5215,11 +5212,12 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
isolate, value, Execution::ToNumber(isolate, value), Object); |
} |
} |
- return JSObject::SetElement(js_object, index, value, attr, |
- strict_mode, true, set_mode); |
+ return JSObject::SetElement(js_object, index, value, attrs, |
+ strict_mode, true, SET_PROPERTY); |
} else { |
if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); |
- return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); |
+ return JSReceiver::SetProperty( |
+ js_object, name, value, attrs, strict_mode); |
} |
} |
@@ -5230,10 +5228,10 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
Handle<String> name = Handle<String>::cast(converted); |
if (name->AsArrayIndex(&index)) { |
- return JSObject::SetElement(js_object, index, value, attr, |
- strict_mode, true, set_mode); |
+ return JSObject::SetElement(js_object, index, value, attrs, |
+ strict_mode, true, SET_PROPERTY); |
} else { |
- return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); |
+ return JSReceiver::SetProperty(js_object, name, value, attrs, strict_mode); |
} |
} |
@@ -5343,11 +5341,11 @@ RUNTIME_FUNCTION(Runtime_SetHiddenProperty) { |
} |
-RUNTIME_FUNCTION(Runtime_SetProperty) { |
+RUNTIME_FUNCTION(Runtime_DefineProperty) { |
HandleScope scope(isolate); |
- RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); |
+ RUNTIME_ASSERT(args.length() == 4); |
- CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
+ 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); |
@@ -5357,17 +5355,37 @@ RUNTIME_FUNCTION(Runtime_SetProperty) { |
PropertyAttributes attributes = |
static_cast<PropertyAttributes>(unchecked_attributes); |
- StrictMode strict_mode = SLOPPY; |
- if (args.length() == 5) { |
- CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 4); |
- strict_mode = strict_mode_arg; |
+#ifdef DEBUG |
+ if (key->IsName()) { |
rossberg
2014/06/27 09:47:30
Hm, it's unfortunate that one can bypass this chec
|
+ LookupIterator it(object, Handle<Name>::cast(key), |
+ LookupIterator::CHECK_OWN); |
+ JSReceiver::GetPropertyAttributes(&it); |
+ RUNTIME_ASSERT(!it.IsFound()); |
} |
+#endif |
+ |
+ Handle<Object> result; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, result, |
+ Runtime::ForceSetObjectProperty(object, key, value, attributes)); |
+ return *result; |
+} |
+ |
+ |
+RUNTIME_FUNCTION(Runtime_SetProperty) { |
+ HandleScope scope(isolate); |
+ RUNTIME_ASSERT(args.length() == 4); |
+ |
+ CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
+ CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 3); |
+ StrictMode strict_mode = strict_mode_arg; |
Handle<Object> result; |
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
isolate, result, |
- Runtime::SetObjectProperty( |
- isolate, object, key, value, attributes, strict_mode)); |
+ Runtime::SetObjectProperty(isolate, object, key, value, strict_mode)); |
return *result; |
} |
@@ -11404,7 +11422,7 @@ static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector( |
RETURN_ON_EXCEPTION( |
isolate, |
- Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), |
+ Runtime::SetObjectProperty(isolate, target, name, value, SLOPPY), |
JSObject); |
} |
@@ -11417,7 +11435,7 @@ static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector( |
RETURN_ON_EXCEPTION( |
isolate, |
- Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), |
+ Runtime::SetObjectProperty(isolate, target, name, value, SLOPPY), |
JSObject); |
} |
@@ -11506,8 +11524,7 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeLocalContext( |
isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); |
RETURN_ON_EXCEPTION( |
isolate, |
- Runtime::SetObjectProperty( |
- isolate, target, key, value, NONE, SLOPPY), |
+ Runtime::SetObjectProperty(isolate, target, key, value, SLOPPY), |
JSObject); |
} |
} |
@@ -11612,7 +11629,7 @@ static bool SetLocalVariableValue(Isolate* isolate, |
// We don't expect this to do anything except replacing |
// property value. |
Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, |
- NONE, SLOPPY).Assert(); |
+ SLOPPY).Assert(); |
return true; |
} |
} |
@@ -11663,8 +11680,7 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeClosure( |
isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); |
RETURN_ON_EXCEPTION( |
isolate, |
- Runtime::SetObjectProperty( |
- isolate, closure_scope, key, value, NONE, SLOPPY), |
+ Runtime::ForceSetObjectProperty(closure_scope, key, value, NONE), |
JSObject); |
} |
} |
@@ -11695,8 +11711,8 @@ static bool SetClosureVariableValue(Isolate* isolate, |
Handle<JSObject> ext(JSObject::cast(context->extension())); |
if (JSReceiver::HasProperty(ext, variable_name)) { |
// We don't expect this to do anything except replacing property value. |
- Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, |
- NONE, SLOPPY).Assert(); |
+ Runtime::ForceSetObjectProperty( |
+ ext, variable_name, new_value, NONE).Assert(); |
return true; |
} |
} |
@@ -11718,8 +11734,7 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeCatchScope( |
isolate->factory()->NewJSObject(isolate->object_function()); |
RETURN_ON_EXCEPTION( |
isolate, |
- Runtime::SetObjectProperty(isolate, catch_scope, name, thrown_object, |
- NONE, SLOPPY), |
+ Runtime::ForceSetObjectProperty(catch_scope, name, thrown_object, NONE), |
JSObject); |
return catch_scope; |
} |
@@ -12782,8 +12797,7 @@ MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject( |
Handle<String> arguments_str = isolate->factory()->arguments_string(); |
RETURN_ON_EXCEPTION( |
isolate, |
- Runtime::SetObjectProperty( |
- isolate, target, arguments_str, arguments, ::NONE, SLOPPY), |
+ Runtime::ForceSetObjectProperty(target, arguments_str, arguments, NONE), |
JSObject); |
return target; |
} |