OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 Handle<Object> result; | 280 Handle<Object> result; |
281 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 281 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
282 isolate, result, | 282 isolate, result, |
283 Object::SetProperty(&it, value, strict_mode, | 283 Object::SetProperty(&it, value, strict_mode, |
284 Object::CERTAINLY_NOT_STORE_FROM_KEYED, | 284 Object::CERTAINLY_NOT_STORE_FROM_KEYED, |
285 Object::SUPER_PROPERTY)); | 285 Object::SUPER_PROPERTY)); |
286 return *result; | 286 return *result; |
287 } | 287 } |
288 | 288 |
289 | 289 |
| 290 static Object* StoreElementToSuper(Isolate* isolate, |
| 291 Handle<JSObject> home_object, |
| 292 Handle<Object> receiver, uint32_t index, |
| 293 Handle<Object> value, |
| 294 StrictMode strict_mode) { |
| 295 if (home_object->IsAccessCheckNeeded() && |
| 296 !isolate->MayIndexedAccess(home_object, index, v8::ACCESS_SET)) { |
| 297 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_SET); |
| 298 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 299 } |
| 300 |
| 301 PrototypeIterator iter(isolate, home_object); |
| 302 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); |
| 303 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value(); |
| 304 |
| 305 Handle<Object> result; |
| 306 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 307 isolate, result, |
| 308 Object::SetElementWithReceiver(isolate, proto, receiver, index, value, |
| 309 strict_mode)); |
| 310 return *result; |
| 311 } |
| 312 |
| 313 |
290 RUNTIME_FUNCTION(Runtime_StoreToSuper_Strict) { | 314 RUNTIME_FUNCTION(Runtime_StoreToSuper_Strict) { |
291 HandleScope scope(isolate); | 315 HandleScope scope(isolate); |
292 DCHECK(args.length() == 4); | 316 DCHECK(args.length() == 4); |
293 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 317 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
294 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 318 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
295 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | 319 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); |
296 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); | 320 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); |
297 | 321 |
298 return StoreToSuper(isolate, home_object, receiver, name, value, STRICT); | 322 return StoreToSuper(isolate, home_object, receiver, name, value, STRICT); |
299 } | 323 } |
300 | 324 |
301 | 325 |
302 RUNTIME_FUNCTION(Runtime_StoreToSuper_Sloppy) { | 326 RUNTIME_FUNCTION(Runtime_StoreToSuper_Sloppy) { |
303 HandleScope scope(isolate); | 327 HandleScope scope(isolate); |
304 DCHECK(args.length() == 4); | 328 DCHECK(args.length() == 4); |
305 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 329 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
306 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 330 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
307 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | 331 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); |
308 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); | 332 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); |
309 | 333 |
310 return StoreToSuper(isolate, home_object, receiver, name, value, SLOPPY); | 334 return StoreToSuper(isolate, home_object, receiver, name, value, SLOPPY); |
311 } | 335 } |
312 | 336 |
313 | 337 |
314 static Object* StoreKeyedToSuper(Isolate* isolate, Handle<JSObject> home_object, | 338 static Object* StoreKeyedToSuper(Isolate* isolate, Handle<JSObject> home_object, |
315 Handle<Object> receiver, Handle<Object> key, | 339 Handle<Object> receiver, Handle<Object> key, |
316 Handle<Object> value, StrictMode strict_mode) { | 340 Handle<Object> value, StrictMode strict_mode) { |
| 341 uint32_t index; |
| 342 |
| 343 if (key->ToArrayIndex(&index)) { |
| 344 return StoreElementToSuper(isolate, home_object, receiver, index, value, |
| 345 strict_mode); |
| 346 } |
317 Handle<Name> name; | 347 Handle<Name> name; |
318 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 348 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
319 Runtime::ToName(isolate, key)); | 349 Runtime::ToName(isolate, key)); |
320 uint32_t index; | |
321 if (name->AsArrayIndex(&index)) { | 350 if (name->AsArrayIndex(&index)) { |
322 // TODO(dslomov): Implement. | 351 return StoreElementToSuper(isolate, home_object, receiver, index, value, |
323 return ThrowUnsupportedSuper(isolate); | 352 strict_mode); |
324 } | 353 } |
325 return StoreToSuper(isolate, home_object, receiver, name, value, strict_mode); | 354 return StoreToSuper(isolate, home_object, receiver, name, value, strict_mode); |
326 } | 355 } |
327 | 356 |
328 | 357 |
329 RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Strict) { | 358 RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Strict) { |
330 HandleScope scope(isolate); | 359 HandleScope scope(isolate); |
331 DCHECK(args.length() == 4); | 360 DCHECK(args.length() == 4); |
332 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 361 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
333 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 362 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
334 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); | 363 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); |
335 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); | 364 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); |
336 | 365 |
337 return StoreKeyedToSuper(isolate, home_object, receiver, key, value, STRICT); | 366 return StoreKeyedToSuper(isolate, home_object, receiver, key, value, STRICT); |
338 } | 367 } |
339 | 368 |
340 | 369 |
341 RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Sloppy) { | 370 RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Sloppy) { |
342 HandleScope scope(isolate); | 371 HandleScope scope(isolate); |
343 DCHECK(args.length() == 4); | 372 DCHECK(args.length() == 4); |
344 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 373 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
345 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 374 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
346 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); | 375 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); |
347 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); | 376 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); |
348 | 377 |
349 return StoreKeyedToSuper(isolate, home_object, receiver, key, value, SLOPPY); | 378 return StoreKeyedToSuper(isolate, home_object, receiver, key, value, SLOPPY); |
350 } | 379 } |
351 } | 380 } |
352 } // namespace v8::internal | 381 } // namespace v8::internal |
OLD | NEW |