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