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 "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 if (!success) return MaybeHandle<Object>(); | 290 if (!success) return MaybeHandle<Object>(); |
291 | 291 |
292 MAYBE_RETURN_NULL(Object::SetProperty(&it, value, language_mode, | 292 MAYBE_RETURN_NULL(Object::SetProperty(&it, value, language_mode, |
293 Object::MAY_BE_STORE_FROM_KEYED)); | 293 Object::MAY_BE_STORE_FROM_KEYED)); |
294 return value; | 294 return value; |
295 } | 295 } |
296 | 296 |
297 | 297 |
298 RUNTIME_FUNCTION(Runtime_GetPrototype) { | 298 RUNTIME_FUNCTION(Runtime_GetPrototype) { |
299 HandleScope scope(isolate); | 299 HandleScope scope(isolate); |
300 DCHECK(args.length() == 1); | 300 DCHECK_EQ(1, args.length()); |
301 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); | 301 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); |
302 RETURN_RESULT_OR_FAILURE(isolate, JSReceiver::GetPrototype(isolate, obj)); | 302 RETURN_RESULT_OR_FAILURE(isolate, JSReceiver::GetPrototype(isolate, obj)); |
303 } | 303 } |
304 | 304 |
305 | 305 |
306 RUNTIME_FUNCTION(Runtime_InternalSetPrototype) { | 306 RUNTIME_FUNCTION(Runtime_InternalSetPrototype) { |
307 HandleScope scope(isolate); | 307 HandleScope scope(isolate); |
308 DCHECK(args.length() == 2); | 308 DCHECK_EQ(2, args.length()); |
309 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); | 309 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); |
310 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); | 310 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); |
311 MAYBE_RETURN( | 311 MAYBE_RETURN( |
312 JSReceiver::SetPrototype(obj, prototype, false, Object::THROW_ON_ERROR), | 312 JSReceiver::SetPrototype(obj, prototype, false, Object::THROW_ON_ERROR), |
313 isolate->heap()->exception()); | 313 isolate->heap()->exception()); |
314 return *obj; | 314 return *obj; |
315 } | 315 } |
316 | 316 |
317 RUNTIME_FUNCTION(Runtime_OptimizeObjectForAddingMultipleProperties) { | 317 RUNTIME_FUNCTION(Runtime_OptimizeObjectForAddingMultipleProperties) { |
318 HandleScope scope(isolate); | 318 HandleScope scope(isolate); |
319 DCHECK(args.length() == 2); | 319 DCHECK_EQ(2, args.length()); |
320 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 320 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
321 CONVERT_SMI_ARG_CHECKED(properties, 1); | 321 CONVERT_SMI_ARG_CHECKED(properties, 1); |
322 // Conservative upper limit to prevent fuzz tests from going OOM. | 322 // Conservative upper limit to prevent fuzz tests from going OOM. |
323 if (properties > 100000) return isolate->ThrowIllegalOperation(); | 323 if (properties > 100000) return isolate->ThrowIllegalOperation(); |
324 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { | 324 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { |
325 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties, | 325 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties, |
326 "OptimizeForAdding"); | 326 "OptimizeForAdding"); |
327 } | 327 } |
328 return *object; | 328 return *object; |
329 } | 329 } |
330 | 330 |
331 | 331 |
332 RUNTIME_FUNCTION(Runtime_GetProperty) { | 332 RUNTIME_FUNCTION(Runtime_GetProperty) { |
333 HandleScope scope(isolate); | 333 HandleScope scope(isolate); |
334 DCHECK(args.length() == 2); | 334 DCHECK_EQ(2, args.length()); |
335 | 335 |
336 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 336 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
337 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 337 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
338 | 338 |
339 RETURN_RESULT_OR_FAILURE(isolate, | 339 RETURN_RESULT_OR_FAILURE(isolate, |
340 Runtime::GetObjectProperty(isolate, object, key)); | 340 Runtime::GetObjectProperty(isolate, object, key)); |
341 } | 341 } |
342 | 342 |
343 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. | 343 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. |
344 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { | 344 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { |
345 HandleScope scope(isolate); | 345 HandleScope scope(isolate); |
346 DCHECK(args.length() == 2); | 346 DCHECK_EQ(2, args.length()); |
347 | 347 |
348 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); | 348 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); |
349 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); | 349 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); |
350 | 350 |
351 RETURN_RESULT_OR_FAILURE( | 351 RETURN_RESULT_OR_FAILURE( |
352 isolate, KeyedGetObjectProperty(isolate, receiver_obj, key_obj)); | 352 isolate, KeyedGetObjectProperty(isolate, receiver_obj, key_obj)); |
353 } | 353 } |
354 | 354 |
355 RUNTIME_FUNCTION(Runtime_AddNamedProperty) { | 355 RUNTIME_FUNCTION(Runtime_AddNamedProperty) { |
356 HandleScope scope(isolate); | 356 HandleScope scope(isolate); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 496 |
497 // Lookup the {name} on {receiver}. | 497 // Lookup the {name} on {receiver}. |
498 Maybe<bool> maybe = JSReceiver::HasProperty(receiver, name); | 498 Maybe<bool> maybe = JSReceiver::HasProperty(receiver, name); |
499 if (!maybe.IsJust()) return isolate->heap()->exception(); | 499 if (!maybe.IsJust()) return isolate->heap()->exception(); |
500 return isolate->heap()->ToBoolean(maybe.FromJust()); | 500 return isolate->heap()->ToBoolean(maybe.FromJust()); |
501 } | 501 } |
502 | 502 |
503 | 503 |
504 RUNTIME_FUNCTION(Runtime_GetOwnPropertyKeys) { | 504 RUNTIME_FUNCTION(Runtime_GetOwnPropertyKeys) { |
505 HandleScope scope(isolate); | 505 HandleScope scope(isolate); |
506 DCHECK(args.length() == 2); | 506 DCHECK_EQ(2, args.length()); |
507 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 507 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
508 CONVERT_SMI_ARG_CHECKED(filter_value, 1); | 508 CONVERT_SMI_ARG_CHECKED(filter_value, 1); |
509 PropertyFilter filter = static_cast<PropertyFilter>(filter_value); | 509 PropertyFilter filter = static_cast<PropertyFilter>(filter_value); |
510 | 510 |
511 Handle<FixedArray> keys; | 511 Handle<FixedArray> keys; |
512 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 512 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
513 isolate, keys, | 513 isolate, keys, |
514 KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly, filter, | 514 KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly, filter, |
515 GetKeysConversion::kConvertToString)); | 515 GetKeysConversion::kConvertToString)); |
516 | 516 |
517 return *isolate->factory()->NewJSArrayWithElements(keys); | 517 return *isolate->factory()->NewJSArrayWithElements(keys); |
518 } | 518 } |
519 | 519 |
520 | 520 |
521 // Return information on whether an object has a named or indexed interceptor. | 521 // Return information on whether an object has a named or indexed interceptor. |
522 // args[0]: object | 522 // args[0]: object |
523 RUNTIME_FUNCTION(Runtime_GetInterceptorInfo) { | 523 RUNTIME_FUNCTION(Runtime_GetInterceptorInfo) { |
524 HandleScope scope(isolate); | 524 HandleScope scope(isolate); |
525 DCHECK(args.length() == 1); | 525 DCHECK_EQ(1, args.length()); |
526 if (!args[0]->IsJSObject()) { | 526 if (!args[0]->IsJSObject()) { |
527 return Smi::kZero; | 527 return Smi::kZero; |
528 } | 528 } |
529 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 529 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
530 | 530 |
531 int result = 0; | 531 int result = 0; |
532 if (obj->HasNamedInterceptor()) result |= 2; | 532 if (obj->HasNamedInterceptor()) result |= 2; |
533 if (obj->HasIndexedInterceptor()) result |= 1; | 533 if (obj->HasIndexedInterceptor()) result |= 1; |
534 | 534 |
535 return Smi::FromInt(result); | 535 return Smi::FromInt(result); |
536 } | 536 } |
537 | 537 |
538 | 538 |
539 RUNTIME_FUNCTION(Runtime_ToFastProperties) { | 539 RUNTIME_FUNCTION(Runtime_ToFastProperties) { |
540 HandleScope scope(isolate); | 540 HandleScope scope(isolate); |
541 DCHECK(args.length() == 1); | 541 DCHECK_EQ(1, args.length()); |
542 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 542 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
543 if (object->IsJSObject() && !object->IsJSGlobalObject()) { | 543 if (object->IsJSObject() && !object->IsJSGlobalObject()) { |
544 JSObject::MigrateSlowToFast(Handle<JSObject>::cast(object), 0, | 544 JSObject::MigrateSlowToFast(Handle<JSObject>::cast(object), 0, |
545 "RuntimeToFastProperties"); | 545 "RuntimeToFastProperties"); |
546 } | 546 } |
547 return *object; | 547 return *object; |
548 } | 548 } |
549 | 549 |
550 | 550 |
551 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { | 551 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { |
552 HandleScope scope(isolate); | 552 HandleScope scope(isolate); |
553 DCHECK(args.length() == 0); | 553 DCHECK_EQ(0, args.length()); |
554 return *isolate->factory()->NewHeapNumber(0); | 554 return *isolate->factory()->NewHeapNumber(0); |
555 } | 555 } |
556 | 556 |
557 | 557 |
558 RUNTIME_FUNCTION(Runtime_NewObject) { | 558 RUNTIME_FUNCTION(Runtime_NewObject) { |
559 HandleScope scope(isolate); | 559 HandleScope scope(isolate); |
560 DCHECK_EQ(2, args.length()); | 560 DCHECK_EQ(2, args.length()); |
561 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); | 561 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); |
562 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, new_target, 1); | 562 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, new_target, 1); |
563 RETURN_RESULT_OR_FAILURE(isolate, JSObject::New(target, new_target)); | 563 RETURN_RESULT_OR_FAILURE(isolate, JSObject::New(target, new_target)); |
564 } | 564 } |
565 | 565 |
566 | 566 |
567 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) { | 567 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) { |
568 HandleScope scope(isolate); | 568 HandleScope scope(isolate); |
569 DCHECK(args.length() == 1); | 569 DCHECK_EQ(1, args.length()); |
570 | 570 |
571 CONVERT_ARG_HANDLE_CHECKED(Map, initial_map, 0); | 571 CONVERT_ARG_HANDLE_CHECKED(Map, initial_map, 0); |
572 initial_map->CompleteInobjectSlackTracking(); | 572 initial_map->CompleteInobjectSlackTracking(); |
573 | 573 |
574 return isolate->heap()->undefined_value(); | 574 return isolate->heap()->undefined_value(); |
575 } | 575 } |
576 | 576 |
577 | 577 |
578 RUNTIME_FUNCTION(Runtime_LoadMutableDouble) { | 578 RUNTIME_FUNCTION(Runtime_LoadMutableDouble) { |
579 HandleScope scope(isolate); | 579 HandleScope scope(isolate); |
580 DCHECK(args.length() == 2); | 580 DCHECK_EQ(2, args.length()); |
581 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 581 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
582 CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1); | 582 CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1); |
583 CHECK((index->value() & 1) == 1); | 583 CHECK((index->value() & 1) == 1); |
584 FieldIndex field_index = | 584 FieldIndex field_index = |
585 FieldIndex::ForLoadByFieldIndex(object->map(), index->value()); | 585 FieldIndex::ForLoadByFieldIndex(object->map(), index->value()); |
586 if (field_index.is_inobject()) { | 586 if (field_index.is_inobject()) { |
587 CHECK(field_index.property_index() < | 587 CHECK(field_index.property_index() < |
588 object->map()->GetInObjectProperties()); | 588 object->map()->GetInObjectProperties()); |
589 } else { | 589 } else { |
590 CHECK(field_index.outobject_array_index() < object->properties()->length()); | 590 CHECK(field_index.outobject_array_index() < object->properties()->length()); |
591 } | 591 } |
592 return *JSObject::FastPropertyAt(object, Representation::Double(), | 592 return *JSObject::FastPropertyAt(object, Representation::Double(), |
593 field_index); | 593 field_index); |
594 } | 594 } |
595 | 595 |
596 | 596 |
597 RUNTIME_FUNCTION(Runtime_TryMigrateInstance) { | 597 RUNTIME_FUNCTION(Runtime_TryMigrateInstance) { |
598 HandleScope scope(isolate); | 598 HandleScope scope(isolate); |
599 DCHECK(args.length() == 1); | 599 DCHECK_EQ(1, args.length()); |
600 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 600 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
601 if (!object->IsJSObject()) return Smi::kZero; | 601 if (!object->IsJSObject()) return Smi::kZero; |
602 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 602 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
603 if (!js_object->map()->is_deprecated()) return Smi::kZero; | 603 if (!js_object->map()->is_deprecated()) return Smi::kZero; |
604 // This call must not cause lazy deopts, because it's called from deferred | 604 // This call must not cause lazy deopts, because it's called from deferred |
605 // code where we can't handle lazy deopts for lack of a suitable bailout | 605 // code where we can't handle lazy deopts for lack of a suitable bailout |
606 // ID. So we just try migration and signal failure if necessary, | 606 // ID. So we just try migration and signal failure if necessary, |
607 // which will also trigger a deopt. | 607 // which will also trigger a deopt. |
608 if (!JSObject::TryMigrateInstance(js_object)) return Smi::kZero; | 608 if (!JSObject::TryMigrateInstance(js_object)) return Smi::kZero; |
609 return *object; | 609 return *object; |
610 } | 610 } |
611 | 611 |
612 | 612 |
613 RUNTIME_FUNCTION(Runtime_IsJSGlobalProxy) { | 613 RUNTIME_FUNCTION(Runtime_IsJSGlobalProxy) { |
614 SealHandleScope shs(isolate); | 614 SealHandleScope shs(isolate); |
615 DCHECK(args.length() == 1); | 615 DCHECK_EQ(1, args.length()); |
616 CONVERT_ARG_CHECKED(Object, obj, 0); | 616 CONVERT_ARG_CHECKED(Object, obj, 0); |
617 return isolate->heap()->ToBoolean(obj->IsJSGlobalProxy()); | 617 return isolate->heap()->ToBoolean(obj->IsJSGlobalProxy()); |
618 } | 618 } |
619 | 619 |
620 static bool IsValidAccessor(Isolate* isolate, Handle<Object> obj) { | 620 static bool IsValidAccessor(Isolate* isolate, Handle<Object> obj) { |
621 return obj->IsUndefined(isolate) || obj->IsCallable() || obj->IsNull(isolate); | 621 return obj->IsUndefined(isolate) || obj->IsCallable() || obj->IsNull(isolate); |
622 } | 622 } |
623 | 623 |
624 | 624 |
625 // Implements part of 8.12.9 DefineOwnProperty. | 625 // Implements part of 8.12.9 DefineOwnProperty. |
626 // There are 3 cases that lead here: | 626 // There are 3 cases that lead here: |
627 // Step 4b - define a new accessor property. | 627 // Step 4b - define a new accessor property. |
628 // Steps 9c & 12 - replace an existing data property with an accessor property. | 628 // Steps 9c & 12 - replace an existing data property with an accessor property. |
629 // Step 12 - update an existing accessor property with an accessor or generic | 629 // Step 12 - update an existing accessor property with an accessor or generic |
630 // descriptor. | 630 // descriptor. |
631 RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) { | 631 RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) { |
632 HandleScope scope(isolate); | 632 HandleScope scope(isolate); |
633 DCHECK(args.length() == 5); | 633 DCHECK_EQ(5, args.length()); |
634 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 634 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
635 CHECK(!obj->IsNull(isolate)); | 635 CHECK(!obj->IsNull(isolate)); |
636 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 636 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
637 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); | 637 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); |
638 CHECK(IsValidAccessor(isolate, getter)); | 638 CHECK(IsValidAccessor(isolate, getter)); |
639 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); | 639 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); |
640 CHECK(IsValidAccessor(isolate, setter)); | 640 CHECK(IsValidAccessor(isolate, setter)); |
641 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 4); | 641 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 4); |
642 | 642 |
643 RETURN_FAILURE_ON_EXCEPTION( | 643 RETURN_FAILURE_ON_EXCEPTION( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 // creating an object literal. | 689 // creating an object literal. |
690 CHECK(JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs, | 690 CHECK(JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs, |
691 Object::DONT_THROW) | 691 Object::DONT_THROW) |
692 .IsJust()); | 692 .IsJust()); |
693 return *object; | 693 return *object; |
694 } | 694 } |
695 | 695 |
696 // Return property without being observable by accessors or interceptors. | 696 // Return property without being observable by accessors or interceptors. |
697 RUNTIME_FUNCTION(Runtime_GetDataProperty) { | 697 RUNTIME_FUNCTION(Runtime_GetDataProperty) { |
698 HandleScope scope(isolate); | 698 HandleScope scope(isolate); |
699 DCHECK(args.length() == 2); | 699 DCHECK_EQ(2, args.length()); |
700 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 700 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
701 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 701 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
702 return *JSReceiver::GetDataProperty(object, name); | 702 return *JSReceiver::GetDataProperty(object, name); |
703 } | 703 } |
704 | 704 |
705 RUNTIME_FUNCTION(Runtime_GetConstructorName) { | 705 RUNTIME_FUNCTION(Runtime_GetConstructorName) { |
706 HandleScope scope(isolate); | 706 HandleScope scope(isolate); |
707 DCHECK(args.length() == 1); | 707 DCHECK_EQ(1, args.length()); |
708 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 708 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
709 | 709 |
710 CHECK(!object->IsUndefined(isolate) && !object->IsNull(isolate)); | 710 CHECK(!object->IsUndefined(isolate) && !object->IsNull(isolate)); |
711 Handle<JSReceiver> recv = Object::ToObject(isolate, object).ToHandleChecked(); | 711 Handle<JSReceiver> recv = Object::ToObject(isolate, object).ToHandleChecked(); |
712 return *JSReceiver::GetConstructorName(recv); | 712 return *JSReceiver::GetConstructorName(recv); |
713 } | 713 } |
714 | 714 |
715 RUNTIME_FUNCTION(Runtime_HasFastPackedElements) { | 715 RUNTIME_FUNCTION(Runtime_HasFastPackedElements) { |
716 SealHandleScope shs(isolate); | 716 SealHandleScope shs(isolate); |
717 DCHECK(args.length() == 1); | 717 DCHECK_EQ(1, args.length()); |
718 CONVERT_ARG_CHECKED(HeapObject, obj, 0); | 718 CONVERT_ARG_CHECKED(HeapObject, obj, 0); |
719 return isolate->heap()->ToBoolean( | 719 return isolate->heap()->ToBoolean( |
720 IsFastPackedElementsKind(obj->map()->elements_kind())); | 720 IsFastPackedElementsKind(obj->map()->elements_kind())); |
721 } | 721 } |
722 | 722 |
723 | 723 |
724 RUNTIME_FUNCTION(Runtime_ValueOf) { | 724 RUNTIME_FUNCTION(Runtime_ValueOf) { |
725 SealHandleScope shs(isolate); | 725 SealHandleScope shs(isolate); |
726 DCHECK(args.length() == 1); | 726 DCHECK_EQ(1, args.length()); |
727 CONVERT_ARG_CHECKED(Object, obj, 0); | 727 CONVERT_ARG_CHECKED(Object, obj, 0); |
728 if (!obj->IsJSValue()) return obj; | 728 if (!obj->IsJSValue()) return obj; |
729 return JSValue::cast(obj)->value(); | 729 return JSValue::cast(obj)->value(); |
730 } | 730 } |
731 | 731 |
732 | 732 |
733 RUNTIME_FUNCTION(Runtime_IsJSReceiver) { | 733 RUNTIME_FUNCTION(Runtime_IsJSReceiver) { |
734 SealHandleScope shs(isolate); | 734 SealHandleScope shs(isolate); |
735 DCHECK(args.length() == 1); | 735 DCHECK_EQ(1, args.length()); |
736 CONVERT_ARG_CHECKED(Object, obj, 0); | 736 CONVERT_ARG_CHECKED(Object, obj, 0); |
737 return isolate->heap()->ToBoolean(obj->IsJSReceiver()); | 737 return isolate->heap()->ToBoolean(obj->IsJSReceiver()); |
738 } | 738 } |
739 | 739 |
740 | 740 |
741 RUNTIME_FUNCTION(Runtime_ClassOf) { | 741 RUNTIME_FUNCTION(Runtime_ClassOf) { |
742 SealHandleScope shs(isolate); | 742 SealHandleScope shs(isolate); |
743 DCHECK(args.length() == 1); | 743 DCHECK_EQ(1, args.length()); |
744 CONVERT_ARG_CHECKED(Object, obj, 0); | 744 CONVERT_ARG_CHECKED(Object, obj, 0); |
745 if (!obj->IsJSReceiver()) return isolate->heap()->null_value(); | 745 if (!obj->IsJSReceiver()) return isolate->heap()->null_value(); |
746 return JSReceiver::cast(obj)->class_name(); | 746 return JSReceiver::cast(obj)->class_name(); |
747 } | 747 } |
748 | 748 |
749 | 749 |
750 RUNTIME_FUNCTION(Runtime_DefineGetterPropertyUnchecked) { | 750 RUNTIME_FUNCTION(Runtime_DefineGetterPropertyUnchecked) { |
751 HandleScope scope(isolate); | 751 HandleScope scope(isolate); |
752 DCHECK(args.length() == 4); | 752 DCHECK_EQ(4, args.length()); |
753 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 753 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
754 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 754 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
755 CONVERT_ARG_HANDLE_CHECKED(JSFunction, getter, 2); | 755 CONVERT_ARG_HANDLE_CHECKED(JSFunction, getter, 2); |
756 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 756 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
757 | 757 |
758 if (String::cast(getter->shared()->name())->length() == 0) { | 758 if (String::cast(getter->shared()->name())->length() == 0) { |
759 JSFunction::SetName(getter, name, isolate->factory()->get_string()); | 759 JSFunction::SetName(getter, name, isolate->factory()->get_string()); |
760 } | 760 } |
761 | 761 |
762 RETURN_FAILURE_ON_EXCEPTION( | 762 RETURN_FAILURE_ON_EXCEPTION( |
763 isolate, | 763 isolate, |
764 JSObject::DefineAccessor(object, name, getter, | 764 JSObject::DefineAccessor(object, name, getter, |
765 isolate->factory()->null_value(), attrs)); | 765 isolate->factory()->null_value(), attrs)); |
766 return isolate->heap()->undefined_value(); | 766 return isolate->heap()->undefined_value(); |
767 } | 767 } |
768 | 768 |
769 | 769 |
770 RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) { | 770 RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) { |
771 HandleScope scope(isolate); | 771 HandleScope scope(isolate); |
772 DCHECK(args.length() == 4); | 772 DCHECK_EQ(4, args.length()); |
773 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 773 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
774 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 774 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
775 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2); | 775 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2); |
776 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 776 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
777 | 777 |
778 if (String::cast(setter->shared()->name())->length() == 0) { | 778 if (String::cast(setter->shared()->name())->length() == 0) { |
779 JSFunction::SetName(setter, name, isolate->factory()->set_string()); | 779 JSFunction::SetName(setter, name, isolate->factory()->set_string()); |
780 } | 780 } |
781 | 781 |
782 RETURN_FAILURE_ON_EXCEPTION( | 782 RETURN_FAILURE_ON_EXCEPTION( |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 RUNTIME_FUNCTION(Runtime_IsAccessCheckNeeded) { | 930 RUNTIME_FUNCTION(Runtime_IsAccessCheckNeeded) { |
931 SealHandleScope shs(isolate); | 931 SealHandleScope shs(isolate); |
932 DCHECK_EQ(1, args.length()); | 932 DCHECK_EQ(1, args.length()); |
933 CONVERT_ARG_CHECKED(Object, object, 0); | 933 CONVERT_ARG_CHECKED(Object, object, 0); |
934 return isolate->heap()->ToBoolean(object->IsAccessCheckNeeded()); | 934 return isolate->heap()->ToBoolean(object->IsAccessCheckNeeded()); |
935 } | 935 } |
936 | 936 |
937 | 937 |
938 RUNTIME_FUNCTION(Runtime_CreateDataProperty) { | 938 RUNTIME_FUNCTION(Runtime_CreateDataProperty) { |
939 HandleScope scope(isolate); | 939 HandleScope scope(isolate); |
940 DCHECK(args.length() == 3); | 940 DCHECK_EQ(3, args.length()); |
941 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, o, 0); | 941 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, o, 0); |
942 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 942 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
943 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 943 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
944 bool success; | 944 bool success; |
945 LookupIterator it = LookupIterator::PropertyOrElement( | 945 LookupIterator it = LookupIterator::PropertyOrElement( |
946 isolate, o, key, &success, LookupIterator::OWN); | 946 isolate, o, key, &success, LookupIterator::OWN); |
947 if (!success) return isolate->heap()->exception(); | 947 if (!success) return isolate->heap()->exception(); |
948 MAYBE_RETURN( | 948 MAYBE_RETURN( |
949 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), | 949 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), |
950 isolate->heap()->exception()); | 950 isolate->heap()->exception()); |
951 return *value; | 951 return *value; |
952 } | 952 } |
953 | 953 |
954 | 954 |
955 } // namespace internal | 955 } // namespace internal |
956 } // namespace v8 | 956 } // namespace v8 |
OLD | NEW |