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 |
| 297 // TODO(conradw): It would be more efficient to have a separate runtime function |
| 298 // for strong mode. |
284 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { | 299 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { |
285 HandleScope scope(isolate); | 300 HandleScope scope(isolate); |
286 DCHECK(args.length() == 3); | 301 DCHECK(args.length() == 4); |
287 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 302 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
288 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 303 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
289 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | 304 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); |
| 305 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); |
290 | 306 |
291 return LoadFromSuper(isolate, receiver, home_object, name); | 307 Handle<Object> result; |
| 308 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 309 isolate, result, |
| 310 LoadFromSuper(isolate, receiver, home_object, name, language_mode)); |
| 311 return *result; |
292 } | 312 } |
293 | 313 |
294 | 314 |
295 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { | 315 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { |
296 HandleScope scope(isolate); | 316 HandleScope scope(isolate); |
297 DCHECK(args.length() == 3); | 317 DCHECK(args.length() == 4); |
298 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 318 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
299 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 319 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
300 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); | 320 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); |
| 321 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); |
301 | 322 |
302 uint32_t index = 0; | 323 uint32_t index = 0; |
| 324 Handle<Object> result; |
| 325 |
303 if (key->ToArrayIndex(&index)) { | 326 if (key->ToArrayIndex(&index)) { |
304 return LoadElementFromSuper(isolate, receiver, home_object, index); | 327 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 328 isolate, result, LoadElementFromSuper(isolate, receiver, home_object, |
| 329 index, language_mode)); |
| 330 return *result; |
305 } | 331 } |
306 | 332 |
307 Handle<Name> name; | 333 Handle<Name> name; |
308 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 334 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
309 Runtime::ToName(isolate, key)); | 335 Runtime::ToName(isolate, key)); |
310 // TODO(verwaest): Unify using LookupIterator. | 336 // TODO(verwaest): Unify using LookupIterator. |
311 if (name->AsArrayIndex(&index)) { | 337 if (name->AsArrayIndex(&index)) { |
312 return LoadElementFromSuper(isolate, receiver, home_object, index); | 338 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 339 isolate, result, LoadElementFromSuper(isolate, receiver, home_object, |
| 340 index, language_mode)); |
| 341 return *result; |
313 } | 342 } |
314 return LoadFromSuper(isolate, receiver, home_object, name); | 343 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 344 isolate, result, |
| 345 LoadFromSuper(isolate, receiver, home_object, name, language_mode)); |
| 346 return *result; |
315 } | 347 } |
316 | 348 |
317 | 349 |
318 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, | 350 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, |
319 Handle<Object> receiver, Handle<Name> name, | 351 Handle<Object> receiver, Handle<Name> name, |
320 Handle<Object> value, LanguageMode language_mode) { | 352 Handle<Object> value, LanguageMode language_mode) { |
321 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { | 353 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { |
322 isolate->ReportFailedAccessCheck(home_object); | 354 isolate->ReportFailedAccessCheck(home_object); |
323 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 355 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
324 } | 356 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 return nullptr; | 482 return nullptr; |
451 } | 483 } |
452 | 484 |
453 | 485 |
454 RUNTIME_FUNCTION(Runtime_CallSuperWithSpread) { | 486 RUNTIME_FUNCTION(Runtime_CallSuperWithSpread) { |
455 UNIMPLEMENTED(); | 487 UNIMPLEMENTED(); |
456 return nullptr; | 488 return nullptr; |
457 } | 489 } |
458 } // namespace internal | 490 } // namespace internal |
459 } // namespace v8 | 491 } // namespace v8 |
OLD | NEW |