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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Object* LoadFromSuper(Isolate* isolate, Handle<Object> receiver, |
255 Handle<JSObject> home_object, Handle<Name> name) { | 256 Handle<JSObject> home_object, Handle<Name> name, |
| 257 LanguageMode language_mode) { |
256 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { | 258 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { |
257 isolate->ReportFailedAccessCheck(home_object); | 259 isolate->ReportFailedAccessCheck(home_object); |
258 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 260 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
259 } | 261 } |
260 | 262 |
261 PrototypeIterator iter(isolate, home_object); | 263 PrototypeIterator iter(isolate, home_object); |
262 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); | 264 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); |
263 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value(); | 265 if (!proto->IsJSReceiver()) { |
| 266 if (is_strong(language_mode)) { |
| 267 THROW_NEW_ERROR_RETURN_FAILURE( |
| 268 isolate, |
| 269 NewTypeError(MessageTemplate::kStrongPropertyAccess, proto, name)); |
| 270 } |
| 271 return isolate->heap()->undefined_value(); |
| 272 } |
264 | 273 |
265 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto)); | 274 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto)); |
266 Handle<Object> result; | 275 Handle<Object> result; |
267 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | 276 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 277 isolate, result, Object::GetProperty(&it, strength(language_mode))); |
268 return *result; | 278 return *result; |
269 } | 279 } |
270 | 280 |
271 | 281 |
272 static Object* LoadElementFromSuper(Isolate* isolate, Handle<Object> receiver, | 282 static Object* LoadElementFromSuper(Isolate* isolate, Handle<Object> receiver, |
273 Handle<JSObject> home_object, | 283 Handle<JSObject> home_object, |
274 uint32_t index) { | 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_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
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 if (is_strong(language_mode)) { |
| 295 Handle<Object> name = isolate->factory()->NewNumberFromUint(index); |
| 296 THROW_NEW_ERROR_RETURN_FAILURE( |
| 297 isolate, |
| 298 NewTypeError(MessageTemplate::kStrongPropertyAccess, proto, name)); |
| 299 } |
| 300 return isolate->heap()->undefined_value(); |
| 301 } |
283 | 302 |
284 LookupIterator it(isolate, receiver, index, Handle<JSReceiver>::cast(proto)); | 303 LookupIterator it(isolate, receiver, index, Handle<JSReceiver>::cast(proto)); |
285 Handle<Object> result; | 304 Handle<Object> result; |
286 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | 305 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 306 isolate, result, Object::GetProperty(&it, strength(language_mode))); |
287 return *result; | 307 return *result; |
288 } | 308 } |
289 | 309 |
290 | 310 |
291 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { | 311 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { |
292 HandleScope scope(isolate); | 312 HandleScope scope(isolate); |
293 DCHECK(args.length() == 3); | 313 DCHECK(args.length() == 4); |
294 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 314 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
295 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 315 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
296 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | 316 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); |
| 317 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); |
297 | 318 |
298 return LoadFromSuper(isolate, receiver, home_object, name); | 319 return LoadFromSuper(isolate, receiver, home_object, name, language_mode); |
299 } | 320 } |
300 | 321 |
301 | 322 |
302 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { | 323 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { |
303 HandleScope scope(isolate); | 324 HandleScope scope(isolate); |
304 DCHECK(args.length() == 3); | 325 DCHECK(args.length() == 4); |
305 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 326 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
306 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 327 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
307 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); | 328 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); |
| 329 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); |
308 | 330 |
309 uint32_t index = 0; | 331 uint32_t index = 0; |
310 if (key->ToArrayIndex(&index)) { | 332 if (key->ToArrayIndex(&index)) { |
311 return LoadElementFromSuper(isolate, receiver, home_object, index); | 333 return LoadElementFromSuper(isolate, receiver, home_object, index, |
| 334 language_mode); |
312 } | 335 } |
313 | 336 |
314 Handle<Name> name; | 337 Handle<Name> name; |
315 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 338 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
316 Runtime::ToName(isolate, key)); | 339 Runtime::ToName(isolate, key)); |
317 if (name->AsArrayIndex(&index)) { | 340 if (name->AsArrayIndex(&index)) { |
318 return LoadElementFromSuper(isolate, receiver, home_object, index); | 341 return LoadElementFromSuper(isolate, receiver, home_object, index, |
| 342 language_mode); |
319 } | 343 } |
320 return LoadFromSuper(isolate, receiver, home_object, name); | 344 return LoadFromSuper(isolate, receiver, home_object, name, language_mode); |
321 } | 345 } |
322 | 346 |
323 | 347 |
324 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, | 348 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, |
325 Handle<Object> receiver, Handle<Name> name, | 349 Handle<Object> receiver, Handle<Name> name, |
326 Handle<Object> value, LanguageMode language_mode) { | 350 Handle<Object> value, LanguageMode language_mode) { |
327 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { | 351 if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) { |
328 isolate->ReportFailedAccessCheck(home_object); | 352 isolate->ReportFailedAccessCheck(home_object); |
329 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 353 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
330 } | 354 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 return nullptr; | 478 return nullptr; |
455 } | 479 } |
456 | 480 |
457 | 481 |
458 RUNTIME_FUNCTION(Runtime_CallSuperWithSpread) { | 482 RUNTIME_FUNCTION(Runtime_CallSuperWithSpread) { |
459 UNIMPLEMENTED(); | 483 UNIMPLEMENTED(); |
460 return nullptr; | 484 return nullptr; |
461 } | 485 } |
462 } // namespace internal | 486 } // namespace internal |
463 } // namespace v8 | 487 } // namespace v8 |
OLD | NEW |