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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 return isolate->ThrowIllegalOperation(); | 238 return isolate->ThrowIllegalOperation(); |
238 } | 239 } |
239 | 240 |
240 Handle<String> source(String::cast(Handle<Script>::cast(script)->source())); | 241 Handle<String> source(String::cast(Handle<Script>::cast(script)->source())); |
241 return *isolate->factory()->NewSubString( | 242 return *isolate->factory()->NewSubString( |
242 source, Handle<Smi>::cast(start_position)->value(), | 243 source, Handle<Smi>::cast(start_position)->value(), |
243 Handle<Smi>::cast(end_position)->value()); | 244 Handle<Smi>::cast(end_position)->value()); |
244 } | 245 } |
245 | 246 |
246 | 247 |
247 static Object* LoadFromSuper(Isolate* isolate, Handle<Object> receiver, | 248 static MaybeHandle<Object> LoadFromSuper(Isolate* isolate, |
248 Handle<JSObject> home_object, Handle<Name> name) { | 249 Handle<Object> receiver, |
| 250 Handle<JSObject> home_object, |
| 251 Handle<Name> name, |
| 252 LanguageMode language_mode) { |
249 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { | 253 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { |
250 isolate->ReportFailedAccessCheck(home_object); | 254 isolate->ReportFailedAccessCheck(home_object); |
251 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 255 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
252 } | 256 } |
253 | 257 |
254 PrototypeIterator iter(isolate, home_object); | 258 PrototypeIterator iter(isolate, home_object); |
255 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); | 259 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); |
256 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value(); | 260 if (!proto->IsJSReceiver()) { |
| 261 return Object::ReadAbsentProperty(isolate, proto, name, language_mode); |
| 262 } |
257 | 263 |
258 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto)); | 264 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto)); |
259 Handle<Object> result; | 265 Handle<Object> result; |
260 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | 266 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, |
261 return *result; | 267 Object::GetProperty(&it, language_mode), Object); |
| 268 return result; |
262 } | 269 } |
263 | 270 |
264 | 271 |
265 static Object* LoadElementFromSuper(Isolate* isolate, Handle<Object> receiver, | 272 static MaybeHandle<Object> LoadElementFromSuper(Isolate* isolate, |
266 Handle<JSObject> home_object, | 273 Handle<Object> receiver, |
267 uint32_t index) { | 274 Handle<JSObject> home_object, |
| 275 uint32_t index, |
| 276 LanguageMode language_mode) { |
268 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { | 277 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { |
269 isolate->ReportFailedAccessCheck(home_object); | 278 isolate->ReportFailedAccessCheck(home_object); |
270 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 279 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
271 } | 280 } |
272 | 281 |
273 PrototypeIterator iter(isolate, home_object); | 282 PrototypeIterator iter(isolate, home_object); |
274 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); | 283 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); |
275 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value(); | 284 if (!proto->IsJSReceiver()) { |
| 285 Handle<Object> name = isolate->factory()->NewNumberFromUint(index); |
| 286 return Object::ReadAbsentProperty(isolate, proto, name, language_mode); |
| 287 } |
276 | 288 |
277 LookupIterator it(isolate, receiver, index, Handle<JSReceiver>::cast(proto)); | 289 LookupIterator it(isolate, receiver, index, Handle<JSReceiver>::cast(proto)); |
278 Handle<Object> result; | 290 Handle<Object> result; |
279 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | 291 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, |
280 return *result; | 292 Object::GetProperty(&it, language_mode), Object); |
| 293 return result; |
281 } | 294 } |
282 | 295 |
283 | 296 |
284 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { | 297 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { |
285 HandleScope scope(isolate); | 298 HandleScope scope(isolate); |
286 DCHECK(args.length() == 3); | 299 DCHECK(args.length() == 4); |
287 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 300 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
288 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 301 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
289 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | 302 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); |
| 303 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); |
290 | 304 |
291 return LoadFromSuper(isolate, receiver, home_object, name); | 305 Handle<Object> result; |
| 306 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 307 isolate, result, |
| 308 LoadFromSuper(isolate, receiver, home_object, name, language_mode)); |
| 309 return *result; |
292 } | 310 } |
293 | 311 |
294 | 312 |
295 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { | 313 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { |
296 HandleScope scope(isolate); | 314 HandleScope scope(isolate); |
297 DCHECK(args.length() == 3); | 315 DCHECK(args.length() == 4); |
298 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 316 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
299 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 317 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
300 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); | 318 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); |
| 319 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); |
301 | 320 |
302 uint32_t index = 0; | 321 uint32_t index = 0; |
| 322 Handle<Object> result; |
| 323 |
303 if (key->ToArrayIndex(&index)) { | 324 if (key->ToArrayIndex(&index)) { |
304 return LoadElementFromSuper(isolate, receiver, home_object, index); | 325 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 326 isolate, result, LoadElementFromSuper(isolate, receiver, home_object, |
| 327 index, language_mode)); |
| 328 return *result; |
305 } | 329 } |
306 | 330 |
307 Handle<Name> name; | 331 Handle<Name> name; |
308 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 332 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
309 Runtime::ToName(isolate, key)); | 333 Runtime::ToName(isolate, key)); |
310 // TODO(verwaest): Unify using LookupIterator. | 334 // TODO(verwaest): Unify using LookupIterator. |
311 if (name->AsArrayIndex(&index)) { | 335 if (name->AsArrayIndex(&index)) { |
312 return LoadElementFromSuper(isolate, receiver, home_object, index); | 336 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 337 isolate, result, LoadElementFromSuper(isolate, receiver, home_object, |
| 338 index, language_mode)); |
| 339 return *result; |
313 } | 340 } |
314 return LoadFromSuper(isolate, receiver, home_object, name); | 341 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 342 isolate, result, |
| 343 LoadFromSuper(isolate, receiver, home_object, name, language_mode)); |
| 344 return *result; |
315 } | 345 } |
316 | 346 |
317 | 347 |
318 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, | 348 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, |
319 Handle<Object> receiver, Handle<Name> name, | 349 Handle<Object> receiver, Handle<Name> name, |
320 Handle<Object> value, LanguageMode language_mode) { | 350 Handle<Object> value, LanguageMode language_mode) { |
321 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { | 351 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { |
322 isolate->ReportFailedAccessCheck(home_object); | 352 isolate->ReportFailedAccessCheck(home_object); |
323 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 353 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
324 } | 354 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 return nullptr; | 480 return nullptr; |
451 } | 481 } |
452 | 482 |
453 | 483 |
454 RUNTIME_FUNCTION(Runtime_CallSuperWithSpread) { | 484 RUNTIME_FUNCTION(Runtime_CallSuperWithSpread) { |
455 UNIMPLEMENTED(); | 485 UNIMPLEMENTED(); |
456 return nullptr; | 486 return nullptr; |
457 } | 487 } |
458 } // namespace internal | 488 } // namespace internal |
459 } // namespace v8 | 489 } // namespace v8 |
OLD | NEW |