Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(898)

Side by Side Diff: src/runtime.cc

Issue 9395075: Cleaned up runtime macros a bit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Incorporated review comments. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 namespace v8 { 62 namespace v8 {
63 namespace internal { 63 namespace internal {
64 64
65 65
66 #define RUNTIME_ASSERT(value) \ 66 #define RUNTIME_ASSERT(value) \
67 if (!(value)) return isolate->ThrowIllegalOperation(); 67 if (!(value)) return isolate->ThrowIllegalOperation();
68 68
69 // Cast the given object to a value of the specified type and store 69 // Cast the given object to a value of the specified type and store
70 // it in a variable with the given name. If the object is not of the 70 // it in a variable with the given name. If the object is not of the
71 // expected type call IllegalOperation and return. 71 // expected type call IllegalOperation and return.
72 #define CONVERT_CHECKED(Type, name, obj) \ 72 #define CONVERT_ARG_CHECKED(Type, name, index) \
73 RUNTIME_ASSERT(obj->Is##Type()); \ 73 RUNTIME_ASSERT(args[index]->Is##Type()); \
74 Type* name = Type::cast(obj); 74 Type* name = Type::cast(args[index]);
75 75
76 #define CONVERT_ARG_CHECKED(Type, name, index) \ 76 #define CONVERT_ARG_HANDLE_CHECKED(Type, name, index) \
77 RUNTIME_ASSERT(args[index]->Is##Type()); \ 77 RUNTIME_ASSERT(args[index]->Is##Type()); \
78 Handle<Type> name = args.at<Type>(index); 78 Handle<Type> name = args.at<Type>(index);
79 79
80 // Cast the given object to a boolean and store it in a variable with 80 // Cast the given object to a boolean and store it in a variable with
81 // the given name. If the object is not a boolean call IllegalOperation 81 // the given name. If the object is not a boolean call IllegalOperation
82 // and return. 82 // and return.
83 #define CONVERT_BOOLEAN_CHECKED(name, obj) \ 83 #define CONVERT_BOOLEAN_ARG_CHECKED(name, index) \
84 RUNTIME_ASSERT(obj->IsBoolean()); \ 84 RUNTIME_ASSERT(args[index]->IsBoolean()); \
85 bool name = (obj)->IsTrue(); 85 bool name = args[index]->IsTrue();
86 86
87 // Cast the given argument to a Smi and store its value in an int variable 87 // Cast the given argument to a Smi and store its value in an int variable
88 // with the given name. If the argument is not a Smi call IllegalOperation 88 // with the given name. If the argument is not a Smi call IllegalOperation
89 // and return. 89 // and return.
90 #define CONVERT_SMI_ARG_CHECKED(name, index) \ 90 #define CONVERT_SMI_ARG_CHECKED(name, index) \
91 RUNTIME_ASSERT(args[index]->IsSmi()); \ 91 RUNTIME_ASSERT(args[index]->IsSmi()); \
92 int name = args.smi_at(index); 92 int name = args.smi_at(index);
93 93
94 // Cast the given argument to a double and store it in a variable with 94 // Cast the given argument to a double and store it in a variable with
95 // the given name. If the argument is not a number (as opposed to 95 // the given name. If the argument is not a number (as opposed to
96 // the number not-a-number) call IllegalOperation and return. 96 // the number not-a-number) call IllegalOperation and return.
97 #define CONVERT_DOUBLE_ARG_CHECKED(name, index) \ 97 #define CONVERT_DOUBLE_ARG_CHECKED(name, index) \
98 RUNTIME_ASSERT(args[index]->IsNumber()); \ 98 RUNTIME_ASSERT(args[index]->IsNumber()); \
99 double name = args.number_at(index); 99 double name = args.number_at(index);
100 100
101 // Call the specified converter on the object *comand store the result in 101 // Call the specified converter on the object *comand store the result in
102 // a variable of the specified type with the given name. If the 102 // a variable of the specified type with the given name. If the
103 // object is not a Number call IllegalOperation and return. 103 // object is not a Number call IllegalOperation and return.
104 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \ 104 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \
105 RUNTIME_ASSERT(obj->IsNumber()); \ 105 RUNTIME_ASSERT(obj->IsNumber()); \
106 type name = NumberTo##Type(obj); 106 type name = NumberTo##Type(obj);
107 107
108 108
109 // Cast the given argument to PropertyDetails and store its value in a
110 // variable with the given name. If the argument is not a Smi call
111 // IllegalOperation and return.
112 #define CONVERT_PROPERTY_DETAILS_CHECKED(name, index) \
113 RUNTIME_ASSERT(args[index]->IsSmi()); \
114 PropertyDetails name = PropertyDetails(Smi::cast(args[index]));
115
116
109 // Assert that the given argument has a valid value for a StrictModeFlag 117 // Assert that the given argument has a valid value for a StrictModeFlag
110 // and store it in a StrictModeFlag variable with the given name. 118 // and store it in a StrictModeFlag variable with the given name.
111 #define CONVERT_STRICT_MODE_ARG(name, index) \ 119 #define CONVERT_STRICT_MODE_ARG_CHECKED(name, index) \
112 ASSERT(args[index]->IsSmi()); \ 120 RUNTIME_ASSERT(args[index]->IsSmi()); \
113 ASSERT(args.smi_at(index) == kStrictMode || \ 121 RUNTIME_ASSERT(args.smi_at(index) == kStrictMode || \
114 args.smi_at(index) == kNonStrictMode); \ 122 args.smi_at(index) == kNonStrictMode); \
115 StrictModeFlag name = \ 123 StrictModeFlag name = \
116 static_cast<StrictModeFlag>(args.smi_at(index)); 124 static_cast<StrictModeFlag>(args.smi_at(index));
117 125
118 126
119 // Assert that the given argument has a valid value for a LanguageMode 127 // Assert that the given argument has a valid value for a LanguageMode
120 // and store it in a LanguageMode variable with the given name. 128 // and store it in a LanguageMode variable with the given name.
121 #define CONVERT_LANGUAGE_MODE_ARG(name, index) \ 129 #define CONVERT_LANGUAGE_MODE_ARG(name, index) \
122 ASSERT(args[index]->IsSmi()); \ 130 ASSERT(args[index]->IsSmi()); \
123 ASSERT(args.smi_at(index) == CLASSIC_MODE || \ 131 ASSERT(args.smi_at(index) == CLASSIC_MODE || \
124 args.smi_at(index) == STRICT_MODE || \ 132 args.smi_at(index) == STRICT_MODE || \
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 default: 559 default:
552 UNREACHABLE(); 560 UNREACHABLE();
553 return Handle<Object>::null(); 561 return Handle<Object>::null();
554 } 562 }
555 } 563 }
556 564
557 565
558 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) { 566 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) {
559 HandleScope scope(isolate); 567 HandleScope scope(isolate);
560 ASSERT(args.length() == 4); 568 ASSERT(args.length() == 4);
561 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 569 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
562 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 570 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
563 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2); 571 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2);
564 CONVERT_SMI_ARG_CHECKED(flags, 3); 572 CONVERT_SMI_ARG_CHECKED(flags, 3);
565 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; 573 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
566 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; 574 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
567 575
568 // Check if boilerplate exists. If not, create it first. 576 // Check if boilerplate exists. If not, create it first.
569 Handle<Object> boilerplate(literals->get(literals_index), isolate); 577 Handle<Object> boilerplate(literals->get(literals_index), isolate);
570 if (*boilerplate == isolate->heap()->undefined_value()) { 578 if (*boilerplate == isolate->heap()->undefined_value()) {
571 boilerplate = CreateObjectLiteralBoilerplate(isolate, 579 boilerplate = CreateObjectLiteralBoilerplate(isolate,
572 literals, 580 literals,
573 constant_properties, 581 constant_properties,
574 should_have_fast_elements, 582 should_have_fast_elements,
575 has_function_literal); 583 has_function_literal);
576 if (boilerplate.is_null()) return Failure::Exception(); 584 if (boilerplate.is_null()) return Failure::Exception();
577 // Update the functions literal and return the boilerplate. 585 // Update the functions literal and return the boilerplate.
578 literals->set(literals_index, *boilerplate); 586 literals->set(literals_index, *boilerplate);
579 } 587 }
580 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate)); 588 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate));
581 } 589 }
582 590
583 591
584 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) { 592 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) {
585 HandleScope scope(isolate); 593 HandleScope scope(isolate);
586 ASSERT(args.length() == 4); 594 ASSERT(args.length() == 4);
587 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 595 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
588 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 596 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
589 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2); 597 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2);
590 CONVERT_SMI_ARG_CHECKED(flags, 3); 598 CONVERT_SMI_ARG_CHECKED(flags, 3);
591 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; 599 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
592 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; 600 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
593 601
594 // Check if boilerplate exists. If not, create it first. 602 // Check if boilerplate exists. If not, create it first.
595 Handle<Object> boilerplate(literals->get(literals_index), isolate); 603 Handle<Object> boilerplate(literals->get(literals_index), isolate);
596 if (*boilerplate == isolate->heap()->undefined_value()) { 604 if (*boilerplate == isolate->heap()->undefined_value()) {
597 boilerplate = CreateObjectLiteralBoilerplate(isolate, 605 boilerplate = CreateObjectLiteralBoilerplate(isolate,
598 literals, 606 literals,
599 constant_properties, 607 constant_properties,
600 should_have_fast_elements, 608 should_have_fast_elements,
601 has_function_literal); 609 has_function_literal);
602 if (boilerplate.is_null()) return Failure::Exception(); 610 if (boilerplate.is_null()) return Failure::Exception();
603 // Update the functions literal and return the boilerplate. 611 // Update the functions literal and return the boilerplate.
604 literals->set(literals_index, *boilerplate); 612 literals->set(literals_index, *boilerplate);
605 } 613 }
606 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate)); 614 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate));
607 } 615 }
608 616
609 617
610 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { 618 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) {
611 HandleScope scope(isolate); 619 HandleScope scope(isolate);
612 ASSERT(args.length() == 3); 620 ASSERT(args.length() == 3);
613 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 621 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
614 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 622 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
615 CONVERT_ARG_CHECKED(FixedArray, elements, 2); 623 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
616 624
617 // Check if boilerplate exists. If not, create it first. 625 // Check if boilerplate exists. If not, create it first.
618 Handle<Object> boilerplate(literals->get(literals_index), isolate); 626 Handle<Object> boilerplate(literals->get(literals_index), isolate);
619 if (*boilerplate == isolate->heap()->undefined_value()) { 627 if (*boilerplate == isolate->heap()->undefined_value()) {
620 boilerplate = 628 boilerplate =
621 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements); 629 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements);
622 if (boilerplate.is_null()) return Failure::Exception(); 630 if (boilerplate.is_null()) return Failure::Exception();
623 // Update the functions literal and return the boilerplate. 631 // Update the functions literal and return the boilerplate.
624 literals->set(literals_index, *boilerplate); 632 literals->set(literals_index, *boilerplate);
625 } 633 }
626 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate)); 634 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate));
627 } 635 }
628 636
629 637
630 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { 638 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) {
631 HandleScope scope(isolate); 639 HandleScope scope(isolate);
632 ASSERT(args.length() == 3); 640 ASSERT(args.length() == 3);
633 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 641 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
634 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 642 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
635 CONVERT_ARG_CHECKED(FixedArray, elements, 2); 643 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
636 644
637 // Check if boilerplate exists. If not, create it first. 645 // Check if boilerplate exists. If not, create it first.
638 Handle<Object> boilerplate(literals->get(literals_index), isolate); 646 Handle<Object> boilerplate(literals->get(literals_index), isolate);
639 if (*boilerplate == isolate->heap()->undefined_value()) { 647 if (*boilerplate == isolate->heap()->undefined_value()) {
640 ASSERT(*elements != isolate->heap()->empty_fixed_array()); 648 ASSERT(*elements != isolate->heap()->empty_fixed_array());
641 boilerplate = 649 boilerplate =
642 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements); 650 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements);
643 if (boilerplate.is_null()) return Failure::Exception(); 651 if (boilerplate.is_null()) return Failure::Exception();
644 // Update the functions literal and return the boilerplate. 652 // Update the functions literal and return the boilerplate.
645 literals->set(literals_index, *boilerplate); 653 literals->set(literals_index, *boilerplate);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 692
685 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSFunctionProxy) { 693 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSFunctionProxy) {
686 ASSERT(args.length() == 1); 694 ASSERT(args.length() == 1);
687 Object* obj = args[0]; 695 Object* obj = args[0];
688 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); 696 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy());
689 } 697 }
690 698
691 699
692 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { 700 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) {
693 ASSERT(args.length() == 1); 701 ASSERT(args.length() == 1);
694 CONVERT_CHECKED(JSProxy, proxy, args[0]); 702 CONVERT_ARG_CHECKED(JSProxy, proxy, 0);
695 return proxy->handler(); 703 return proxy->handler();
696 } 704 }
697 705
698 706
699 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetCallTrap) { 707 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetCallTrap) {
700 ASSERT(args.length() == 1); 708 ASSERT(args.length() == 1);
701 CONVERT_CHECKED(JSFunctionProxy, proxy, args[0]); 709 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0);
702 return proxy->call_trap(); 710 return proxy->call_trap();
703 } 711 }
704 712
705 713
706 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructTrap) { 714 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructTrap) {
707 ASSERT(args.length() == 1); 715 ASSERT(args.length() == 1);
708 CONVERT_CHECKED(JSFunctionProxy, proxy, args[0]); 716 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0);
709 return proxy->construct_trap(); 717 return proxy->construct_trap();
710 } 718 }
711 719
712 720
713 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { 721 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) {
714 ASSERT(args.length() == 1); 722 ASSERT(args.length() == 1);
715 CONVERT_CHECKED(JSProxy, proxy, args[0]); 723 CONVERT_ARG_CHECKED(JSProxy, proxy, 0);
716 proxy->Fix(); 724 proxy->Fix();
717 return isolate->heap()->undefined_value(); 725 return isolate->heap()->undefined_value();
718 } 726 }
719 727
720 728
721 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInitialize) { 729 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInitialize) {
722 HandleScope scope(isolate); 730 HandleScope scope(isolate);
723 ASSERT(args.length() == 1); 731 ASSERT(args.length() == 1);
724 CONVERT_ARG_CHECKED(JSSet, holder, 0); 732 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
725 Handle<ObjectHashSet> table = isolate->factory()->NewObjectHashSet(0); 733 Handle<ObjectHashSet> table = isolate->factory()->NewObjectHashSet(0);
726 holder->set_table(*table); 734 holder->set_table(*table);
727 return *holder; 735 return *holder;
728 } 736 }
729 737
730 738
731 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) { 739 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) {
732 HandleScope scope(isolate); 740 HandleScope scope(isolate);
733 ASSERT(args.length() == 2); 741 ASSERT(args.length() == 2);
734 CONVERT_ARG_CHECKED(JSSet, holder, 0); 742 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
735 Handle<Object> key(args[1]); 743 Handle<Object> key(args[1]);
736 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); 744 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table()));
737 table = ObjectHashSetAdd(table, key); 745 table = ObjectHashSetAdd(table, key);
738 holder->set_table(*table); 746 holder->set_table(*table);
739 return isolate->heap()->undefined_symbol(); 747 return isolate->heap()->undefined_symbol();
740 } 748 }
741 749
742 750
743 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHas) { 751 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHas) {
744 HandleScope scope(isolate); 752 HandleScope scope(isolate);
745 ASSERT(args.length() == 2); 753 ASSERT(args.length() == 2);
746 CONVERT_ARG_CHECKED(JSSet, holder, 0); 754 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
747 Handle<Object> key(args[1]); 755 Handle<Object> key(args[1]);
748 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); 756 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table()));
749 return isolate->heap()->ToBoolean(table->Contains(*key)); 757 return isolate->heap()->ToBoolean(table->Contains(*key));
750 } 758 }
751 759
752 760
753 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) { 761 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) {
754 HandleScope scope(isolate); 762 HandleScope scope(isolate);
755 ASSERT(args.length() == 2); 763 ASSERT(args.length() == 2);
756 CONVERT_ARG_CHECKED(JSSet, holder, 0); 764 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
757 Handle<Object> key(args[1]); 765 Handle<Object> key(args[1]);
758 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); 766 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table()));
759 table = ObjectHashSetRemove(table, key); 767 table = ObjectHashSetRemove(table, key);
760 holder->set_table(*table); 768 holder->set_table(*table);
761 return isolate->heap()->undefined_symbol(); 769 return isolate->heap()->undefined_symbol();
762 } 770 }
763 771
764 772
765 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapInitialize) { 773 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapInitialize) {
766 HandleScope scope(isolate); 774 HandleScope scope(isolate);
767 ASSERT(args.length() == 1); 775 ASSERT(args.length() == 1);
768 CONVERT_ARG_CHECKED(JSMap, holder, 0); 776 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
769 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); 777 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0);
770 holder->set_table(*table); 778 holder->set_table(*table);
771 return *holder; 779 return *holder;
772 } 780 }
773 781
774 782
775 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGet) { 783 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGet) {
776 HandleScope scope(isolate); 784 HandleScope scope(isolate);
777 ASSERT(args.length() == 2); 785 ASSERT(args.length() == 2);
778 CONVERT_ARG_CHECKED(JSMap, holder, 0); 786 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
779 Handle<Object> key(args[1]); 787 Handle<Object> key(args[1]);
780 return ObjectHashTable::cast(holder->table())->Lookup(*key); 788 return ObjectHashTable::cast(holder->table())->Lookup(*key);
781 } 789 }
782 790
783 791
784 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { 792 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) {
785 HandleScope scope(isolate); 793 HandleScope scope(isolate);
786 ASSERT(args.length() == 3); 794 ASSERT(args.length() == 3);
787 CONVERT_ARG_CHECKED(JSMap, holder, 0); 795 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
788 Handle<Object> key(args[1]); 796 Handle<Object> key(args[1]);
789 Handle<Object> value(args[2]); 797 Handle<Object> value(args[2]);
790 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); 798 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
791 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); 799 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value);
792 holder->set_table(*new_table); 800 holder->set_table(*new_table);
793 return *value; 801 return *value;
794 } 802 }
795 803
796 804
797 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) { 805 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) {
798 HandleScope scope(isolate); 806 HandleScope scope(isolate);
799 ASSERT(args.length() == 1); 807 ASSERT(args.length() == 1);
800 CONVERT_ARG_CHECKED(JSWeakMap, weakmap, 0); 808 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0);
801 ASSERT(weakmap->map()->inobject_properties() == 0); 809 ASSERT(weakmap->map()->inobject_properties() == 0);
802 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); 810 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0);
803 weakmap->set_table(*table); 811 weakmap->set_table(*table);
804 weakmap->set_next(Smi::FromInt(0)); 812 weakmap->set_next(Smi::FromInt(0));
805 return *weakmap; 813 return *weakmap;
806 } 814 }
807 815
808 816
809 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) { 817 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) {
810 NoHandleAllocation ha; 818 NoHandleAllocation ha;
811 ASSERT(args.length() == 2); 819 ASSERT(args.length() == 2);
812 CONVERT_ARG_CHECKED(JSWeakMap, weakmap, 0); 820 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0);
813 CONVERT_ARG_CHECKED(JSReceiver, key, 1); 821 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1);
814 return ObjectHashTable::cast(weakmap->table())->Lookup(*key); 822 return ObjectHashTable::cast(weakmap->table())->Lookup(*key);
815 } 823 }
816 824
817 825
818 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) { 826 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) {
819 HandleScope scope(isolate); 827 HandleScope scope(isolate);
820 ASSERT(args.length() == 3); 828 ASSERT(args.length() == 3);
821 CONVERT_ARG_CHECKED(JSWeakMap, weakmap, 0); 829 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0);
822 CONVERT_ARG_CHECKED(JSReceiver, key, 1); 830 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1);
823 Handle<Object> value(args[2]); 831 Handle<Object> value(args[2]);
824 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); 832 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table()));
825 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); 833 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value);
826 weakmap->set_table(*new_table); 834 weakmap->set_table(*new_table);
827 return *value; 835 return *value;
828 } 836 }
829 837
830 838
831 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { 839 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) {
832 NoHandleAllocation ha; 840 NoHandleAllocation ha;
833 ASSERT(args.length() == 1); 841 ASSERT(args.length() == 1);
834 Object* obj = args[0]; 842 Object* obj = args[0];
835 if (!obj->IsJSObject()) return isolate->heap()->null_value(); 843 if (!obj->IsJSObject()) return isolate->heap()->null_value();
836 return JSObject::cast(obj)->class_name(); 844 return JSObject::cast(obj)->class_name();
837 } 845 }
838 846
839 847
840 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { 848 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) {
841 NoHandleAllocation ha; 849 NoHandleAllocation ha;
842 ASSERT(args.length() == 1); 850 ASSERT(args.length() == 1);
843 CONVERT_CHECKED(JSReceiver, input_obj, args[0]); 851 CONVERT_ARG_CHECKED(JSReceiver, input_obj, 0);
844 Object* obj = input_obj; 852 Object* obj = input_obj;
845 // We don't expect access checks to be needed on JSProxy objects. 853 // We don't expect access checks to be needed on JSProxy objects.
846 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); 854 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject());
847 do { 855 do {
848 if (obj->IsAccessCheckNeeded() && 856 if (obj->IsAccessCheckNeeded() &&
849 !isolate->MayNamedAccess(JSObject::cast(obj), 857 !isolate->MayNamedAccess(JSObject::cast(obj),
850 isolate->heap()->Proto_symbol(), 858 isolate->heap()->Proto_symbol(),
851 v8::ACCESS_GET)) { 859 v8::ACCESS_GET)) {
852 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET); 860 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET);
853 return isolate->heap()->undefined_value(); 861 return isolate->heap()->undefined_value();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 // [false, value, Writeable, Enumerable, Configurable] 1010 // [false, value, Writeable, Enumerable, Configurable]
1003 // if args[1] is an accessor on args[0] 1011 // if args[1] is an accessor on args[0]
1004 // [true, GetFunction, SetFunction, Enumerable, Configurable] 1012 // [true, GetFunction, SetFunction, Enumerable, Configurable]
1005 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) { 1013 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) {
1006 ASSERT(args.length() == 2); 1014 ASSERT(args.length() == 2);
1007 Heap* heap = isolate->heap(); 1015 Heap* heap = isolate->heap();
1008 HandleScope scope(isolate); 1016 HandleScope scope(isolate);
1009 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); 1017 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE);
1010 Handle<JSArray> desc = isolate->factory()->NewJSArrayWithElements(elms); 1018 Handle<JSArray> desc = isolate->factory()->NewJSArrayWithElements(elms);
1011 LookupResult result(isolate); 1019 LookupResult result(isolate);
1012 CONVERT_ARG_CHECKED(JSObject, obj, 0); 1020 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
1013 CONVERT_ARG_CHECKED(String, name, 1); 1021 CONVERT_ARG_HANDLE_CHECKED(String, name, 1);
1014 1022
1015 // This could be an element. 1023 // This could be an element.
1016 uint32_t index; 1024 uint32_t index;
1017 if (name->AsArrayIndex(&index)) { 1025 if (name->AsArrayIndex(&index)) {
1018 switch (obj->HasLocalElement(index)) { 1026 switch (obj->HasLocalElement(index)) {
1019 case JSObject::UNDEFINED_ELEMENT: 1027 case JSObject::UNDEFINED_ELEMENT:
1020 return heap->undefined_value(); 1028 return heap->undefined_value();
1021 1029
1022 case JSObject::STRING_CHARACTER_ELEMENT: { 1030 case JSObject::STRING_CHARACTER_ELEMENT: {
1023 // Special handling of string objects according to ECMAScript 5 1031 // Special handling of string objects according to ECMAScript 5
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 } 1148 }
1141 elms->set(VALUE_INDEX, value); 1149 elms->set(VALUE_INDEX, value);
1142 } 1150 }
1143 1151
1144 return *desc; 1152 return *desc;
1145 } 1153 }
1146 1154
1147 1155
1148 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { 1156 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) {
1149 ASSERT(args.length() == 1); 1157 ASSERT(args.length() == 1);
1150 CONVERT_CHECKED(JSObject, obj, args[0]); 1158 CONVERT_ARG_CHECKED(JSObject, obj, 0);
1151 return obj->PreventExtensions(); 1159 return obj->PreventExtensions();
1152 } 1160 }
1153 1161
1154 1162
1155 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { 1163 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) {
1156 ASSERT(args.length() == 1); 1164 ASSERT(args.length() == 1);
1157 CONVERT_CHECKED(JSObject, obj, args[0]); 1165 CONVERT_ARG_CHECKED(JSObject, obj, 0);
1158 if (obj->IsJSGlobalProxy()) { 1166 if (obj->IsJSGlobalProxy()) {
1159 Object* proto = obj->GetPrototype(); 1167 Object* proto = obj->GetPrototype();
1160 if (proto->IsNull()) return isolate->heap()->false_value(); 1168 if (proto->IsNull()) return isolate->heap()->false_value();
1161 ASSERT(proto->IsJSGlobalObject()); 1169 ASSERT(proto->IsJSGlobalObject());
1162 obj = JSObject::cast(proto); 1170 obj = JSObject::cast(proto);
1163 } 1171 }
1164 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); 1172 return isolate->heap()->ToBoolean(obj->map()->is_extensible());
1165 } 1173 }
1166 1174
1167 1175
1168 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { 1176 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) {
1169 HandleScope scope(isolate); 1177 HandleScope scope(isolate);
1170 ASSERT(args.length() == 3); 1178 ASSERT(args.length() == 3);
1171 CONVERT_ARG_CHECKED(JSRegExp, re, 0); 1179 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0);
1172 CONVERT_ARG_CHECKED(String, pattern, 1); 1180 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1);
1173 CONVERT_ARG_CHECKED(String, flags, 2); 1181 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2);
1174 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); 1182 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags);
1175 if (result.is_null()) return Failure::Exception(); 1183 if (result.is_null()) return Failure::Exception();
1176 return *result; 1184 return *result;
1177 } 1185 }
1178 1186
1179 1187
1180 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) { 1188 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) {
1181 HandleScope scope(isolate); 1189 HandleScope scope(isolate);
1182 ASSERT(args.length() == 1); 1190 ASSERT(args.length() == 1);
1183 CONVERT_ARG_CHECKED(FunctionTemplateInfo, data, 0); 1191 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0);
1184 return *isolate->factory()->CreateApiFunction(data); 1192 return *isolate->factory()->CreateApiFunction(data);
1185 } 1193 }
1186 1194
1187 1195
1188 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsTemplate) { 1196 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsTemplate) {
1189 ASSERT(args.length() == 1); 1197 ASSERT(args.length() == 1);
1190 Object* arg = args[0]; 1198 Object* arg = args[0];
1191 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); 1199 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo();
1192 return isolate->heap()->ToBoolean(result); 1200 return isolate->heap()->ToBoolean(result);
1193 } 1201 }
1194 1202
1195 1203
1196 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) { 1204 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) {
1197 ASSERT(args.length() == 2); 1205 ASSERT(args.length() == 2);
1198 CONVERT_CHECKED(HeapObject, templ, args[0]); 1206 CONVERT_ARG_CHECKED(HeapObject, templ, 0);
1199 CONVERT_CHECKED(Smi, field, args[1]); 1207 CONVERT_SMI_ARG_CHECKED(index, 1)
1200 int index = field->value();
1201 int offset = index * kPointerSize + HeapObject::kHeaderSize; 1208 int offset = index * kPointerSize + HeapObject::kHeaderSize;
1202 InstanceType type = templ->map()->instance_type(); 1209 InstanceType type = templ->map()->instance_type();
1203 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || 1210 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE ||
1204 type == OBJECT_TEMPLATE_INFO_TYPE); 1211 type == OBJECT_TEMPLATE_INFO_TYPE);
1205 RUNTIME_ASSERT(offset > 0); 1212 RUNTIME_ASSERT(offset > 0);
1206 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { 1213 if (type == FUNCTION_TEMPLATE_INFO_TYPE) {
1207 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); 1214 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize);
1208 } else { 1215 } else {
1209 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); 1216 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize);
1210 } 1217 }
1211 return *HeapObject::RawField(templ, offset); 1218 return *HeapObject::RawField(templ, offset);
1212 } 1219 }
1213 1220
1214 1221
1215 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) { 1222 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) {
1216 ASSERT(args.length() == 1); 1223 ASSERT(args.length() == 1);
1217 CONVERT_CHECKED(HeapObject, object, args[0]); 1224 CONVERT_ARG_CHECKED(HeapObject, object, 0);
1218 Map* old_map = object->map(); 1225 Map* old_map = object->map();
1219 bool needs_access_checks = old_map->is_access_check_needed(); 1226 bool needs_access_checks = old_map->is_access_check_needed();
1220 if (needs_access_checks) { 1227 if (needs_access_checks) {
1221 // Copy map so it won't interfere constructor's initial map. 1228 // Copy map so it won't interfere constructor's initial map.
1222 Object* new_map; 1229 Object* new_map;
1223 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); 1230 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions();
1224 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; 1231 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
1225 } 1232 }
1226 1233
1227 Map::cast(new_map)->set_is_access_check_needed(false); 1234 Map::cast(new_map)->set_is_access_check_needed(false);
1228 object->set_map(Map::cast(new_map)); 1235 object->set_map(Map::cast(new_map));
1229 } 1236 }
1230 return isolate->heap()->ToBoolean(needs_access_checks); 1237 return isolate->heap()->ToBoolean(needs_access_checks);
1231 } 1238 }
1232 1239
1233 1240
1234 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { 1241 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) {
1235 ASSERT(args.length() == 1); 1242 ASSERT(args.length() == 1);
1236 CONVERT_CHECKED(HeapObject, object, args[0]); 1243 CONVERT_ARG_CHECKED(HeapObject, object, 0);
1237 Map* old_map = object->map(); 1244 Map* old_map = object->map();
1238 if (!old_map->is_access_check_needed()) { 1245 if (!old_map->is_access_check_needed()) {
1239 // Copy map so it won't interfere constructor's initial map. 1246 // Copy map so it won't interfere constructor's initial map.
1240 Object* new_map; 1247 Object* new_map;
1241 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); 1248 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions();
1242 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; 1249 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
1243 } 1250 }
1244 1251
1245 Map::cast(new_map)->set_is_access_check_needed(true); 1252 Map::cast(new_map)->set_is_access_check_needed(true);
1246 object->set_map(Map::cast(new_map)); 1253 object->set_map(Map::cast(new_map));
(...skipping 15 matching lines...) Expand all
1262 } 1269 }
1263 1270
1264 1271
1265 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) { 1272 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) {
1266 ASSERT(args.length() == 3); 1273 ASSERT(args.length() == 3);
1267 HandleScope scope(isolate); 1274 HandleScope scope(isolate);
1268 Handle<GlobalObject> global = Handle<GlobalObject>( 1275 Handle<GlobalObject> global = Handle<GlobalObject>(
1269 isolate->context()->global()); 1276 isolate->context()->global());
1270 1277
1271 Handle<Context> context = args.at<Context>(0); 1278 Handle<Context> context = args.at<Context>(0);
1272 CONVERT_ARG_CHECKED(FixedArray, pairs, 1); 1279 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1);
1273 CONVERT_SMI_ARG_CHECKED(flags, 2); 1280 CONVERT_SMI_ARG_CHECKED(flags, 2);
1274 1281
1275 // Traverse the name/value pairs and set the properties. 1282 // Traverse the name/value pairs and set the properties.
1276 int length = pairs->length(); 1283 int length = pairs->length();
1277 for (int i = 0; i < length; i += 2) { 1284 for (int i = 0; i < length; i += 2) {
1278 HandleScope scope(isolate); 1285 HandleScope scope(isolate);
1279 Handle<String> name(String::cast(pairs->get(i))); 1286 Handle<String> name(String::cast(pairs->get(i)));
1280 Handle<Object> value(pairs->get(i + 1), isolate); 1287 Handle<Object> value(pairs->get(i + 1), isolate);
1281 1288
1282 // We have to declare a global const property. To capture we only 1289 // We have to declare a global const property. To capture we only
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 NoHandleAllocation nha; 1471 NoHandleAllocation nha;
1465 // args[0] == name 1472 // args[0] == name
1466 // args[1] == language_mode 1473 // args[1] == language_mode
1467 // args[2] == value (optional) 1474 // args[2] == value (optional)
1468 1475
1469 // Determine if we need to assign to the variable if it already 1476 // Determine if we need to assign to the variable if it already
1470 // exists (based on the number of arguments). 1477 // exists (based on the number of arguments).
1471 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); 1478 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3);
1472 bool assign = args.length() == 3; 1479 bool assign = args.length() == 3;
1473 1480
1474 CONVERT_ARG_CHECKED(String, name, 0); 1481 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
1475 GlobalObject* global = isolate->context()->global(); 1482 GlobalObject* global = isolate->context()->global();
1476 RUNTIME_ASSERT(args[1]->IsSmi()); 1483 RUNTIME_ASSERT(args[1]->IsSmi());
1477 CONVERT_LANGUAGE_MODE_ARG(language_mode, 1); 1484 CONVERT_LANGUAGE_MODE_ARG(language_mode, 1);
1478 StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE) 1485 StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE)
1479 ? kNonStrictMode : kStrictMode; 1486 ? kNonStrictMode : kStrictMode;
1480 1487
1481 // According to ECMA-262, section 12.2, page 62, the property must 1488 // According to ECMA-262, section 12.2, page 62, the property must
1482 // not be deletable. 1489 // not be deletable.
1483 PropertyAttributes attributes = DONT_DELETE; 1490 PropertyAttributes attributes = DONT_DELETE;
1484 1491
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 } 1528 }
1522 return isolate->heap()->undefined_value(); 1529 return isolate->heap()->undefined_value();
1523 } 1530 }
1524 1531
1525 1532
1526 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) { 1533 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) {
1527 // All constants are declared with an initial value. The name 1534 // All constants are declared with an initial value. The name
1528 // of the constant is the first argument and the initial value 1535 // of the constant is the first argument and the initial value
1529 // is the second. 1536 // is the second.
1530 RUNTIME_ASSERT(args.length() == 2); 1537 RUNTIME_ASSERT(args.length() == 2);
1531 CONVERT_ARG_CHECKED(String, name, 0); 1538 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
1532 Handle<Object> value = args.at<Object>(1); 1539 Handle<Object> value = args.at<Object>(1);
1533 1540
1534 // Get the current global object from top. 1541 // Get the current global object from top.
1535 GlobalObject* global = isolate->context()->global(); 1542 GlobalObject* global = isolate->context()->global();
1536 1543
1537 // According to ECMA-262, section 12.2, page 62, the property must 1544 // According to ECMA-262, section 12.2, page 62, the property must
1538 // not be deletable. Since it's a const, it must be READ_ONLY too. 1545 // not be deletable. Since it's a const, it must be READ_ONLY too.
1539 PropertyAttributes attributes = 1546 PropertyAttributes attributes =
1540 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); 1547 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
1541 1548
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 } 1700 }
1694 1701
1695 return *value; 1702 return *value;
1696 } 1703 }
1697 1704
1698 1705
1699 RUNTIME_FUNCTION(MaybeObject*, 1706 RUNTIME_FUNCTION(MaybeObject*,
1700 Runtime_OptimizeObjectForAddingMultipleProperties) { 1707 Runtime_OptimizeObjectForAddingMultipleProperties) {
1701 HandleScope scope(isolate); 1708 HandleScope scope(isolate);
1702 ASSERT(args.length() == 2); 1709 ASSERT(args.length() == 2);
1703 CONVERT_ARG_CHECKED(JSObject, object, 0); 1710 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
1704 CONVERT_SMI_ARG_CHECKED(properties, 1); 1711 CONVERT_SMI_ARG_CHECKED(properties, 1);
1705 if (object->HasFastProperties()) { 1712 if (object->HasFastProperties()) {
1706 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); 1713 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties);
1707 } 1714 }
1708 return *object; 1715 return *object;
1709 } 1716 }
1710 1717
1711 1718
1712 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExec) { 1719 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExec) {
1713 HandleScope scope(isolate); 1720 HandleScope scope(isolate);
1714 ASSERT(args.length() == 4); 1721 ASSERT(args.length() == 4);
1715 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); 1722 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0);
1716 CONVERT_ARG_CHECKED(String, subject, 1); 1723 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1);
1717 // Due to the way the JS calls are constructed this must be less than the 1724 // Due to the way the JS calls are constructed this must be less than the
1718 // length of a string, i.e. it is always a Smi. We check anyway for security. 1725 // length of a string, i.e. it is always a Smi. We check anyway for security.
1719 CONVERT_SMI_ARG_CHECKED(index, 2); 1726 CONVERT_SMI_ARG_CHECKED(index, 2);
1720 CONVERT_ARG_CHECKED(JSArray, last_match_info, 3); 1727 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3);
1721 RUNTIME_ASSERT(last_match_info->HasFastElements()); 1728 RUNTIME_ASSERT(last_match_info->HasFastElements());
1722 RUNTIME_ASSERT(index >= 0); 1729 RUNTIME_ASSERT(index >= 0);
1723 RUNTIME_ASSERT(index <= subject->length()); 1730 RUNTIME_ASSERT(index <= subject->length());
1724 isolate->counters()->regexp_entry_runtime()->Increment(); 1731 isolate->counters()->regexp_entry_runtime()->Increment();
1725 Handle<Object> result = RegExpImpl::Exec(regexp, 1732 Handle<Object> result = RegExpImpl::Exec(regexp,
1726 subject, 1733 subject,
1727 index, 1734 index,
1728 last_match_info); 1735 last_match_info);
1729 if (result.is_null()) return Failure::Exception(); 1736 if (result.is_null()) return Failure::Exception();
1730 return *result; 1737 return *result;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 // Write in-object properties after the length of the array. 1769 // Write in-object properties after the length of the array.
1763 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); 1770 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]);
1764 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); 1771 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]);
1765 return array; 1772 return array;
1766 } 1773 }
1767 1774
1768 1775
1769 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { 1776 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) {
1770 AssertNoAllocation no_alloc; 1777 AssertNoAllocation no_alloc;
1771 ASSERT(args.length() == 5); 1778 ASSERT(args.length() == 5);
1772 CONVERT_CHECKED(JSRegExp, regexp, args[0]); 1779 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
1773 CONVERT_CHECKED(String, source, args[1]); 1780 CONVERT_ARG_CHECKED(String, source, 1);
1774 1781
1775 Object* global = args[2]; 1782 Object* global = args[2];
1776 if (!global->IsTrue()) global = isolate->heap()->false_value(); 1783 if (!global->IsTrue()) global = isolate->heap()->false_value();
1777 1784
1778 Object* ignoreCase = args[3]; 1785 Object* ignoreCase = args[3];
1779 if (!ignoreCase->IsTrue()) ignoreCase = isolate->heap()->false_value(); 1786 if (!ignoreCase->IsTrue()) ignoreCase = isolate->heap()->false_value();
1780 1787
1781 Object* multiline = args[4]; 1788 Object* multiline = args[4];
1782 if (!multiline->IsTrue()) multiline = isolate->heap()->false_value(); 1789 if (!multiline->IsTrue()) multiline = isolate->heap()->false_value();
1783 1790
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 writable); 1838 writable);
1832 ASSERT(!result->IsFailure()); 1839 ASSERT(!result->IsFailure());
1833 USE(result); 1840 USE(result);
1834 return regexp; 1841 return regexp;
1835 } 1842 }
1836 1843
1837 1844
1838 RUNTIME_FUNCTION(MaybeObject*, Runtime_FinishArrayPrototypeSetup) { 1845 RUNTIME_FUNCTION(MaybeObject*, Runtime_FinishArrayPrototypeSetup) {
1839 HandleScope scope(isolate); 1846 HandleScope scope(isolate);
1840 ASSERT(args.length() == 1); 1847 ASSERT(args.length() == 1);
1841 CONVERT_ARG_CHECKED(JSArray, prototype, 0); 1848 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0);
1842 // This is necessary to enable fast checks for absence of elements 1849 // This is necessary to enable fast checks for absence of elements
1843 // on Array.prototype and below. 1850 // on Array.prototype and below.
1844 prototype->set_elements(isolate->heap()->empty_fixed_array()); 1851 prototype->set_elements(isolate->heap()->empty_fixed_array());
1845 return Smi::FromInt(0); 1852 return Smi::FromInt(0);
1846 } 1853 }
1847 1854
1848 1855
1849 static Handle<JSFunction> InstallBuiltin(Isolate* isolate, 1856 static Handle<JSFunction> InstallBuiltin(Isolate* isolate,
1850 Handle<JSObject> holder, 1857 Handle<JSObject> holder,
1851 const char* name, 1858 const char* name,
1852 Builtins::Name builtin_name) { 1859 Builtins::Name builtin_name) {
1853 Handle<String> key = isolate->factory()->LookupAsciiSymbol(name); 1860 Handle<String> key = isolate->factory()->LookupAsciiSymbol(name);
1854 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); 1861 Handle<Code> code(isolate->builtins()->builtin(builtin_name));
1855 Handle<JSFunction> optimized = 1862 Handle<JSFunction> optimized =
1856 isolate->factory()->NewFunction(key, 1863 isolate->factory()->NewFunction(key,
1857 JS_OBJECT_TYPE, 1864 JS_OBJECT_TYPE,
1858 JSObject::kHeaderSize, 1865 JSObject::kHeaderSize,
1859 code, 1866 code,
1860 false); 1867 false);
1861 optimized->shared()->DontAdaptArguments(); 1868 optimized->shared()->DontAdaptArguments();
1862 JSReceiver::SetProperty(holder, key, optimized, NONE, kStrictMode); 1869 JSReceiver::SetProperty(holder, key, optimized, NONE, kStrictMode);
1863 return optimized; 1870 return optimized;
1864 } 1871 }
1865 1872
1866 1873
1867 RUNTIME_FUNCTION(MaybeObject*, Runtime_SpecialArrayFunctions) { 1874 RUNTIME_FUNCTION(MaybeObject*, Runtime_SpecialArrayFunctions) {
1868 HandleScope scope(isolate); 1875 HandleScope scope(isolate);
1869 ASSERT(args.length() == 1); 1876 ASSERT(args.length() == 1);
1870 CONVERT_ARG_CHECKED(JSObject, holder, 0); 1877 CONVERT_ARG_HANDLE_CHECKED(JSObject, holder, 0);
1871 1878
1872 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); 1879 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop);
1873 InstallBuiltin(isolate, holder, "push", Builtins::kArrayPush); 1880 InstallBuiltin(isolate, holder, "push", Builtins::kArrayPush);
1874 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); 1881 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift);
1875 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); 1882 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift);
1876 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); 1883 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice);
1877 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); 1884 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice);
1878 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); 1885 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat);
1879 1886
1880 return *holder; 1887 return *holder;
1881 } 1888 }
1882 1889
1883 1890
1884 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { 1891 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) {
1885 ASSERT(args.length() == 1); 1892 ASSERT(args.length() == 1);
1886 CONVERT_CHECKED(JSReceiver, callable, args[0]); 1893 CONVERT_ARG_CHECKED(JSReceiver, callable, 0);
1887 1894
1888 if (!callable->IsJSFunction()) { 1895 if (!callable->IsJSFunction()) {
1889 HandleScope scope(isolate); 1896 HandleScope scope(isolate);
1890 bool threw = false; 1897 bool threw = false;
1891 Handle<Object> delegate = 1898 Handle<Object> delegate =
1892 Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable), &threw); 1899 Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable), &threw);
1893 if (threw) return Failure::Exception(); 1900 if (threw) return Failure::Exception();
1894 callable = JSFunction::cast(*delegate); 1901 callable = JSFunction::cast(*delegate);
1895 } 1902 }
1896 JSFunction* function = JSFunction::cast(callable); 1903 JSFunction* function = JSFunction::cast(callable);
1897 1904
1898 SharedFunctionInfo* shared = function->shared(); 1905 SharedFunctionInfo* shared = function->shared();
1899 if (shared->native() || !shared->is_classic_mode()) { 1906 if (shared->native() || !shared->is_classic_mode()) {
1900 return isolate->heap()->undefined_value(); 1907 return isolate->heap()->undefined_value();
1901 } 1908 }
1902 // Returns undefined for strict or native functions, or 1909 // Returns undefined for strict or native functions, or
1903 // the associated global receiver for "normal" functions. 1910 // the associated global receiver for "normal" functions.
1904 1911
1905 Context* global_context = 1912 Context* global_context =
1906 function->context()->global()->global_context(); 1913 function->context()->global()->global_context();
1907 return global_context->global()->global_receiver(); 1914 return global_context->global()->global_receiver();
1908 } 1915 }
1909 1916
1910 1917
1911 RUNTIME_FUNCTION(MaybeObject*, Runtime_MaterializeRegExpLiteral) { 1918 RUNTIME_FUNCTION(MaybeObject*, Runtime_MaterializeRegExpLiteral) {
1912 HandleScope scope(isolate); 1919 HandleScope scope(isolate);
1913 ASSERT(args.length() == 4); 1920 ASSERT(args.length() == 4);
1914 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 1921 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
1915 int index = args.smi_at(1); 1922 int index = args.smi_at(1);
1916 Handle<String> pattern = args.at<String>(2); 1923 Handle<String> pattern = args.at<String>(2);
1917 Handle<String> flags = args.at<String>(3); 1924 Handle<String> flags = args.at<String>(3);
1918 1925
1919 // Get the RegExp function from the context in the literals array. 1926 // Get the RegExp function from the context in the literals array.
1920 // This is the RegExp function from the context in which the 1927 // This is the RegExp function from the context in which the
1921 // function was created. We do not use the RegExp function from the 1928 // function was created. We do not use the RegExp function from the
1922 // current global context because this might be the RegExp function 1929 // current global context because this might be the RegExp function
1923 // from another context which we should not have access to. 1930 // from another context which we should not have access to.
1924 Handle<JSFunction> constructor = 1931 Handle<JSFunction> constructor =
(...skipping 10 matching lines...) Expand all
1935 } 1942 }
1936 literals->set(index, *regexp); 1943 literals->set(index, *regexp);
1937 return *regexp; 1944 return *regexp;
1938 } 1945 }
1939 1946
1940 1947
1941 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) { 1948 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) {
1942 NoHandleAllocation ha; 1949 NoHandleAllocation ha;
1943 ASSERT(args.length() == 1); 1950 ASSERT(args.length() == 1);
1944 1951
1945 CONVERT_CHECKED(JSFunction, f, args[0]); 1952 CONVERT_ARG_CHECKED(JSFunction, f, 0);
1946 return f->shared()->name(); 1953 return f->shared()->name();
1947 } 1954 }
1948 1955
1949 1956
1950 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetName) { 1957 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetName) {
1951 NoHandleAllocation ha; 1958 NoHandleAllocation ha;
1952 ASSERT(args.length() == 2); 1959 ASSERT(args.length() == 2);
1953 1960
1954 CONVERT_CHECKED(JSFunction, f, args[0]); 1961 CONVERT_ARG_CHECKED(JSFunction, f, 0);
1955 CONVERT_CHECKED(String, name, args[1]); 1962 CONVERT_ARG_CHECKED(String, name, 1);
1956 f->shared()->set_name(name); 1963 f->shared()->set_name(name);
1957 return isolate->heap()->undefined_value(); 1964 return isolate->heap()->undefined_value();
1958 } 1965 }
1959 1966
1960 1967
1961 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) { 1968 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) {
1962 NoHandleAllocation ha; 1969 NoHandleAllocation ha;
1963 ASSERT(args.length() == 1); 1970 ASSERT(args.length() == 1);
1964 CONVERT_CHECKED(JSFunction, f, args[0]); 1971 CONVERT_ARG_CHECKED(JSFunction, f, 0);
1965 return isolate->heap()->ToBoolean( 1972 return isolate->heap()->ToBoolean(
1966 f->shared()->name_should_print_as_anonymous()); 1973 f->shared()->name_should_print_as_anonymous());
1967 } 1974 }
1968 1975
1969 1976
1970 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { 1977 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) {
1971 NoHandleAllocation ha; 1978 NoHandleAllocation ha;
1972 ASSERT(args.length() == 1); 1979 ASSERT(args.length() == 1);
1973 CONVERT_CHECKED(JSFunction, f, args[0]); 1980 CONVERT_ARG_CHECKED(JSFunction, f, 0);
1974 f->shared()->set_name_should_print_as_anonymous(true); 1981 f->shared()->set_name_should_print_as_anonymous(true);
1975 return isolate->heap()->undefined_value(); 1982 return isolate->heap()->undefined_value();
1976 } 1983 }
1977 1984
1978 1985
1979 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { 1986 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) {
1980 NoHandleAllocation ha; 1987 NoHandleAllocation ha;
1981 ASSERT(args.length() == 1); 1988 ASSERT(args.length() == 1);
1982 1989
1983 CONVERT_CHECKED(JSFunction, f, args[0]); 1990 CONVERT_ARG_CHECKED(JSFunction, f, 0);
1984 Object* obj = f->RemovePrototype(); 1991 Object* obj = f->RemovePrototype();
1985 if (obj->IsFailure()) return obj; 1992 if (obj->IsFailure()) return obj;
1986 1993
1987 return isolate->heap()->undefined_value(); 1994 return isolate->heap()->undefined_value();
1988 } 1995 }
1989 1996
1990 1997
1991 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) { 1998 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) {
1992 HandleScope scope(isolate); 1999 HandleScope scope(isolate);
1993 ASSERT(args.length() == 1); 2000 ASSERT(args.length() == 1);
1994 2001
1995 CONVERT_CHECKED(JSFunction, fun, args[0]); 2002 CONVERT_ARG_CHECKED(JSFunction, fun, 0);
1996 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate); 2003 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate);
1997 if (!script->IsScript()) return isolate->heap()->undefined_value(); 2004 if (!script->IsScript()) return isolate->heap()->undefined_value();
1998 2005
1999 return *GetScriptWrapper(Handle<Script>::cast(script)); 2006 return *GetScriptWrapper(Handle<Script>::cast(script));
2000 } 2007 }
2001 2008
2002 2009
2003 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetSourceCode) { 2010 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetSourceCode) {
2004 HandleScope scope(isolate); 2011 HandleScope scope(isolate);
2005 ASSERT(args.length() == 1); 2012 ASSERT(args.length() == 1);
2006 2013
2007 CONVERT_ARG_CHECKED(JSFunction, f, 0); 2014 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0);
2008 Handle<SharedFunctionInfo> shared(f->shared()); 2015 Handle<SharedFunctionInfo> shared(f->shared());
2009 return *shared->GetSourceCode(); 2016 return *shared->GetSourceCode();
2010 } 2017 }
2011 2018
2012 2019
2013 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScriptSourcePosition) { 2020 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScriptSourcePosition) {
2014 NoHandleAllocation ha; 2021 NoHandleAllocation ha;
2015 ASSERT(args.length() == 1); 2022 ASSERT(args.length() == 1);
2016 2023
2017 CONVERT_CHECKED(JSFunction, fun, args[0]); 2024 CONVERT_ARG_CHECKED(JSFunction, fun, 0);
2018 int pos = fun->shared()->start_position(); 2025 int pos = fun->shared()->start_position();
2019 return Smi::FromInt(pos); 2026 return Smi::FromInt(pos);
2020 } 2027 }
2021 2028
2022 2029
2023 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) { 2030 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) {
2024 ASSERT(args.length() == 2); 2031 ASSERT(args.length() == 2);
2025 2032
2026 CONVERT_CHECKED(Code, code, args[0]); 2033 CONVERT_ARG_CHECKED(Code, code, 0);
2027 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); 2034 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]);
2028 2035
2029 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); 2036 RUNTIME_ASSERT(0 <= offset && offset < code->Size());
2030 2037
2031 Address pc = code->address() + offset; 2038 Address pc = code->address() + offset;
2032 return Smi::FromInt(code->SourcePosition(pc)); 2039 return Smi::FromInt(code->SourcePosition(pc));
2033 } 2040 }
2034 2041
2035 2042
2036 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetInstanceClassName) { 2043 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetInstanceClassName) {
2037 NoHandleAllocation ha; 2044 NoHandleAllocation ha;
2038 ASSERT(args.length() == 2); 2045 ASSERT(args.length() == 2);
2039 2046
2040 CONVERT_CHECKED(JSFunction, fun, args[0]); 2047 CONVERT_ARG_CHECKED(JSFunction, fun, 0);
2041 CONVERT_CHECKED(String, name, args[1]); 2048 CONVERT_ARG_CHECKED(String, name, 1);
2042 fun->SetInstanceClassName(name); 2049 fun->SetInstanceClassName(name);
2043 return isolate->heap()->undefined_value(); 2050 return isolate->heap()->undefined_value();
2044 } 2051 }
2045 2052
2046 2053
2047 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) { 2054 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) {
2048 NoHandleAllocation ha; 2055 NoHandleAllocation ha;
2049 ASSERT(args.length() == 2); 2056 ASSERT(args.length() == 2);
2050 2057
2051 CONVERT_CHECKED(JSFunction, fun, args[0]); 2058 CONVERT_ARG_CHECKED(JSFunction, fun, 0);
2052 CONVERT_CHECKED(Smi, length, args[1]); 2059 CONVERT_SMI_ARG_CHECKED(length, 1);
2053 fun->shared()->set_length(length->value()); 2060 fun->shared()->set_length(length);
2054 return length; 2061 return isolate->heap()->undefined_value();
2055 } 2062 }
2056 2063
2057 2064
2058 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { 2065 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) {
2059 NoHandleAllocation ha; 2066 NoHandleAllocation ha;
2060 ASSERT(args.length() == 2); 2067 ASSERT(args.length() == 2);
2061 2068
2062 CONVERT_CHECKED(JSFunction, fun, args[0]); 2069 CONVERT_ARG_CHECKED(JSFunction, fun, 0);
2063 ASSERT(fun->should_have_prototype()); 2070 ASSERT(fun->should_have_prototype());
2064 Object* obj; 2071 Object* obj;
2065 { MaybeObject* maybe_obj = 2072 { MaybeObject* maybe_obj =
2066 Accessors::FunctionSetPrototype(fun, args[1], NULL); 2073 Accessors::FunctionSetPrototype(fun, args[1], NULL);
2067 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 2074 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2068 } 2075 }
2069 return args[0]; // return TOS 2076 return args[0]; // return TOS
2070 } 2077 }
2071 2078
2072 2079
2073 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { 2080 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) {
2074 NoHandleAllocation ha; 2081 NoHandleAllocation ha;
2075 RUNTIME_ASSERT(args.length() == 1); 2082 RUNTIME_ASSERT(args.length() == 1);
2076 CONVERT_CHECKED(JSFunction, function, args[0]); 2083 CONVERT_ARG_CHECKED(JSFunction, function, 0);
2077 2084
2078 MaybeObject* maybe_name = 2085 MaybeObject* maybe_name =
2079 isolate->heap()->AllocateStringFromAscii(CStrVector("prototype")); 2086 isolate->heap()->AllocateStringFromAscii(CStrVector("prototype"));
2080 String* name; 2087 String* name;
2081 if (!maybe_name->To(&name)) return maybe_name; 2088 if (!maybe_name->To(&name)) return maybe_name;
2082 2089
2083 if (function->HasFastProperties()) { 2090 if (function->HasFastProperties()) {
2084 // Construct a new field descriptor with updated attributes. 2091 // Construct a new field descriptor with updated attributes.
2085 DescriptorArray* instance_desc = function->map()->instance_descriptors(); 2092 DescriptorArray* instance_desc = function->map()->instance_descriptors();
2086 int index = instance_desc->Search(name); 2093 int index = instance_desc->Search(name);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 function->property_dictionary()->DetailsAtPut(entry, new_details); 2129 function->property_dictionary()->DetailsAtPut(entry, new_details);
2123 } 2130 }
2124 return function; 2131 return function;
2125 } 2132 }
2126 2133
2127 2134
2128 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { 2135 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) {
2129 NoHandleAllocation ha; 2136 NoHandleAllocation ha;
2130 ASSERT(args.length() == 1); 2137 ASSERT(args.length() == 1);
2131 2138
2132 CONVERT_CHECKED(JSFunction, f, args[0]); 2139 CONVERT_ARG_CHECKED(JSFunction, f, 0);
2133 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); 2140 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction());
2134 } 2141 }
2135 2142
2136 2143
2137 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { 2144 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) {
2138 NoHandleAllocation ha; 2145 NoHandleAllocation ha;
2139 ASSERT(args.length() == 1); 2146 ASSERT(args.length() == 1);
2140 2147
2141 CONVERT_CHECKED(JSFunction, f, args[0]); 2148 CONVERT_ARG_CHECKED(JSFunction, f, 0);
2142 return isolate->heap()->ToBoolean(f->IsBuiltin()); 2149 return isolate->heap()->ToBoolean(f->IsBuiltin());
2143 } 2150 }
2144 2151
2145 2152
2146 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { 2153 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) {
2147 HandleScope scope(isolate); 2154 HandleScope scope(isolate);
2148 ASSERT(args.length() == 2); 2155 ASSERT(args.length() == 2);
2149 2156
2150 CONVERT_ARG_CHECKED(JSFunction, target, 0); 2157 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0);
2151 Handle<Object> code = args.at<Object>(1); 2158 Handle<Object> code = args.at<Object>(1);
2152 2159
2153 Handle<Context> context(target->context()); 2160 Handle<Context> context(target->context());
2154 2161
2155 if (!code->IsNull()) { 2162 if (!code->IsNull()) {
2156 RUNTIME_ASSERT(code->IsJSFunction()); 2163 RUNTIME_ASSERT(code->IsJSFunction());
2157 Handle<JSFunction> fun = Handle<JSFunction>::cast(code); 2164 Handle<JSFunction> fun = Handle<JSFunction>::cast(code);
2158 Handle<SharedFunctionInfo> shared(fun->shared()); 2165 Handle<SharedFunctionInfo> shared(fun->shared());
2159 2166
2160 if (!SharedFunctionInfo::EnsureCompiled(shared, KEEP_EXCEPTION)) { 2167 if (!SharedFunctionInfo::EnsureCompiled(shared, KEEP_EXCEPTION)) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2204 } 2211 }
2205 2212
2206 target->set_context(*context); 2213 target->set_context(*context);
2207 return *target; 2214 return *target;
2208 } 2215 }
2209 2216
2210 2217
2211 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) { 2218 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) {
2212 HandleScope scope(isolate); 2219 HandleScope scope(isolate);
2213 ASSERT(args.length() == 2); 2220 ASSERT(args.length() == 2);
2214 CONVERT_ARG_CHECKED(JSFunction, function, 0); 2221 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
2215 CONVERT_SMI_ARG_CHECKED(num, 1); 2222 CONVERT_SMI_ARG_CHECKED(num, 1);
2216 RUNTIME_ASSERT(num >= 0); 2223 RUNTIME_ASSERT(num >= 0);
2217 SetExpectedNofProperties(function, num); 2224 SetExpectedNofProperties(function, num);
2218 return isolate->heap()->undefined_value(); 2225 return isolate->heap()->undefined_value();
2219 } 2226 }
2220 2227
2221 2228
2222 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate, 2229 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate,
2223 Object* char_code) { 2230 Object* char_code) {
2224 uint32_t code; 2231 uint32_t code;
2225 if (char_code->ToArrayIndex(&code)) { 2232 if (char_code->ToArrayIndex(&code)) {
2226 if (code <= 0xffff) { 2233 if (code <= 0xffff) {
2227 return isolate->heap()->LookupSingleCharacterStringFromCode(code); 2234 return isolate->heap()->LookupSingleCharacterStringFromCode(code);
2228 } 2235 }
2229 } 2236 }
2230 return isolate->heap()->empty_string(); 2237 return isolate->heap()->empty_string();
2231 } 2238 }
2232 2239
2233 2240
2234 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) { 2241 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) {
2235 NoHandleAllocation ha; 2242 NoHandleAllocation ha;
2236 ASSERT(args.length() == 2); 2243 ASSERT(args.length() == 2);
2237 2244
2238 CONVERT_CHECKED(String, subject, args[0]); 2245 CONVERT_ARG_CHECKED(String, subject, 0);
2239 Object* index = args[1]; 2246 Object* index = args[1];
2240 RUNTIME_ASSERT(index->IsNumber()); 2247 RUNTIME_ASSERT(index->IsNumber());
2241 2248
2242 uint32_t i = 0; 2249 uint32_t i = 0;
2243 if (index->IsSmi()) { 2250 if (index->IsSmi()) {
2244 int value = Smi::cast(index)->value(); 2251 int value = Smi::cast(index)->value();
2245 if (value < 0) return isolate->heap()->nan_value(); 2252 if (value < 0) return isolate->heap()->nan_value();
2246 i = value; 2253 i = value;
2247 } else { 2254 } else {
2248 ASSERT(index->IsHeapNumber()); 2255 ASSERT(index->IsHeapNumber());
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
3205 MemoryChunk::IncrementLiveBytesFromMutator(answer->address(), -delta); 3212 MemoryChunk::IncrementLiveBytesFromMutator(answer->address(), -delta);
3206 } 3213 }
3207 3214
3208 return *answer; 3215 return *answer;
3209 } 3216 }
3210 3217
3211 3218
3212 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceRegExpWithString) { 3219 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceRegExpWithString) {
3213 ASSERT(args.length() == 4); 3220 ASSERT(args.length() == 4);
3214 3221
3215 CONVERT_CHECKED(String, subject, args[0]); 3222 CONVERT_ARG_CHECKED(String, subject, 0);
3216 if (!subject->IsFlat()) { 3223 if (!subject->IsFlat()) {
3217 Object* flat_subject; 3224 Object* flat_subject;
3218 { MaybeObject* maybe_flat_subject = subject->TryFlatten(); 3225 { MaybeObject* maybe_flat_subject = subject->TryFlatten();
3219 if (!maybe_flat_subject->ToObject(&flat_subject)) { 3226 if (!maybe_flat_subject->ToObject(&flat_subject)) {
3220 return maybe_flat_subject; 3227 return maybe_flat_subject;
3221 } 3228 }
3222 } 3229 }
3223 subject = String::cast(flat_subject); 3230 subject = String::cast(flat_subject);
3224 } 3231 }
3225 3232
3226 CONVERT_CHECKED(String, replacement, args[2]); 3233 CONVERT_ARG_CHECKED(String, replacement, 2);
3227 if (!replacement->IsFlat()) { 3234 if (!replacement->IsFlat()) {
3228 Object* flat_replacement; 3235 Object* flat_replacement;
3229 { MaybeObject* maybe_flat_replacement = replacement->TryFlatten(); 3236 { MaybeObject* maybe_flat_replacement = replacement->TryFlatten();
3230 if (!maybe_flat_replacement->ToObject(&flat_replacement)) { 3237 if (!maybe_flat_replacement->ToObject(&flat_replacement)) {
3231 return maybe_flat_replacement; 3238 return maybe_flat_replacement;
3232 } 3239 }
3233 } 3240 }
3234 replacement = String::cast(flat_replacement); 3241 replacement = String::cast(flat_replacement);
3235 } 3242 }
3236 3243
3237 CONVERT_CHECKED(JSRegExp, regexp, args[1]); 3244 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1);
3238 CONVERT_CHECKED(JSArray, last_match_info, args[3]); 3245 CONVERT_ARG_CHECKED(JSArray, last_match_info, 3);
3239 3246
3240 ASSERT(last_match_info->HasFastElements()); 3247 ASSERT(last_match_info->HasFastElements());
3241 3248
3242 if (replacement->length() == 0) { 3249 if (replacement->length() == 0) {
3243 if (subject->HasOnlyAsciiChars()) { 3250 if (subject->HasOnlyAsciiChars()) {
3244 return StringReplaceRegExpWithEmptyString<SeqAsciiString>( 3251 return StringReplaceRegExpWithEmptyString<SeqAsciiString>(
3245 isolate, subject, regexp, last_match_info); 3252 isolate, subject, regexp, last_match_info);
3246 } else { 3253 } else {
3247 return StringReplaceRegExpWithEmptyString<SeqTwoByteString>( 3254 return StringReplaceRegExpWithEmptyString<SeqTwoByteString>(
3248 isolate, subject, regexp, last_match_info); 3255 isolate, subject, regexp, last_match_info);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3298 Handle<String> second = 3305 Handle<String> second =
3299 isolate->factory()->NewSubString(subject, index + 1, subject->length()); 3306 isolate->factory()->NewSubString(subject, index + 1, subject->length());
3300 return isolate->factory()->NewConsString(cons1, second); 3307 return isolate->factory()->NewConsString(cons1, second);
3301 } 3308 }
3302 } 3309 }
3303 3310
3304 3311
3305 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceOneCharWithString) { 3312 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceOneCharWithString) {
3306 ASSERT(args.length() == 3); 3313 ASSERT(args.length() == 3);
3307 HandleScope scope(isolate); 3314 HandleScope scope(isolate);
3308 CONVERT_ARG_CHECKED(String, subject, 0); 3315 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
3309 CONVERT_ARG_CHECKED(String, search, 1); 3316 CONVERT_ARG_HANDLE_CHECKED(String, search, 1);
3310 CONVERT_ARG_CHECKED(String, replace, 2); 3317 CONVERT_ARG_HANDLE_CHECKED(String, replace, 2);
3311 3318
3312 // If the cons string tree is too deep, we simply abort the recursion and 3319 // If the cons string tree is too deep, we simply abort the recursion and
3313 // retry with a flattened subject string. 3320 // retry with a flattened subject string.
3314 const int kRecursionLimit = 0x1000; 3321 const int kRecursionLimit = 0x1000;
3315 bool found = false; 3322 bool found = false;
3316 Handle<String> result = 3323 Handle<String> result =
3317 Runtime::StringReplaceOneCharWithString(isolate, 3324 Runtime::StringReplaceOneCharWithString(isolate,
3318 subject, 3325 subject,
3319 search, 3326 search,
3320 replace, 3327 replace,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3379 seq_sub.ToUC16Vector(), 3386 seq_sub.ToUC16Vector(),
3380 pat_vector, 3387 pat_vector,
3381 start_index); 3388 start_index);
3382 } 3389 }
3383 3390
3384 3391
3385 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringIndexOf) { 3392 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringIndexOf) {
3386 HandleScope scope(isolate); // create a new handle scope 3393 HandleScope scope(isolate); // create a new handle scope
3387 ASSERT(args.length() == 3); 3394 ASSERT(args.length() == 3);
3388 3395
3389 CONVERT_ARG_CHECKED(String, sub, 0); 3396 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0);
3390 CONVERT_ARG_CHECKED(String, pat, 1); 3397 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1);
3391 3398
3392 Object* index = args[2]; 3399 Object* index = args[2];
3393 uint32_t start_index; 3400 uint32_t start_index;
3394 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); 3401 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1);
3395 3402
3396 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length())); 3403 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length()));
3397 int position = 3404 int position =
3398 Runtime::StringMatch(isolate, sub, pat, start_index); 3405 Runtime::StringMatch(isolate, sub, pat, start_index);
3399 return Smi::FromInt(position); 3406 return Smi::FromInt(position);
3400 } 3407 }
(...skipping 30 matching lines...) Expand all
3431 return i; 3438 return i;
3432 } 3439 }
3433 } 3440 }
3434 return -1; 3441 return -1;
3435 } 3442 }
3436 3443
3437 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) { 3444 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) {
3438 HandleScope scope(isolate); // create a new handle scope 3445 HandleScope scope(isolate); // create a new handle scope
3439 ASSERT(args.length() == 3); 3446 ASSERT(args.length() == 3);
3440 3447
3441 CONVERT_ARG_CHECKED(String, sub, 0); 3448 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0);
3442 CONVERT_ARG_CHECKED(String, pat, 1); 3449 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1);
3443 3450
3444 Object* index = args[2]; 3451 Object* index = args[2];
3445 uint32_t start_index; 3452 uint32_t start_index;
3446 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); 3453 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1);
3447 3454
3448 uint32_t pat_length = pat->length(); 3455 uint32_t pat_length = pat->length();
3449 uint32_t sub_length = sub->length(); 3456 uint32_t sub_length = sub->length();
3450 3457
3451 if (start_index + pat_length > sub_length) { 3458 if (start_index + pat_length > sub_length) {
3452 start_index = sub_length - pat_length; 3459 start_index = sub_length - pat_length;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3490 } 3497 }
3491 3498
3492 return Smi::FromInt(position); 3499 return Smi::FromInt(position);
3493 } 3500 }
3494 3501
3495 3502
3496 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) { 3503 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) {
3497 NoHandleAllocation ha; 3504 NoHandleAllocation ha;
3498 ASSERT(args.length() == 2); 3505 ASSERT(args.length() == 2);
3499 3506
3500 CONVERT_CHECKED(String, str1, args[0]); 3507 CONVERT_ARG_CHECKED(String, str1, 0);
3501 CONVERT_CHECKED(String, str2, args[1]); 3508 CONVERT_ARG_CHECKED(String, str2, 1);
3502 3509
3503 if (str1 == str2) return Smi::FromInt(0); // Equal. 3510 if (str1 == str2) return Smi::FromInt(0); // Equal.
3504 int str1_length = str1->length(); 3511 int str1_length = str1->length();
3505 int str2_length = str2->length(); 3512 int str2_length = str2->length();
3506 3513
3507 // Decide trivial cases without flattening. 3514 // Decide trivial cases without flattening.
3508 if (str1_length == 0) { 3515 if (str1_length == 0) {
3509 if (str2_length == 0) return Smi::FromInt(0); // Equal. 3516 if (str2_length == 0) return Smi::FromInt(0); // Equal.
3510 return Smi::FromInt(-str2_length); 3517 return Smi::FromInt(-str2_length);
3511 } else { 3518 } else {
(...skipping 26 matching lines...) Expand all
3538 } 3545 }
3539 3546
3540 return Smi::FromInt(str1_length - str2_length); 3547 return Smi::FromInt(str1_length - str2_length);
3541 } 3548 }
3542 3549
3543 3550
3544 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) { 3551 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) {
3545 NoHandleAllocation ha; 3552 NoHandleAllocation ha;
3546 ASSERT(args.length() == 3); 3553 ASSERT(args.length() == 3);
3547 3554
3548 CONVERT_CHECKED(String, value, args[0]); 3555 CONVERT_ARG_CHECKED(String, value, 0);
3549 int start, end; 3556 int start, end;
3550 // We have a fast integer-only case here to avoid a conversion to double in 3557 // We have a fast integer-only case here to avoid a conversion to double in
3551 // the common case where from and to are Smis. 3558 // the common case where from and to are Smis.
3552 if (args[1]->IsSmi() && args[2]->IsSmi()) { 3559 if (args[1]->IsSmi() && args[2]->IsSmi()) {
3553 CONVERT_SMI_ARG_CHECKED(from_number, 1); 3560 CONVERT_SMI_ARG_CHECKED(from_number, 1);
3554 CONVERT_SMI_ARG_CHECKED(to_number, 2); 3561 CONVERT_SMI_ARG_CHECKED(to_number, 2);
3555 start = from_number; 3562 start = from_number;
3556 end = to_number; 3563 end = to_number;
3557 } else { 3564 } else {
3558 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); 3565 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1);
3559 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); 3566 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2);
3560 start = FastD2I(from_number); 3567 start = FastD2I(from_number);
3561 end = FastD2I(to_number); 3568 end = FastD2I(to_number);
3562 } 3569 }
3563 RUNTIME_ASSERT(end >= start); 3570 RUNTIME_ASSERT(end >= start);
3564 RUNTIME_ASSERT(start >= 0); 3571 RUNTIME_ASSERT(start >= 0);
3565 RUNTIME_ASSERT(end <= value->length()); 3572 RUNTIME_ASSERT(end <= value->length());
3566 isolate->counters()->sub_string_runtime()->Increment(); 3573 isolate->counters()->sub_string_runtime()->Increment();
3567 return value->SubString(start, end); 3574 return value->SubString(start, end);
3568 } 3575 }
3569 3576
3570 3577
3571 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { 3578 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) {
3572 ASSERT_EQ(3, args.length()); 3579 ASSERT_EQ(3, args.length());
3573 3580
3574 CONVERT_ARG_CHECKED(String, subject, 0); 3581 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
3575 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1); 3582 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
3576 CONVERT_ARG_CHECKED(JSArray, regexp_info, 2); 3583 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2);
3577 HandleScope handles; 3584 HandleScope handles;
3578 3585
3579 Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info); 3586 Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info);
3580 3587
3581 if (match.is_null()) { 3588 if (match.is_null()) {
3582 return Failure::Exception(); 3589 return Failure::Exception();
3583 } 3590 }
3584 if (match->IsNull()) { 3591 if (match->IsNull()) {
3585 return isolate->heap()->null_value(); 3592 return isolate->heap()->null_value();
3586 } 3593 }
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
3957 } 3964 }
3958 // No matches at all, return failure or exception result directly. 3965 // No matches at all, return failure or exception result directly.
3959 return result; 3966 return result;
3960 } 3967 }
3961 3968
3962 3969
3963 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExecMultiple) { 3970 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExecMultiple) {
3964 ASSERT(args.length() == 4); 3971 ASSERT(args.length() == 4);
3965 HandleScope handles(isolate); 3972 HandleScope handles(isolate);
3966 3973
3967 CONVERT_ARG_CHECKED(String, subject, 1); 3974 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1);
3968 if (!subject->IsFlat()) FlattenString(subject); 3975 if (!subject->IsFlat()) FlattenString(subject);
3969 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); 3976 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0);
3970 CONVERT_ARG_CHECKED(JSArray, last_match_info, 2); 3977 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 2);
3971 CONVERT_ARG_CHECKED(JSArray, result_array, 3); 3978 CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3);
3972 3979
3973 ASSERT(last_match_info->HasFastElements()); 3980 ASSERT(last_match_info->HasFastElements());
3974 ASSERT(regexp->GetFlags().is_global()); 3981 ASSERT(regexp->GetFlags().is_global());
3975 Handle<FixedArray> result_elements; 3982 Handle<FixedArray> result_elements;
3976 if (result_array->HasFastElements()) { 3983 if (result_array->HasFastElements()) {
3977 result_elements = 3984 result_elements =
3978 Handle<FixedArray>(FixedArray::cast(result_array->elements())); 3985 Handle<FixedArray>(FixedArray::cast(result_array->elements()));
3979 } 3986 }
3980 if (result_elements.is_null() || result_elements->length() < 16) { 3987 if (result_elements.is_null() || result_elements->length() < 16) {
3981 result_elements = isolate->factory()->NewFixedArrayWithHoles(16); 3988 result_elements = isolate->factory()->NewFixedArrayWithHoles(16);
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
4310 4317
4311 // Implements part of 8.12.9 DefineOwnProperty. 4318 // Implements part of 8.12.9 DefineOwnProperty.
4312 // There are 3 cases that lead here: 4319 // There are 3 cases that lead here:
4313 // Step 4b - define a new accessor property. 4320 // Step 4b - define a new accessor property.
4314 // Steps 9c & 12 - replace an existing data property with an accessor property. 4321 // Steps 9c & 12 - replace an existing data property with an accessor property.
4315 // Step 12 - update an existing accessor property with an accessor or generic 4322 // Step 12 - update an existing accessor property with an accessor or generic
4316 // descriptor. 4323 // descriptor.
4317 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineAccessorProperty) { 4324 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineAccessorProperty) {
4318 ASSERT(args.length() == 5); 4325 ASSERT(args.length() == 5);
4319 HandleScope scope(isolate); 4326 HandleScope scope(isolate);
4320 CONVERT_ARG_CHECKED(JSObject, obj, 0); 4327 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
4321 CONVERT_CHECKED(String, name, args[1]); 4328 CONVERT_ARG_CHECKED(String, name, 1);
4322 CONVERT_CHECKED(Smi, flag_setter, args[2]); 4329 CONVERT_SMI_ARG_CHECKED(flag_setter, 2);
4323 Object* fun = args[3]; 4330 Object* fun = args[3];
4324 CONVERT_CHECKED(Smi, flag_attr, args[4]); 4331 CONVERT_SMI_ARG_CHECKED(unchecked, 4);
4325 4332
4326 int unchecked = flag_attr->value();
4327 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 4333 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
4328 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); 4334 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked);
4329 4335
4330 RUNTIME_ASSERT(!obj->IsNull()); 4336 RUNTIME_ASSERT(!obj->IsNull());
4331 RUNTIME_ASSERT(fun->IsSpecFunction() || fun->IsUndefined()); 4337 RUNTIME_ASSERT(fun->IsSpecFunction() || fun->IsUndefined());
4332 return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr); 4338 return obj->DefineAccessor(name, flag_setter == 0, fun, attr);
4333 } 4339 }
4334 4340
4335 // Implements part of 8.12.9 DefineOwnProperty. 4341 // Implements part of 8.12.9 DefineOwnProperty.
4336 // There are 3 cases that lead here: 4342 // There are 3 cases that lead here:
4337 // Step 4a - define a new data property. 4343 // Step 4a - define a new data property.
4338 // Steps 9b & 12 - replace an existing accessor property with a data property. 4344 // Steps 9b & 12 - replace an existing accessor property with a data property.
4339 // Step 12 - update an existing data property with a data or generic 4345 // Step 12 - update an existing data property with a data or generic
4340 // descriptor. 4346 // descriptor.
4341 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) { 4347 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) {
4342 ASSERT(args.length() == 4); 4348 ASSERT(args.length() == 4);
4343 HandleScope scope(isolate); 4349 HandleScope scope(isolate);
4344 CONVERT_ARG_CHECKED(JSObject, js_object, 0); 4350 CONVERT_ARG_HANDLE_CHECKED(JSObject, js_object, 0);
4345 CONVERT_ARG_CHECKED(String, name, 1); 4351 CONVERT_ARG_HANDLE_CHECKED(String, name, 1);
4346 Handle<Object> obj_value = args.at<Object>(2); 4352 Handle<Object> obj_value = args.at<Object>(2);
4347 CONVERT_CHECKED(Smi, flag, args[3]); 4353 CONVERT_SMI_ARG_CHECKED(unchecked, 3);
4348 4354
4349 int unchecked = flag->value();
4350 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 4355 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
4351 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); 4356 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked);
4352 4357
4353 // Check if this is an element. 4358 // Check if this is an element.
4354 uint32_t index; 4359 uint32_t index;
4355 bool is_element = name->AsArrayIndex(&index); 4360 bool is_element = name->AsArrayIndex(&index);
4356 4361
4357 // Special case for elements if any of the flags might be involved. 4362 // Special case for elements if any of the flags might be involved.
4358 // If elements are in fast case we always implicitly assume that: 4363 // If elements are in fast case we always implicitly assume that:
4359 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. 4364 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false.
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
4660 Handle<Object> value = args.at<Object>(2); 4665 Handle<Object> value = args.at<Object>(2);
4661 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); 4666 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3);
4662 RUNTIME_ASSERT( 4667 RUNTIME_ASSERT(
4663 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 4668 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
4664 // Compute attributes. 4669 // Compute attributes.
4665 PropertyAttributes attributes = 4670 PropertyAttributes attributes =
4666 static_cast<PropertyAttributes>(unchecked_attributes); 4671 static_cast<PropertyAttributes>(unchecked_attributes);
4667 4672
4668 StrictModeFlag strict_mode = kNonStrictMode; 4673 StrictModeFlag strict_mode = kNonStrictMode;
4669 if (args.length() == 5) { 4674 if (args.length() == 5) {
4670 CONVERT_STRICT_MODE_ARG(strict_mode_flag, 4); 4675 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_flag, 4);
4671 strict_mode = strict_mode_flag; 4676 strict_mode = strict_mode_flag;
4672 } 4677 }
4673 4678
4674 return Runtime::SetObjectProperty(isolate, 4679 return Runtime::SetObjectProperty(isolate,
4675 object, 4680 object,
4676 key, 4681 key,
4677 value, 4682 value,
4678 attributes, 4683 attributes,
4679 strict_mode); 4684 strict_mode);
4680 } 4685 }
(...skipping 27 matching lines...) Expand all
4708 if (object->IsJSFunction()) { 4713 if (object->IsJSFunction()) {
4709 JSFunction* func = JSFunction::cast(*object); 4714 JSFunction* func = JSFunction::cast(*object);
4710 func->shared()->set_native(true); 4715 func->shared()->set_native(true);
4711 } 4716 }
4712 return isolate->heap()->undefined_value(); 4717 return isolate->heap()->undefined_value();
4713 } 4718 }
4714 4719
4715 4720
4716 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) { 4721 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) {
4717 RUNTIME_ASSERT(args.length() == 5); 4722 RUNTIME_ASSERT(args.length() == 5);
4718 CONVERT_ARG_CHECKED(JSObject, object, 0); 4723 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
4719 CONVERT_SMI_ARG_CHECKED(store_index, 1); 4724 CONVERT_SMI_ARG_CHECKED(store_index, 1);
4720 Handle<Object> value = args.at<Object>(2); 4725 Handle<Object> value = args.at<Object>(2);
4721 CONVERT_ARG_CHECKED(FixedArray, literals, 3); 4726 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3);
4722 CONVERT_SMI_ARG_CHECKED(literal_index, 4); 4727 CONVERT_SMI_ARG_CHECKED(literal_index, 4);
4723 HandleScope scope; 4728 HandleScope scope;
4724 4729
4725 Object* raw_boilerplate_object = literals->get(literal_index); 4730 Object* raw_boilerplate_object = literals->get(literal_index);
4726 Handle<JSArray> boilerplate_object(JSArray::cast(raw_boilerplate_object)); 4731 Handle<JSArray> boilerplate_object(JSArray::cast(raw_boilerplate_object));
4727 #if DEBUG 4732 #if DEBUG
4728 ElementsKind elements_kind = object->GetElementsKind(); 4733 ElementsKind elements_kind = object->GetElementsKind();
4729 #endif 4734 #endif
4730 ASSERT(elements_kind <= FAST_DOUBLE_ELEMENTS); 4735 ASSERT(elements_kind <= FAST_DOUBLE_ELEMENTS);
4731 // Smis should never trigger transitions. 4736 // Smis should never trigger transitions.
(...skipping 19 matching lines...) Expand all
4751 } 4756 }
4752 return *object; 4757 return *object;
4753 } 4758 }
4754 4759
4755 4760
4756 // Set a local property, even if it is READ_ONLY. If the property does not 4761 // Set a local property, even if it is READ_ONLY. If the property does not
4757 // exist, it will be added with attributes NONE. 4762 // exist, it will be added with attributes NONE.
4758 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { 4763 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) {
4759 NoHandleAllocation ha; 4764 NoHandleAllocation ha;
4760 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); 4765 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4);
4761 CONVERT_CHECKED(JSObject, object, args[0]); 4766 CONVERT_ARG_CHECKED(JSObject, object, 0);
4762 CONVERT_CHECKED(String, name, args[1]); 4767 CONVERT_ARG_CHECKED(String, name, 1);
4763 // Compute attributes. 4768 // Compute attributes.
4764 PropertyAttributes attributes = NONE; 4769 PropertyAttributes attributes = NONE;
4765 if (args.length() == 4) { 4770 if (args.length() == 4) {
4766 CONVERT_CHECKED(Smi, value_obj, args[3]); 4771 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3);
4767 int unchecked_value = value_obj->value();
4768 // Only attribute bits should be set. 4772 // Only attribute bits should be set.
4769 RUNTIME_ASSERT( 4773 RUNTIME_ASSERT(
4770 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 4774 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
4771 attributes = static_cast<PropertyAttributes>(unchecked_value); 4775 attributes = static_cast<PropertyAttributes>(unchecked_value);
4772 } 4776 }
4773 4777
4774 return object-> 4778 return object->
4775 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); 4779 SetLocalPropertyIgnoreAttributes(name, args[2], attributes);
4776 } 4780 }
4777 4781
4778 4782
4779 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { 4783 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) {
4780 NoHandleAllocation ha; 4784 NoHandleAllocation ha;
4781 ASSERT(args.length() == 3); 4785 ASSERT(args.length() == 3);
4782 4786
4783 CONVERT_CHECKED(JSReceiver, object, args[0]); 4787 CONVERT_ARG_CHECKED(JSReceiver, object, 0);
4784 CONVERT_CHECKED(String, key, args[1]); 4788 CONVERT_ARG_CHECKED(String, key, 1);
4785 CONVERT_STRICT_MODE_ARG(strict_mode, 2); 4789 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2);
4786 return object->DeleteProperty(key, (strict_mode == kStrictMode) 4790 return object->DeleteProperty(key, (strict_mode == kStrictMode)
4787 ? JSReceiver::STRICT_DELETION 4791 ? JSReceiver::STRICT_DELETION
4788 : JSReceiver::NORMAL_DELETION); 4792 : JSReceiver::NORMAL_DELETION);
4789 } 4793 }
4790 4794
4791 4795
4792 static Object* HasLocalPropertyImplementation(Isolate* isolate, 4796 static Object* HasLocalPropertyImplementation(Isolate* isolate,
4793 Handle<JSObject> object, 4797 Handle<JSObject> object,
4794 Handle<String> key) { 4798 Handle<String> key) {
4795 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); 4799 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value();
4796 // Handle hidden prototypes. If there's a hidden prototype above this thing 4800 // Handle hidden prototypes. If there's a hidden prototype above this thing
4797 // then we have to check it for properties, because they are supposed to 4801 // then we have to check it for properties, because they are supposed to
4798 // look like they are on this object. 4802 // look like they are on this object.
4799 Handle<Object> proto(object->GetPrototype()); 4803 Handle<Object> proto(object->GetPrototype());
4800 if (proto->IsJSObject() && 4804 if (proto->IsJSObject() &&
4801 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { 4805 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) {
4802 return HasLocalPropertyImplementation(isolate, 4806 return HasLocalPropertyImplementation(isolate,
4803 Handle<JSObject>::cast(proto), 4807 Handle<JSObject>::cast(proto),
4804 key); 4808 key);
4805 } 4809 }
4806 return isolate->heap()->false_value(); 4810 return isolate->heap()->false_value();
4807 } 4811 }
4808 4812
4809 4813
4810 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { 4814 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) {
4811 NoHandleAllocation ha; 4815 NoHandleAllocation ha;
4812 ASSERT(args.length() == 2); 4816 ASSERT(args.length() == 2);
4813 CONVERT_CHECKED(String, key, args[1]); 4817 CONVERT_ARG_CHECKED(String, key, 1);
4814 4818
4815 uint32_t index; 4819 uint32_t index;
4816 const bool key_is_array_index = key->AsArrayIndex(&index); 4820 const bool key_is_array_index = key->AsArrayIndex(&index);
4817 4821
4818 Object* obj = args[0]; 4822 Object* obj = args[0];
4819 // Only JS objects can have properties. 4823 // Only JS objects can have properties.
4820 if (obj->IsJSObject()) { 4824 if (obj->IsJSObject()) {
4821 JSObject* object = JSObject::cast(obj); 4825 JSObject* object = JSObject::cast(obj);
4822 // Fast case: either the key is a real named property or it is not 4826 // Fast case: either the key is a real named property or it is not
4823 // an array index and there are no interceptors or hidden 4827 // an array index and there are no interceptors or hidden
(...skipping 17 matching lines...) Expand all
4841 return isolate->heap()->true_value(); 4845 return isolate->heap()->true_value();
4842 } 4846 }
4843 } 4847 }
4844 return isolate->heap()->false_value(); 4848 return isolate->heap()->false_value();
4845 } 4849 }
4846 4850
4847 4851
4848 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { 4852 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) {
4849 NoHandleAllocation na; 4853 NoHandleAllocation na;
4850 ASSERT(args.length() == 2); 4854 ASSERT(args.length() == 2);
4851 CONVERT_CHECKED(JSReceiver, receiver, args[0]); 4855 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0);
4852 CONVERT_CHECKED(String, key, args[1]); 4856 CONVERT_ARG_CHECKED(String, key, 1);
4853 4857
4854 bool result = receiver->HasProperty(key); 4858 bool result = receiver->HasProperty(key);
4855 if (isolate->has_pending_exception()) return Failure::Exception(); 4859 if (isolate->has_pending_exception()) return Failure::Exception();
4856 return isolate->heap()->ToBoolean(result); 4860 return isolate->heap()->ToBoolean(result);
4857 } 4861 }
4858 4862
4859 4863
4860 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { 4864 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) {
4861 NoHandleAllocation na; 4865 NoHandleAllocation na;
4862 ASSERT(args.length() == 2); 4866 ASSERT(args.length() == 2);
4863 CONVERT_CHECKED(JSReceiver, receiver, args[0]); 4867 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0);
4864 CONVERT_CHECKED(Smi, index, args[1]); 4868 CONVERT_SMI_ARG_CHECKED(index, 1);
4865 4869
4866 bool result = receiver->HasElement(index->value()); 4870 bool result = receiver->HasElement(index);
4867 if (isolate->has_pending_exception()) return Failure::Exception(); 4871 if (isolate->has_pending_exception()) return Failure::Exception();
4868 return isolate->heap()->ToBoolean(result); 4872 return isolate->heap()->ToBoolean(result);
4869 } 4873 }
4870 4874
4871 4875
4872 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { 4876 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) {
4873 NoHandleAllocation ha; 4877 NoHandleAllocation ha;
4874 ASSERT(args.length() == 2); 4878 ASSERT(args.length() == 2);
4875 4879
4876 CONVERT_CHECKED(JSObject, object, args[0]); 4880 CONVERT_ARG_CHECKED(JSObject, object, 0);
4877 CONVERT_CHECKED(String, key, args[1]); 4881 CONVERT_ARG_CHECKED(String, key, 1);
4878 4882
4879 uint32_t index; 4883 uint32_t index;
4880 if (key->AsArrayIndex(&index)) { 4884 if (key->AsArrayIndex(&index)) {
4881 JSObject::LocalElementType type = object->HasLocalElement(index); 4885 JSObject::LocalElementType type = object->HasLocalElement(index);
4882 switch (type) { 4886 switch (type) {
4883 case JSObject::UNDEFINED_ELEMENT: 4887 case JSObject::UNDEFINED_ELEMENT:
4884 case JSObject::STRING_CHARACTER_ELEMENT: 4888 case JSObject::STRING_CHARACTER_ELEMENT:
4885 return isolate->heap()->false_value(); 4889 return isolate->heap()->false_value();
4886 case JSObject::INTERCEPTED_ELEMENT: 4890 case JSObject::INTERCEPTED_ELEMENT:
4887 case JSObject::FAST_ELEMENT: 4891 case JSObject::FAST_ELEMENT:
(...skipping 24 matching lines...) Expand all
4912 } 4916 }
4913 4917
4914 PropertyAttributes att = object->GetLocalPropertyAttribute(key); 4918 PropertyAttributes att = object->GetLocalPropertyAttribute(key);
4915 return isolate->heap()->ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0); 4919 return isolate->heap()->ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0);
4916 } 4920 }
4917 4921
4918 4922
4919 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) { 4923 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) {
4920 HandleScope scope(isolate); 4924 HandleScope scope(isolate);
4921 ASSERT(args.length() == 1); 4925 ASSERT(args.length() == 1);
4922 CONVERT_ARG_CHECKED(JSReceiver, object, 0); 4926 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
4923 bool threw = false; 4927 bool threw = false;
4924 Handle<JSArray> result = GetKeysFor(object, &threw); 4928 Handle<JSArray> result = GetKeysFor(object, &threw);
4925 if (threw) return Failure::Exception(); 4929 if (threw) return Failure::Exception();
4926 return *result; 4930 return *result;
4927 } 4931 }
4928 4932
4929 4933
4930 // Returns either a FixedArray as Runtime_GetPropertyNames, 4934 // Returns either a FixedArray as Runtime_GetPropertyNames,
4931 // or, if the given object has an enum cache that contains 4935 // or, if the given object has an enum cache that contains
4932 // all enumerable properties of the object and its prototypes 4936 // all enumerable properties of the object and its prototypes
4933 // have none, the map of the object. This is used to speed up 4937 // have none, the map of the object. This is used to speed up
4934 // the check for deletions during a for-in. 4938 // the check for deletions during a for-in.
4935 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) { 4939 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) {
4936 ASSERT(args.length() == 1); 4940 ASSERT(args.length() == 1);
4937 4941
4938 CONVERT_CHECKED(JSReceiver, raw_object, args[0]); 4942 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0);
4939 4943
4940 if (raw_object->IsSimpleEnum()) return raw_object->map(); 4944 if (raw_object->IsSimpleEnum()) return raw_object->map();
4941 4945
4942 HandleScope scope(isolate); 4946 HandleScope scope(isolate);
4943 Handle<JSReceiver> object(raw_object); 4947 Handle<JSReceiver> object(raw_object);
4944 bool threw = false; 4948 bool threw = false;
4945 Handle<FixedArray> content = 4949 Handle<FixedArray> content =
4946 GetKeysInFixedArrayFor(object, INCLUDE_PROTOS, &threw); 4950 GetKeysInFixedArrayFor(object, INCLUDE_PROTOS, &threw);
4947 if (threw) return Failure::Exception(); 4951 if (threw) return Failure::Exception();
4948 4952
(...skipping 20 matching lines...) Expand all
4969 4973
4970 4974
4971 // Return the names of the local named properties. 4975 // Return the names of the local named properties.
4972 // args[0]: object 4976 // args[0]: object
4973 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { 4977 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) {
4974 HandleScope scope(isolate); 4978 HandleScope scope(isolate);
4975 ASSERT(args.length() == 1); 4979 ASSERT(args.length() == 1);
4976 if (!args[0]->IsJSObject()) { 4980 if (!args[0]->IsJSObject()) {
4977 return isolate->heap()->undefined_value(); 4981 return isolate->heap()->undefined_value();
4978 } 4982 }
4979 CONVERT_ARG_CHECKED(JSObject, obj, 0); 4983 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
4980 4984
4981 // Skip the global proxy as it has no properties and always delegates to the 4985 // Skip the global proxy as it has no properties and always delegates to the
4982 // real global object. 4986 // real global object.
4983 if (obj->IsJSGlobalProxy()) { 4987 if (obj->IsJSGlobalProxy()) {
4984 // Only collect names if access is permitted. 4988 // Only collect names if access is permitted.
4985 if (obj->IsAccessCheckNeeded() && 4989 if (obj->IsAccessCheckNeeded() &&
4986 !isolate->MayNamedAccess(*obj, 4990 !isolate->MayNamedAccess(*obj,
4987 isolate->heap()->undefined_value(), 4991 isolate->heap()->undefined_value(),
4988 v8::ACCESS_KEYS)) { 4992 v8::ACCESS_KEYS)) {
4989 isolate->ReportFailedAccessCheck(*obj, v8::ACCESS_KEYS); 4993 isolate->ReportFailedAccessCheck(*obj, v8::ACCESS_KEYS);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
5056 5060
5057 5061
5058 // Return the names of the local indexed properties. 5062 // Return the names of the local indexed properties.
5059 // args[0]: object 5063 // args[0]: object
5060 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalElementNames) { 5064 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalElementNames) {
5061 HandleScope scope(isolate); 5065 HandleScope scope(isolate);
5062 ASSERT(args.length() == 1); 5066 ASSERT(args.length() == 1);
5063 if (!args[0]->IsJSObject()) { 5067 if (!args[0]->IsJSObject()) {
5064 return isolate->heap()->undefined_value(); 5068 return isolate->heap()->undefined_value();
5065 } 5069 }
5066 CONVERT_ARG_CHECKED(JSObject, obj, 0); 5070 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
5067 5071
5068 int n = obj->NumberOfLocalElements(static_cast<PropertyAttributes>(NONE)); 5072 int n = obj->NumberOfLocalElements(static_cast<PropertyAttributes>(NONE));
5069 Handle<FixedArray> names = isolate->factory()->NewFixedArray(n); 5073 Handle<FixedArray> names = isolate->factory()->NewFixedArray(n);
5070 obj->GetLocalElementKeys(*names, static_cast<PropertyAttributes>(NONE)); 5074 obj->GetLocalElementKeys(*names, static_cast<PropertyAttributes>(NONE));
5071 return *isolate->factory()->NewJSArrayWithElements(names); 5075 return *isolate->factory()->NewJSArrayWithElements(names);
5072 } 5076 }
5073 5077
5074 5078
5075 // Return information on whether an object has a named or indexed interceptor. 5079 // Return information on whether an object has a named or indexed interceptor.
5076 // args[0]: object 5080 // args[0]: object
5077 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetInterceptorInfo) { 5081 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetInterceptorInfo) {
5078 HandleScope scope(isolate); 5082 HandleScope scope(isolate);
5079 ASSERT(args.length() == 1); 5083 ASSERT(args.length() == 1);
5080 if (!args[0]->IsJSObject()) { 5084 if (!args[0]->IsJSObject()) {
5081 return Smi::FromInt(0); 5085 return Smi::FromInt(0);
5082 } 5086 }
5083 CONVERT_ARG_CHECKED(JSObject, obj, 0); 5087 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
5084 5088
5085 int result = 0; 5089 int result = 0;
5086 if (obj->HasNamedInterceptor()) result |= 2; 5090 if (obj->HasNamedInterceptor()) result |= 2;
5087 if (obj->HasIndexedInterceptor()) result |= 1; 5091 if (obj->HasIndexedInterceptor()) result |= 1;
5088 5092
5089 return Smi::FromInt(result); 5093 return Smi::FromInt(result);
5090 } 5094 }
5091 5095
5092 5096
5093 // Return property names from named interceptor. 5097 // Return property names from named interceptor.
5094 // args[0]: object 5098 // args[0]: object
5095 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetNamedInterceptorPropertyNames) { 5099 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetNamedInterceptorPropertyNames) {
5096 HandleScope scope(isolate); 5100 HandleScope scope(isolate);
5097 ASSERT(args.length() == 1); 5101 ASSERT(args.length() == 1);
5098 CONVERT_ARG_CHECKED(JSObject, obj, 0); 5102 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
5099 5103
5100 if (obj->HasNamedInterceptor()) { 5104 if (obj->HasNamedInterceptor()) {
5101 v8::Handle<v8::Array> result = GetKeysForNamedInterceptor(obj, obj); 5105 v8::Handle<v8::Array> result = GetKeysForNamedInterceptor(obj, obj);
5102 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); 5106 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result);
5103 } 5107 }
5104 return isolate->heap()->undefined_value(); 5108 return isolate->heap()->undefined_value();
5105 } 5109 }
5106 5110
5107 5111
5108 // Return element names from indexed interceptor. 5112 // Return element names from indexed interceptor.
5109 // args[0]: object 5113 // args[0]: object
5110 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetIndexedInterceptorElementNames) { 5114 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetIndexedInterceptorElementNames) {
5111 HandleScope scope(isolate); 5115 HandleScope scope(isolate);
5112 ASSERT(args.length() == 1); 5116 ASSERT(args.length() == 1);
5113 CONVERT_ARG_CHECKED(JSObject, obj, 0); 5117 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
5114 5118
5115 if (obj->HasIndexedInterceptor()) { 5119 if (obj->HasIndexedInterceptor()) {
5116 v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj); 5120 v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj);
5117 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); 5121 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result);
5118 } 5122 }
5119 return isolate->heap()->undefined_value(); 5123 return isolate->heap()->undefined_value();
5120 } 5124 }
5121 5125
5122 5126
5123 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) { 5127 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) {
5124 ASSERT_EQ(args.length(), 1); 5128 ASSERT_EQ(args.length(), 1);
5125 CONVERT_CHECKED(JSObject, raw_object, args[0]); 5129 CONVERT_ARG_CHECKED(JSObject, raw_object, 0);
5126 HandleScope scope(isolate); 5130 HandleScope scope(isolate);
5127 Handle<JSObject> object(raw_object); 5131 Handle<JSObject> object(raw_object);
5128 5132
5129 if (object->IsJSGlobalProxy()) { 5133 if (object->IsJSGlobalProxy()) {
5130 // Do access checks before going to the global object. 5134 // Do access checks before going to the global object.
5131 if (object->IsAccessCheckNeeded() && 5135 if (object->IsAccessCheckNeeded() &&
5132 !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(), 5136 !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(),
5133 v8::ACCESS_KEYS)) { 5137 v8::ACCESS_KEYS)) {
5134 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS); 5138 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS);
5135 return *isolate->factory()->NewJSArray(0); 5139 return *isolate->factory()->NewJSArray(0);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
5307 d = 10 * d + (s[i] - '0'); 5311 d = 10 * d + (s[i] - '0');
5308 } 5312 }
5309 5313
5310 return d; 5314 return d;
5311 } 5315 }
5312 5316
5313 5317
5314 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) { 5318 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) {
5315 NoHandleAllocation ha; 5319 NoHandleAllocation ha;
5316 ASSERT(args.length() == 1); 5320 ASSERT(args.length() == 1);
5317 CONVERT_CHECKED(String, subject, args[0]); 5321 CONVERT_ARG_CHECKED(String, subject, 0);
5318 subject->TryFlatten(); 5322 subject->TryFlatten();
5319 5323
5320 // Fast case: short integer or some sorts of junk values. 5324 // Fast case: short integer or some sorts of junk values.
5321 int len = subject->length(); 5325 int len = subject->length();
5322 if (subject->IsSeqAsciiString()) { 5326 if (subject->IsSeqAsciiString()) {
5323 if (len == 0) return Smi::FromInt(0); 5327 if (len == 0) return Smi::FromInt(0);
5324 5328
5325 char const* data = SeqAsciiString::cast(subject)->GetChars(); 5329 char const* data = SeqAsciiString::cast(subject)->GetChars();
5326 bool minus = (data[0] == '-'); 5330 bool minus = (data[0] == '-');
5327 int start_pos = (minus ? 1 : 0); 5331 int start_pos = (minus ? 1 : 0);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5363 // Slower case. 5367 // Slower case.
5364 return isolate->heap()->NumberFromDouble( 5368 return isolate->heap()->NumberFromDouble(
5365 StringToDouble(isolate->unicode_cache(), subject, ALLOW_HEX)); 5369 StringToDouble(isolate->unicode_cache(), subject, ALLOW_HEX));
5366 } 5370 }
5367 5371
5368 5372
5369 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringFromCharCodeArray) { 5373 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringFromCharCodeArray) {
5370 NoHandleAllocation ha; 5374 NoHandleAllocation ha;
5371 ASSERT(args.length() == 1); 5375 ASSERT(args.length() == 1);
5372 5376
5373 CONVERT_CHECKED(JSArray, codes, args[0]); 5377 CONVERT_ARG_CHECKED(JSArray, codes, 0);
5374 int length = Smi::cast(codes->length())->value(); 5378 int length = Smi::cast(codes->length())->value();
5375 5379
5376 // Check if the string can be ASCII. 5380 // Check if the string can be ASCII.
5377 int i; 5381 int i;
5378 for (i = 0; i < length; i++) { 5382 for (i = 0; i < length; i++) {
5379 Object* element; 5383 Object* element;
5380 { MaybeObject* maybe_element = codes->GetElement(i); 5384 { MaybeObject* maybe_element = codes->GetElement(i);
5381 // We probably can't get an exception here, but just in order to enforce 5385 // We probably can't get an exception here, but just in order to enforce
5382 // the checking of inputs in the runtime calls we check here. 5386 // the checking of inputs in the runtime calls we check here.
5383 if (!maybe_element->ToObject(&element)) return maybe_element; 5387 if (!maybe_element->ToObject(&element)) return maybe_element;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
5443 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5447 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5444 }; 5448 };
5445 return kNotEscaped[character] != 0; 5449 return kNotEscaped[character] != 0;
5446 } 5450 }
5447 5451
5448 5452
5449 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) { 5453 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) {
5450 const char hex_chars[] = "0123456789ABCDEF"; 5454 const char hex_chars[] = "0123456789ABCDEF";
5451 NoHandleAllocation ha; 5455 NoHandleAllocation ha;
5452 ASSERT(args.length() == 1); 5456 ASSERT(args.length() == 1);
5453 CONVERT_CHECKED(String, source, args[0]); 5457 CONVERT_ARG_CHECKED(String, source, 0);
5454 5458
5455 source->TryFlatten(); 5459 source->TryFlatten();
5456 5460
5457 int escaped_length = 0; 5461 int escaped_length = 0;
5458 int length = source->length(); 5462 int length = source->length();
5459 { 5463 {
5460 Access<StringInputBuffer> buffer( 5464 Access<StringInputBuffer> buffer(
5461 isolate->runtime_state()->string_input_buffer()); 5465 isolate->runtime_state()->string_input_buffer());
5462 buffer->Reset(source); 5466 buffer->Reset(source);
5463 while (buffer->has_more()) { 5467 while (buffer->has_more()) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
5561 } else { 5565 } else {
5562 *step = 1; 5566 *step = 1;
5563 return character; 5567 return character;
5564 } 5568 }
5565 } 5569 }
5566 5570
5567 5571
5568 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) { 5572 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) {
5569 NoHandleAllocation ha; 5573 NoHandleAllocation ha;
5570 ASSERT(args.length() == 1); 5574 ASSERT(args.length() == 1);
5571 CONVERT_CHECKED(String, source, args[0]); 5575 CONVERT_ARG_CHECKED(String, source, 0);
5572 5576
5573 source->TryFlatten(); 5577 source->TryFlatten();
5574 5578
5575 bool ascii = true; 5579 bool ascii = true;
5576 int length = source->length(); 5580 int length = source->length();
5577 5581
5578 int unescaped_length = 0; 5582 int unescaped_length = 0;
5579 for (int i = 0; i < length; unescaped_length++) { 5583 for (int i = 0; i < length; unescaped_length++) {
5580 int step; 5584 int step;
5581 if (Unescape(source, i, length, &step) > String::kMaxAsciiCharCode) { 5585 if (Unescape(source, i, length, &step) > String::kMaxAsciiCharCode) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
5818 new_string->address() + SeqString::kHeaderSize)); 5822 new_string->address() + SeqString::kHeaderSize));
5819 isolate->heap()->new_space()-> 5823 isolate->heap()->new_space()->
5820 template ShrinkStringAtAllocationBoundary<StringType>( 5824 template ShrinkStringAtAllocationBoundary<StringType>(
5821 new_string, final_length); 5825 new_string, final_length);
5822 return new_string; 5826 return new_string;
5823 } 5827 }
5824 5828
5825 5829
5826 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONString) { 5830 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONString) {
5827 NoHandleAllocation ha; 5831 NoHandleAllocation ha;
5828 CONVERT_CHECKED(String, str, args[0]); 5832 CONVERT_ARG_CHECKED(String, str, 0);
5829 if (!str->IsFlat()) { 5833 if (!str->IsFlat()) {
5830 MaybeObject* try_flatten = str->TryFlatten(); 5834 MaybeObject* try_flatten = str->TryFlatten();
5831 Object* flat; 5835 Object* flat;
5832 if (!try_flatten->ToObject(&flat)) { 5836 if (!try_flatten->ToObject(&flat)) {
5833 return try_flatten; 5837 return try_flatten;
5834 } 5838 }
5835 str = String::cast(flat); 5839 str = String::cast(flat);
5836 ASSERT(str->IsFlat()); 5840 ASSERT(str->IsFlat());
5837 } 5841 }
5838 String::FlatContent flat = str->GetFlatContent(); 5842 String::FlatContent flat = str->GetFlatContent();
5839 ASSERT(flat.IsFlat()); 5843 ASSERT(flat.IsFlat());
5840 if (flat.IsTwoByte()) { 5844 if (flat.IsTwoByte()) {
5841 return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate, 5845 return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate,
5842 flat.ToUC16Vector()); 5846 flat.ToUC16Vector());
5843 } else { 5847 } else {
5844 return QuoteJsonString<char, SeqAsciiString, false>(isolate, 5848 return QuoteJsonString<char, SeqAsciiString, false>(isolate,
5845 flat.ToAsciiVector()); 5849 flat.ToAsciiVector());
5846 } 5850 }
5847 } 5851 }
5848 5852
5849 5853
5850 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringComma) { 5854 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringComma) {
5851 NoHandleAllocation ha; 5855 NoHandleAllocation ha;
5852 CONVERT_CHECKED(String, str, args[0]); 5856 CONVERT_ARG_CHECKED(String, str, 0);
5853 if (!str->IsFlat()) { 5857 if (!str->IsFlat()) {
5854 MaybeObject* try_flatten = str->TryFlatten(); 5858 MaybeObject* try_flatten = str->TryFlatten();
5855 Object* flat; 5859 Object* flat;
5856 if (!try_flatten->ToObject(&flat)) { 5860 if (!try_flatten->ToObject(&flat)) {
5857 return try_flatten; 5861 return try_flatten;
5858 } 5862 }
5859 str = String::cast(flat); 5863 str = String::cast(flat);
5860 ASSERT(str->IsFlat()); 5864 ASSERT(str->IsFlat());
5861 } 5865 }
5862 String::FlatContent flat = str->GetFlatContent(); 5866 String::FlatContent flat = str->GetFlatContent();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
5919 isolate->heap()->new_space()-> 5923 isolate->heap()->new_space()->
5920 template ShrinkStringAtAllocationBoundary<StringType>( 5924 template ShrinkStringAtAllocationBoundary<StringType>(
5921 new_string, final_length); 5925 new_string, final_length);
5922 return new_string; 5926 return new_string;
5923 } 5927 }
5924 5928
5925 5929
5926 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringArray) { 5930 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringArray) {
5927 NoHandleAllocation ha; 5931 NoHandleAllocation ha;
5928 ASSERT(args.length() == 1); 5932 ASSERT(args.length() == 1);
5929 CONVERT_CHECKED(JSArray, array, args[0]); 5933 CONVERT_ARG_CHECKED(JSArray, array, 0);
5930 5934
5931 if (!array->HasFastElements()) return isolate->heap()->undefined_value(); 5935 if (!array->HasFastElements()) return isolate->heap()->undefined_value();
5932 FixedArray* elements = FixedArray::cast(array->elements()); 5936 FixedArray* elements = FixedArray::cast(array->elements());
5933 int n = elements->length(); 5937 int n = elements->length();
5934 bool ascii = true; 5938 bool ascii = true;
5935 int total_length = 0; 5939 int total_length = 0;
5936 5940
5937 for (int i = 0; i < n; i++) { 5941 for (int i = 0; i < n; i++) {
5938 Object* elt = elements->get(i); 5942 Object* elt = elements->get(i);
5939 if (!elt->IsString()) return isolate->heap()->undefined_value(); 5943 if (!elt->IsString()) return isolate->heap()->undefined_value();
(...skipping 21 matching lines...) Expand all
5961 return QuoteJsonStringArray<uc16, SeqTwoByteString>(isolate, 5965 return QuoteJsonStringArray<uc16, SeqTwoByteString>(isolate,
5962 elements, 5966 elements,
5963 worst_case_length); 5967 worst_case_length);
5964 } 5968 }
5965 } 5969 }
5966 5970
5967 5971
5968 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { 5972 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) {
5969 NoHandleAllocation ha; 5973 NoHandleAllocation ha;
5970 5974
5971 CONVERT_CHECKED(String, s, args[0]); 5975 CONVERT_ARG_CHECKED(String, s, 0);
5972 CONVERT_SMI_ARG_CHECKED(radix, 1); 5976 CONVERT_SMI_ARG_CHECKED(radix, 1);
5973 5977
5974 s->TryFlatten(); 5978 s->TryFlatten();
5975 5979
5976 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); 5980 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36));
5977 double value = StringToInt(isolate->unicode_cache(), s, radix); 5981 double value = StringToInt(isolate->unicode_cache(), s, radix);
5978 return isolate->heap()->NumberFromDouble(value); 5982 return isolate->heap()->NumberFromDouble(value);
5979 } 5983 }
5980 5984
5981 5985
5982 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { 5986 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) {
5983 NoHandleAllocation ha; 5987 NoHandleAllocation ha;
5984 CONVERT_CHECKED(String, str, args[0]); 5988 CONVERT_ARG_CHECKED(String, str, 0);
5985 5989
5986 // ECMA-262 section 15.1.2.3, empty string is NaN 5990 // ECMA-262 section 15.1.2.3, empty string is NaN
5987 double value = StringToDouble(isolate->unicode_cache(), 5991 double value = StringToDouble(isolate->unicode_cache(),
5988 str, ALLOW_TRAILING_JUNK, OS::nan_value()); 5992 str, ALLOW_TRAILING_JUNK, OS::nan_value());
5989 5993
5990 // Create a number object from the value. 5994 // Create a number object from the value.
5991 return isolate->heap()->NumberFromDouble(value); 5995 return isolate->heap()->NumberFromDouble(value);
5992 } 5996 }
5993 5997
5994 5998
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
6223 6227
6224 } // namespace 6228 } // namespace
6225 6229
6226 6230
6227 template <typename ConvertTraits> 6231 template <typename ConvertTraits>
6228 MUST_USE_RESULT static MaybeObject* ConvertCase( 6232 MUST_USE_RESULT static MaybeObject* ConvertCase(
6229 Arguments args, 6233 Arguments args,
6230 Isolate* isolate, 6234 Isolate* isolate,
6231 unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) { 6235 unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) {
6232 NoHandleAllocation ha; 6236 NoHandleAllocation ha;
6233 CONVERT_CHECKED(String, s, args[0]); 6237 CONVERT_ARG_CHECKED(String, s, 0);
6234 s = s->TryFlattenGetString(); 6238 s = s->TryFlattenGetString();
6235 6239
6236 const int length = s->length(); 6240 const int length = s->length();
6237 // Assume that the string is not empty; we need this assumption later 6241 // Assume that the string is not empty; we need this assumption later
6238 if (length == 0) return s; 6242 if (length == 0) return s;
6239 6243
6240 // Simpler handling of ASCII strings. 6244 // Simpler handling of ASCII strings.
6241 // 6245 //
6242 // NOTE: This assumes that the upper/lower case of an ASCII 6246 // NOTE: This assumes that the upper/lower case of an ASCII
6243 // character is also ASCII. This is currently the case, but it 6247 // character is also ASCII. This is currently the case, but it
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
6285 6289
6286 static inline bool IsTrimWhiteSpace(unibrow::uchar c) { 6290 static inline bool IsTrimWhiteSpace(unibrow::uchar c) {
6287 return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff; 6291 return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff;
6288 } 6292 }
6289 6293
6290 6294
6291 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { 6295 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) {
6292 NoHandleAllocation ha; 6296 NoHandleAllocation ha;
6293 ASSERT(args.length() == 3); 6297 ASSERT(args.length() == 3);
6294 6298
6295 CONVERT_CHECKED(String, s, args[0]); 6299 CONVERT_ARG_CHECKED(String, s, 0);
6296 CONVERT_BOOLEAN_CHECKED(trimLeft, args[1]); 6300 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1);
6297 CONVERT_BOOLEAN_CHECKED(trimRight, args[2]); 6301 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2);
6298 6302
6299 s->TryFlatten(); 6303 s->TryFlatten();
6300 int length = s->length(); 6304 int length = s->length();
6301 6305
6302 int left = 0; 6306 int left = 0;
6303 if (trimLeft) { 6307 if (trimLeft) {
6304 while (left < length && IsTrimWhiteSpace(s->Get(left))) { 6308 while (left < length && IsTrimWhiteSpace(s->Get(left))) {
6305 left++; 6309 left++;
6306 } 6310 }
6307 } 6311 }
6308 6312
6309 int right = length; 6313 int right = length;
6310 if (trimRight) { 6314 if (trimRight) {
6311 while (right > left && IsTrimWhiteSpace(s->Get(right - 1))) { 6315 while (right > left && IsTrimWhiteSpace(s->Get(right - 1))) {
6312 right--; 6316 right--;
6313 } 6317 }
6314 } 6318 }
6315 return s->SubString(left, right); 6319 return s->SubString(left, right);
6316 } 6320 }
6317 6321
6318 6322
6319 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) { 6323 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) {
6320 ASSERT(args.length() == 3); 6324 ASSERT(args.length() == 3);
6321 HandleScope handle_scope(isolate); 6325 HandleScope handle_scope(isolate);
6322 CONVERT_ARG_CHECKED(String, subject, 0); 6326 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
6323 CONVERT_ARG_CHECKED(String, pattern, 1); 6327 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1);
6324 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); 6328 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]);
6325 6329
6326 int subject_length = subject->length(); 6330 int subject_length = subject->length();
6327 int pattern_length = pattern->length(); 6331 int pattern_length = pattern->length();
6328 RUNTIME_ASSERT(pattern_length > 0); 6332 RUNTIME_ASSERT(pattern_length > 0);
6329 6333
6330 if (limit == 0xffffffffu) { 6334 if (limit == 0xffffffffu) {
6331 Handle<Object> cached_answer(StringSplitCache::Lookup( 6335 Handle<Object> cached_answer(StringSplitCache::Lookup(
6332 isolate->heap()->string_split_cache(), 6336 isolate->heap()->string_split_cache(),
6333 *subject, 6337 *subject,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
6434 #endif 6438 #endif
6435 return i; 6439 return i;
6436 } 6440 }
6437 6441
6438 6442
6439 // Converts a String to JSArray. 6443 // Converts a String to JSArray.
6440 // For example, "foo" => ["f", "o", "o"]. 6444 // For example, "foo" => ["f", "o", "o"].
6441 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToArray) { 6445 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToArray) {
6442 HandleScope scope(isolate); 6446 HandleScope scope(isolate);
6443 ASSERT(args.length() == 2); 6447 ASSERT(args.length() == 2);
6444 CONVERT_ARG_CHECKED(String, s, 0); 6448 CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
6445 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); 6449 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
6446 6450
6447 s = FlattenGetString(s); 6451 s = FlattenGetString(s);
6448 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit)); 6452 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit));
6449 6453
6450 Handle<FixedArray> elements; 6454 Handle<FixedArray> elements;
6451 int position = 0; 6455 int position = 0;
6452 if (s->IsFlat() && s->IsAsciiRepresentation()) { 6456 if (s->IsFlat() && s->IsAsciiRepresentation()) {
6453 // Try using cached chars where possible. 6457 // Try using cached chars where possible.
6454 Object* obj; 6458 Object* obj;
(...skipping 30 matching lines...) Expand all
6485 } 6489 }
6486 #endif 6490 #endif
6487 6491
6488 return *isolate->factory()->NewJSArrayWithElements(elements); 6492 return *isolate->factory()->NewJSArrayWithElements(elements);
6489 } 6493 }
6490 6494
6491 6495
6492 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { 6496 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) {
6493 NoHandleAllocation ha; 6497 NoHandleAllocation ha;
6494 ASSERT(args.length() == 1); 6498 ASSERT(args.length() == 1);
6495 CONVERT_CHECKED(String, value, args[0]); 6499 CONVERT_ARG_CHECKED(String, value, 0);
6496 return value->ToObject(); 6500 return value->ToObject();
6497 } 6501 }
6498 6502
6499 6503
6500 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { 6504 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) {
6501 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; 6505 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth];
6502 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); 6506 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars);
6503 return char_length == 0; 6507 return char_length == 0;
6504 } 6508 }
6505 6509
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
6676 6680
6677 x = modulo(x, y); 6681 x = modulo(x, y);
6678 // NumberFromDouble may return a Smi instead of a Number object 6682 // NumberFromDouble may return a Smi instead of a Number object
6679 return isolate->heap()->NumberFromDouble(x); 6683 return isolate->heap()->NumberFromDouble(x);
6680 } 6684 }
6681 6685
6682 6686
6683 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) { 6687 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) {
6684 NoHandleAllocation ha; 6688 NoHandleAllocation ha;
6685 ASSERT(args.length() == 2); 6689 ASSERT(args.length() == 2);
6686 CONVERT_CHECKED(String, str1, args[0]); 6690 CONVERT_ARG_CHECKED(String, str1, 0);
6687 CONVERT_CHECKED(String, str2, args[1]); 6691 CONVERT_ARG_CHECKED(String, str2, 1);
6688 isolate->counters()->string_add_runtime()->Increment(); 6692 isolate->counters()->string_add_runtime()->Increment();
6689 return isolate->heap()->AllocateConsString(str1, str2); 6693 return isolate->heap()->AllocateConsString(str1, str2);
6690 } 6694 }
6691 6695
6692 6696
6693 template <typename sinkchar> 6697 template <typename sinkchar>
6694 static inline void StringBuilderConcatHelper(String* special, 6698 static inline void StringBuilderConcatHelper(String* special,
6695 sinkchar* sink, 6699 sinkchar* sink,
6696 FixedArray* fixed_array, 6700 FixedArray* fixed_array,
6697 int array_length) { 6701 int array_length) {
(...skipping 27 matching lines...) Expand all
6725 String::WriteToFlat(string, sink + position, 0, element_length); 6729 String::WriteToFlat(string, sink + position, 0, element_length);
6726 position += element_length; 6730 position += element_length;
6727 } 6731 }
6728 } 6732 }
6729 } 6733 }
6730 6734
6731 6735
6732 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { 6736 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) {
6733 NoHandleAllocation ha; 6737 NoHandleAllocation ha;
6734 ASSERT(args.length() == 3); 6738 ASSERT(args.length() == 3);
6735 CONVERT_CHECKED(JSArray, array, args[0]); 6739 CONVERT_ARG_CHECKED(JSArray, array, 0);
6736 if (!args[1]->IsSmi()) { 6740 if (!args[1]->IsSmi()) {
6737 isolate->context()->mark_out_of_memory(); 6741 isolate->context()->mark_out_of_memory();
6738 return Failure::OutOfMemoryException(); 6742 return Failure::OutOfMemoryException();
6739 } 6743 }
6740 int array_length = args.smi_at(1); 6744 int array_length = args.smi_at(1);
6741 CONVERT_CHECKED(String, special, args[2]); 6745 CONVERT_ARG_CHECKED(String, special, 2);
6742 6746
6743 // This assumption is used by the slice encoding in one or two smis. 6747 // This assumption is used by the slice encoding in one or two smis.
6744 ASSERT(Smi::kMaxValue >= String::kMaxLength); 6748 ASSERT(Smi::kMaxValue >= String::kMaxLength);
6745 6749
6746 MaybeObject* maybe_result = array->EnsureCanContainHeapObjectElements(); 6750 MaybeObject* maybe_result = array->EnsureCanContainHeapObjectElements();
6747 if (maybe_result->IsFailure()) return maybe_result; 6751 if (maybe_result->IsFailure()) return maybe_result;
6748 6752
6749 int special_length = special->length(); 6753 int special_length = special->length();
6750 if (!array->HasFastElements()) { 6754 if (!array->HasFastElements()) {
6751 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 6755 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
6841 fixed_array, 6845 fixed_array,
6842 array_length); 6846 array_length);
6843 return answer; 6847 return answer;
6844 } 6848 }
6845 } 6849 }
6846 6850
6847 6851
6848 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { 6852 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) {
6849 NoHandleAllocation ha; 6853 NoHandleAllocation ha;
6850 ASSERT(args.length() == 3); 6854 ASSERT(args.length() == 3);
6851 CONVERT_CHECKED(JSArray, array, args[0]); 6855 CONVERT_ARG_CHECKED(JSArray, array, 0);
6852 if (!args[1]->IsSmi()) { 6856 if (!args[1]->IsSmi()) {
6853 isolate->context()->mark_out_of_memory(); 6857 isolate->context()->mark_out_of_memory();
6854 return Failure::OutOfMemoryException(); 6858 return Failure::OutOfMemoryException();
6855 } 6859 }
6856 int array_length = args.smi_at(1); 6860 int array_length = args.smi_at(1);
6857 CONVERT_CHECKED(String, separator, args[2]); 6861 CONVERT_ARG_CHECKED(String, separator, 2);
6858 6862
6859 if (!array->HasFastElements()) { 6863 if (!array->HasFastElements()) {
6860 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 6864 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6861 } 6865 }
6862 FixedArray* fixed_array = FixedArray::cast(array->elements()); 6866 FixedArray* fixed_array = FixedArray::cast(array->elements());
6863 if (fixed_array->length() < array_length) { 6867 if (fixed_array->length() < array_length) {
6864 array_length = fixed_array->length(); 6868 array_length = fixed_array->length();
6865 } 6869 }
6866 6870
6867 if (array_length == 0) { 6871 if (array_length == 0) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
6965 previous_separator_position++; 6969 previous_separator_position++;
6966 } 6970 }
6967 } 6971 }
6968 ASSERT(cursor <= buffer.length()); 6972 ASSERT(cursor <= buffer.length());
6969 } 6973 }
6970 6974
6971 6975
6972 RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { 6976 RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) {
6973 NoHandleAllocation ha; 6977 NoHandleAllocation ha;
6974 ASSERT(args.length() == 3); 6978 ASSERT(args.length() == 3);
6975 CONVERT_CHECKED(JSArray, elements_array, args[0]); 6979 CONVERT_ARG_CHECKED(JSArray, elements_array, 0);
6976 RUNTIME_ASSERT(elements_array->HasFastElements() || 6980 RUNTIME_ASSERT(elements_array->HasFastElements() ||
6977 elements_array->HasFastSmiOnlyElements()); 6981 elements_array->HasFastSmiOnlyElements());
6978 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); 6982 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]);
6979 CONVERT_CHECKED(String, separator, args[2]); 6983 CONVERT_ARG_CHECKED(String, separator, 2);
6980 // elements_array is fast-mode JSarray of alternating positions 6984 // elements_array is fast-mode JSarray of alternating positions
6981 // (increasing order) and strings. 6985 // (increasing order) and strings.
6982 // array_length is length of original array (used to add separators); 6986 // array_length is length of original array (used to add separators);
6983 // separator is string to put between elements. Assumed to be non-empty. 6987 // separator is string to put between elements. Assumed to be non-empty.
6984 6988
6985 // Find total length of join result. 6989 // Find total length of join result.
6986 int string_length = 0; 6990 int string_length = 0;
6987 bool is_ascii = separator->IsAsciiRepresentation(); 6991 bool is_ascii = separator->IsAsciiRepresentation();
6988 int max_string_length; 6992 int max_string_length;
6989 if (is_ascii) { 6993 if (is_ascii) {
6990 max_string_length = SeqAsciiString::kMaxLength; 6994 max_string_length = SeqAsciiString::kMaxLength;
6991 } else { 6995 } else {
6992 max_string_length = SeqTwoByteString::kMaxLength; 6996 max_string_length = SeqTwoByteString::kMaxLength;
6993 } 6997 }
6994 bool overflow = false; 6998 bool overflow = false;
6995 CONVERT_NUMBER_CHECKED(int, elements_length, 6999 CONVERT_NUMBER_CHECKED(int, elements_length,
6996 Int32, elements_array->length()); 7000 Int32, elements_array->length());
6997 RUNTIME_ASSERT((elements_length & 1) == 0); // Even length. 7001 RUNTIME_ASSERT((elements_length & 1) == 0); // Even length.
6998 FixedArray* elements = FixedArray::cast(elements_array->elements()); 7002 FixedArray* elements = FixedArray::cast(elements_array->elements());
6999 for (int i = 0; i < elements_length; i += 2) { 7003 for (int i = 0; i < elements_length; i += 2) {
7000 RUNTIME_ASSERT(elements->get(i)->IsNumber()); 7004 RUNTIME_ASSERT(elements->get(i)->IsNumber());
7001 CONVERT_CHECKED(String, string, elements->get(i + 1)); 7005 RUNTIME_ASSERT(elements->get(i + 1)->IsString());
7006 String* string = String::cast(elements->get(i + 1));
7002 int length = string->length(); 7007 int length = string->length();
7003 if (is_ascii && !string->IsAsciiRepresentation()) { 7008 if (is_ascii && !string->IsAsciiRepresentation()) {
7004 is_ascii = false; 7009 is_ascii = false;
7005 max_string_length = SeqTwoByteString::kMaxLength; 7010 max_string_length = SeqTwoByteString::kMaxLength;
7006 } 7011 }
7007 if (length > max_string_length || 7012 if (length > max_string_length ||
7008 max_string_length - length < string_length) { 7013 max_string_length - length < string_length) {
7009 overflow = true; 7014 overflow = true;
7010 break; 7015 break;
7011 } 7016 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
7149 result = Smi::FromInt(NOT_EQUAL); 7154 result = Smi::FromInt(NOT_EQUAL);
7150 } 7155 }
7151 return result; 7156 return result;
7152 } 7157 }
7153 7158
7154 7159
7155 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringEquals) { 7160 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringEquals) {
7156 NoHandleAllocation ha; 7161 NoHandleAllocation ha;
7157 ASSERT(args.length() == 2); 7162 ASSERT(args.length() == 2);
7158 7163
7159 CONVERT_CHECKED(String, x, args[0]); 7164 CONVERT_ARG_CHECKED(String, x, 0);
7160 CONVERT_CHECKED(String, y, args[1]); 7165 CONVERT_ARG_CHECKED(String, y, 1);
7161 7166
7162 bool not_equal = !x->Equals(y); 7167 bool not_equal = !x->Equals(y);
7163 // This is slightly convoluted because the value that signifies 7168 // This is slightly convoluted because the value that signifies
7164 // equality is 0 and inequality is 1 so we have to negate the result 7169 // equality is 0 and inequality is 1 so we have to negate the result
7165 // from String::Equals. 7170 // from String::Equals.
7166 ASSERT(not_equal == 0 || not_equal == 1); 7171 ASSERT(not_equal == 0 || not_equal == 1);
7167 STATIC_CHECK(EQUAL == 0); 7172 STATIC_CHECK(EQUAL == 0);
7168 STATIC_CHECK(NOT_EQUAL == 1); 7173 STATIC_CHECK(NOT_EQUAL == 1);
7169 return Smi::FromInt(not_equal); 7174 return Smi::FromInt(not_equal);
7170 } 7175 }
(...skipping 10 matching lines...) Expand all
7181 if (isless(x, y)) return Smi::FromInt(LESS); 7186 if (isless(x, y)) return Smi::FromInt(LESS);
7182 return Smi::FromInt(GREATER); 7187 return Smi::FromInt(GREATER);
7183 } 7188 }
7184 7189
7185 7190
7186 // Compare two Smis as if they were converted to strings and then 7191 // Compare two Smis as if they were converted to strings and then
7187 // compared lexicographically. 7192 // compared lexicographically.
7188 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) { 7193 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) {
7189 NoHandleAllocation ha; 7194 NoHandleAllocation ha;
7190 ASSERT(args.length() == 2); 7195 ASSERT(args.length() == 2);
7191 7196 CONVERT_SMI_ARG_CHECKED(x_value, 0);
7192 // Extract the integer values from the Smis. 7197 CONVERT_SMI_ARG_CHECKED(y_value, 1);
7193 CONVERT_CHECKED(Smi, x, args[0]);
7194 CONVERT_CHECKED(Smi, y, args[1]);
7195 int x_value = x->value();
7196 int y_value = y->value();
7197 7198
7198 // If the integers are equal so are the string representations. 7199 // If the integers are equal so are the string representations.
7199 if (x_value == y_value) return Smi::FromInt(EQUAL); 7200 if (x_value == y_value) return Smi::FromInt(EQUAL);
7200 7201
7201 // If one of the integers is zero the normal integer order is the 7202 // If one of the integers is zero the normal integer order is the
7202 // same as the lexicographic order of the string representations. 7203 // same as the lexicographic order of the string representations.
7203 if (x_value == 0 || y_value == 0) 7204 if (x_value == 0 || y_value == 0)
7204 return Smi::FromInt(x_value < y_value ? LESS : GREATER); 7205 return Smi::FromInt(x_value < y_value ? LESS : GREATER);
7205 7206
7206 // If only one of the integers is negative the negative number is 7207 // If only one of the integers is negative the negative number is
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
7326 ASSERT(result == 7327 ASSERT(result ==
7327 StringInputBufferCompare(Isolate::Current()->runtime_state(), x, y)); 7328 StringInputBufferCompare(Isolate::Current()->runtime_state(), x, y));
7328 return result; 7329 return result;
7329 } 7330 }
7330 7331
7331 7332
7332 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) { 7333 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) {
7333 NoHandleAllocation ha; 7334 NoHandleAllocation ha;
7334 ASSERT(args.length() == 2); 7335 ASSERT(args.length() == 2);
7335 7336
7336 CONVERT_CHECKED(String, x, args[0]); 7337 CONVERT_ARG_CHECKED(String, x, 0);
7337 CONVERT_CHECKED(String, y, args[1]); 7338 CONVERT_ARG_CHECKED(String, y, 1);
7338 7339
7339 isolate->counters()->string_compare_runtime()->Increment(); 7340 isolate->counters()->string_compare_runtime()->Increment();
7340 7341
7341 // A few fast case tests before we flatten. 7342 // A few fast case tests before we flatten.
7342 if (x == y) return Smi::FromInt(EQUAL); 7343 if (x == y) return Smi::FromInt(EQUAL);
7343 if (y->length() == 0) { 7344 if (y->length() == 0) {
7344 if (x->length() == 0) return Smi::FromInt(EQUAL); 7345 if (x->length() == 0) return Smi::FromInt(EQUAL);
7345 return Smi::FromInt(GREATER); 7346 return Smi::FromInt(GREATER);
7346 } else if (x->length() == 0) { 7347 } else if (x->length() == 0) {
7347 return Smi::FromInt(LESS); 7348 return Smi::FromInt(LESS);
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
7934 DateYMDFromTimeSlow(date, year, month, day); 7935 DateYMDFromTimeSlow(date, year, month, day);
7935 } 7936 }
7936 } 7937 }
7937 7938
7938 7939
7939 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateYMDFromTime) { 7940 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateYMDFromTime) {
7940 NoHandleAllocation ha; 7941 NoHandleAllocation ha;
7941 ASSERT(args.length() == 2); 7942 ASSERT(args.length() == 2);
7942 7943
7943 CONVERT_DOUBLE_ARG_CHECKED(t, 0); 7944 CONVERT_DOUBLE_ARG_CHECKED(t, 0);
7944 CONVERT_CHECKED(JSArray, res_array, args[1]); 7945 CONVERT_ARG_CHECKED(JSArray, res_array, 1);
7945 7946
7946 int year, month, day; 7947 int year, month, day;
7947 DateYMDFromTime(static_cast<int>(floor(t / 86400000)), year, month, day); 7948 DateYMDFromTime(static_cast<int>(floor(t / 86400000)), year, month, day);
7948 7949
7949 FixedArrayBase* elms_base = FixedArrayBase::cast(res_array->elements()); 7950 FixedArrayBase* elms_base = FixedArrayBase::cast(res_array->elements());
7950 RUNTIME_ASSERT(elms_base->length() == 3); 7951 RUNTIME_ASSERT(elms_base->length() == 3);
7951 RUNTIME_ASSERT(res_array->HasFastTypeElements()); 7952 RUNTIME_ASSERT(res_array->HasFastTypeElements());
7952 7953
7953 MaybeObject* maybe = res_array->EnsureWritableFastElements(); 7954 MaybeObject* maybe = res_array->EnsureWritableFastElements();
7954 if (maybe->IsFailure()) return maybe; 7955 if (maybe->IsFailure()) return maybe;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
8089 } 8090 }
8090 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); 8091 JSObject::cast(result)->set_elements(FixedArray::cast(obj));
8091 } 8092 }
8092 return result; 8093 return result;
8093 } 8094 }
8094 8095
8095 8096
8096 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewClosure) { 8097 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewClosure) {
8097 HandleScope scope(isolate); 8098 HandleScope scope(isolate);
8098 ASSERT(args.length() == 3); 8099 ASSERT(args.length() == 3);
8099 CONVERT_ARG_CHECKED(Context, context, 0); 8100 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0);
8100 CONVERT_ARG_CHECKED(SharedFunctionInfo, shared, 1); 8101 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 1);
8101 CONVERT_BOOLEAN_CHECKED(pretenure, args[2]); 8102 CONVERT_BOOLEAN_ARG_CHECKED(pretenure, 2);
8102 8103
8103 // The caller ensures that we pretenure closures that are assigned 8104 // The caller ensures that we pretenure closures that are assigned
8104 // directly to properties. 8105 // directly to properties.
8105 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; 8106 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED;
8106 Handle<JSFunction> result = 8107 Handle<JSFunction> result =
8107 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, 8108 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
8108 context, 8109 context,
8109 pretenure_flag); 8110 pretenure_flag);
8110 return *result; 8111 return *result;
8111 } 8112 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
8157 param_data[prefix_argc + i] = val; 8158 param_data[prefix_argc + i] = val;
8158 } 8159 }
8159 return param_data; 8160 return param_data;
8160 } 8161 }
8161 } 8162 }
8162 8163
8163 8164
8164 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionBindArguments) { 8165 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionBindArguments) {
8165 HandleScope scope(isolate); 8166 HandleScope scope(isolate);
8166 ASSERT(args.length() == 4); 8167 ASSERT(args.length() == 4);
8167 CONVERT_ARG_CHECKED(JSFunction, bound_function, 0); 8168 CONVERT_ARG_HANDLE_CHECKED(JSFunction, bound_function, 0);
8168 RUNTIME_ASSERT(args[3]->IsNumber()); 8169 RUNTIME_ASSERT(args[3]->IsNumber());
8169 Handle<Object> bindee = args.at<Object>(1); 8170 Handle<Object> bindee = args.at<Object>(1);
8170 8171
8171 // TODO(lrn): Create bound function in C++ code from premade shared info. 8172 // TODO(lrn): Create bound function in C++ code from premade shared info.
8172 bound_function->shared()->set_bound(true); 8173 bound_function->shared()->set_bound(true);
8173 // Get all arguments of calling function (Function.prototype.bind). 8174 // Get all arguments of calling function (Function.prototype.bind).
8174 int argc = 0; 8175 int argc = 0;
8175 SmartArrayPointer<Handle<Object> > arguments = GetCallerArguments(0, &argc); 8176 SmartArrayPointer<Handle<Object> > arguments = GetCallerArguments(0, &argc);
8176 // Don't count the this-arg. 8177 // Don't count the this-arg.
8177 if (argc > 0) { 8178 if (argc > 0) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
8215 PropertyAttributes attr = 8216 PropertyAttributes attr =
8216 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY); 8217 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY);
8217 ForceSetProperty(bound_function, length_symbol, new_length, attr); 8218 ForceSetProperty(bound_function, length_symbol, new_length, attr);
8218 return *bound_function; 8219 return *bound_function;
8219 } 8220 }
8220 8221
8221 8222
8222 RUNTIME_FUNCTION(MaybeObject*, Runtime_BoundFunctionGetBindings) { 8223 RUNTIME_FUNCTION(MaybeObject*, Runtime_BoundFunctionGetBindings) {
8223 HandleScope handles(isolate); 8224 HandleScope handles(isolate);
8224 ASSERT(args.length() == 1); 8225 ASSERT(args.length() == 1);
8225 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); 8226 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, callable, 0);
8226 if (callable->IsJSFunction()) { 8227 if (callable->IsJSFunction()) {
8227 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); 8228 Handle<JSFunction> function = Handle<JSFunction>::cast(callable);
8228 if (function->shared()->bound()) { 8229 if (function->shared()->bound()) {
8229 Handle<FixedArray> bindings(function->function_bindings()); 8230 Handle<FixedArray> bindings(function->function_bindings());
8230 ASSERT(bindings->map() == isolate->heap()->fixed_cow_array_map()); 8231 ASSERT(bindings->map() == isolate->heap()->fixed_cow_array_map());
8231 return *isolate->factory()->NewJSArrayWithElements(bindings); 8232 return *isolate->factory()->NewJSArrayWithElements(bindings);
8232 } 8233 }
8233 } 8234 }
8234 return isolate->heap()->undefined_value(); 8235 return isolate->heap()->undefined_value();
8235 } 8236 }
8236 8237
8237 8238
8238 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObjectFromBound) { 8239 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObjectFromBound) {
8239 HandleScope scope(isolate); 8240 HandleScope scope(isolate);
8240 ASSERT(args.length() == 1); 8241 ASSERT(args.length() == 1);
8241 // First argument is a function to use as a constructor. 8242 // First argument is a function to use as a constructor.
8242 CONVERT_ARG_CHECKED(JSFunction, function, 0); 8243 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8243 RUNTIME_ASSERT(function->shared()->bound()); 8244 RUNTIME_ASSERT(function->shared()->bound());
8244 8245
8245 // The argument is a bound function. Extract its bound arguments 8246 // The argument is a bound function. Extract its bound arguments
8246 // and callable. 8247 // and callable.
8247 Handle<FixedArray> bound_args = 8248 Handle<FixedArray> bound_args =
8248 Handle<FixedArray>(FixedArray::cast(function->function_bindings())); 8249 Handle<FixedArray>(FixedArray::cast(function->function_bindings()));
8249 int bound_argc = bound_args->length() - JSFunction::kBoundArgumentsStartIndex; 8250 int bound_argc = bound_args->length() - JSFunction::kBoundArgumentsStartIndex;
8250 Handle<Object> bound_function( 8251 Handle<Object> bound_function(
8251 JSReceiver::cast(bound_args->get(JSFunction::kBoundFunctionIndex))); 8252 JSReceiver::cast(bound_args->get(JSFunction::kBoundFunctionIndex)));
8252 ASSERT(!bound_function->IsJSFunction() || 8253 ASSERT(!bound_function->IsJSFunction() ||
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
8373 isolate->counters()->constructed_objects_runtime()->Increment(); 8374 isolate->counters()->constructed_objects_runtime()->Increment();
8374 8375
8375 return *result; 8376 return *result;
8376 } 8377 }
8377 8378
8378 8379
8379 RUNTIME_FUNCTION(MaybeObject*, Runtime_FinalizeInstanceSize) { 8380 RUNTIME_FUNCTION(MaybeObject*, Runtime_FinalizeInstanceSize) {
8380 HandleScope scope(isolate); 8381 HandleScope scope(isolate);
8381 ASSERT(args.length() == 1); 8382 ASSERT(args.length() == 1);
8382 8383
8383 CONVERT_ARG_CHECKED(JSFunction, function, 0); 8384 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8384 function->shared()->CompleteInobjectSlackTracking(); 8385 function->shared()->CompleteInobjectSlackTracking();
8385 TrySettingInlineConstructStub(isolate, function); 8386 TrySettingInlineConstructStub(isolate, function);
8386 8387
8387 return isolate->heap()->undefined_value(); 8388 return isolate->heap()->undefined_value();
8388 } 8389 }
8389 8390
8390 8391
8391 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyCompile) { 8392 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyCompile) {
8392 HandleScope scope(isolate); 8393 HandleScope scope(isolate);
8393 ASSERT(args.length() == 1); 8394 ASSERT(args.length() == 1);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
8562 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) { 8563 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) {
8563 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); 8564 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
8564 delete deoptimizer; 8565 delete deoptimizer;
8565 return isolate->heap()->undefined_value(); 8566 return isolate->heap()->undefined_value();
8566 } 8567 }
8567 8568
8568 8569
8569 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeoptimizeFunction) { 8570 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeoptimizeFunction) {
8570 HandleScope scope(isolate); 8571 HandleScope scope(isolate);
8571 ASSERT(args.length() == 1); 8572 ASSERT(args.length() == 1);
8572 CONVERT_ARG_CHECKED(JSFunction, function, 0); 8573 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8573 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); 8574 if (!function->IsOptimized()) return isolate->heap()->undefined_value();
8574 8575
8575 Deoptimizer::DeoptimizeFunction(*function); 8576 Deoptimizer::DeoptimizeFunction(*function);
8576 8577
8577 return isolate->heap()->undefined_value(); 8578 return isolate->heap()->undefined_value();
8578 } 8579 }
8579 8580
8580 8581
8581 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) { 8582 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) {
8582 #if defined(USE_SIMULATOR) 8583 #if defined(USE_SIMULATOR)
8583 return isolate->heap()->true_value(); 8584 return isolate->heap()->true_value();
8584 #else 8585 #else
8585 return isolate->heap()->false_value(); 8586 return isolate->heap()->false_value();
8586 #endif 8587 #endif
8587 } 8588 }
8588 8589
8589 8590
8590 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) { 8591 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) {
8591 HandleScope scope(isolate); 8592 HandleScope scope(isolate);
8592 ASSERT(args.length() == 1); 8593 ASSERT(args.length() == 1);
8593 CONVERT_ARG_CHECKED(JSFunction, function, 0); 8594 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8594 if (!function->IsOptimizable()) return isolate->heap()->undefined_value(); 8595 if (!function->IsOptimizable()) return isolate->heap()->undefined_value();
8595 function->MarkForLazyRecompilation(); 8596 function->MarkForLazyRecompilation();
8596 return isolate->heap()->undefined_value(); 8597 return isolate->heap()->undefined_value();
8597 } 8598 }
8598 8599
8599 8600
8600 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) { 8601 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) {
8601 HandleScope scope(isolate); 8602 HandleScope scope(isolate);
8602 ASSERT(args.length() == 1); 8603 ASSERT(args.length() == 1);
8603 // The least significant bit (after untagging) indicates whether the 8604 // The least significant bit (after untagging) indicates whether the
8604 // function is currently optimized, regardless of reason. 8605 // function is currently optimized, regardless of reason.
8605 if (!V8::UseCrankshaft()) { 8606 if (!V8::UseCrankshaft()) {
8606 return Smi::FromInt(4); // 4 == "never". 8607 return Smi::FromInt(4); // 4 == "never".
8607 } 8608 }
8608 if (FLAG_always_opt) { 8609 if (FLAG_always_opt) {
8609 return Smi::FromInt(3); // 3 == "always". 8610 return Smi::FromInt(3); // 3 == "always".
8610 } 8611 }
8611 CONVERT_ARG_CHECKED(JSFunction, function, 0); 8612 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8612 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". 8613 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes".
8613 : Smi::FromInt(2); // 2 == "no". 8614 : Smi::FromInt(2); // 2 == "no".
8614 } 8615 }
8615 8616
8616 8617
8617 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) { 8618 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) {
8618 HandleScope scope(isolate); 8619 HandleScope scope(isolate);
8619 ASSERT(args.length() == 1); 8620 ASSERT(args.length() == 1);
8620 CONVERT_ARG_CHECKED(JSFunction, function, 0); 8621 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8621 return Smi::FromInt(function->shared()->opt_count()); 8622 return Smi::FromInt(function->shared()->opt_count());
8622 } 8623 }
8623 8624
8624 8625
8625 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { 8626 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
8626 HandleScope scope(isolate); 8627 HandleScope scope(isolate);
8627 ASSERT(args.length() == 1); 8628 ASSERT(args.length() == 1);
8628 CONVERT_ARG_CHECKED(JSFunction, function, 0); 8629 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8629 8630
8630 // We're not prepared to handle a function with arguments object. 8631 // We're not prepared to handle a function with arguments object.
8631 ASSERT(!function->shared()->uses_arguments()); 8632 ASSERT(!function->shared()->uses_arguments());
8632 8633
8633 // We have hit a back edge in an unoptimized frame for a function that was 8634 // We have hit a back edge in an unoptimized frame for a function that was
8634 // selected for on-stack replacement. Find the unoptimized code object. 8635 // selected for on-stack replacement. Find the unoptimized code object.
8635 Handle<Code> unoptimized(function->shared()->code(), isolate); 8636 Handle<Code> unoptimized(function->shared()->code(), isolate);
8636 // Keep track of whether we've succeeded in optimizing. 8637 // Keep track of whether we've succeeded in optimizing.
8637 bool succeeded = unoptimized->optimizable(); 8638 bool succeeded = unoptimized->optimizable();
8638 if (succeeded) { 8639 if (succeeded) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
8747 8748
8748 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) { 8749 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) {
8749 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); 8750 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
8750 return isolate->heap()->undefined_value(); 8751 return isolate->heap()->undefined_value();
8751 } 8752 }
8752 8753
8753 8754
8754 RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) { 8755 RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) {
8755 HandleScope scope(isolate); 8756 HandleScope scope(isolate);
8756 ASSERT(args.length() >= 2); 8757 ASSERT(args.length() >= 2);
8757 CONVERT_CHECKED(JSReceiver, fun, args[args.length() - 1]); 8758 int argc = args.length() - 2;
8759 CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1);
8758 Object* receiver = args[0]; 8760 Object* receiver = args[0];
8759 int argc = args.length() - 2;
8760 8761
8761 // If there are too many arguments, allocate argv via malloc. 8762 // If there are too many arguments, allocate argv via malloc.
8762 const int argv_small_size = 10; 8763 const int argv_small_size = 10;
8763 Handle<Object> argv_small_buffer[argv_small_size]; 8764 Handle<Object> argv_small_buffer[argv_small_size];
8764 SmartArrayPointer<Handle<Object> > argv_large_buffer; 8765 SmartArrayPointer<Handle<Object> > argv_large_buffer;
8765 Handle<Object>* argv = argv_small_buffer; 8766 Handle<Object>* argv = argv_small_buffer;
8766 if (argc > argv_small_size) { 8767 if (argc > argv_small_size) {
8767 argv = new Handle<Object>[argc]; 8768 argv = new Handle<Object>[argc];
8768 if (argv == NULL) return isolate->StackOverflow(); 8769 if (argv == NULL) return isolate->StackOverflow();
8769 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); 8770 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv);
(...skipping 13 matching lines...) Expand all
8783 Execution::Call(hfun, hreceiver, argc, argv, &threw, true); 8784 Execution::Call(hfun, hreceiver, argc, argv, &threw, true);
8784 8785
8785 if (threw) return Failure::Exception(); 8786 if (threw) return Failure::Exception();
8786 return *result; 8787 return *result;
8787 } 8788 }
8788 8789
8789 8790
8790 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) { 8791 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) {
8791 HandleScope scope(isolate); 8792 HandleScope scope(isolate);
8792 ASSERT(args.length() == 5); 8793 ASSERT(args.length() == 5);
8793 CONVERT_ARG_CHECKED(JSReceiver, fun, 0); 8794 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, fun, 0);
8794 Handle<Object> receiver = args.at<Object>(1); 8795 Handle<Object> receiver = args.at<Object>(1);
8795 CONVERT_ARG_CHECKED(JSObject, arguments, 2); 8796 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 2);
8796 CONVERT_SMI_ARG_CHECKED(offset, 3); 8797 CONVERT_SMI_ARG_CHECKED(offset, 3);
8797 CONVERT_SMI_ARG_CHECKED(argc, 4); 8798 CONVERT_SMI_ARG_CHECKED(argc, 4);
8798 ASSERT(offset >= 0); 8799 ASSERT(offset >= 0);
8799 ASSERT(argc >= 0); 8800 ASSERT(argc >= 0);
8800 8801
8801 // If there are too many arguments, allocate argv via malloc. 8802 // If there are too many arguments, allocate argv via malloc.
8802 const int argv_small_size = 10; 8803 const int argv_small_size = 10;
8803 Handle<Object> argv_small_buffer[argv_small_size]; 8804 Handle<Object> argv_small_buffer[argv_small_size];
8804 SmartArrayPointer<Handle<Object> > argv_large_buffer; 8805 SmartArrayPointer<Handle<Object> > argv_large_buffer;
8805 Handle<Object>* argv = argv_small_buffer; 8806 Handle<Object>* argv = argv_small_buffer;
(...skipping 29 matching lines...) Expand all
8835 ASSERT(args.length() == 1); 8836 ASSERT(args.length() == 1);
8836 RUNTIME_ASSERT(!args[0]->IsJSFunction()); 8837 RUNTIME_ASSERT(!args[0]->IsJSFunction());
8837 return *Execution::GetConstructorDelegate(args.at<Object>(0)); 8838 return *Execution::GetConstructorDelegate(args.at<Object>(0));
8838 } 8839 }
8839 8840
8840 8841
8841 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) { 8842 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) {
8842 NoHandleAllocation ha; 8843 NoHandleAllocation ha;
8843 ASSERT(args.length() == 1); 8844 ASSERT(args.length() == 1);
8844 8845
8845 CONVERT_CHECKED(JSFunction, function, args[0]); 8846 CONVERT_ARG_CHECKED(JSFunction, function, 0);
8846 int length = function->shared()->scope_info()->ContextLength(); 8847 int length = function->shared()->scope_info()->ContextLength();
8847 Object* result; 8848 Object* result;
8848 { MaybeObject* maybe_result = 8849 { MaybeObject* maybe_result =
8849 isolate->heap()->AllocateFunctionContext(length, function); 8850 isolate->heap()->AllocateFunctionContext(length, function);
8850 if (!maybe_result->ToObject(&result)) return maybe_result; 8851 if (!maybe_result->ToObject(&result)) return maybe_result;
8851 } 8852 }
8852 8853
8853 isolate->set_context(Context::cast(result)); 8854 isolate->set_context(Context::cast(result));
8854 8855
8855 return result; // non-failure 8856 return result; // non-failure
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
8947 if (!maybe_context->To(&context)) return maybe_context; 8948 if (!maybe_context->To(&context)) return maybe_context;
8948 isolate->set_context(context); 8949 isolate->set_context(context);
8949 return context; 8950 return context;
8950 } 8951 }
8951 8952
8952 8953
8953 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteContextSlot) { 8954 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteContextSlot) {
8954 HandleScope scope(isolate); 8955 HandleScope scope(isolate);
8955 ASSERT(args.length() == 2); 8956 ASSERT(args.length() == 2);
8956 8957
8957 CONVERT_ARG_CHECKED(Context, context, 0); 8958 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0);
8958 CONVERT_ARG_CHECKED(String, name, 1); 8959 CONVERT_ARG_HANDLE_CHECKED(String, name, 1);
8959 8960
8960 int index; 8961 int index;
8961 PropertyAttributes attributes; 8962 PropertyAttributes attributes;
8962 ContextLookupFlags flags = FOLLOW_CHAINS; 8963 ContextLookupFlags flags = FOLLOW_CHAINS;
8963 BindingFlags binding_flags; 8964 BindingFlags binding_flags;
8964 Handle<Object> holder = context->Lookup(name, 8965 Handle<Object> holder = context->Lookup(name,
8965 flags, 8966 flags,
8966 &index, 8967 &index,
8967 &attributes, 8968 &attributes,
8968 &binding_flags); 8969 &binding_flags);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
9140 RUNTIME_FUNCTION(ObjectPair, Runtime_LoadContextSlotNoReferenceError) { 9141 RUNTIME_FUNCTION(ObjectPair, Runtime_LoadContextSlotNoReferenceError) {
9141 return LoadContextSlotHelper(args, isolate, false); 9142 return LoadContextSlotHelper(args, isolate, false);
9142 } 9143 }
9143 9144
9144 9145
9145 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) { 9146 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) {
9146 HandleScope scope(isolate); 9147 HandleScope scope(isolate);
9147 ASSERT(args.length() == 4); 9148 ASSERT(args.length() == 4);
9148 9149
9149 Handle<Object> value(args[0], isolate); 9150 Handle<Object> value(args[0], isolate);
9150 CONVERT_ARG_CHECKED(Context, context, 1); 9151 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1);
9151 CONVERT_ARG_CHECKED(String, name, 2); 9152 CONVERT_ARG_HANDLE_CHECKED(String, name, 2);
9152 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3); 9153 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3);
9153 StrictModeFlag strict_mode = (language_mode == CLASSIC_MODE) 9154 StrictModeFlag strict_mode = (language_mode == CLASSIC_MODE)
9154 ? kNonStrictMode : kStrictMode; 9155 ? kNonStrictMode : kStrictMode;
9155 9156
9156 int index; 9157 int index;
9157 PropertyAttributes attributes; 9158 PropertyAttributes attributes;
9158 ContextLookupFlags flags = FOLLOW_CHAINS; 9159 ContextLookupFlags flags = FOLLOW_CHAINS;
9159 BindingFlags binding_flags; 9160 BindingFlags binding_flags;
9160 Handle<Object> holder = context->Lookup(name, 9161 Handle<Object> holder = context->Lookup(name,
9161 flags, 9162 flags,
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
9374 // the OS time. 9375 // the OS time.
9375 double millis = floor(OS::TimeCurrentMillis()); 9376 double millis = floor(OS::TimeCurrentMillis());
9376 return isolate->heap()->NumberFromDouble(millis); 9377 return isolate->heap()->NumberFromDouble(millis);
9377 } 9378 }
9378 9379
9379 9380
9380 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { 9381 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) {
9381 HandleScope scope(isolate); 9382 HandleScope scope(isolate);
9382 ASSERT(args.length() == 2); 9383 ASSERT(args.length() == 2);
9383 9384
9384 CONVERT_ARG_CHECKED(String, str, 0); 9385 CONVERT_ARG_HANDLE_CHECKED(String, str, 0);
9385 FlattenString(str); 9386 FlattenString(str);
9386 9387
9387 CONVERT_ARG_CHECKED(JSArray, output, 1); 9388 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1);
9388 9389
9389 MaybeObject* maybe_result_array = 9390 MaybeObject* maybe_result_array =
9390 output->EnsureCanContainHeapObjectElements(); 9391 output->EnsureCanContainHeapObjectElements();
9391 if (maybe_result_array->IsFailure()) return maybe_result_array; 9392 if (maybe_result_array->IsFailure()) return maybe_result_array;
9392 RUNTIME_ASSERT(output->HasFastElements()); 9393 RUNTIME_ASSERT(output->HasFastElements());
9393 9394
9394 AssertNoAllocation no_allocation; 9395 AssertNoAllocation no_allocation;
9395 9396
9396 FixedArray* output_array = FixedArray::cast(output->elements()); 9397 FixedArray* output_array = FixedArray::cast(output->elements());
9397 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE); 9398 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
9447 ASSERT(args.length() == 1); 9448 ASSERT(args.length() == 1);
9448 Object* global = args[0]; 9449 Object* global = args[0];
9449 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); 9450 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value();
9450 return JSGlobalObject::cast(global)->global_receiver(); 9451 return JSGlobalObject::cast(global)->global_receiver();
9451 } 9452 }
9452 9453
9453 9454
9454 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { 9455 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) {
9455 HandleScope scope(isolate); 9456 HandleScope scope(isolate);
9456 ASSERT_EQ(1, args.length()); 9457 ASSERT_EQ(1, args.length());
9457 CONVERT_ARG_CHECKED(String, source, 0); 9458 CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
9458 9459
9459 source = Handle<String>(source->TryFlattenGetString()); 9460 source = Handle<String>(source->TryFlattenGetString());
9460 // Optimized fast case where we only have ASCII characters. 9461 // Optimized fast case where we only have ASCII characters.
9461 Handle<Object> result; 9462 Handle<Object> result;
9462 if (source->IsSeqAsciiString()) { 9463 if (source->IsSeqAsciiString()) {
9463 result = JsonParser<true>::Parse(source); 9464 result = JsonParser<true>::Parse(source);
9464 } else { 9465 } else {
9465 result = JsonParser<false>::Parse(source); 9466 result = JsonParser<false>::Parse(source);
9466 } 9467 }
9467 if (result.is_null()) { 9468 if (result.is_null()) {
(...skipping 18 matching lines...) Expand all
9486 // Callback set. Let it decide if code generation is allowed. 9487 // Callback set. Let it decide if code generation is allowed.
9487 VMState state(isolate, EXTERNAL); 9488 VMState state(isolate, EXTERNAL);
9488 return callback(v8::Utils::ToLocal(context)); 9489 return callback(v8::Utils::ToLocal(context));
9489 } 9490 }
9490 } 9491 }
9491 9492
9492 9493
9493 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileString) { 9494 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileString) {
9494 HandleScope scope(isolate); 9495 HandleScope scope(isolate);
9495 ASSERT_EQ(1, args.length()); 9496 ASSERT_EQ(1, args.length());
9496 CONVERT_ARG_CHECKED(String, source, 0); 9497 CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
9497 9498
9498 // Extract global context. 9499 // Extract global context.
9499 Handle<Context> context(isolate->context()->global_context()); 9500 Handle<Context> context(isolate->context()->global_context());
9500 9501
9501 // Check if global context allows code generation from 9502 // Check if global context allows code generation from
9502 // strings. Throw an exception if it doesn't. 9503 // strings. Throw an exception if it doesn't.
9503 if (context->allow_code_gen_from_strings()->IsFalse() && 9504 if (context->allow_code_gen_from_strings()->IsFalse() &&
9504 !CodeGenerationFromStringsAllowed(isolate, context)) { 9505 !CodeGenerationFromStringsAllowed(isolate, context)) {
9505 return isolate->Throw(*isolate->factory()->NewError( 9506 return isolate->Throw(*isolate->factory()->NewError(
9506 "code_gen_from_strings", HandleVector<Object>(NULL, 0))); 9507 "code_gen_from_strings", HandleVector<Object>(NULL, 0)));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
9577 } 9578 }
9578 9579
9579 9580
9580 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNewFunctionAttributes) { 9581 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNewFunctionAttributes) {
9581 // This utility adjusts the property attributes for newly created Function 9582 // This utility adjusts the property attributes for newly created Function
9582 // object ("new Function(...)") by changing the map. 9583 // object ("new Function(...)") by changing the map.
9583 // All it does is changing the prototype property to enumerable 9584 // All it does is changing the prototype property to enumerable
9584 // as specified in ECMA262, 15.3.5.2. 9585 // as specified in ECMA262, 15.3.5.2.
9585 HandleScope scope(isolate); 9586 HandleScope scope(isolate);
9586 ASSERT(args.length() == 1); 9587 ASSERT(args.length() == 1);
9587 CONVERT_ARG_CHECKED(JSFunction, func, 0); 9588 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
9588 9589
9589 Handle<Map> map = func->shared()->is_classic_mode() 9590 Handle<Map> map = func->shared()->is_classic_mode()
9590 ? isolate->function_instance_map() 9591 ? isolate->function_instance_map()
9591 : isolate->strict_mode_function_instance_map(); 9592 : isolate->strict_mode_function_instance_map();
9592 9593
9593 ASSERT(func->map()->instance_type() == map->instance_type()); 9594 ASSERT(func->map()->instance_type() == map->instance_type());
9594 ASSERT(func->map()->instance_size() == map->instance_size()); 9595 ASSERT(func->map()->instance_size() == map->instance_size());
9595 func->set_map(*map); 9596 func->set_map(*map);
9596 return *func; 9597 return *func;
9597 } 9598 }
9598 9599
9599 9600
9600 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) { 9601 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) {
9601 // Allocate a block of memory in NewSpace (filled with a filler). 9602 // Allocate a block of memory in NewSpace (filled with a filler).
9602 // Use as fallback for allocation in generated code when NewSpace 9603 // Use as fallback for allocation in generated code when NewSpace
9603 // is full. 9604 // is full.
9604 ASSERT(args.length() == 1); 9605 ASSERT(args.length() == 1);
9605 CONVERT_ARG_CHECKED(Smi, size_smi, 0); 9606 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0);
9606 int size = size_smi->value(); 9607 int size = size_smi->value();
9607 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); 9608 RUNTIME_ASSERT(IsAligned(size, kPointerSize));
9608 RUNTIME_ASSERT(size > 0); 9609 RUNTIME_ASSERT(size > 0);
9609 Heap* heap = isolate->heap(); 9610 Heap* heap = isolate->heap();
9610 const int kMinFreeNewSpaceAfterGC = heap->InitialSemiSpaceSize() * 3/4; 9611 const int kMinFreeNewSpaceAfterGC = heap->InitialSemiSpaceSize() * 3/4;
9611 RUNTIME_ASSERT(size <= kMinFreeNewSpaceAfterGC); 9612 RUNTIME_ASSERT(size <= kMinFreeNewSpaceAfterGC);
9612 Object* allocation; 9613 Object* allocation;
9613 { MaybeObject* maybe_allocation = heap->new_space()->AllocateRaw(size); 9614 { MaybeObject* maybe_allocation = heap->new_space()->AllocateRaw(size);
9614 if (maybe_allocation->ToObject(&allocation)) { 9615 if (maybe_allocation->ToObject(&allocation)) {
9615 heap->CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size); 9616 heap->CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size);
9616 } 9617 }
9617 return maybe_allocation; 9618 return maybe_allocation;
9618 } 9619 }
9619 } 9620 }
9620 9621
9621 9622
9622 // Push an object unto an array of objects if it is not already in the 9623 // Push an object unto an array of objects if it is not already in the
9623 // array. Returns true if the element was pushed on the stack and 9624 // array. Returns true if the element was pushed on the stack and
9624 // false otherwise. 9625 // false otherwise.
9625 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { 9626 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) {
9626 ASSERT(args.length() == 2); 9627 ASSERT(args.length() == 2);
9627 CONVERT_CHECKED(JSArray, array, args[0]); 9628 CONVERT_ARG_CHECKED(JSArray, array, 0);
9628 CONVERT_CHECKED(JSObject, element, args[1]); 9629 CONVERT_ARG_CHECKED(JSObject, element, 1);
9629 RUNTIME_ASSERT(array->HasFastElements() || array->HasFastSmiOnlyElements()); 9630 RUNTIME_ASSERT(array->HasFastElements() || array->HasFastSmiOnlyElements());
9630 int length = Smi::cast(array->length())->value(); 9631 int length = Smi::cast(array->length())->value();
9631 FixedArray* elements = FixedArray::cast(array->elements()); 9632 FixedArray* elements = FixedArray::cast(array->elements());
9632 for (int i = 0; i < length; i++) { 9633 for (int i = 0; i < length; i++) {
9633 if (elements->get(i) == element) return isolate->heap()->false_value(); 9634 if (elements->get(i) == element) return isolate->heap()->false_value();
9634 } 9635 }
9635 Object* obj; 9636 Object* obj;
9636 // Strict not needed. Used for cycle detection in Array join implementation. 9637 // Strict not needed. Used for cycle detection in Array join implementation.
9637 { MaybeObject* maybe_obj = 9638 { MaybeObject* maybe_obj =
9638 array->SetFastElement(length, element, kNonStrictMode, true); 9639 array->SetFastElement(length, element, kNonStrictMode, true);
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
10109 /** 10110 /**
10110 * Array::concat implementation. 10111 * Array::concat implementation.
10111 * See ECMAScript 262, 15.4.4.4. 10112 * See ECMAScript 262, 15.4.4.4.
10112 * TODO(581): Fix non-compliance for very large concatenations and update to 10113 * TODO(581): Fix non-compliance for very large concatenations and update to
10113 * following the ECMAScript 5 specification. 10114 * following the ECMAScript 5 specification.
10114 */ 10115 */
10115 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConcat) { 10116 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConcat) {
10116 ASSERT(args.length() == 1); 10117 ASSERT(args.length() == 1);
10117 HandleScope handle_scope(isolate); 10118 HandleScope handle_scope(isolate);
10118 10119
10119 CONVERT_ARG_CHECKED(JSArray, arguments, 0); 10120 CONVERT_ARG_HANDLE_CHECKED(JSArray, arguments, 0);
10120 int argument_count = static_cast<int>(arguments->length()->Number()); 10121 int argument_count = static_cast<int>(arguments->length()->Number());
10121 RUNTIME_ASSERT(arguments->HasFastElements()); 10122 RUNTIME_ASSERT(arguments->HasFastElements());
10122 Handle<FixedArray> elements(FixedArray::cast(arguments->elements())); 10123 Handle<FixedArray> elements(FixedArray::cast(arguments->elements()));
10123 10124
10124 // Pass 1: estimate the length and number of elements of the result. 10125 // Pass 1: estimate the length and number of elements of the result.
10125 // The actual length can be larger if any of the arguments have getters 10126 // The actual length can be larger if any of the arguments have getters
10126 // that mutate other arguments (but will otherwise be precise). 10127 // that mutate other arguments (but will otherwise be precise).
10127 // The number of elements is precise if there are no inherited elements. 10128 // The number of elements is precise if there are no inherited elements.
10128 10129
10129 uint32_t estimate_result_length = 0; 10130 uint32_t estimate_result_length = 0;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
10204 return *visitor.ToArray(); 10205 return *visitor.ToArray();
10205 } 10206 }
10206 10207
10207 10208
10208 // This will not allocate (flatten the string), but it may run 10209 // This will not allocate (flatten the string), but it may run
10209 // very slowly for very deeply nested ConsStrings. For debugging use only. 10210 // very slowly for very deeply nested ConsStrings. For debugging use only.
10210 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) { 10211 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) {
10211 NoHandleAllocation ha; 10212 NoHandleAllocation ha;
10212 ASSERT(args.length() == 1); 10213 ASSERT(args.length() == 1);
10213 10214
10214 CONVERT_CHECKED(String, string, args[0]); 10215 CONVERT_ARG_CHECKED(String, string, 0);
10215 StringInputBuffer buffer(string); 10216 StringInputBuffer buffer(string);
10216 while (buffer.has_more()) { 10217 while (buffer.has_more()) {
10217 uint16_t character = buffer.GetNext(); 10218 uint16_t character = buffer.GetNext();
10218 PrintF("%c", character); 10219 PrintF("%c", character);
10219 } 10220 }
10220 return string; 10221 return string;
10221 } 10222 }
10222 10223
10223 // Moves all own elements of an object, that are below a limit, to positions 10224 // Moves all own elements of an object, that are below a limit, to positions
10224 // starting at zero. All undefined values are placed after non-undefined values, 10225 // starting at zero. All undefined values are placed after non-undefined values,
10225 // and are followed by non-existing element. Does not change the length 10226 // and are followed by non-existing element. Does not change the length
10226 // property. 10227 // property.
10227 // Returns the number of non-undefined elements collected. 10228 // Returns the number of non-undefined elements collected.
10228 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) { 10229 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) {
10229 ASSERT(args.length() == 2); 10230 ASSERT(args.length() == 2);
10230 CONVERT_CHECKED(JSObject, object, args[0]); 10231 CONVERT_ARG_CHECKED(JSObject, object, 0);
10231 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); 10232 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
10232 return object->PrepareElementsForSort(limit); 10233 return object->PrepareElementsForSort(limit);
10233 } 10234 }
10234 10235
10235 10236
10236 // Move contents of argument 0 (an array) to argument 1 (an array) 10237 // Move contents of argument 0 (an array) to argument 1 (an array)
10237 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { 10238 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) {
10238 ASSERT(args.length() == 2); 10239 ASSERT(args.length() == 2);
10239 CONVERT_CHECKED(JSArray, from, args[0]); 10240 CONVERT_ARG_CHECKED(JSArray, from, 0);
10240 CONVERT_CHECKED(JSArray, to, args[1]); 10241 CONVERT_ARG_CHECKED(JSArray, to, 1);
10241 FixedArrayBase* new_elements = from->elements(); 10242 FixedArrayBase* new_elements = from->elements();
10242 MaybeObject* maybe_new_map; 10243 MaybeObject* maybe_new_map;
10243 ElementsKind elements_kind; 10244 ElementsKind elements_kind;
10244 if (new_elements->map() == isolate->heap()->fixed_array_map() || 10245 if (new_elements->map() == isolate->heap()->fixed_array_map() ||
10245 new_elements->map() == isolate->heap()->fixed_cow_array_map()) { 10246 new_elements->map() == isolate->heap()->fixed_cow_array_map()) {
10246 elements_kind = FAST_ELEMENTS; 10247 elements_kind = FAST_ELEMENTS;
10247 } else if (new_elements->map() == 10248 } else if (new_elements->map() ==
10248 isolate->heap()->fixed_double_array_map()) { 10249 isolate->heap()->fixed_double_array_map()) {
10249 elements_kind = FAST_DOUBLE_ELEMENTS; 10250 elements_kind = FAST_DOUBLE_ELEMENTS;
10250 } else { 10251 } else {
(...skipping 10 matching lines...) Expand all
10261 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 10262 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
10262 } 10263 }
10263 from->set_length(Smi::FromInt(0)); 10264 from->set_length(Smi::FromInt(0));
10264 return to; 10265 return to;
10265 } 10266 }
10266 10267
10267 10268
10268 // How many elements does this object/array have? 10269 // How many elements does this object/array have?
10269 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) { 10270 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) {
10270 ASSERT(args.length() == 1); 10271 ASSERT(args.length() == 1);
10271 CONVERT_CHECKED(JSObject, object, args[0]); 10272 CONVERT_ARG_CHECKED(JSObject, object, 0);
10272 HeapObject* elements = object->elements(); 10273 HeapObject* elements = object->elements();
10273 if (elements->IsDictionary()) { 10274 if (elements->IsDictionary()) {
10274 int result = SeededNumberDictionary::cast(elements)->NumberOfElements(); 10275 int result = SeededNumberDictionary::cast(elements)->NumberOfElements();
10275 return Smi::FromInt(result); 10276 return Smi::FromInt(result);
10276 } else if (object->IsJSArray()) { 10277 } else if (object->IsJSArray()) {
10277 return JSArray::cast(object)->length(); 10278 return JSArray::cast(object)->length();
10278 } else { 10279 } else {
10279 return Smi::FromInt(FixedArray::cast(elements)->length()); 10280 return Smi::FromInt(FixedArray::cast(elements)->length());
10280 } 10281 }
10281 } 10282 }
10282 10283
10283 10284
10284 RUNTIME_FUNCTION(MaybeObject*, Runtime_SwapElements) { 10285 RUNTIME_FUNCTION(MaybeObject*, Runtime_SwapElements) {
10285 HandleScope handle_scope(isolate); 10286 HandleScope handle_scope(isolate);
10286 10287
10287 ASSERT_EQ(3, args.length()); 10288 ASSERT_EQ(3, args.length());
10288 10289
10289 CONVERT_ARG_CHECKED(JSObject, object, 0); 10290 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
10290 Handle<Object> key1 = args.at<Object>(1); 10291 Handle<Object> key1 = args.at<Object>(1);
10291 Handle<Object> key2 = args.at<Object>(2); 10292 Handle<Object> key2 = args.at<Object>(2);
10292 10293
10293 uint32_t index1, index2; 10294 uint32_t index1, index2;
10294 if (!key1->ToArrayIndex(&index1) 10295 if (!key1->ToArrayIndex(&index1)
10295 || !key2->ToArrayIndex(&index2)) { 10296 || !key2->ToArrayIndex(&index2)) {
10296 return isolate->ThrowIllegalOperation(); 10297 return isolate->ThrowIllegalOperation();
10297 } 10298 }
10298 10299
10299 Handle<JSObject> jsobject = Handle<JSObject>::cast(object); 10300 Handle<JSObject> jsobject = Handle<JSObject>::cast(object);
(...skipping 12 matching lines...) Expand all
10312 10313
10313 10314
10314 // Returns an array that tells you where in the [0, length) interval an array 10315 // Returns an array that tells you where in the [0, length) interval an array
10315 // might have elements. Can either return keys (positive integers) or 10316 // might have elements. Can either return keys (positive integers) or
10316 // intervals (pair of a negative integer (-start-1) followed by a 10317 // intervals (pair of a negative integer (-start-1) followed by a
10317 // positive (length)) or undefined values. 10318 // positive (length)) or undefined values.
10318 // Intervals can span over some keys that are not in the object. 10319 // Intervals can span over some keys that are not in the object.
10319 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) { 10320 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) {
10320 ASSERT(args.length() == 2); 10321 ASSERT(args.length() == 2);
10321 HandleScope scope(isolate); 10322 HandleScope scope(isolate);
10322 CONVERT_ARG_CHECKED(JSObject, array, 0); 10323 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
10323 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); 10324 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]);
10324 if (array->elements()->IsDictionary()) { 10325 if (array->elements()->IsDictionary()) {
10325 // Create an array and get all the keys into it, then remove all the 10326 // Create an array and get all the keys into it, then remove all the
10326 // keys that are not integers in the range 0 to length-1. 10327 // keys that are not integers in the range 0 to length-1.
10327 bool threw = false; 10328 bool threw = false;
10328 Handle<FixedArray> keys = 10329 Handle<FixedArray> keys =
10329 GetKeysInFixedArrayFor(array, INCLUDE_PROTOS, &threw); 10330 GetKeysInFixedArrayFor(array, INCLUDE_PROTOS, &threw);
10330 if (threw) return Failure::Exception(); 10331 if (threw) return Failure::Exception();
10331 10332
10332 int keys_length = keys->length(); 10333 int keys_length = keys->length();
(...skipping 28 matching lines...) Expand all
10361 // DefineAccessor takes an optional final argument which is the 10362 // DefineAccessor takes an optional final argument which is the
10362 // property attributes (e.g. DONT_ENUM, DONT_DELETE). IMPORTANT: due 10363 // property attributes (e.g. DONT_ENUM, DONT_DELETE). IMPORTANT: due
10363 // to the way accessors are implemented, it is set for both the getter 10364 // to the way accessors are implemented, it is set for both the getter
10364 // and setter on the first call to DefineAccessor and ignored on 10365 // and setter on the first call to DefineAccessor and ignored on
10365 // subsequent calls. 10366 // subsequent calls.
10366 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineAccessor) { 10367 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineAccessor) {
10367 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); 10368 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5);
10368 // Compute attributes. 10369 // Compute attributes.
10369 PropertyAttributes attributes = NONE; 10370 PropertyAttributes attributes = NONE;
10370 if (args.length() == 5) { 10371 if (args.length() == 5) {
10371 CONVERT_CHECKED(Smi, attrs, args[4]); 10372 CONVERT_SMI_ARG_CHECKED(value, 4);
10372 int value = attrs->value();
10373 // Only attribute bits should be set. 10373 // Only attribute bits should be set.
10374 ASSERT((value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 10374 ASSERT((value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
10375 attributes = static_cast<PropertyAttributes>(value); 10375 attributes = static_cast<PropertyAttributes>(value);
10376 } 10376 }
10377 10377
10378 CONVERT_CHECKED(JSObject, obj, args[0]); 10378 CONVERT_ARG_CHECKED(JSObject, obj, 0);
10379 CONVERT_CHECKED(String, name, args[1]); 10379 CONVERT_ARG_CHECKED(String, name, 1);
10380 CONVERT_CHECKED(Smi, flag, args[2]); 10380 CONVERT_SMI_ARG_CHECKED(flag, 2);
10381 CONVERT_CHECKED(JSFunction, fun, args[3]); 10381 CONVERT_ARG_CHECKED(JSFunction, fun, 3);
10382 return obj->DefineAccessor(name, flag->value() == 0, fun, attributes); 10382 return obj->DefineAccessor(name, flag == 0, fun, attributes);
10383 } 10383 }
10384 10384
10385 10385
10386 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { 10386 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) {
10387 ASSERT(args.length() == 3); 10387 ASSERT(args.length() == 3);
10388 CONVERT_CHECKED(JSObject, obj, args[0]); 10388 CONVERT_ARG_CHECKED(JSObject, obj, 0);
10389 CONVERT_CHECKED(String, name, args[1]); 10389 CONVERT_ARG_CHECKED(String, name, 1);
10390 CONVERT_CHECKED(Smi, flag, args[2]); 10390 CONVERT_SMI_ARG_CHECKED(flag, 2);
10391 return obj->LookupAccessor(name, flag->value() == 0); 10391 return obj->LookupAccessor(name, flag == 0);
10392 } 10392 }
10393 10393
10394 10394
10395 #ifdef ENABLE_DEBUGGER_SUPPORT 10395 #ifdef ENABLE_DEBUGGER_SUPPORT
10396 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) { 10396 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) {
10397 ASSERT(args.length() == 0); 10397 ASSERT(args.length() == 0);
10398 return Execution::DebugBreakHelper(); 10398 return Execution::DebugBreakHelper();
10399 } 10399 }
10400 10400
10401 10401
10402 // Helper functions for wrapping and unwrapping stack frame ids. 10402 // Helper functions for wrapping and unwrapping stack frame ids.
10403 static Smi* WrapFrameId(StackFrame::Id id) { 10403 static Smi* WrapFrameId(StackFrame::Id id) {
10404 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); 10404 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4)));
10405 return Smi::FromInt(id >> 2); 10405 return Smi::FromInt(id >> 2);
10406 } 10406 }
10407 10407
10408 10408
10409 static StackFrame::Id UnwrapFrameId(Smi* wrapped) { 10409 static StackFrame::Id UnwrapFrameId(int wrapped) {
10410 return static_cast<StackFrame::Id>(wrapped->value() << 2); 10410 return static_cast<StackFrame::Id>(wrapped << 2);
10411 } 10411 }
10412 10412
10413 10413
10414 // Adds a JavaScript function as a debug event listener. 10414 // Adds a JavaScript function as a debug event listener.
10415 // args[0]: debug event listener function to set or null or undefined for 10415 // args[0]: debug event listener function to set or null or undefined for
10416 // clearing the event listener function 10416 // clearing the event listener function
10417 // args[1]: object supplied during callback 10417 // args[1]: object supplied during callback
10418 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDebugEventListener) { 10418 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDebugEventListener) {
10419 ASSERT(args.length() == 2); 10419 ASSERT(args.length() == 2);
10420 RUNTIME_ASSERT(args[0]->IsJSFunction() || 10420 RUNTIME_ASSERT(args[0]->IsJSFunction() ||
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
10503 // 2: Property value is exception 10503 // 2: Property value is exception
10504 // 3: Getter function if defined 10504 // 3: Getter function if defined
10505 // 4: Setter function if defined 10505 // 4: Setter function if defined
10506 // Items 2-4 are only filled if the property has either a getter or a setter 10506 // Items 2-4 are only filled if the property has either a getter or a setter
10507 // defined through __defineGetter__ and/or __defineSetter__. 10507 // defined through __defineGetter__ and/or __defineSetter__.
10508 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPropertyDetails) { 10508 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPropertyDetails) {
10509 HandleScope scope(isolate); 10509 HandleScope scope(isolate);
10510 10510
10511 ASSERT(args.length() == 2); 10511 ASSERT(args.length() == 2);
10512 10512
10513 CONVERT_ARG_CHECKED(JSObject, obj, 0); 10513 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
10514 CONVERT_ARG_CHECKED(String, name, 1); 10514 CONVERT_ARG_HANDLE_CHECKED(String, name, 1);
10515 10515
10516 // Make sure to set the current context to the context before the debugger was 10516 // Make sure to set the current context to the context before the debugger was
10517 // entered (if the debugger is entered). The reason for switching context here 10517 // entered (if the debugger is entered). The reason for switching context here
10518 // is that for some property lookups (accessors and interceptors) callbacks 10518 // is that for some property lookups (accessors and interceptors) callbacks
10519 // into the embedding application can occour, and the embedding application 10519 // into the embedding application can occour, and the embedding application
10520 // could have the assumption that its own global context is the current 10520 // could have the assumption that its own global context is the current
10521 // context and not some internal debugger context. 10521 // context and not some internal debugger context.
10522 SaveContext save(isolate); 10522 SaveContext save(isolate);
10523 if (isolate->debug()->InDebugger()) { 10523 if (isolate->debug()->InDebugger()) {
10524 isolate->set_context(*isolate->debug()->debugger_entry()->GetContext()); 10524 isolate->set_context(*isolate->debug()->debugger_entry()->GetContext());
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
10601 10601
10602 return isolate->heap()->undefined_value(); 10602 return isolate->heap()->undefined_value();
10603 } 10603 }
10604 10604
10605 10605
10606 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) { 10606 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) {
10607 HandleScope scope(isolate); 10607 HandleScope scope(isolate);
10608 10608
10609 ASSERT(args.length() == 2); 10609 ASSERT(args.length() == 2);
10610 10610
10611 CONVERT_ARG_CHECKED(JSObject, obj, 0); 10611 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
10612 CONVERT_ARG_CHECKED(String, name, 1); 10612 CONVERT_ARG_HANDLE_CHECKED(String, name, 1);
10613 10613
10614 LookupResult result(isolate); 10614 LookupResult result(isolate);
10615 obj->Lookup(*name, &result); 10615 obj->Lookup(*name, &result);
10616 if (result.IsProperty()) { 10616 if (result.IsProperty()) {
10617 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL); 10617 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL);
10618 } 10618 }
10619 return isolate->heap()->undefined_value(); 10619 return isolate->heap()->undefined_value();
10620 } 10620 }
10621 10621
10622 10622
10623 // Return the property type calculated from the property details. 10623 // Return the property type calculated from the property details.
10624 // args[0]: smi with property details. 10624 // args[0]: smi with property details.
10625 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) { 10625 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) {
10626 ASSERT(args.length() == 1); 10626 ASSERT(args.length() == 1);
10627 CONVERT_CHECKED(Smi, details, args[0]); 10627 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0);
10628 PropertyType type = PropertyDetails(details).type(); 10628 return Smi::FromInt(static_cast<int>(details.type()));
10629 return Smi::FromInt(static_cast<int>(type));
10630 } 10629 }
10631 10630
10632 10631
10633 // Return the property attribute calculated from the property details. 10632 // Return the property attribute calculated from the property details.
10634 // args[0]: smi with property details. 10633 // args[0]: smi with property details.
10635 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) { 10634 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) {
10636 ASSERT(args.length() == 1); 10635 ASSERT(args.length() == 1);
10637 CONVERT_CHECKED(Smi, details, args[0]); 10636 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0);
10638 PropertyAttributes attributes = PropertyDetails(details).attributes(); 10637 return Smi::FromInt(static_cast<int>(details.attributes()));
10639 return Smi::FromInt(static_cast<int>(attributes));
10640 } 10638 }
10641 10639
10642 10640
10643 // Return the property insertion index calculated from the property details. 10641 // Return the property insertion index calculated from the property details.
10644 // args[0]: smi with property details. 10642 // args[0]: smi with property details.
10645 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyIndexFromDetails) { 10643 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyIndexFromDetails) {
10646 ASSERT(args.length() == 1); 10644 ASSERT(args.length() == 1);
10647 CONVERT_CHECKED(Smi, details, args[0]); 10645 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0);
10648 int index = PropertyDetails(details).index(); 10646 return Smi::FromInt(details.index());
10649 return Smi::FromInt(index);
10650 } 10647 }
10651 10648
10652 10649
10653 // Return property value from named interceptor. 10650 // Return property value from named interceptor.
10654 // args[0]: object 10651 // args[0]: object
10655 // args[1]: property name 10652 // args[1]: property name
10656 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) { 10653 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) {
10657 HandleScope scope(isolate); 10654 HandleScope scope(isolate);
10658 ASSERT(args.length() == 2); 10655 ASSERT(args.length() == 2);
10659 CONVERT_ARG_CHECKED(JSObject, obj, 0); 10656 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
10660 RUNTIME_ASSERT(obj->HasNamedInterceptor()); 10657 RUNTIME_ASSERT(obj->HasNamedInterceptor());
10661 CONVERT_ARG_CHECKED(String, name, 1); 10658 CONVERT_ARG_HANDLE_CHECKED(String, name, 1);
10662 10659
10663 PropertyAttributes attributes; 10660 PropertyAttributes attributes;
10664 return obj->GetPropertyWithInterceptor(*obj, *name, &attributes); 10661 return obj->GetPropertyWithInterceptor(*obj, *name, &attributes);
10665 } 10662 }
10666 10663
10667 10664
10668 // Return element value from indexed interceptor. 10665 // Return element value from indexed interceptor.
10669 // args[0]: object 10666 // args[0]: object
10670 // args[1]: index 10667 // args[1]: index
10671 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) { 10668 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) {
10672 HandleScope scope(isolate); 10669 HandleScope scope(isolate);
10673 ASSERT(args.length() == 2); 10670 ASSERT(args.length() == 2);
10674 CONVERT_ARG_CHECKED(JSObject, obj, 0); 10671 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
10675 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); 10672 RUNTIME_ASSERT(obj->HasIndexedInterceptor());
10676 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); 10673 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]);
10677 10674
10678 return obj->GetElementWithInterceptor(*obj, index); 10675 return obj->GetElementWithInterceptor(*obj, index);
10679 } 10676 }
10680 10677
10681 10678
10682 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckExecutionState) { 10679 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckExecutionState) {
10683 ASSERT(args.length() >= 1); 10680 ASSERT(args.length() >= 1);
10684 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 10681 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
11600 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { 11597 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) {
11601 HandleScope scope(isolate); 11598 HandleScope scope(isolate);
11602 ASSERT(args.length() == 2); 11599 ASSERT(args.length() == 2);
11603 11600
11604 // Check arguments. 11601 // Check arguments.
11605 Object* check; 11602 Object* check;
11606 { MaybeObject* maybe_check = Runtime_CheckExecutionState( 11603 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11607 RUNTIME_ARGUMENTS(isolate, args)); 11604 RUNTIME_ARGUMENTS(isolate, args));
11608 if (!maybe_check->ToObject(&check)) return maybe_check; 11605 if (!maybe_check->ToObject(&check)) return maybe_check;
11609 } 11606 }
11610 CONVERT_CHECKED(Smi, wrapped_id, args[1]); 11607 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
11611 11608
11612 // Get the frame where the debugging is performed. 11609 // Get the frame where the debugging is performed.
11613 StackFrame::Id id = UnwrapFrameId(wrapped_id); 11610 StackFrame::Id id = UnwrapFrameId(wrapped_id);
11614 JavaScriptFrameIterator it(isolate, id); 11611 JavaScriptFrameIterator it(isolate, id);
11615 JavaScriptFrame* frame = it.frame(); 11612 JavaScriptFrame* frame = it.frame();
11616 11613
11617 // Count the visible scopes. 11614 // Count the visible scopes.
11618 int n = 0; 11615 int n = 0;
11619 for (ScopeIterator it(isolate, frame, 0); 11616 for (ScopeIterator it(isolate, frame, 0);
11620 !it.Done(); 11617 !it.Done();
(...skipping 21 matching lines...) Expand all
11642 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) { 11639 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) {
11643 HandleScope scope(isolate); 11640 HandleScope scope(isolate);
11644 ASSERT(args.length() == 4); 11641 ASSERT(args.length() == 4);
11645 11642
11646 // Check arguments. 11643 // Check arguments.
11647 Object* check; 11644 Object* check;
11648 { MaybeObject* maybe_check = Runtime_CheckExecutionState( 11645 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11649 RUNTIME_ARGUMENTS(isolate, args)); 11646 RUNTIME_ARGUMENTS(isolate, args));
11650 if (!maybe_check->ToObject(&check)) return maybe_check; 11647 if (!maybe_check->ToObject(&check)) return maybe_check;
11651 } 11648 }
11652 CONVERT_CHECKED(Smi, wrapped_id, args[1]); 11649 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
11653 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); 11650 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
11654 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); 11651 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]);
11655 11652
11656 // Get the frame where the debugging is performed. 11653 // Get the frame where the debugging is performed.
11657 StackFrame::Id id = UnwrapFrameId(wrapped_id); 11654 StackFrame::Id id = UnwrapFrameId(wrapped_id);
11658 JavaScriptFrameIterator frame_it(isolate, id); 11655 JavaScriptFrameIterator frame_it(isolate, id);
11659 JavaScriptFrame* frame = frame_it.frame(); 11656 JavaScriptFrame* frame = frame_it.frame();
11660 11657
11661 // Find the requested scope. 11658 // Find the requested scope.
11662 int n = 0; 11659 int n = 0;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
11782 // Convert to JS array and return. 11779 // Convert to JS array and return.
11783 return *isolate->factory()->NewJSArrayWithElements(details); 11780 return *isolate->factory()->NewJSArrayWithElements(details);
11784 } 11781 }
11785 11782
11786 11783
11787 // Sets the disable break state 11784 // Sets the disable break state
11788 // args[0]: disable break state 11785 // args[0]: disable break state
11789 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) { 11786 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) {
11790 HandleScope scope(isolate); 11787 HandleScope scope(isolate);
11791 ASSERT(args.length() == 1); 11788 ASSERT(args.length() == 1);
11792 CONVERT_BOOLEAN_CHECKED(disable_break, args[0]); 11789 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0);
11793 isolate->debug()->set_disable_break(disable_break); 11790 isolate->debug()->set_disable_break(disable_break);
11794 return isolate->heap()->undefined_value(); 11791 return isolate->heap()->undefined_value();
11795 } 11792 }
11796 11793
11797 11794
11798 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) { 11795 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) {
11799 HandleScope scope(isolate); 11796 HandleScope scope(isolate);
11800 ASSERT(args.length() == 1); 11797 ASSERT(args.length() == 1);
11801 11798
11802 CONVERT_ARG_CHECKED(JSFunction, fun, 0); 11799 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
11803 Handle<SharedFunctionInfo> shared(fun->shared()); 11800 Handle<SharedFunctionInfo> shared(fun->shared());
11804 // Find the number of break points 11801 // Find the number of break points
11805 Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared); 11802 Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared);
11806 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); 11803 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value();
11807 // Return array as JS array 11804 // Return array as JS array
11808 return *isolate->factory()->NewJSArrayWithElements( 11805 return *isolate->factory()->NewJSArrayWithElements(
11809 Handle<FixedArray>::cast(break_locations)); 11806 Handle<FixedArray>::cast(break_locations));
11810 } 11807 }
11811 11808
11812 11809
11813 // Set a break point in a function 11810 // Set a break point in a function
11814 // args[0]: function 11811 // args[0]: function
11815 // args[1]: number: break source position (within the function source) 11812 // args[1]: number: break source position (within the function source)
11816 // args[2]: number: break point object 11813 // args[2]: number: break point object
11817 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFunctionBreakPoint) { 11814 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFunctionBreakPoint) {
11818 HandleScope scope(isolate); 11815 HandleScope scope(isolate);
11819 ASSERT(args.length() == 3); 11816 ASSERT(args.length() == 3);
11820 CONVERT_ARG_CHECKED(JSFunction, fun, 0); 11817 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
11821 Handle<SharedFunctionInfo> shared(fun->shared()); 11818 Handle<SharedFunctionInfo> shared(fun->shared());
11822 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); 11819 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
11823 RUNTIME_ASSERT(source_position >= 0); 11820 RUNTIME_ASSERT(source_position >= 0);
11824 Handle<Object> break_point_object_arg = args.at<Object>(2); 11821 Handle<Object> break_point_object_arg = args.at<Object>(2);
11825 11822
11826 // Set break point. 11823 // Set break point.
11827 isolate->debug()->SetBreakPoint(shared, break_point_object_arg, 11824 isolate->debug()->SetBreakPoint(shared, break_point_object_arg,
11828 &source_position); 11825 &source_position);
11829 11826
11830 return Smi::FromInt(source_position); 11827 return Smi::FromInt(source_position);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
11916 11913
11917 // Changes the state of a break point in a script and returns source position 11914 // Changes the state of a break point in a script and returns source position
11918 // where break point was set. NOTE: Regarding performance see the NOTE for 11915 // where break point was set. NOTE: Regarding performance see the NOTE for
11919 // GetScriptFromScriptData. 11916 // GetScriptFromScriptData.
11920 // args[0]: script to set break point in 11917 // args[0]: script to set break point in
11921 // args[1]: number: break source position (within the script source) 11918 // args[1]: number: break source position (within the script source)
11922 // args[2]: number: break point object 11919 // args[2]: number: break point object
11923 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) { 11920 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) {
11924 HandleScope scope(isolate); 11921 HandleScope scope(isolate);
11925 ASSERT(args.length() == 3); 11922 ASSERT(args.length() == 3);
11926 CONVERT_ARG_CHECKED(JSValue, wrapper, 0); 11923 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0);
11927 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); 11924 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
11928 RUNTIME_ASSERT(source_position >= 0); 11925 RUNTIME_ASSERT(source_position >= 0);
11929 Handle<Object> break_point_object_arg = args.at<Object>(2); 11926 Handle<Object> break_point_object_arg = args.at<Object>(2);
11930 11927
11931 // Get the script from the script wrapper. 11928 // Get the script from the script wrapper.
11932 RUNTIME_ASSERT(wrapper->value()->IsScript()); 11929 RUNTIME_ASSERT(wrapper->value()->IsScript());
11933 Handle<Script> script(Script::cast(wrapper->value())); 11930 Handle<Script> script(Script::cast(wrapper->value()));
11934 11931
11935 Object* result = Runtime::FindSharedFunctionInfoInScript( 11932 Object* result = Runtime::FindSharedFunctionInfoInScript(
11936 isolate, script, source_position); 11933 isolate, script, source_position);
(...skipping 29 matching lines...) Expand all
11966 } 11963 }
11967 11964
11968 11965
11969 // Change the state of break on exceptions. 11966 // Change the state of break on exceptions.
11970 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions. 11967 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions.
11971 // args[1]: Boolean indicating on/off. 11968 // args[1]: Boolean indicating on/off.
11972 RUNTIME_FUNCTION(MaybeObject*, Runtime_ChangeBreakOnException) { 11969 RUNTIME_FUNCTION(MaybeObject*, Runtime_ChangeBreakOnException) {
11973 HandleScope scope(isolate); 11970 HandleScope scope(isolate);
11974 ASSERT(args.length() == 2); 11971 ASSERT(args.length() == 2);
11975 RUNTIME_ASSERT(args[0]->IsNumber()); 11972 RUNTIME_ASSERT(args[0]->IsNumber());
11976 CONVERT_BOOLEAN_CHECKED(enable, args[1]); 11973 CONVERT_BOOLEAN_ARG_CHECKED(enable, 1);
11977 11974
11978 // If the number doesn't match an enum value, the ChangeBreakOnException 11975 // If the number doesn't match an enum value, the ChangeBreakOnException
11979 // function will default to affecting caught exceptions. 11976 // function will default to affecting caught exceptions.
11980 ExceptionBreakType type = 11977 ExceptionBreakType type =
11981 static_cast<ExceptionBreakType>(NumberToUint32(args[0])); 11978 static_cast<ExceptionBreakType>(NumberToUint32(args[0]));
11982 // Update break point state. 11979 // Update break point state.
11983 isolate->debug()->ChangeBreakOnException(type, enable); 11980 isolate->debug()->ChangeBreakOnException(type, enable);
11984 return isolate->heap()->undefined_value(); 11981 return isolate->heap()->undefined_value();
11985 } 11982 }
11986 11983
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
12181 // Check the execution state and decode arguments frame and source to be 12178 // Check the execution state and decode arguments frame and source to be
12182 // evaluated. 12179 // evaluated.
12183 ASSERT(args.length() == 6); 12180 ASSERT(args.length() == 6);
12184 Object* check_result; 12181 Object* check_result;
12185 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( 12182 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(
12186 RUNTIME_ARGUMENTS(isolate, args)); 12183 RUNTIME_ARGUMENTS(isolate, args));
12187 if (!maybe_check_result->ToObject(&check_result)) { 12184 if (!maybe_check_result->ToObject(&check_result)) {
12188 return maybe_check_result; 12185 return maybe_check_result;
12189 } 12186 }
12190 } 12187 }
12191 CONVERT_CHECKED(Smi, wrapped_id, args[1]); 12188 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
12192 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); 12189 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
12193 CONVERT_ARG_CHECKED(String, source, 3); 12190 CONVERT_ARG_HANDLE_CHECKED(String, source, 3);
12194 CONVERT_BOOLEAN_CHECKED(disable_break, args[4]); 12191 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4);
12195 Handle<Object> additional_context(args[5]); 12192 Handle<Object> additional_context(args[5]);
12196 12193
12197 // Handle the processing of break. 12194 // Handle the processing of break.
12198 DisableBreak disable_break_save(disable_break); 12195 DisableBreak disable_break_save(disable_break);
12199 12196
12200 // Get the frame where the debugging is performed. 12197 // Get the frame where the debugging is performed.
12201 StackFrame::Id id = UnwrapFrameId(wrapped_id); 12198 StackFrame::Id id = UnwrapFrameId(wrapped_id);
12202 JavaScriptFrameIterator it(isolate, id); 12199 JavaScriptFrameIterator it(isolate, id);
12203 JavaScriptFrame* frame = it.frame(); 12200 JavaScriptFrame* frame = it.frame();
12204 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); 12201 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
12320 // Check the execution state and decode arguments frame and source to be 12317 // Check the execution state and decode arguments frame and source to be
12321 // evaluated. 12318 // evaluated.
12322 ASSERT(args.length() == 4); 12319 ASSERT(args.length() == 4);
12323 Object* check_result; 12320 Object* check_result;
12324 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( 12321 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(
12325 RUNTIME_ARGUMENTS(isolate, args)); 12322 RUNTIME_ARGUMENTS(isolate, args));
12326 if (!maybe_check_result->ToObject(&check_result)) { 12323 if (!maybe_check_result->ToObject(&check_result)) {
12327 return maybe_check_result; 12324 return maybe_check_result;
12328 } 12325 }
12329 } 12326 }
12330 CONVERT_ARG_CHECKED(String, source, 1); 12327 CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
12331 CONVERT_BOOLEAN_CHECKED(disable_break, args[2]); 12328 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2);
12332 Handle<Object> additional_context(args[3]); 12329 Handle<Object> additional_context(args[3]);
12333 12330
12334 // Handle the processing of break. 12331 // Handle the processing of break.
12335 DisableBreak disable_break_save(disable_break); 12332 DisableBreak disable_break_save(disable_break);
12336 12333
12337 // Enter the top context from before the debugger was invoked. 12334 // Enter the top context from before the debugger was invoked.
12338 SaveContext save(isolate); 12335 SaveContext save(isolate);
12339 SaveContext* top = &save; 12336 SaveContext* top = &save;
12340 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { 12337 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) {
12341 top = top->prev(); 12338 top = top->prev();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
12494 12491
12495 // First perform a full GC in order to avoid references from dead objects. 12492 // First perform a full GC in order to avoid references from dead objects.
12496 isolate->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, 12493 isolate->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask,
12497 "%DebugReferencedBy"); 12494 "%DebugReferencedBy");
12498 // The heap iterator reserves the right to do a GC to make the heap iterable. 12495 // The heap iterator reserves the right to do a GC to make the heap iterable.
12499 // Due to the GC above we know it won't need to do that, but it seems cleaner 12496 // Due to the GC above we know it won't need to do that, but it seems cleaner
12500 // to get the heap iterator constructed before we start having unprotected 12497 // to get the heap iterator constructed before we start having unprotected
12501 // Object* locals that are not protected by handles. 12498 // Object* locals that are not protected by handles.
12502 12499
12503 // Check parameters. 12500 // Check parameters.
12504 CONVERT_CHECKED(JSObject, target, args[0]); 12501 CONVERT_ARG_CHECKED(JSObject, target, 0);
12505 Object* instance_filter = args[1]; 12502 Object* instance_filter = args[1];
12506 RUNTIME_ASSERT(instance_filter->IsUndefined() || 12503 RUNTIME_ASSERT(instance_filter->IsUndefined() ||
12507 instance_filter->IsJSObject()); 12504 instance_filter->IsJSObject());
12508 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); 12505 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]);
12509 RUNTIME_ASSERT(max_references >= 0); 12506 RUNTIME_ASSERT(max_references >= 0);
12510 12507
12511 12508
12512 // Get the constructor function for context extension and arguments array. 12509 // Get the constructor function for context extension and arguments array.
12513 JSObject* arguments_boilerplate = 12510 JSObject* arguments_boilerplate =
12514 isolate->context()->global_context()->arguments_boilerplate(); 12511 isolate->context()->global_context()->arguments_boilerplate();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
12582 // args[0]: the constructor to find instances of 12579 // args[0]: the constructor to find instances of
12583 // args[1]: the the maximum number of objects to return 12580 // args[1]: the the maximum number of objects to return
12584 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugConstructedBy) { 12581 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugConstructedBy) {
12585 ASSERT(args.length() == 2); 12582 ASSERT(args.length() == 2);
12586 12583
12587 // First perform a full GC in order to avoid dead objects. 12584 // First perform a full GC in order to avoid dead objects.
12588 isolate->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, 12585 isolate->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask,
12589 "%DebugConstructedBy"); 12586 "%DebugConstructedBy");
12590 12587
12591 // Check parameters. 12588 // Check parameters.
12592 CONVERT_CHECKED(JSFunction, constructor, args[0]); 12589 CONVERT_ARG_CHECKED(JSFunction, constructor, 0);
12593 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); 12590 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]);
12594 RUNTIME_ASSERT(max_references >= 0); 12591 RUNTIME_ASSERT(max_references >= 0);
12595 12592
12596 // Get the number of referencing objects. 12593 // Get the number of referencing objects.
12597 int count; 12594 int count;
12598 HeapIterator heap_iterator; 12595 HeapIterator heap_iterator;
12599 count = DebugConstructedBy(&heap_iterator, 12596 count = DebugConstructedBy(&heap_iterator,
12600 constructor, 12597 constructor,
12601 max_references, 12598 max_references,
12602 NULL, 12599 NULL,
(...skipping 23 matching lines...) Expand all
12626 } 12623 }
12627 return JSArray::cast(result)->SetContent(instances); 12624 return JSArray::cast(result)->SetContent(instances);
12628 } 12625 }
12629 12626
12630 12627
12631 // Find the effective prototype object as returned by __proto__. 12628 // Find the effective prototype object as returned by __proto__.
12632 // args[0]: the object to find the prototype for. 12629 // args[0]: the object to find the prototype for.
12633 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrototype) { 12630 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrototype) {
12634 ASSERT(args.length() == 1); 12631 ASSERT(args.length() == 1);
12635 12632
12636 CONVERT_CHECKED(JSObject, obj, args[0]); 12633 CONVERT_ARG_CHECKED(JSObject, obj, 0);
12637 12634
12638 // Use the __proto__ accessor. 12635 // Use the __proto__ accessor.
12639 return Accessors::ObjectPrototype.getter(obj, NULL); 12636 return Accessors::ObjectPrototype.getter(obj, NULL);
12640 } 12637 }
12641 12638
12642 12639
12643 RUNTIME_FUNCTION(MaybeObject*, Runtime_SystemBreak) { 12640 RUNTIME_FUNCTION(MaybeObject*, Runtime_SystemBreak) {
12644 ASSERT(args.length() == 0); 12641 ASSERT(args.length() == 0);
12645 CPU::DebugBreak(); 12642 CPU::DebugBreak();
12646 return isolate->heap()->undefined_value(); 12643 return isolate->heap()->undefined_value();
12647 } 12644 }
12648 12645
12649 12646
12650 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleFunction) { 12647 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleFunction) {
12651 #ifdef DEBUG 12648 #ifdef DEBUG
12652 HandleScope scope(isolate); 12649 HandleScope scope(isolate);
12653 ASSERT(args.length() == 1); 12650 ASSERT(args.length() == 1);
12654 // Get the function and make sure it is compiled. 12651 // Get the function and make sure it is compiled.
12655 CONVERT_ARG_CHECKED(JSFunction, func, 0); 12652 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
12656 Handle<SharedFunctionInfo> shared(func->shared()); 12653 Handle<SharedFunctionInfo> shared(func->shared());
12657 if (!SharedFunctionInfo::EnsureCompiled(shared, KEEP_EXCEPTION)) { 12654 if (!SharedFunctionInfo::EnsureCompiled(shared, KEEP_EXCEPTION)) {
12658 return Failure::Exception(); 12655 return Failure::Exception();
12659 } 12656 }
12660 func->code()->PrintLn(); 12657 func->code()->PrintLn();
12661 #endif // DEBUG 12658 #endif // DEBUG
12662 return isolate->heap()->undefined_value(); 12659 return isolate->heap()->undefined_value();
12663 } 12660 }
12664 12661
12665 12662
12666 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleConstructor) { 12663 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleConstructor) {
12667 #ifdef DEBUG 12664 #ifdef DEBUG
12668 HandleScope scope(isolate); 12665 HandleScope scope(isolate);
12669 ASSERT(args.length() == 1); 12666 ASSERT(args.length() == 1);
12670 // Get the function and make sure it is compiled. 12667 // Get the function and make sure it is compiled.
12671 CONVERT_ARG_CHECKED(JSFunction, func, 0); 12668 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
12672 Handle<SharedFunctionInfo> shared(func->shared()); 12669 Handle<SharedFunctionInfo> shared(func->shared());
12673 if (!SharedFunctionInfo::EnsureCompiled(shared, KEEP_EXCEPTION)) { 12670 if (!SharedFunctionInfo::EnsureCompiled(shared, KEEP_EXCEPTION)) {
12674 return Failure::Exception(); 12671 return Failure::Exception();
12675 } 12672 }
12676 shared->construct_stub()->PrintLn(); 12673 shared->construct_stub()->PrintLn();
12677 #endif // DEBUG 12674 #endif // DEBUG
12678 return isolate->heap()->undefined_value(); 12675 return isolate->heap()->undefined_value();
12679 } 12676 }
12680 12677
12681 12678
12682 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) { 12679 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) {
12683 NoHandleAllocation ha; 12680 NoHandleAllocation ha;
12684 ASSERT(args.length() == 1); 12681 ASSERT(args.length() == 1);
12685 12682
12686 CONVERT_CHECKED(JSFunction, f, args[0]); 12683 CONVERT_ARG_CHECKED(JSFunction, f, 0);
12687 return f->shared()->inferred_name(); 12684 return f->shared()->inferred_name();
12688 } 12685 }
12689 12686
12690 12687
12691 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, 12688 static int FindSharedFunctionInfosForScript(HeapIterator* iterator,
12692 Script* script, 12689 Script* script,
12693 FixedArray* buffer) { 12690 FixedArray* buffer) {
12694 AssertNoAllocation no_allocations; 12691 AssertNoAllocation no_allocations;
12695 int counter = 0; 12692 int counter = 0;
12696 int buffer_size = buffer->length(); 12693 int buffer_size = buffer->length();
(...skipping 16 matching lines...) Expand all
12713 return counter; 12710 return counter;
12714 } 12711 }
12715 12712
12716 // For a script finds all SharedFunctionInfo's in the heap that points 12713 // For a script finds all SharedFunctionInfo's in the heap that points
12717 // to this script. Returns JSArray of SharedFunctionInfo wrapped 12714 // to this script. Returns JSArray of SharedFunctionInfo wrapped
12718 // in OpaqueReferences. 12715 // in OpaqueReferences.
12719 RUNTIME_FUNCTION(MaybeObject*, 12716 RUNTIME_FUNCTION(MaybeObject*,
12720 Runtime_LiveEditFindSharedFunctionInfosForScript) { 12717 Runtime_LiveEditFindSharedFunctionInfosForScript) {
12721 ASSERT(args.length() == 1); 12718 ASSERT(args.length() == 1);
12722 HandleScope scope(isolate); 12719 HandleScope scope(isolate);
12723 CONVERT_CHECKED(JSValue, script_value, args[0]); 12720 CONVERT_ARG_CHECKED(JSValue, script_value, 0);
12724 12721
12725 12722
12726 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); 12723 Handle<Script> script = Handle<Script>(Script::cast(script_value->value()));
12727 12724
12728 const int kBufferSize = 32; 12725 const int kBufferSize = 32;
12729 12726
12730 Handle<FixedArray> array; 12727 Handle<FixedArray> array;
12731 array = isolate->factory()->NewFixedArray(kBufferSize); 12728 array = isolate->factory()->NewFixedArray(kBufferSize);
12732 int number; 12729 int number;
12733 { 12730 {
(...skipping 25 matching lines...) Expand all
12759 // For a script calculates compilation information about all its functions. 12756 // For a script calculates compilation information about all its functions.
12760 // The script source is explicitly specified by the second argument. 12757 // The script source is explicitly specified by the second argument.
12761 // The source of the actual script is not used, however it is important that 12758 // The source of the actual script is not used, however it is important that
12762 // all generated code keeps references to this particular instance of script. 12759 // all generated code keeps references to this particular instance of script.
12763 // Returns a JSArray of compilation infos. The array is ordered so that 12760 // Returns a JSArray of compilation infos. The array is ordered so that
12764 // each function with all its descendant is always stored in a continues range 12761 // each function with all its descendant is always stored in a continues range
12765 // with the function itself going first. The root function is a script function. 12762 // with the function itself going first. The root function is a script function.
12766 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditGatherCompileInfo) { 12763 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditGatherCompileInfo) {
12767 ASSERT(args.length() == 2); 12764 ASSERT(args.length() == 2);
12768 HandleScope scope(isolate); 12765 HandleScope scope(isolate);
12769 CONVERT_CHECKED(JSValue, script, args[0]); 12766 CONVERT_ARG_CHECKED(JSValue, script, 0);
12770 CONVERT_ARG_CHECKED(String, source, 1); 12767 CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
12771 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); 12768 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
12772 12769
12773 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source); 12770 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source);
12774 12771
12775 if (isolate->has_pending_exception()) { 12772 if (isolate->has_pending_exception()) {
12776 return Failure::Exception(); 12773 return Failure::Exception();
12777 } 12774 }
12778 12775
12779 return result; 12776 return result;
12780 } 12777 }
12781 12778
12782 // Changes the source of the script to a new_source. 12779 // Changes the source of the script to a new_source.
12783 // If old_script_name is provided (i.e. is a String), also creates a copy of 12780 // If old_script_name is provided (i.e. is a String), also creates a copy of
12784 // the script with its original source and sends notification to debugger. 12781 // the script with its original source and sends notification to debugger.
12785 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) { 12782 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) {
12786 ASSERT(args.length() == 3); 12783 ASSERT(args.length() == 3);
12787 HandleScope scope(isolate); 12784 HandleScope scope(isolate);
12788 CONVERT_CHECKED(JSValue, original_script_value, args[0]); 12785 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0);
12789 CONVERT_ARG_CHECKED(String, new_source, 1); 12786 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1);
12790 Handle<Object> old_script_name(args[2], isolate); 12787 Handle<Object> old_script_name(args[2], isolate);
12791 12788
12792 CONVERT_CHECKED(Script, original_script_pointer, 12789 RUNTIME_ASSERT(original_script_value->value()->IsScript());
12793 original_script_value->value()); 12790 Handle<Script> original_script(Script::cast(original_script_value->value()));
12794 Handle<Script> original_script(original_script_pointer);
12795 12791
12796 Object* old_script = LiveEdit::ChangeScriptSource(original_script, 12792 Object* old_script = LiveEdit::ChangeScriptSource(original_script,
12797 new_source, 12793 new_source,
12798 old_script_name); 12794 old_script_name);
12799 12795
12800 if (old_script->IsScript()) { 12796 if (old_script->IsScript()) {
12801 Handle<Script> script_handle(Script::cast(old_script)); 12797 Handle<Script> script_handle(Script::cast(old_script));
12802 return *(GetScriptWrapper(script_handle)); 12798 return *(GetScriptWrapper(script_handle));
12803 } else { 12799 } else {
12804 return isolate->heap()->null_value(); 12800 return isolate->heap()->null_value();
12805 } 12801 }
12806 } 12802 }
12807 12803
12808 12804
12809 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSourceUpdated) { 12805 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSourceUpdated) {
12810 ASSERT(args.length() == 1); 12806 ASSERT(args.length() == 1);
12811 HandleScope scope(isolate); 12807 HandleScope scope(isolate);
12812 CONVERT_ARG_CHECKED(JSArray, shared_info, 0); 12808 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0);
12813 return LiveEdit::FunctionSourceUpdated(shared_info); 12809 return LiveEdit::FunctionSourceUpdated(shared_info);
12814 } 12810 }
12815 12811
12816 12812
12817 // Replaces code of SharedFunctionInfo with a new one. 12813 // Replaces code of SharedFunctionInfo with a new one.
12818 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceFunctionCode) { 12814 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceFunctionCode) {
12819 ASSERT(args.length() == 2); 12815 ASSERT(args.length() == 2);
12820 HandleScope scope(isolate); 12816 HandleScope scope(isolate);
12821 CONVERT_ARG_CHECKED(JSArray, new_compile_info, 0); 12817 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0);
12822 CONVERT_ARG_CHECKED(JSArray, shared_info, 1); 12818 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1);
12823 12819
12824 return LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); 12820 return LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info);
12825 } 12821 }
12826 12822
12827 // Connects SharedFunctionInfo to another script. 12823 // Connects SharedFunctionInfo to another script.
12828 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) { 12824 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) {
12829 ASSERT(args.length() == 2); 12825 ASSERT(args.length() == 2);
12830 HandleScope scope(isolate); 12826 HandleScope scope(isolate);
12831 Handle<Object> function_object(args[0], isolate); 12827 Handle<Object> function_object(args[0], isolate);
12832 Handle<Object> script_object(args[1], isolate); 12828 Handle<Object> script_object(args[1], isolate);
12833 12829
12834 if (function_object->IsJSValue()) { 12830 if (function_object->IsJSValue()) {
12835 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); 12831 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object);
12836 if (script_object->IsJSValue()) { 12832 if (script_object->IsJSValue()) {
12837 CONVERT_CHECKED(Script, script, JSValue::cast(*script_object)->value()); 12833 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript());
12834 Script* script = Script::cast(JSValue::cast(*script_object)->value());
12838 script_object = Handle<Object>(script, isolate); 12835 script_object = Handle<Object>(script, isolate);
12839 } 12836 }
12840 12837
12841 LiveEdit::SetFunctionScript(function_wrapper, script_object); 12838 LiveEdit::SetFunctionScript(function_wrapper, script_object);
12842 } else { 12839 } else {
12843 // Just ignore this. We may not have a SharedFunctionInfo for some functions 12840 // Just ignore this. We may not have a SharedFunctionInfo for some functions
12844 // and we check it in this function. 12841 // and we check it in this function.
12845 } 12842 }
12846 12843
12847 return isolate->heap()->undefined_value(); 12844 return isolate->heap()->undefined_value();
12848 } 12845 }
12849 12846
12850 12847
12851 // In a code of a parent function replaces original function as embedded object 12848 // In a code of a parent function replaces original function as embedded object
12852 // with a substitution one. 12849 // with a substitution one.
12853 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceRefToNestedFunction) { 12850 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceRefToNestedFunction) {
12854 ASSERT(args.length() == 3); 12851 ASSERT(args.length() == 3);
12855 HandleScope scope(isolate); 12852 HandleScope scope(isolate);
12856 12853
12857 CONVERT_ARG_CHECKED(JSValue, parent_wrapper, 0); 12854 CONVERT_ARG_HANDLE_CHECKED(JSValue, parent_wrapper, 0);
12858 CONVERT_ARG_CHECKED(JSValue, orig_wrapper, 1); 12855 CONVERT_ARG_HANDLE_CHECKED(JSValue, orig_wrapper, 1);
12859 CONVERT_ARG_CHECKED(JSValue, subst_wrapper, 2); 12856 CONVERT_ARG_HANDLE_CHECKED(JSValue, subst_wrapper, 2);
12860 12857
12861 LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper, 12858 LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper,
12862 subst_wrapper); 12859 subst_wrapper);
12863 12860
12864 return isolate->heap()->undefined_value(); 12861 return isolate->heap()->undefined_value();
12865 } 12862 }
12866 12863
12867 12864
12868 // Updates positions of a shared function info (first parameter) according 12865 // Updates positions of a shared function info (first parameter) according
12869 // to script source change. Text change is described in second parameter as 12866 // to script source change. Text change is described in second parameter as
12870 // array of groups of 3 numbers: 12867 // array of groups of 3 numbers:
12871 // (change_begin, change_end, change_end_new_position). 12868 // (change_begin, change_end, change_end_new_position).
12872 // Each group describes a change in text; groups are sorted by change_begin. 12869 // Each group describes a change in text; groups are sorted by change_begin.
12873 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditPatchFunctionPositions) { 12870 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditPatchFunctionPositions) {
12874 ASSERT(args.length() == 2); 12871 ASSERT(args.length() == 2);
12875 HandleScope scope(isolate); 12872 HandleScope scope(isolate);
12876 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); 12873 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0);
12877 CONVERT_ARG_CHECKED(JSArray, position_change_array, 1); 12874 CONVERT_ARG_HANDLE_CHECKED(JSArray, position_change_array, 1);
12878 12875
12879 return LiveEdit::PatchFunctionPositions(shared_array, position_change_array); 12876 return LiveEdit::PatchFunctionPositions(shared_array, position_change_array);
12880 } 12877 }
12881 12878
12882 12879
12883 // For array of SharedFunctionInfo's (each wrapped in JSValue) 12880 // For array of SharedFunctionInfo's (each wrapped in JSValue)
12884 // checks that none of them have activations on stacks (of any thread). 12881 // checks that none of them have activations on stacks (of any thread).
12885 // Returns array of the same length with corresponding results of 12882 // Returns array of the same length with corresponding results of
12886 // LiveEdit::FunctionPatchabilityStatus type. 12883 // LiveEdit::FunctionPatchabilityStatus type.
12887 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) { 12884 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) {
12888 ASSERT(args.length() == 2); 12885 ASSERT(args.length() == 2);
12889 HandleScope scope(isolate); 12886 HandleScope scope(isolate);
12890 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); 12887 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0);
12891 CONVERT_BOOLEAN_CHECKED(do_drop, args[1]); 12888 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1);
12892 12889
12893 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); 12890 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop);
12894 } 12891 }
12895 12892
12896 // Compares 2 strings line-by-line, then token-wise and returns diff in form 12893 // Compares 2 strings line-by-line, then token-wise and returns diff in form
12897 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list 12894 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list
12898 // of diff chunks. 12895 // of diff chunks.
12899 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { 12896 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) {
12900 ASSERT(args.length() == 2); 12897 ASSERT(args.length() == 2);
12901 HandleScope scope(isolate); 12898 HandleScope scope(isolate);
12902 CONVERT_ARG_CHECKED(String, s1, 0); 12899 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0);
12903 CONVERT_ARG_CHECKED(String, s2, 1); 12900 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1);
12904 12901
12905 return *LiveEdit::CompareStrings(s1, s2); 12902 return *LiveEdit::CompareStrings(s1, s2);
12906 } 12903 }
12907 12904
12908 12905
12909 // A testing entry. Returns statement position which is the closest to 12906 // A testing entry. Returns statement position which is the closest to
12910 // source_position. 12907 // source_position.
12911 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) { 12908 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) {
12912 ASSERT(args.length() == 2); 12909 ASSERT(args.length() == 2);
12913 HandleScope scope(isolate); 12910 HandleScope scope(isolate);
12914 CONVERT_ARG_CHECKED(JSFunction, function, 0); 12911 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
12915 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); 12912 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
12916 12913
12917 Handle<Code> code(function->code(), isolate); 12914 Handle<Code> code(function->code(), isolate);
12918 12915
12919 if (code->kind() != Code::FUNCTION && 12916 if (code->kind() != Code::FUNCTION &&
12920 code->kind() != Code::OPTIMIZED_FUNCTION) { 12917 code->kind() != Code::OPTIMIZED_FUNCTION) {
12921 return isolate->heap()->undefined_value(); 12918 return isolate->heap()->undefined_value();
12922 } 12919 }
12923 12920
12924 RelocIterator it(*code, RelocInfo::ModeMask(RelocInfo::STATEMENT_POSITION)); 12921 RelocIterator it(*code, RelocInfo::ModeMask(RelocInfo::STATEMENT_POSITION));
(...skipping 16 matching lines...) Expand all
12941 return Smi::FromInt(closest_pc); 12938 return Smi::FromInt(closest_pc);
12942 } 12939 }
12943 12940
12944 12941
12945 // Calls specified function with or without entering the debugger. 12942 // Calls specified function with or without entering the debugger.
12946 // This is used in unit tests to run code as if debugger is entered or simply 12943 // This is used in unit tests to run code as if debugger is entered or simply
12947 // to have a stack with C++ frame in the middle. 12944 // to have a stack with C++ frame in the middle.
12948 RUNTIME_FUNCTION(MaybeObject*, Runtime_ExecuteInDebugContext) { 12945 RUNTIME_FUNCTION(MaybeObject*, Runtime_ExecuteInDebugContext) {
12949 ASSERT(args.length() == 2); 12946 ASSERT(args.length() == 2);
12950 HandleScope scope(isolate); 12947 HandleScope scope(isolate);
12951 CONVERT_ARG_CHECKED(JSFunction, function, 0); 12948 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
12952 CONVERT_BOOLEAN_CHECKED(without_debugger, args[1]); 12949 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1);
12953 12950
12954 Handle<Object> result; 12951 Handle<Object> result;
12955 bool pending_exception; 12952 bool pending_exception;
12956 { 12953 {
12957 if (without_debugger) { 12954 if (without_debugger) {
12958 result = Execution::Call(function, isolate->global(), 0, NULL, 12955 result = Execution::Call(function, isolate->global(), 0, NULL,
12959 &pending_exception); 12956 &pending_exception);
12960 } else { 12957 } else {
12961 EnterDebugger enter_debugger; 12958 EnterDebugger enter_debugger;
12962 result = Execution::Call(function, isolate->global(), 0, NULL, 12959 result = Execution::Call(function, isolate->global(), 0, NULL,
12963 &pending_exception); 12960 &pending_exception);
12964 } 12961 }
12965 } 12962 }
12966 if (!pending_exception) { 12963 if (!pending_exception) {
12967 return *result; 12964 return *result;
12968 } else { 12965 } else {
12969 return Failure::Exception(); 12966 return Failure::Exception();
12970 } 12967 }
12971 } 12968 }
12972 12969
12973 12970
12974 // Sets a v8 flag. 12971 // Sets a v8 flag.
12975 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { 12972 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) {
12976 CONVERT_CHECKED(String, arg, args[0]); 12973 CONVERT_ARG_CHECKED(String, arg, 0);
12977 SmartArrayPointer<char> flags = 12974 SmartArrayPointer<char> flags =
12978 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 12975 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
12979 FlagList::SetFlagsFromString(*flags, StrLength(*flags)); 12976 FlagList::SetFlagsFromString(*flags, StrLength(*flags));
12980 return isolate->heap()->undefined_value(); 12977 return isolate->heap()->undefined_value();
12981 } 12978 }
12982 12979
12983 12980
12984 // Performs a GC. 12981 // Performs a GC.
12985 // Presently, it only does a full GC. 12982 // Presently, it only does a full GC.
12986 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) { 12983 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
13036 // specified by id1 and id2. 13033 // specified by id1 and id2.
13037 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be 13034 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be
13038 // dumped. 13035 // dumped.
13039 RUNTIME_FUNCTION(MaybeObject*, Runtime_DumpLOL) { 13036 RUNTIME_FUNCTION(MaybeObject*, Runtime_DumpLOL) {
13040 #ifdef LIVE_OBJECT_LIST 13037 #ifdef LIVE_OBJECT_LIST
13041 HandleScope scope; 13038 HandleScope scope;
13042 CONVERT_SMI_ARG_CHECKED(id1, 0); 13039 CONVERT_SMI_ARG_CHECKED(id1, 0);
13043 CONVERT_SMI_ARG_CHECKED(id2, 1); 13040 CONVERT_SMI_ARG_CHECKED(id2, 1);
13044 CONVERT_SMI_ARG_CHECKED(start, 2); 13041 CONVERT_SMI_ARG_CHECKED(start, 2);
13045 CONVERT_SMI_ARG_CHECKED(count, 3); 13042 CONVERT_SMI_ARG_CHECKED(count, 3);
13046 CONVERT_ARG_CHECKED(JSObject, filter_obj, 4); 13043 CONVERT_ARG_HANDLE_CHECKED(JSObject, filter_obj, 4);
13047 EnterDebugger enter_debugger; 13044 EnterDebugger enter_debugger;
13048 return LiveObjectList::Dump(id1, id2, start, count, filter_obj); 13045 return LiveObjectList::Dump(id1, id2, start, count, filter_obj);
13049 #else 13046 #else
13050 return isolate->heap()->undefined_value(); 13047 return isolate->heap()->undefined_value();
13051 #endif 13048 #endif
13052 } 13049 }
13053 13050
13054 13051
13055 // Gets the specified object as requested by the debugger. 13052 // Gets the specified object as requested by the debugger.
13056 // This is only used for obj ids shown in live object lists. 13053 // This is only used for obj ids shown in live object lists.
13057 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObj) { 13054 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObj) {
13058 #ifdef LIVE_OBJECT_LIST 13055 #ifdef LIVE_OBJECT_LIST
13059 CONVERT_SMI_ARG_CHECKED(obj_id, 0); 13056 CONVERT_SMI_ARG_CHECKED(obj_id, 0);
13060 Object* result = LiveObjectList::GetObj(obj_id); 13057 Object* result = LiveObjectList::GetObj(obj_id);
13061 return result; 13058 return result;
13062 #else 13059 #else
13063 return isolate->heap()->undefined_value(); 13060 return isolate->heap()->undefined_value();
13064 #endif 13061 #endif
13065 } 13062 }
13066 13063
13067 13064
13068 // Gets the obj id for the specified address if valid. 13065 // Gets the obj id for the specified address if valid.
13069 // This is only used for obj ids shown in live object lists. 13066 // This is only used for obj ids shown in live object lists.
13070 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObjId) { 13067 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObjId) {
13071 #ifdef LIVE_OBJECT_LIST 13068 #ifdef LIVE_OBJECT_LIST
13072 HandleScope scope; 13069 HandleScope scope;
13073 CONVERT_ARG_CHECKED(String, address, 0); 13070 CONVERT_ARG_HANDLE_CHECKED(String, address, 0);
13074 Object* result = LiveObjectList::GetObjId(address); 13071 Object* result = LiveObjectList::GetObjId(address);
13075 return result; 13072 return result;
13076 #else 13073 #else
13077 return isolate->heap()->undefined_value(); 13074 return isolate->heap()->undefined_value();
13078 #endif 13075 #endif
13079 } 13076 }
13080 13077
13081 13078
13082 // Gets the retainers that references the specified object alive. 13079 // Gets the retainers that references the specified object alive.
13083 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObjRetainers) { 13080 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObjRetainers) {
13084 #ifdef LIVE_OBJECT_LIST 13081 #ifdef LIVE_OBJECT_LIST
13085 HandleScope scope; 13082 HandleScope scope;
13086 CONVERT_SMI_ARG_CHECKED(obj_id, 0); 13083 CONVERT_SMI_ARG_CHECKED(obj_id, 0);
13087 RUNTIME_ASSERT(args[1]->IsUndefined() || args[1]->IsJSObject()); 13084 RUNTIME_ASSERT(args[1]->IsUndefined() || args[1]->IsJSObject());
13088 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsBoolean()); 13085 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsBoolean());
13089 RUNTIME_ASSERT(args[3]->IsUndefined() || args[3]->IsSmi()); 13086 RUNTIME_ASSERT(args[3]->IsUndefined() || args[3]->IsSmi());
13090 RUNTIME_ASSERT(args[4]->IsUndefined() || args[4]->IsSmi()); 13087 RUNTIME_ASSERT(args[4]->IsUndefined() || args[4]->IsSmi());
13091 CONVERT_ARG_CHECKED(JSObject, filter_obj, 5); 13088 CONVERT_ARG_HANDLE_CHECKED(JSObject, filter_obj, 5);
13092 13089
13093 Handle<JSObject> instance_filter; 13090 Handle<JSObject> instance_filter;
13094 if (args[1]->IsJSObject()) { 13091 if (args[1]->IsJSObject()) {
13095 instance_filter = args.at<JSObject>(1); 13092 instance_filter = args.at<JSObject>(1);
13096 } 13093 }
13097 bool verbose = false; 13094 bool verbose = false;
13098 if (args[2]->IsBoolean()) { 13095 if (args[2]->IsBoolean()) {
13099 verbose = args[2]->IsTrue(); 13096 verbose = args[2]->IsTrue();
13100 } 13097 }
13101 int start = 0; 13098 int start = 0;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
13182 // Generates the response to a debugger request for a summary of the types 13179 // Generates the response to a debugger request for a summary of the types
13183 // of objects in the difference between the captured live object lists 13180 // of objects in the difference between the captured live object lists
13184 // specified by id1 and id2. 13181 // specified by id1 and id2.
13185 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be 13182 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be
13186 // summarized. 13183 // summarized.
13187 RUNTIME_FUNCTION(MaybeObject*, Runtime_SummarizeLOL) { 13184 RUNTIME_FUNCTION(MaybeObject*, Runtime_SummarizeLOL) {
13188 #ifdef LIVE_OBJECT_LIST 13185 #ifdef LIVE_OBJECT_LIST
13189 HandleScope scope; 13186 HandleScope scope;
13190 CONVERT_SMI_ARG_CHECKED(id1, 0); 13187 CONVERT_SMI_ARG_CHECKED(id1, 0);
13191 CONVERT_SMI_ARG_CHECKED(id2, 1); 13188 CONVERT_SMI_ARG_CHECKED(id2, 1);
13192 CONVERT_ARG_CHECKED(JSObject, filter_obj, 2); 13189 CONVERT_ARG_HANDLE_CHECKED(JSObject, filter_obj, 2);
13193 13190
13194 EnterDebugger enter_debugger; 13191 EnterDebugger enter_debugger;
13195 return LiveObjectList::Summarize(id1, id2, filter_obj); 13192 return LiveObjectList::Summarize(id1, id2, filter_obj);
13196 #else 13193 #else
13197 return isolate->heap()->undefined_value(); 13194 return isolate->heap()->undefined_value();
13198 #endif 13195 #endif
13199 } 13196 }
13200 13197
13201 #endif // ENABLE_DEBUGGER_SUPPORT 13198 #endif // ENABLE_DEBUGGER_SUPPORT
13202 13199
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
13250 13247
13251 13248
13252 // Get the script object from script data. NOTE: Regarding performance 13249 // Get the script object from script data. NOTE: Regarding performance
13253 // see the NOTE for GetScriptFromScriptData. 13250 // see the NOTE for GetScriptFromScriptData.
13254 // args[0]: script data for the script to find the source for 13251 // args[0]: script data for the script to find the source for
13255 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScript) { 13252 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScript) {
13256 HandleScope scope(isolate); 13253 HandleScope scope(isolate);
13257 13254
13258 ASSERT(args.length() == 1); 13255 ASSERT(args.length() == 1);
13259 13256
13260 CONVERT_CHECKED(String, script_name, args[0]); 13257 CONVERT_ARG_CHECKED(String, script_name, 0);
13261 13258
13262 // Find the requested script. 13259 // Find the requested script.
13263 Handle<Object> result = 13260 Handle<Object> result =
13264 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); 13261 Runtime_GetScriptFromScriptName(Handle<String>(script_name));
13265 return *result; 13262 return *result;
13266 } 13263 }
13267 13264
13268 13265
13269 // Determines whether the given stack frame should be displayed in 13266 // Determines whether the given stack frame should be displayed in
13270 // a stack trace. The caller is the error constructor that asked 13267 // a stack trace. The caller is the error constructor that asked
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
13305 } 13302 }
13306 return true; 13303 return true;
13307 } 13304 }
13308 13305
13309 13306
13310 // Collect the raw data for a stack trace. Returns an array of 4 13307 // Collect the raw data for a stack trace. Returns an array of 4
13311 // element segments each containing a receiver, function, code and 13308 // element segments each containing a receiver, function, code and
13312 // native code offset. 13309 // native code offset.
13313 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { 13310 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) {
13314 ASSERT_EQ(args.length(), 3); 13311 ASSERT_EQ(args.length(), 3);
13315 CONVERT_ARG_CHECKED(JSObject, error_object, 0); 13312 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0);
13316 Handle<Object> caller = args.at<Object>(1); 13313 Handle<Object> caller = args.at<Object>(1);
13317 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]); 13314 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]);
13318 13315
13319 HandleScope scope(isolate); 13316 HandleScope scope(isolate);
13320 Factory* factory = isolate->factory(); 13317 Factory* factory = isolate->factory();
13321 13318
13322 limit = Max(limit, 0); // Ensure that limit is not negative. 13319 limit = Max(limit, 0); // Ensure that limit is not negative.
13323 int initial_size = Min(limit, 10); 13320 int initial_size = Min(limit, 10);
13324 Handle<FixedArray> elements = 13321 Handle<FixedArray> elements =
13325 factory->NewFixedArrayWithHoles(initial_size * 4); 13322 factory->NewFixedArrayWithHoles(initial_size * 4);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
13390 reinterpret_cast<char*>(args[0]) + args.smi_at(1)); 13387 reinterpret_cast<char*>(args[0]) + args.smi_at(1));
13391 isolate->PrintStack(); 13388 isolate->PrintStack();
13392 OS::Abort(); 13389 OS::Abort();
13393 UNREACHABLE(); 13390 UNREACHABLE();
13394 return NULL; 13391 return NULL;
13395 } 13392 }
13396 13393
13397 13394
13398 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) { 13395 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) {
13399 // This is only called from codegen, so checks might be more lax. 13396 // This is only called from codegen, so checks might be more lax.
13400 CONVERT_CHECKED(JSFunctionResultCache, cache, args[0]); 13397 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0);
13401 Object* key = args[1]; 13398 Object* key = args[1];
13402 13399
13403 int finger_index = cache->finger_index(); 13400 int finger_index = cache->finger_index();
13404 Object* o = cache->get(finger_index); 13401 Object* o = cache->get(finger_index);
13405 if (o == key) { 13402 if (o == key) {
13406 // The fastest case: hit the same place again. 13403 // The fastest case: hit the same place again.
13407 return cache->get(finger_index + 1); 13404 return cache->get(finger_index + 1);
13408 } 13405 }
13409 13406
13410 for (int i = finger_index - 2; 13407 for (int i = finger_index - 2;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
13486 cache_handle->JSFunctionResultCacheVerify(); 13483 cache_handle->JSFunctionResultCacheVerify();
13487 } 13484 }
13488 #endif 13485 #endif
13489 13486
13490 return *value; 13487 return *value;
13491 } 13488 }
13492 13489
13493 13490
13494 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewMessageObject) { 13491 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewMessageObject) {
13495 HandleScope scope(isolate); 13492 HandleScope scope(isolate);
13496 CONVERT_ARG_CHECKED(String, type, 0); 13493 CONVERT_ARG_HANDLE_CHECKED(String, type, 0);
13497 CONVERT_ARG_CHECKED(JSArray, arguments, 1); 13494 CONVERT_ARG_HANDLE_CHECKED(JSArray, arguments, 1);
13498 return *isolate->factory()->NewJSMessageObject( 13495 return *isolate->factory()->NewJSMessageObject(
13499 type, 13496 type,
13500 arguments, 13497 arguments,
13501 0, 13498 0,
13502 0, 13499 0,
13503 isolate->factory()->undefined_value(), 13500 isolate->factory()->undefined_value(),
13504 isolate->factory()->undefined_value(), 13501 isolate->factory()->undefined_value(),
13505 isolate->factory()->undefined_value()); 13502 isolate->factory()->undefined_value());
13506 } 13503 }
13507 13504
13508 13505
13509 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetType) { 13506 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetType) {
13510 CONVERT_CHECKED(JSMessageObject, message, args[0]); 13507 CONVERT_ARG_CHECKED(JSMessageObject, message, 0);
13511 return message->type(); 13508 return message->type();
13512 } 13509 }
13513 13510
13514 13511
13515 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetArguments) { 13512 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetArguments) {
13516 CONVERT_CHECKED(JSMessageObject, message, args[0]); 13513 CONVERT_ARG_CHECKED(JSMessageObject, message, 0);
13517 return message->arguments(); 13514 return message->arguments();
13518 } 13515 }
13519 13516
13520 13517
13521 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetStartPosition) { 13518 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetStartPosition) {
13522 CONVERT_CHECKED(JSMessageObject, message, args[0]); 13519 CONVERT_ARG_CHECKED(JSMessageObject, message, 0);
13523 return Smi::FromInt(message->start_position()); 13520 return Smi::FromInt(message->start_position());
13524 } 13521 }
13525 13522
13526 13523
13527 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetScript) { 13524 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetScript) {
13528 CONVERT_CHECKED(JSMessageObject, message, args[0]); 13525 CONVERT_ARG_CHECKED(JSMessageObject, message, 0);
13529 return message->script(); 13526 return message->script();
13530 } 13527 }
13531 13528
13532 13529
13533 #ifdef DEBUG 13530 #ifdef DEBUG
13534 // ListNatives is ONLY used by the fuzz-natives.js in debug mode 13531 // ListNatives is ONLY used by the fuzz-natives.js in debug mode
13535 // Exclude the code in release mode. 13532 // Exclude the code in release mode.
13536 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) { 13533 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) {
13537 ASSERT(args.length() == 0); 13534 ASSERT(args.length() == 0);
13538 HandleScope scope; 13535 HandleScope scope;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
13572 #undef ADD_ENTRY 13569 #undef ADD_ENTRY
13573 ASSERT_EQ(index, entry_count); 13570 ASSERT_EQ(index, entry_count);
13574 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); 13571 Handle<JSArray> result = factory->NewJSArrayWithElements(elements);
13575 return *result; 13572 return *result;
13576 } 13573 }
13577 #endif 13574 #endif
13578 13575
13579 13576
13580 RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) { 13577 RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) {
13581 ASSERT(args.length() == 2); 13578 ASSERT(args.length() == 2);
13582 CONVERT_CHECKED(String, format, args[0]); 13579 CONVERT_ARG_CHECKED(String, format, 0);
13583 CONVERT_CHECKED(JSArray, elms, args[1]); 13580 CONVERT_ARG_CHECKED(JSArray, elms, 1);
13584 String::FlatContent format_content = format->GetFlatContent(); 13581 String::FlatContent format_content = format->GetFlatContent();
13585 RUNTIME_ASSERT(format_content.IsAscii()); 13582 RUNTIME_ASSERT(format_content.IsAscii());
13586 Vector<const char> chars = format_content.ToAsciiVector(); 13583 Vector<const char> chars = format_content.ToAsciiVector();
13587 LOGGER->LogRuntime(chars, elms); 13584 LOGGER->LogRuntime(chars, elms);
13588 return isolate->heap()->undefined_value(); 13585 return isolate->heap()->undefined_value();
13589 } 13586 }
13590 13587
13591 13588
13592 RUNTIME_FUNCTION(MaybeObject*, Runtime_IS_VAR) { 13589 RUNTIME_FUNCTION(MaybeObject*, Runtime_IS_VAR) {
13593 UNREACHABLE(); // implemented as macro in the parser 13590 UNREACHABLE(); // implemented as macro in the parser
13594 return NULL; 13591 return NULL;
13595 } 13592 }
13596 13593
13597 13594
13598 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ 13595 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \
13599 RUNTIME_FUNCTION(MaybeObject*, Runtime_Has##Name) { \ 13596 RUNTIME_FUNCTION(MaybeObject*, Runtime_Has##Name) { \
13600 CONVERT_CHECKED(JSObject, obj, args[0]); \ 13597 CONVERT_ARG_CHECKED(JSObject, obj, 0); \
13601 return isolate->heap()->ToBoolean(obj->Has##Name()); \ 13598 return isolate->heap()->ToBoolean(obj->Has##Name()); \
13602 } 13599 }
13603 13600
13604 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOnlyElements) 13601 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOnlyElements)
13605 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastElements) 13602 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastElements)
13606 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements) 13603 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements)
13607 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements) 13604 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements)
13608 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalPixelElements) 13605 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalPixelElements)
13609 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements) 13606 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements)
13610 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalByteElements) 13607 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalByteElements)
13611 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedByteElements) 13608 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedByteElements)
13612 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalShortElements) 13609 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalShortElements)
13613 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedShortElements) 13610 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedShortElements)
13614 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalIntElements) 13611 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalIntElements)
13615 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedIntElements) 13612 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedIntElements)
13616 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalFloatElements) 13613 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalFloatElements)
13617 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalDoubleElements) 13614 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalDoubleElements)
13618 13615
13619 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION 13616 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION
13620 13617
13621 13618
13622 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { 13619 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) {
13623 ASSERT(args.length() == 2); 13620 ASSERT(args.length() == 2);
13624 CONVERT_CHECKED(JSObject, obj1, args[0]); 13621 CONVERT_ARG_CHECKED(JSObject, obj1, 0);
13625 CONVERT_CHECKED(JSObject, obj2, args[1]); 13622 CONVERT_ARG_CHECKED(JSObject, obj2, 1);
13626 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); 13623 return isolate->heap()->ToBoolean(obj1->map() == obj2->map());
13627 } 13624 }
13628 13625
13629 // ---------------------------------------------------------------------------- 13626 // ----------------------------------------------------------------------------
13630 // Implementation of Runtime 13627 // Implementation of Runtime
13631 13628
13632 #define F(name, number_of_args, result_size) \ 13629 #define F(name, number_of_args, result_size) \
13633 { Runtime::k##name, Runtime::RUNTIME, #name, \ 13630 { Runtime::k##name, Runtime::RUNTIME, #name, \
13634 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, 13631 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size },
13635 13632
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
13704 // Handle last resort GC and make sure to allow future allocations 13701 // Handle last resort GC and make sure to allow future allocations
13705 // to grow the heap without causing GCs (if possible). 13702 // to grow the heap without causing GCs (if possible).
13706 isolate->counters()->gc_last_resort_from_js()->Increment(); 13703 isolate->counters()->gc_last_resort_from_js()->Increment();
13707 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13704 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13708 "Runtime::PerformGC"); 13705 "Runtime::PerformGC");
13709 } 13706 }
13710 } 13707 }
13711 13708
13712 13709
13713 } } // namespace v8::internal 13710 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698