| Index: src/runtime.cc
|
| diff --git a/src/runtime.cc b/src/runtime.cc
|
| index 0c15f60f30677bc02c172b4f6929e5ac559273cd..dcbfb20000581cabce315ac92b0b86d0fb249399 100644
|
| --- a/src/runtime.cc
|
| +++ b/src/runtime.cc
|
| @@ -335,7 +335,10 @@ static Handle<Object> CreateObjectLiteralBoilerplate(
|
| if (key->IsSymbol()) {
|
| if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
|
| // Array index as string (uint32).
|
| - result = SetOwnElement(boilerplate, element_index, value);
|
| + result = SetOwnElement(boilerplate,
|
| + element_index,
|
| + value,
|
| + kNonStrictMode);
|
| } else {
|
| Handle<String> name(String::cast(*key));
|
| ASSERT(!name->AsArrayIndex(&element_index));
|
| @@ -344,7 +347,10 @@ static Handle<Object> CreateObjectLiteralBoilerplate(
|
| }
|
| } else if (key->ToArrayIndex(&element_index)) {
|
| // Array index (uint32).
|
| - result = SetOwnElement(boilerplate, element_index, value);
|
| + result = SetOwnElement(boilerplate,
|
| + element_index,
|
| + value,
|
| + kNonStrictMode);
|
| } else {
|
| // Non-uint32 number.
|
| ASSERT(key->IsNumber());
|
| @@ -1184,7 +1190,8 @@ static MaybeObject* Runtime_DeclareContextSlot(Arguments args) {
|
| } else {
|
| // The holder is an arguments object.
|
| Handle<JSObject> arguments(Handle<JSObject>::cast(holder));
|
| - Handle<Object> result = SetElement(arguments, index, initial_value);
|
| + Handle<Object> result = SetElement(arguments, index, initial_value,
|
| + kNonStrictMode);
|
| if (result.is_null()) return Failure::Exception();
|
| }
|
| } else {
|
| @@ -1469,7 +1476,7 @@ static MaybeObject* Runtime_InitializeConstContextSlot(Arguments args) {
|
| // The holder is an arguments object.
|
| ASSERT((attributes & READ_ONLY) == 0);
|
| Handle<JSObject> arguments(Handle<JSObject>::cast(holder));
|
| - SetElement(arguments, index, value);
|
| + SetElement(arguments, index, value, kNonStrictMode);
|
| }
|
| return *value;
|
| }
|
| @@ -3812,8 +3819,7 @@ MaybeObject* Runtime::SetObjectProperty(Handle<Object> object,
|
| return *value;
|
| }
|
|
|
| - // TODO(1220): Implement SetElement strict mode.
|
| - Handle<Object> result = SetElement(js_object, index, value);
|
| + Handle<Object> result = SetElement(js_object, index, value, strict);
|
| if (result.is_null()) return Failure::Exception();
|
| return *value;
|
| }
|
| @@ -3821,7 +3827,7 @@ MaybeObject* Runtime::SetObjectProperty(Handle<Object> object,
|
| if (key->IsString()) {
|
| Handle<Object> result;
|
| if (Handle<String>::cast(key)->AsArrayIndex(&index)) {
|
| - result = SetElement(js_object, index, value);
|
| + result = SetElement(js_object, index, value, strict);
|
| } else {
|
| Handle<String> key_string = Handle<String>::cast(key);
|
| key_string->TryFlatten();
|
| @@ -3838,8 +3844,7 @@ MaybeObject* Runtime::SetObjectProperty(Handle<Object> object,
|
| Handle<String> name = Handle<String>::cast(converted);
|
|
|
| if (name->AsArrayIndex(&index)) {
|
| - // TODO(1220): Implement SetElement strict mode.
|
| - return js_object->SetElement(index, *value);
|
| + return js_object->SetElement(index, *value, strict);
|
| } else {
|
| return js_object->SetProperty(*name, *value, attr, strict);
|
| }
|
| @@ -3866,12 +3871,12 @@ MaybeObject* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object,
|
| return *value;
|
| }
|
|
|
| - return js_object->SetElement(index, *value);
|
| + return js_object->SetElement(index, *value, kNonStrictMode);
|
| }
|
|
|
| if (key->IsString()) {
|
| if (Handle<String>::cast(key)->AsArrayIndex(&index)) {
|
| - return js_object->SetElement(index, *value);
|
| + return js_object->SetElement(index, *value, kNonStrictMode);
|
| } else {
|
| Handle<String> key_string = Handle<String>::cast(key);
|
| key_string->TryFlatten();
|
| @@ -3888,7 +3893,7 @@ MaybeObject* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object,
|
| Handle<String> name = Handle<String>::cast(converted);
|
|
|
| if (name->AsArrayIndex(&index)) {
|
| - return js_object->SetElement(index, *value);
|
| + return js_object->SetElement(index, *value, kNonStrictMode);
|
| } else {
|
| return js_object->SetLocalPropertyIgnoreAttributes(*name, *value, attr);
|
| }
|
| @@ -7557,11 +7562,17 @@ static MaybeObject* Runtime_StoreContextSlot(Arguments args) {
|
| if ((attributes & READ_ONLY) == 0) {
|
| // Context is a fixed array and set cannot fail.
|
| Context::cast(*holder)->set(index, *value);
|
| + } else if (strict == kStrictMode) {
|
| + // Setting read only property in strict mode.
|
| + Handle<Object> error =
|
| + Factory::NewTypeError("strict_cannot_assign",
|
| + HandleVector(&name, 1));
|
| + return Top::Throw(*error);
|
| }
|
| } else {
|
| ASSERT((attributes & READ_ONLY) == 0);
|
| Handle<Object> result =
|
| - SetElement(Handle<JSObject>::cast(holder), index, value);
|
| + SetElement(Handle<JSObject>::cast(holder), index, value, strict);
|
| if (result.is_null()) {
|
| ASSERT(Top::has_pending_exception());
|
| return Failure::Exception();
|
| @@ -7592,7 +7603,7 @@ static MaybeObject* Runtime_StoreContextSlot(Arguments args) {
|
| } else if (strict == kStrictMode && (attributes & READ_ONLY) != 0) {
|
| // Setting read only property in strict mode.
|
| Handle<Object> error =
|
| - Factory::NewTypeError("strict_cannot_assign", HandleVector(&name, 1));
|
| + Factory::NewTypeError("strict_cannot_assign", HandleVector(&name, 1));
|
| return Top::Throw(*error);
|
| }
|
| return *value;
|
| @@ -8064,7 +8075,9 @@ static MaybeObject* Runtime_PushIfAbsent(Arguments args) {
|
| if (elements->get(i) == element) return Heap::false_value();
|
| }
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = array->SetFastElement(length, element);
|
| + // Strict not needed. Used for cycle detection in Array join implementation.
|
| + { MaybeObject* maybe_obj = array->SetFastElement(length, element,
|
| + kNonStrictMode);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| return Heap::true_value();
|
| @@ -8659,8 +8672,8 @@ static MaybeObject* Runtime_SwapElements(Arguments args) {
|
| Handle<Object> tmp1 = GetElement(jsobject, index1);
|
| Handle<Object> tmp2 = GetElement(jsobject, index2);
|
|
|
| - SetElement(jsobject, index1, tmp2);
|
| - SetElement(jsobject, index2, tmp1);
|
| + SetElement(jsobject, index1, tmp2, kNonStrictMode);
|
| + SetElement(jsobject, index2, tmp1, kNonStrictMode);
|
|
|
| return Heap::undefined_value();
|
| }
|
| @@ -11293,10 +11306,11 @@ static MaybeObject* Runtime_CollectStackTrace(Arguments args) {
|
| elements->set(cursor++, *code);
|
| elements->set(cursor++, *offset);
|
| } else {
|
| - SetElement(result, cursor++, recv);
|
| - SetElement(result, cursor++, fun);
|
| - SetElement(result, cursor++, code);
|
| - SetElement(result, cursor++, offset);
|
| + // Strict mode not required for collecting stack trace.
|
| + SetElement(result, cursor++, recv, kNonStrictMode);
|
| + SetElement(result, cursor++, fun, kNonStrictMode);
|
| + SetElement(result, cursor++, code, kNonStrictMode);
|
| + SetElement(result, cursor++, offset, kNonStrictMode);
|
| }
|
| }
|
| }
|
| @@ -11483,9 +11497,9 @@ static MaybeObject* Runtime_ListNatives(Arguments args) {
|
| Vector<const char>(#Name, StrLength(#Name))); \
|
| } \
|
| Handle<JSArray> pair = Factory::NewJSArray(0); \
|
| - SetElement(pair, 0, name); \
|
| - SetElement(pair, 1, Handle<Smi>(Smi::FromInt(argc))); \
|
| - SetElement(result, index++, pair); \
|
| + SetElement(pair, 0, name, kNonStrictMode); \
|
| + SetElement(pair, 1, Handle<Smi>(Smi::FromInt(argc)), kNonStrictMode); \
|
| + SetElement(result, index++, pair, kNonStrictMode); \
|
| }
|
| inline_runtime_functions = false;
|
| RUNTIME_FUNCTION_LIST(ADD_ENTRY)
|
|
|