| 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 Strength::WEAK)); |
| 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, |
| 269 strength(language_mode)); |
| 270 } |
| 264 | 271 |
| 265 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto)); | 272 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto)); |
| 266 Handle<Object> result; | 273 Handle<Object> result; |
| 267 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | 274 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, |
| 268 return *result; | 275 Object::GetProperty(&it, strength(language_mode)), |
| 276 Object); |
| 277 return result; |
| 269 } | 278 } |
| 270 | 279 |
| 271 | 280 |
| 272 static Object* LoadElementFromSuper(Isolate* isolate, Handle<Object> receiver, | 281 static MaybeHandle<Object> LoadElementFromSuper(Isolate* isolate, |
| 273 Handle<JSObject> home_object, | 282 Handle<Object> receiver, |
| 274 uint32_t index) { | 283 Handle<JSObject> home_object, |
| 284 uint32_t index, |
| 285 LanguageMode language_mode) { |
| 275 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { | 286 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { |
| 276 isolate->ReportFailedAccessCheck(home_object); | 287 isolate->ReportFailedAccessCheck(home_object); |
| 277 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 288 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 278 } | 289 } |
| 279 | 290 |
| 280 PrototypeIterator iter(isolate, home_object); | 291 PrototypeIterator iter(isolate, home_object); |
| 281 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); | 292 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); |
| 282 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value(); | 293 if (!proto->IsJSReceiver()) { |
| 294 Handle<Object> name = isolate->factory()->NewNumberFromUint(index); |
| 295 return Object::ReadAbsentProperty(isolate, proto, name, |
| 296 strength(language_mode)); |
| 297 } |
| 283 | 298 |
| 284 LookupIterator it(isolate, receiver, index, Handle<JSReceiver>::cast(proto)); | 299 LookupIterator it(isolate, receiver, index, Handle<JSReceiver>::cast(proto)); |
| 285 Handle<Object> result; | 300 Handle<Object> result; |
| 286 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | 301 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, |
| 287 return *result; | 302 Object::GetProperty(&it, strength(language_mode)), |
| 303 Object); |
| 304 return result; |
| 288 } | 305 } |
| 289 | 306 |
| 290 | 307 |
| 291 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { | 308 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { |
| 292 HandleScope scope(isolate); | 309 HandleScope scope(isolate); |
| 293 DCHECK(args.length() == 3); | 310 DCHECK(args.length() == 4); |
| 294 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 311 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
| 295 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 312 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
| 296 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | 313 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); |
| 314 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); |
| 297 | 315 |
| 298 return LoadFromSuper(isolate, receiver, home_object, name); | 316 Handle<Object> result; |
| 317 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 318 isolate, result, |
| 319 LoadFromSuper(isolate, receiver, home_object, name, language_mode)); |
| 320 return *result; |
| 299 } | 321 } |
| 300 | 322 |
| 301 | 323 |
| 302 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { | 324 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { |
| 303 HandleScope scope(isolate); | 325 HandleScope scope(isolate); |
| 304 DCHECK(args.length() == 3); | 326 DCHECK(args.length() == 4); |
| 305 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 327 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
| 306 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 328 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
| 307 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); | 329 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); |
| 330 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); |
| 308 | 331 |
| 309 uint32_t index = 0; | 332 uint32_t index = 0; |
| 333 Handle<Object> result; |
| 334 |
| 310 if (key->ToArrayIndex(&index)) { | 335 if (key->ToArrayIndex(&index)) { |
| 311 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; |
| 312 } | 340 } |
| 313 | 341 |
| 314 Handle<Name> name; | 342 Handle<Name> name; |
| 315 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 343 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
| 316 Runtime::ToName(isolate, key)); | 344 Runtime::ToName(isolate, key)); |
| 317 if (name->AsArrayIndex(&index)) { | 345 if (name->AsArrayIndex(&index)) { |
| 318 return LoadElementFromSuper(isolate, receiver, home_object, index); | 346 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 347 isolate, result, LoadElementFromSuper(isolate, receiver, home_object, |
| 348 index, language_mode)); |
| 349 return *result; |
| 319 } | 350 } |
| 320 return LoadFromSuper(isolate, receiver, home_object, name); | 351 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 352 isolate, result, |
| 353 LoadFromSuper(isolate, receiver, home_object, name, language_mode)); |
| 354 return *result; |
| 321 } | 355 } |
| 322 | 356 |
| 323 | 357 |
| 324 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, | 358 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, |
| 325 Handle<Object> receiver, Handle<Name> name, | 359 Handle<Object> receiver, Handle<Name> name, |
| 326 Handle<Object> value, LanguageMode language_mode) { | 360 Handle<Object> value, LanguageMode language_mode) { |
| 327 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { | 361 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { |
| 328 isolate->ReportFailedAccessCheck(home_object); | 362 isolate->ReportFailedAccessCheck(home_object); |
| 329 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 363 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 330 } | 364 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 return nullptr; | 488 return nullptr; |
| 455 } | 489 } |
| 456 | 490 |
| 457 | 491 |
| 458 RUNTIME_FUNCTION(Runtime_CallSuperWithSpread) { | 492 RUNTIME_FUNCTION(Runtime_CallSuperWithSpread) { |
| 459 UNIMPLEMENTED(); | 493 UNIMPLEMENTED(); |
| 460 return nullptr; | 494 return nullptr; |
| 461 } | 495 } |
| 462 } // namespace internal | 496 } // namespace internal |
| 463 } // namespace v8 | 497 } // namespace v8 |
| OLD | NEW |