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/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 prototype_parent = isolate->factory()->null_value(); | 113 prototype_parent = isolate->factory()->null_value(); |
114 } else if (super_class->IsSpecFunction()) { | 114 } else if (super_class->IsSpecFunction()) { |
115 if (Handle<JSFunction>::cast(super_class)->shared()->is_generator()) { | 115 if (Handle<JSFunction>::cast(super_class)->shared()->is_generator()) { |
116 THROW_NEW_ERROR_RETURN_FAILURE( | 116 THROW_NEW_ERROR_RETURN_FAILURE( |
117 isolate, | 117 isolate, |
118 NewTypeError(MessageTemplate::kExtendsValueGenerator, super_class)); | 118 NewTypeError(MessageTemplate::kExtendsValueGenerator, super_class)); |
119 } | 119 } |
120 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 120 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
121 isolate, prototype_parent, | 121 isolate, prototype_parent, |
122 Runtime::GetObjectProperty(isolate, super_class, | 122 Runtime::GetObjectProperty(isolate, super_class, |
123 isolate->factory()->prototype_string())); | 123 isolate->factory()->prototype_string(), |
| 124 SLOPPY)); |
124 if (!prototype_parent->IsNull() && !prototype_parent->IsSpecObject()) { | 125 if (!prototype_parent->IsNull() && !prototype_parent->IsSpecObject()) { |
125 THROW_NEW_ERROR_RETURN_FAILURE( | 126 THROW_NEW_ERROR_RETURN_FAILURE( |
126 isolate, NewTypeError(MessageTemplate::kPrototypeParentNotAnObject, | 127 isolate, NewTypeError(MessageTemplate::kPrototypeParentNotAnObject, |
127 prototype_parent)); | 128 prototype_parent)); |
128 } | 129 } |
129 constructor_parent = super_class; | 130 constructor_parent = super_class; |
130 } else { | 131 } else { |
131 // TODO(arv): Should be IsConstructor. | 132 // TODO(arv): Should be IsConstructor. |
132 THROW_NEW_ERROR_RETURN_FAILURE( | 133 THROW_NEW_ERROR_RETURN_FAILURE( |
133 isolate, | 134 isolate, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 return isolate->ThrowIllegalOperation(); | 245 return isolate->ThrowIllegalOperation(); |
245 } | 246 } |
246 | 247 |
247 Handle<String> source(String::cast(Handle<Script>::cast(script)->source())); | 248 Handle<String> source(String::cast(Handle<Script>::cast(script)->source())); |
248 return *isolate->factory()->NewSubString( | 249 return *isolate->factory()->NewSubString( |
249 source, Handle<Smi>::cast(start_position)->value(), | 250 source, Handle<Smi>::cast(start_position)->value(), |
250 Handle<Smi>::cast(end_position)->value()); | 251 Handle<Smi>::cast(end_position)->value()); |
251 } | 252 } |
252 | 253 |
253 | 254 |
254 static Object* LoadFromSuper(Isolate* isolate, Handle<Object> receiver, | 255 static MaybeHandle<Object> LoadFromSuper(Isolate* isolate, |
255 Handle<JSObject> home_object, Handle<Name> name) { | 256 Handle<Object> receiver, |
| 257 Handle<JSObject> home_object, |
| 258 Handle<Name> name, |
| 259 LanguageMode language_mode) { |
256 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { | 260 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { |
257 isolate->ReportFailedAccessCheck(home_object); | 261 isolate->ReportFailedAccessCheck(home_object); |
258 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 262 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
259 } | 263 } |
260 | 264 |
261 PrototypeIterator iter(isolate, home_object); | 265 PrototypeIterator iter(isolate, home_object); |
262 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); | 266 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); |
263 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value(); | 267 if (!proto->IsJSReceiver()) { |
| 268 return Object::ReadAbsentProperty(isolate, proto, name, language_mode); |
| 269 } |
264 | 270 |
265 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto)); | 271 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto)); |
266 Handle<Object> result; | 272 Handle<Object> result; |
267 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | 273 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, |
268 return *result; | 274 Object::GetProperty(&it, language_mode), Object); |
| 275 return result; |
269 } | 276 } |
270 | 277 |
271 | 278 |
272 static Object* LoadElementFromSuper(Isolate* isolate, Handle<Object> receiver, | 279 static MaybeHandle<Object> LoadElementFromSuper(Isolate* isolate, |
273 Handle<JSObject> home_object, | 280 Handle<Object> receiver, |
274 uint32_t index) { | 281 Handle<JSObject> home_object, |
| 282 uint32_t index, |
| 283 LanguageMode language_mode) { |
275 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { | 284 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { |
276 isolate->ReportFailedAccessCheck(home_object); | 285 isolate->ReportFailedAccessCheck(home_object); |
277 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 286 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
278 } | 287 } |
279 | 288 |
280 PrototypeIterator iter(isolate, home_object); | 289 PrototypeIterator iter(isolate, home_object); |
281 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); | 290 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); |
282 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value(); | 291 if (!proto->IsJSReceiver()) { |
| 292 Handle<Object> name = isolate->factory()->NewNumberFromUint(index); |
| 293 return Object::ReadAbsentProperty(isolate, proto, name, language_mode); |
| 294 } |
283 | 295 |
284 LookupIterator it(isolate, receiver, index, Handle<JSReceiver>::cast(proto)); | 296 LookupIterator it(isolate, receiver, index, Handle<JSReceiver>::cast(proto)); |
285 Handle<Object> result; | 297 Handle<Object> result; |
286 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | 298 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, |
287 return *result; | 299 Object::GetProperty(&it, language_mode), Object); |
| 300 return result; |
288 } | 301 } |
289 | 302 |
290 | 303 |
291 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { | 304 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { |
292 HandleScope scope(isolate); | 305 HandleScope scope(isolate); |
293 DCHECK(args.length() == 3); | 306 DCHECK(args.length() == 4); |
294 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 307 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
295 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 308 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
296 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | 309 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); |
| 310 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); |
297 | 311 |
298 return LoadFromSuper(isolate, receiver, home_object, name); | 312 Handle<Object> result; |
| 313 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 314 isolate, result, |
| 315 LoadFromSuper(isolate, receiver, home_object, name, language_mode)); |
| 316 return *result; |
299 } | 317 } |
300 | 318 |
301 | 319 |
302 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { | 320 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { |
303 HandleScope scope(isolate); | 321 HandleScope scope(isolate); |
304 DCHECK(args.length() == 3); | 322 DCHECK(args.length() == 4); |
305 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 323 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
306 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 324 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
307 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); | 325 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); |
| 326 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); |
308 | 327 |
309 uint32_t index = 0; | 328 uint32_t index = 0; |
| 329 Handle<Object> result; |
| 330 |
310 if (key->ToArrayIndex(&index)) { | 331 if (key->ToArrayIndex(&index)) { |
311 return LoadElementFromSuper(isolate, receiver, home_object, index); | 332 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 333 isolate, result, LoadElementFromSuper(isolate, receiver, home_object, |
| 334 index, language_mode)); |
| 335 return *result; |
312 } | 336 } |
313 | 337 |
314 Handle<Name> name; | 338 Handle<Name> name; |
315 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 339 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
316 Runtime::ToName(isolate, key)); | 340 Runtime::ToName(isolate, key)); |
317 if (name->AsArrayIndex(&index)) { | 341 if (name->AsArrayIndex(&index)) { |
318 return LoadElementFromSuper(isolate, receiver, home_object, index); | 342 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 343 isolate, result, LoadElementFromSuper(isolate, receiver, home_object, |
| 344 index, language_mode)); |
| 345 return *result; |
319 } | 346 } |
320 return LoadFromSuper(isolate, receiver, home_object, name); | 347 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 348 isolate, result, |
| 349 LoadFromSuper(isolate, receiver, home_object, name, language_mode)); |
| 350 return *result; |
321 } | 351 } |
322 | 352 |
323 | 353 |
324 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, | 354 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, |
325 Handle<Object> receiver, Handle<Name> name, | 355 Handle<Object> receiver, Handle<Name> name, |
326 Handle<Object> value, LanguageMode language_mode) { | 356 Handle<Object> value, LanguageMode language_mode) { |
327 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { | 357 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { |
328 isolate->ReportFailedAccessCheck(home_object); | 358 isolate->ReportFailedAccessCheck(home_object); |
329 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 359 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
330 } | 360 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 return nullptr; | 484 return nullptr; |
455 } | 485 } |
456 | 486 |
457 | 487 |
458 RUNTIME_FUNCTION(Runtime_CallSuperWithSpread) { | 488 RUNTIME_FUNCTION(Runtime_CallSuperWithSpread) { |
459 UNIMPLEMENTED(); | 489 UNIMPLEMENTED(); |
460 return nullptr; | 490 return nullptr; |
461 } | 491 } |
462 } // namespace internal | 492 } // namespace internal |
463 } // namespace v8 | 493 } // namespace v8 |
OLD | NEW |