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

Side by Side Diff: src/runtime.cc

Issue 239313002: Harden runtime functions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: more Created 6 years, 8 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 | src/v8conversions.h » ('j') | 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 using std::isless; 98 using std::isless;
99 #endif 99 #endif
100 100
101 namespace v8 { 101 namespace v8 {
102 namespace internal { 102 namespace internal {
103 103
104 104
105 #define RUNTIME_ASSERT(value) \ 105 #define RUNTIME_ASSERT(value) \
106 if (!(value)) return isolate->ThrowIllegalOperation(); 106 if (!(value)) return isolate->ThrowIllegalOperation();
107 107
108 #define RUNTIME_ASSERT_HANDLIFIED(value, T) \
109 if (!(value)) { \
110 isolate->ThrowIllegalOperation(); \
111 return MaybeHandle<T>(); \
112 }
113
108 // Cast the given object to a value of the specified type and store 114 // Cast the given object to a value of the specified type and store
109 // it in a variable with the given name. If the object is not of the 115 // it in a variable with the given name. If the object is not of the
110 // expected type call IllegalOperation and return. 116 // expected type call IllegalOperation and return.
111 #define CONVERT_ARG_CHECKED(Type, name, index) \ 117 #define CONVERT_ARG_CHECKED(Type, name, index) \
112 RUNTIME_ASSERT(args[index]->Is##Type()); \ 118 RUNTIME_ASSERT(args[index]->Is##Type()); \
113 Type* name = Type::cast(args[index]); 119 Type* name = Type::cast(args[index]);
114 120
115 #define CONVERT_ARG_HANDLE_CHECKED(Type, name, index) \ 121 #define CONVERT_ARG_HANDLE_CHECKED(Type, name, index) \
116 RUNTIME_ASSERT(args[index]->Is##Type()); \ 122 RUNTIME_ASSERT(args[index]->Is##Type()); \
117 Handle<Type> name = args.at<Type>(index); 123 Handle<Type> name = args.at<Type>(index);
118 124
125 #define CONVERT_NUMBER_ARG_HANDLE_CHECKED(name, index) \
126 RUNTIME_ASSERT(args[index]->IsNumber()); \
127 Handle<Object> name = args.at<Object>(index);
128
119 // Cast the given object to a boolean and store it in a variable with 129 // Cast the given object to a boolean and store it in a variable with
120 // the given name. If the object is not a boolean call IllegalOperation 130 // the given name. If the object is not a boolean call IllegalOperation
121 // and return. 131 // and return.
122 #define CONVERT_BOOLEAN_ARG_CHECKED(name, index) \ 132 #define CONVERT_BOOLEAN_ARG_CHECKED(name, index) \
123 RUNTIME_ASSERT(args[index]->IsBoolean()); \ 133 RUNTIME_ASSERT(args[index]->IsBoolean()); \
124 bool name = args[index]->IsTrue(); 134 bool name = args[index]->IsTrue();
125 135
126 // Cast the given argument to a Smi and store its value in an int variable 136 // Cast the given argument to a Smi and store its value in an int variable
127 // with the given name. If the argument is not a Smi call IllegalOperation 137 // with the given name. If the argument is not a Smi call IllegalOperation
128 // and return. 138 // and return.
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateObjectLiteral) { 486 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateObjectLiteral) {
477 HandleScope scope(isolate); 487 HandleScope scope(isolate);
478 ASSERT(args.length() == 4); 488 ASSERT(args.length() == 4);
479 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 489 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
480 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 490 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
481 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); 491 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2);
482 CONVERT_SMI_ARG_CHECKED(flags, 3); 492 CONVERT_SMI_ARG_CHECKED(flags, 3);
483 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; 493 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
484 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; 494 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
485 495
496 RUNTIME_ASSERT(literals_index >= 0 && literals_index < literals->length());
497
486 // Check if boilerplate exists. If not, create it first. 498 // Check if boilerplate exists. If not, create it first.
487 Handle<Object> literal_site(literals->get(literals_index), isolate); 499 Handle<Object> literal_site(literals->get(literals_index), isolate);
488 Handle<AllocationSite> site; 500 Handle<AllocationSite> site;
489 Handle<JSObject> boilerplate; 501 Handle<JSObject> boilerplate;
490 if (*literal_site == isolate->heap()->undefined_value()) { 502 if (*literal_site == isolate->heap()->undefined_value()) {
491 Handle<Object> raw_boilerplate; 503 Handle<Object> raw_boilerplate;
492 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 504 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
493 isolate, raw_boilerplate, 505 isolate, raw_boilerplate,
494 CreateObjectLiteralBoilerplate( 506 CreateObjectLiteralBoilerplate(
495 isolate, 507 isolate,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 565
554 return site; 566 return site;
555 } 567 }
556 568
557 569
558 static MaybeHandle<JSObject> CreateArrayLiteralImpl(Isolate* isolate, 570 static MaybeHandle<JSObject> CreateArrayLiteralImpl(Isolate* isolate,
559 Handle<FixedArray> literals, 571 Handle<FixedArray> literals,
560 int literals_index, 572 int literals_index,
561 Handle<FixedArray> elements, 573 Handle<FixedArray> elements,
562 int flags) { 574 int flags) {
575 RUNTIME_ASSERT_HANDLIFIED(literals_index >= 0 &&
576 literals_index < literals->length(), JSObject);
563 Handle<AllocationSite> site; 577 Handle<AllocationSite> site;
564 ASSIGN_RETURN_ON_EXCEPTION( 578 ASSIGN_RETURN_ON_EXCEPTION(
565 isolate, site, 579 isolate, site,
566 GetLiteralAllocationSite(isolate, literals, literals_index, elements), 580 GetLiteralAllocationSite(isolate, literals, literals_index, elements),
567 JSObject); 581 JSObject);
568 582
569 bool enable_mementos = (flags & ArrayLiteral::kDisableMementos) == 0; 583 bool enable_mementos = (flags & ArrayLiteral::kDisableMementos) == 0;
570 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); 584 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info()));
571 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos); 585 AllocationSiteUsageContext usage_context(isolate, site, enable_mementos);
572 usage_context.EnterNewScope(); 586 usage_context.EnterNewScope();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, 621 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
608 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, 622 CreateArrayLiteralImpl(isolate, literals, literals_index, elements,
609 ArrayLiteral::kShallowElements)); 623 ArrayLiteral::kShallowElements));
610 return *result; 624 return *result;
611 } 625 }
612 626
613 627
614 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) { 628 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) {
615 HandleScope scope(isolate); 629 HandleScope scope(isolate);
616 ASSERT(args.length() == 1); 630 ASSERT(args.length() == 1);
617 Handle<Object> name = args.at<Object>(0); 631 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
618 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); 632 RUNTIME_ASSERT(name->IsString() || name->IsUndefined());
619 Handle<Symbol> symbol = isolate->factory()->NewSymbol(); 633 Handle<Symbol> symbol = isolate->factory()->NewSymbol();
620 if (name->IsString()) symbol->set_name(*name); 634 if (name->IsString()) symbol->set_name(*name);
621 return *symbol; 635 return *symbol;
622 } 636 }
623 637
624 638
625 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreatePrivateSymbol) { 639 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreatePrivateSymbol) {
626 HandleScope scope(isolate); 640 HandleScope scope(isolate);
627 ASSERT(args.length() == 1); 641 ASSERT(args.length() == 1);
628 Handle<Object> name = args.at<Object>(0); 642 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
629 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); 643 RUNTIME_ASSERT(name->IsString() || name->IsUndefined());
630 Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol(); 644 Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol();
631 if (name->IsString()) symbol->set_name(*name); 645 if (name->IsString()) symbol->set_name(*name);
632 return *symbol; 646 return *symbol;
633 } 647 }
634 648
635 649
636 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateGlobalPrivateSymbol) { 650 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateGlobalPrivateSymbol) {
637 HandleScope scope(isolate); 651 HandleScope scope(isolate);
638 ASSERT(args.length() == 1); 652 ASSERT(args.length() == 1);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 ASSERT(args.length() == 1); 698 ASSERT(args.length() == 1);
685 CONVERT_ARG_CHECKED(Symbol, symbol, 0); 699 CONVERT_ARG_CHECKED(Symbol, symbol, 0);
686 return isolate->heap()->ToBoolean(symbol->is_private()); 700 return isolate->heap()->ToBoolean(symbol->is_private());
687 } 701 }
688 702
689 703
690 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { 704 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) {
691 HandleScope scope(isolate); 705 HandleScope scope(isolate);
692 ASSERT(args.length() == 2); 706 ASSERT(args.length() == 2);
693 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); 707 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0);
694 Handle<Object> prototype = args.at<Object>(1); 708 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
695 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); 709 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value();
696 return *isolate->factory()->NewJSProxy(handler, prototype); 710 return *isolate->factory()->NewJSProxy(handler, prototype);
697 } 711 }
698 712
699 713
700 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSFunctionProxy) { 714 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSFunctionProxy) {
701 HandleScope scope(isolate); 715 HandleScope scope(isolate);
702 ASSERT(args.length() == 4); 716 ASSERT(args.length() == 4);
703 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); 717 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0);
704 Handle<Object> call_trap = args.at<Object>(1); 718 CONVERT_ARG_HANDLE_CHECKED(Object, call_trap, 1);
705 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); 719 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy());
706 CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 2); 720 CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 2);
707 Handle<Object> prototype = args.at<Object>(3); 721 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 3);
708 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); 722 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value();
709 return *isolate->factory()->NewJSFunctionProxy( 723 return *isolate->factory()->NewJSFunctionProxy(
710 handler, call_trap, construct_trap, prototype); 724 handler, call_trap, construct_trap, prototype);
711 } 725 }
712 726
713 727
714 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSProxy) { 728 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSProxy) {
715 SealHandleScope shs(isolate); 729 SealHandleScope shs(isolate);
716 ASSERT(args.length() == 1); 730 ASSERT(args.length() == 1);
717 Object* obj = args[0]; 731 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0);
718 return isolate->heap()->ToBoolean(obj->IsJSProxy()); 732 return isolate->heap()->ToBoolean(obj->IsJSProxy());
719 } 733 }
720 734
721 735
722 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSFunctionProxy) { 736 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSFunctionProxy) {
723 SealHandleScope shs(isolate); 737 SealHandleScope shs(isolate);
724 ASSERT(args.length() == 1); 738 ASSERT(args.length() == 1);
725 Object* obj = args[0]; 739 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0);
726 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); 740 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy());
727 } 741 }
728 742
729 743
730 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { 744 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) {
731 SealHandleScope shs(isolate); 745 SealHandleScope shs(isolate);
732 ASSERT(args.length() == 1); 746 ASSERT(args.length() == 1);
733 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); 747 CONVERT_ARG_CHECKED(JSProxy, proxy, 0);
734 return proxy->handler(); 748 return proxy->handler();
735 } 749 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 Handle<JSArrayBuffer> array_buffer, 824 Handle<JSArrayBuffer> array_buffer,
811 size_t allocated_length, 825 size_t allocated_length,
812 bool initialize) { 826 bool initialize) {
813 void* data; 827 void* data;
814 CHECK(V8::ArrayBufferAllocator() != NULL); 828 CHECK(V8::ArrayBufferAllocator() != NULL);
815 if (allocated_length != 0) { 829 if (allocated_length != 0) {
816 if (initialize) { 830 if (initialize) {
817 data = V8::ArrayBufferAllocator()->Allocate(allocated_length); 831 data = V8::ArrayBufferAllocator()->Allocate(allocated_length);
818 } else { 832 } else {
819 data = 833 data =
820 V8::ArrayBufferAllocator()->AllocateUninitialized(allocated_length); 834 V8::ArrayBufferAllocator()->AllocateUninitialized(allocated_length);
821 } 835 }
822 if (data == NULL) return false; 836 if (data == NULL) return false;
823 } else { 837 } else {
824 data = NULL; 838 data = NULL;
825 } 839 }
826 840
827 SetupArrayBuffer(isolate, array_buffer, false, data, allocated_length); 841 SetupArrayBuffer(isolate, array_buffer, false, data, allocated_length);
828 842
829 isolate->heap()->AdjustAmountOfExternalAllocatedMemory(allocated_length); 843 isolate->heap()->AdjustAmountOfExternalAllocatedMemory(allocated_length);
830 844
(...skipping 16 matching lines...) Expand all
847 view_obj = handle(view->weak_next(), isolate); 861 view_obj = handle(view->weak_next(), isolate);
848 } 862 }
849 array_buffer->Neuter(); 863 array_buffer->Neuter();
850 } 864 }
851 865
852 866
853 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferInitialize) { 867 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferInitialize) {
854 HandleScope scope(isolate); 868 HandleScope scope(isolate);
855 ASSERT(args.length() == 2); 869 ASSERT(args.length() == 2);
856 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, holder, 0); 870 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, holder, 0);
857 CONVERT_ARG_HANDLE_CHECKED(Object, byteLength, 1); 871 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byteLength, 1);
858 size_t allocated_length; 872 size_t allocated_length = 0;
859 if (byteLength->IsSmi()) { 873 if (!TryNumberToSize(isolate, *byteLength, &allocated_length)) {
860 allocated_length = Smi::cast(*byteLength)->value(); 874 return isolate->Throw(
861 } else { 875 *isolate->factory()->NewRangeError("invalid_array_buffer_length",
862 ASSERT(byteLength->IsHeapNumber()); 876 HandleVector<Object>(NULL, 0)));
863 double value = HeapNumber::cast(*byteLength)->value();
864
865 ASSERT(value >= 0);
866
867 if (value > std::numeric_limits<size_t>::max()) {
868 return isolate->Throw(
869 *isolate->factory()->NewRangeError("invalid_array_buffer_length",
870 HandleVector<Object>(NULL, 0)));
871 }
872
873 allocated_length = static_cast<size_t>(value);
874 } 877 }
875
876 if (!Runtime::SetupArrayBufferAllocatingData(isolate, 878 if (!Runtime::SetupArrayBufferAllocatingData(isolate,
877 holder, allocated_length)) { 879 holder, allocated_length)) {
878 return isolate->Throw(*isolate->factory()-> 880 return isolate->Throw(
879 NewRangeError("invalid_array_buffer_length", 881 *isolate->factory()->NewRangeError("invalid_array_buffer_length",
880 HandleVector<Object>(NULL, 0))); 882 HandleVector<Object>(NULL, 0)));
881 } 883 }
882
883 return *holder; 884 return *holder;
884 } 885 }
885 886
886 887
887 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferGetByteLength) { 888 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferGetByteLength) {
888 SealHandleScope shs(isolate); 889 SealHandleScope shs(isolate);
889 ASSERT(args.length() == 1); 890 ASSERT(args.length() == 1);
890 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); 891 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0);
891 return holder->byte_length(); 892 return holder->byte_length();
892 } 893 }
893 894
894 895
895 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferSliceImpl) { 896 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferSliceImpl) {
896 HandleScope scope(isolate); 897 HandleScope scope(isolate);
897 ASSERT(args.length() == 3); 898 ASSERT(args.length() == 3);
898 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, source, 0); 899 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, source, 0);
899 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, target, 1); 900 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, target, 1);
900 CONVERT_DOUBLE_ARG_CHECKED(first, 2); 901 CONVERT_NUMBER_ARG_HANDLE_CHECKED(first, 2);
901 size_t start = static_cast<size_t>(first); 902 size_t start = 0;
903 RUNTIME_ASSERT(TryNumberToSize(isolate, *first, &start));
902 size_t target_length = NumberToSize(isolate, target->byte_length()); 904 size_t target_length = NumberToSize(isolate, target->byte_length());
903 905
904 if (target_length == 0) return isolate->heap()->undefined_value(); 906 if (target_length == 0) return isolate->heap()->undefined_value();
905 907
906 size_t source_byte_length = NumberToSize(isolate, source->byte_length()); 908 size_t source_byte_length = NumberToSize(isolate, source->byte_length());
907 CHECK(start <= source_byte_length); 909 RUNTIME_ASSERT(start <= source_byte_length);
908 CHECK(source_byte_length - start >= target_length); 910 RUNTIME_ASSERT(source_byte_length - start >= target_length);
909 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store()); 911 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store());
910 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store()); 912 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store());
911 CopyBytes(target_data, source_data + start, target_length); 913 CopyBytes(target_data, source_data + start, target_length);
912 return isolate->heap()->undefined_value(); 914 return isolate->heap()->undefined_value();
913 } 915 }
914 916
915 917
916 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferIsView) { 918 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferIsView) {
917 HandleScope scope(isolate); 919 HandleScope scope(isolate);
918 ASSERT(args.length() == 1); 920 ASSERT(args.length() == 1);
919 CONVERT_ARG_CHECKED(Object, object, 0); 921 CONVERT_ARG_CHECKED(Object, object, 0);
920 return object->IsJSArrayBufferView() 922 return isolate->heap()->ToBoolean(object->IsJSArrayBufferView());
921 ? isolate->heap()->true_value()
922 : isolate->heap()->false_value();
923 } 923 }
924 924
925 925
926 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferNeuter) { 926 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferNeuter) {
927 HandleScope scope(isolate); 927 HandleScope scope(isolate);
928 ASSERT(args.length() == 1);
928 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, array_buffer, 0); 929 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, array_buffer, 0);
929 if (array_buffer->backing_store() == NULL) { 930 if (array_buffer->backing_store() == NULL) {
930 CHECK(Smi::FromInt(0) == array_buffer->byte_length()); 931 CHECK(Smi::FromInt(0) == array_buffer->byte_length());
931 return isolate->heap()->undefined_value(); 932 return isolate->heap()->undefined_value();
932 } 933 }
933 ASSERT(!array_buffer->is_external()); 934 ASSERT(!array_buffer->is_external());
934 void* backing_store = array_buffer->backing_store(); 935 void* backing_store = array_buffer->backing_store();
935 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); 936 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length());
936 array_buffer->set_is_external(true); 937 array_buffer->set_is_external(true);
937 Runtime::NeuterArrayBuffer(array_buffer); 938 Runtime::NeuterArrayBuffer(array_buffer);
(...skipping 25 matching lines...) Expand all
963 } 964 }
964 } 965 }
965 966
966 967
967 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) { 968 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) {
968 HandleScope scope(isolate); 969 HandleScope scope(isolate);
969 ASSERT(args.length() == 5); 970 ASSERT(args.length() == 5);
970 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); 971 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0);
971 CONVERT_SMI_ARG_CHECKED(arrayId, 1); 972 CONVERT_SMI_ARG_CHECKED(arrayId, 1);
972 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_buffer, 2); 973 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_buffer, 2);
973 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset_object, 3); 974 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset_object, 3);
974 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 4); 975 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length_object, 4);
975 976
976 ASSERT(holder->GetInternalFieldCount() == 977 ASSERT(holder->GetInternalFieldCount() ==
977 v8::ArrayBufferView::kInternalFieldCount); 978 v8::ArrayBufferView::kInternalFieldCount);
978 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { 979 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
979 holder->SetInternalField(i, Smi::FromInt(0)); 980 holder->SetInternalField(i, Smi::FromInt(0));
980 } 981 }
981 982
982 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. 983 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization.
983 size_t element_size = 1; // Bogus initialization. 984 size_t element_size = 1; // Bogus initialization.
984 ElementsKind external_elements_kind = 985 ElementsKind external_elements_kind =
985 EXTERNAL_INT8_ELEMENTS; // Bogus initialization. 986 EXTERNAL_INT8_ELEMENTS; // Bogus initialization.
986 ElementsKind fixed_elements_kind = INT8_ELEMENTS; // Bogus initialization. 987 ElementsKind fixed_elements_kind = INT8_ELEMENTS; // Bogus initialization.
987 Runtime::ArrayIdToTypeAndSize(arrayId, 988 Runtime::ArrayIdToTypeAndSize(arrayId,
988 &array_type, 989 &array_type,
989 &external_elements_kind, 990 &external_elements_kind,
990 &fixed_elements_kind, 991 &fixed_elements_kind,
991 &element_size); 992 &element_size);
992 993
994 size_t byte_offset = 0;
995 size_t byte_length = 0;
996 RUNTIME_ASSERT(TryNumberToSize(isolate, *byte_offset_object, &byte_offset));
997 RUNTIME_ASSERT(TryNumberToSize(isolate, *byte_length_object, &byte_length));
998
993 holder->set_byte_offset(*byte_offset_object); 999 holder->set_byte_offset(*byte_offset_object);
994 holder->set_byte_length(*byte_length_object); 1000 holder->set_byte_length(*byte_length_object);
995 1001
996 size_t byte_offset = NumberToSize(isolate, *byte_offset_object);
997 size_t byte_length = NumberToSize(isolate, *byte_length_object);
998
999 CHECK_EQ(0, static_cast<int>(byte_length % element_size)); 1002 CHECK_EQ(0, static_cast<int>(byte_length % element_size));
1000 size_t length = byte_length / element_size; 1003 size_t length = byte_length / element_size;
1001 1004
1002 if (length > static_cast<unsigned>(Smi::kMaxValue)) { 1005 if (length > static_cast<unsigned>(Smi::kMaxValue)) {
1003 return isolate->Throw(*isolate->factory()-> 1006 return isolate->Throw(
1004 NewRangeError("invalid_typed_array_length", 1007 *isolate->factory()->NewRangeError("invalid_typed_array_length",
1005 HandleVector<Object>(NULL, 0))); 1008 HandleVector<Object>(NULL, 0)));
1006 } 1009 }
1007 1010
1011
1012 // TODO(jkummerow): continue here
Jakob Kummerow 2014/04/16 17:29:56 oops :-)
1013
1014
1008 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); 1015 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length);
1009 holder->set_length(*length_obj); 1016 holder->set_length(*length_obj);
1010 if (!maybe_buffer->IsNull()) { 1017 if (!maybe_buffer->IsNull()) {
1011 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(*maybe_buffer)); 1018 Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(*maybe_buffer));
1012 1019
1013 size_t array_buffer_byte_length = 1020 size_t array_buffer_byte_length =
1014 NumberToSize(isolate, buffer->byte_length()); 1021 NumberToSize(isolate, buffer->byte_length());
1015 CHECK(byte_offset <= array_buffer_byte_length); 1022 CHECK(byte_offset <= array_buffer_byte_length);
1016 CHECK(array_buffer_byte_length - byte_offset >= byte_length); 1023 CHECK(array_buffer_byte_length - byte_offset >= byte_length);
1017 1024
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, 1187 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1,
1181 // Set from typed array of the different type, non-overlapping. 1188 // Set from typed array of the different type, non-overlapping.
1182 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, 1189 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2,
1183 // Set from non-typed array. 1190 // Set from non-typed array.
1184 TYPED_ARRAY_SET_NON_TYPED_ARRAY = 3 1191 TYPED_ARRAY_SET_NON_TYPED_ARRAY = 3
1185 }; 1192 };
1186 1193
1187 1194
1188 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArraySetFastCases) { 1195 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArraySetFastCases) {
1189 HandleScope scope(isolate); 1196 HandleScope scope(isolate);
1197 ASSERT(args.length() == 3);
1190 CONVERT_ARG_HANDLE_CHECKED(Object, target_obj, 0); 1198 CONVERT_ARG_HANDLE_CHECKED(Object, target_obj, 0);
1191 CONVERT_ARG_HANDLE_CHECKED(Object, source_obj, 1); 1199 CONVERT_ARG_HANDLE_CHECKED(Object, source_obj, 1);
1192 CONVERT_ARG_HANDLE_CHECKED(Object, offset_obj, 2); 1200 CONVERT_ARG_HANDLE_CHECKED(Object, offset_obj, 2);
1193 1201
1194 if (!target_obj->IsJSTypedArray()) 1202 if (!target_obj->IsJSTypedArray())
1195 return isolate->Throw(*isolate->factory()->NewTypeError( 1203 return isolate->Throw(*isolate->factory()->NewTypeError(
1196 "not_typed_array", HandleVector<Object>(NULL, 0))); 1204 "not_typed_array", HandleVector<Object>(NULL, 0)));
1197 1205
1198 if (!source_obj->IsJSTypedArray()) 1206 if (!source_obj->IsJSTypedArray())
1199 return Smi::FromInt(TYPED_ARRAY_SET_NON_TYPED_ARRAY); 1207 return Smi::FromInt(TYPED_ARRAY_SET_NON_TYPED_ARRAY);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 target->GetBuffer()->backing_store() == 1245 target->GetBuffer()->backing_store() ==
1238 source->GetBuffer()->backing_store()); 1246 source->GetBuffer()->backing_store());
1239 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); 1247 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING);
1240 } else { // Non-overlapping typed arrays 1248 } else { // Non-overlapping typed arrays
1241 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); 1249 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING);
1242 } 1250 }
1243 } 1251 }
1244 1252
1245 1253
1246 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayMaxSizeInHeap) { 1254 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayMaxSizeInHeap) {
1255 ASSERT(args.length() == 0);
1247 ASSERT_OBJECT_SIZE( 1256 ASSERT_OBJECT_SIZE(
1248 FLAG_typed_array_max_size_in_heap + FixedTypedArrayBase::kDataOffset); 1257 FLAG_typed_array_max_size_in_heap + FixedTypedArrayBase::kDataOffset);
1249 return Smi::FromInt(FLAG_typed_array_max_size_in_heap); 1258 return Smi::FromInt(FLAG_typed_array_max_size_in_heap);
1250 } 1259 }
1251 1260
1252 1261
1253 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) { 1262 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) {
1254 HandleScope scope(isolate); 1263 HandleScope scope(isolate);
1255 ASSERT(args.length() == 4); 1264 ASSERT(args.length() == 4);
1256 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); 1265 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 Handle<OrderedHashSet> table = isolate->factory()->NewOrderedHashSet(); 1524 Handle<OrderedHashSet> table = isolate->factory()->NewOrderedHashSet();
1516 holder->set_table(*table); 1525 holder->set_table(*table);
1517 return *holder; 1526 return *holder;
1518 } 1527 }
1519 1528
1520 1529
1521 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) { 1530 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) {
1522 HandleScope scope(isolate); 1531 HandleScope scope(isolate);
1523 ASSERT(args.length() == 2); 1532 ASSERT(args.length() == 2);
1524 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); 1533 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
1525 Handle<Object> key(args[1], isolate); 1534 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
1526 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); 1535 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()));
1527 table = OrderedHashSet::Add(table, key); 1536 table = OrderedHashSet::Add(table, key);
1528 holder->set_table(*table); 1537 holder->set_table(*table);
1529 return isolate->heap()->undefined_value(); 1538 return isolate->heap()->undefined_value();
1530 } 1539 }
1531 1540
1532 1541
1533 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHas) { 1542 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHas) {
1534 HandleScope scope(isolate); 1543 HandleScope scope(isolate);
1535 ASSERT(args.length() == 2); 1544 ASSERT(args.length() == 2);
1536 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); 1545 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
1537 Handle<Object> key(args[1], isolate); 1546 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
1538 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); 1547 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()));
1539 return isolate->heap()->ToBoolean(table->Contains(*key)); 1548 return isolate->heap()->ToBoolean(table->Contains(*key));
1540 } 1549 }
1541 1550
1542 1551
1543 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) { 1552 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) {
1544 HandleScope scope(isolate); 1553 HandleScope scope(isolate);
1545 ASSERT(args.length() == 2); 1554 ASSERT(args.length() == 2);
1546 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); 1555 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
1547 Handle<Object> key(args[1], isolate); 1556 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
1548 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); 1557 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()));
1549 table = OrderedHashSet::Remove(table, key); 1558 table = OrderedHashSet::Remove(table, key);
1550 holder->set_table(*table); 1559 holder->set_table(*table);
1551 return isolate->heap()->undefined_value(); 1560 return isolate->heap()->undefined_value();
1552 } 1561 }
1553 1562
1554 1563
1555 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetGetSize) { 1564 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetGetSize) {
1556 HandleScope scope(isolate); 1565 HandleScope scope(isolate);
1557 ASSERT(args.length() == 1); 1566 ASSERT(args.length() == 1);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 weak_collection->set_table(*new_table); 1693 weak_collection->set_table(*new_table);
1685 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); 1694 return isolate->heap()->ToBoolean(!lookup->IsTheHole());
1686 } 1695 }
1687 1696
1688 1697
1689 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionSet) { 1698 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionSet) {
1690 HandleScope scope(isolate); 1699 HandleScope scope(isolate);
1691 ASSERT(args.length() == 3); 1700 ASSERT(args.length() == 3);
1692 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); 1701 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0);
1693 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 1702 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
1694 Handle<Object> value(args[2], isolate); 1703 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
1695 Handle<ObjectHashTable> table( 1704 Handle<ObjectHashTable> table(
1696 ObjectHashTable::cast(weak_collection->table())); 1705 ObjectHashTable::cast(weak_collection->table()));
1697 Handle<ObjectHashTable> new_table = ObjectHashTable::Put(table, key, value); 1706 Handle<ObjectHashTable> new_table = ObjectHashTable::Put(table, key, value);
1698 weak_collection->set_table(*new_table); 1707 weak_collection->set_table(*new_table);
1699 return isolate->heap()->undefined_value(); 1708 return isolate->heap()->undefined_value();
1700 } 1709 }
1701 1710
1702 1711
1703 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { 1712 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) {
1704 SealHandleScope shs(isolate); 1713 SealHandleScope shs(isolate);
1705 ASSERT(args.length() == 1); 1714 ASSERT(args.length() == 1);
1706 Object* obj = args[0]; 1715 CONVERT_ARG_CHECKED(Object, obj, 0);
1707 if (!obj->IsJSObject()) return isolate->heap()->null_value(); 1716 if (!obj->IsJSObject()) return isolate->heap()->null_value();
1708 return JSObject::cast(obj)->class_name(); 1717 return JSObject::cast(obj)->class_name();
1709 } 1718 }
1710 1719
1711 1720
1712 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { 1721 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) {
1713 HandleScope scope(isolate); 1722 HandleScope scope(isolate);
1714 ASSERT(args.length() == 1); 1723 ASSERT(args.length() == 1);
1715 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); 1724 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0);
1716 // We don't expect access checks to be needed on JSProxy objects. 1725 // We don't expect access checks to be needed on JSProxy objects.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 Handle<Object> result = JSObject::SetPrototype(obj, prototype, true); 1781 Handle<Object> result = JSObject::SetPrototype(obj, prototype, true);
1773 RETURN_IF_EMPTY_HANDLE(isolate, result); 1782 RETURN_IF_EMPTY_HANDLE(isolate, result);
1774 return *result; 1783 return *result;
1775 } 1784 }
1776 1785
1777 1786
1778 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { 1787 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) {
1779 HandleScope shs(isolate); 1788 HandleScope shs(isolate);
1780 ASSERT(args.length() == 2); 1789 ASSERT(args.length() == 2);
1781 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). 1790 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8).
1782 Handle<Object> O = args.at<Object>(0); 1791 CONVERT_ARG_HANDLE_CHECKED(Object, O, 0);
1783 Handle<Object> V = args.at<Object>(1); 1792 CONVERT_ARG_HANDLE_CHECKED(Object, V, 1);
1784 while (true) { 1793 while (true) {
1785 Handle<Object> prototype = Object::GetPrototype(isolate, V); 1794 Handle<Object> prototype = Object::GetPrototype(isolate, V);
1786 if (prototype->IsNull()) return isolate->heap()->false_value(); 1795 if (prototype->IsNull()) return isolate->heap()->false_value();
1787 if (*O == *prototype) return isolate->heap()->true_value(); 1796 if (*O == *prototype) return isolate->heap()->true_value();
1788 V = prototype; 1797 V = prototype;
1789 } 1798 }
1790 } 1799 }
1791 1800
1792 1801
1793 static bool CheckAccessException(Object* callback, 1802 static bool CheckAccessException(Object* callback,
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 HandleScope scope(isolate); 2040 HandleScope scope(isolate);
2032 ASSERT(args.length() == 1); 2041 ASSERT(args.length() == 1);
2033 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); 2042 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0);
2034 return *isolate->factory()->CreateApiFunction(data); 2043 return *isolate->factory()->CreateApiFunction(data);
2035 } 2044 }
2036 2045
2037 2046
2038 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsTemplate) { 2047 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsTemplate) {
2039 SealHandleScope shs(isolate); 2048 SealHandleScope shs(isolate);
2040 ASSERT(args.length() == 1); 2049 ASSERT(args.length() == 1);
2041 Object* arg = args[0]; 2050 CONVERT_ARG_HANDLE_CHECKED(Object, arg, 0);
2042 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); 2051 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo();
2043 return isolate->heap()->ToBoolean(result); 2052 return isolate->heap()->ToBoolean(result);
2044 } 2053 }
2045 2054
2046 2055
2047 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) { 2056 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) {
2048 SealHandleScope shs(isolate); 2057 SealHandleScope shs(isolate);
2049 ASSERT(args.length() == 2); 2058 ASSERT(args.length() == 2);
2050 CONVERT_ARG_CHECKED(HeapObject, templ, 0); 2059 CONVERT_ARG_CHECKED(HeapObject, templ, 0);
2051 CONVERT_SMI_ARG_CHECKED(index, 1) 2060 CONVERT_SMI_ARG_CHECKED(index, 1);
2052 int offset = index * kPointerSize + HeapObject::kHeaderSize; 2061 int offset = index * kPointerSize + HeapObject::kHeaderSize;
2053 InstanceType type = templ->map()->instance_type(); 2062 InstanceType type = templ->map()->instance_type();
2054 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || 2063 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE ||
2055 type == OBJECT_TEMPLATE_INFO_TYPE); 2064 type == OBJECT_TEMPLATE_INFO_TYPE);
2056 RUNTIME_ASSERT(offset > 0); 2065 RUNTIME_ASSERT(offset > 0);
2057 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { 2066 if (type == FUNCTION_TEMPLATE_INFO_TYPE) {
2058 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); 2067 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize);
2059 } else { 2068 } else {
2060 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); 2069 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize);
2061 } 2070 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2141 return isolate->Throw(*error); 2150 return isolate->Throw(*error);
2142 } 2151 }
2143 2152
2144 2153
2145 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareGlobals) { 2154 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareGlobals) {
2146 HandleScope scope(isolate); 2155 HandleScope scope(isolate);
2147 ASSERT(args.length() == 3); 2156 ASSERT(args.length() == 3);
2148 Handle<GlobalObject> global = Handle<GlobalObject>( 2157 Handle<GlobalObject> global = Handle<GlobalObject>(
2149 isolate->context()->global_object()); 2158 isolate->context()->global_object());
2150 2159
2151 Handle<Context> context = args.at<Context>(0); 2160 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0);
2152 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1); 2161 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1);
2153 CONVERT_SMI_ARG_CHECKED(flags, 2); 2162 CONVERT_SMI_ARG_CHECKED(flags, 2);
2154 2163
2155 // Traverse the name/value pairs and set the properties. 2164 // Traverse the name/value pairs and set the properties.
2156 int length = pairs->length(); 2165 int length = pairs->length();
2157 for (int i = 0; i < length; i += 2) { 2166 for (int i = 0; i < length; i += 2) {
2158 HandleScope scope(isolate); 2167 HandleScope scope(isolate);
2159 Handle<String> name(String::cast(pairs->get(i))); 2168 Handle<String> name(String::cast(pairs->get(i)));
2160 Handle<Object> value(pairs->get(i + 1), isolate); 2169 Handle<Object> value(pairs->get(i + 1), isolate);
2161 2170
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2238 } 2247 }
2239 2248
2240 2249
2241 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareContextSlot) { 2250 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareContextSlot) {
2242 HandleScope scope(isolate); 2251 HandleScope scope(isolate);
2243 ASSERT(args.length() == 4); 2252 ASSERT(args.length() == 4);
2244 2253
2245 // Declarations are always made in a function or native context. In the 2254 // Declarations are always made in a function or native context. In the
2246 // case of eval code, the context passed is the context of the caller, 2255 // case of eval code, the context passed is the context of the caller,
2247 // which may be some nested context and not the declaration context. 2256 // which may be some nested context and not the declaration context.
2248 RUNTIME_ASSERT(args[0]->IsContext()); 2257 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 0);
2249 Handle<Context> context(Context::cast(args[0])->declaration_context()); 2258 Handle<Context> context(context_arg->declaration_context());
2250 2259 CONVERT_ARG_HANDLE_CHECKED(String, name, 1);
2251 Handle<String> name(String::cast(args[1])); 2260 CONVERT_SMI_ARG_CHECKED(mode_arg, 2);
2252 PropertyAttributes mode = static_cast<PropertyAttributes>(args.smi_at(2)); 2261 PropertyAttributes mode = static_cast<PropertyAttributes>(mode_arg);
2253 RUNTIME_ASSERT(mode == READ_ONLY || mode == NONE); 2262 RUNTIME_ASSERT(mode == READ_ONLY || mode == NONE);
2254 Handle<Object> initial_value(args[3], isolate); 2263 CONVERT_ARG_HANDLE_CHECKED(Object, initial_value, 3);
2255 2264
2256 int index; 2265 int index;
2257 PropertyAttributes attributes; 2266 PropertyAttributes attributes;
2258 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; 2267 ContextLookupFlags flags = DONT_FOLLOW_CHAINS;
2259 BindingFlags binding_flags; 2268 BindingFlags binding_flags;
2260 Handle<Object> holder = 2269 Handle<Object> holder =
2261 context->Lookup(name, flags, &index, &attributes, &binding_flags); 2270 context->Lookup(name, flags, &index, &attributes, &binding_flags);
2262 2271
2263 if (attributes != ABSENT) { 2272 if (attributes != ABSENT) {
2264 // The name was declared before; check for conflicting re-declarations. 2273 // The name was declared before; check for conflicting re-declarations.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 // args[0] == name 2352 // args[0] == name
2344 // args[1] == language_mode 2353 // args[1] == language_mode
2345 // args[2] == value (optional) 2354 // args[2] == value (optional)
2346 2355
2347 // Determine if we need to assign to the variable if it already 2356 // Determine if we need to assign to the variable if it already
2348 // exists (based on the number of arguments). 2357 // exists (based on the number of arguments).
2349 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); 2358 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3);
2350 bool assign = args.length() == 3; 2359 bool assign = args.length() == 3;
2351 2360
2352 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 2361 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
2353 RUNTIME_ASSERT(args[1]->IsSmi());
2354 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 1); 2362 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 1);
2355 2363
2356 // According to ECMA-262, section 12.2, page 62, the property must 2364 // According to ECMA-262, section 12.2, page 62, the property must
2357 // not be deletable. 2365 // not be deletable.
2358 PropertyAttributes attributes = DONT_DELETE; 2366 PropertyAttributes attributes = DONT_DELETE;
2359 2367
2360 // Lookup the property locally in the global object. If it isn't 2368 // Lookup the property locally in the global object. If it isn't
2361 // there, there is a property with this name in the prototype chain. 2369 // there, there is a property with this name in the prototype chain.
2362 // We follow Safari and Firefox behavior and only set the property 2370 // We follow Safari and Firefox behavior and only set the property
2363 // locally if there is an explicit initialization value that we have 2371 // locally if there is an explicit initialization value that we have
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 } 2407 }
2400 2408
2401 2409
2402 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InitializeConstGlobal) { 2410 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InitializeConstGlobal) {
2403 SealHandleScope shs(isolate); 2411 SealHandleScope shs(isolate);
2404 // All constants are declared with an initial value. The name 2412 // All constants are declared with an initial value. The name
2405 // of the constant is the first argument and the initial value 2413 // of the constant is the first argument and the initial value
2406 // is the second. 2414 // is the second.
2407 RUNTIME_ASSERT(args.length() == 2); 2415 RUNTIME_ASSERT(args.length() == 2);
2408 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 2416 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
2409 Handle<Object> value = args.at<Object>(1); 2417 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
2410 2418
2411 // Get the current global object from top. 2419 // Get the current global object from top.
2412 GlobalObject* global = isolate->context()->global_object(); 2420 GlobalObject* global = isolate->context()->global_object();
2413 2421
2414 // According to ECMA-262, section 12.2, page 62, the property must 2422 // According to ECMA-262, section 12.2, page 62, the property must
2415 // not be deletable. Since it's a const, it must be READ_ONLY too. 2423 // not be deletable. Since it's a const, it must be READ_ONLY too.
2416 PropertyAttributes attributes = 2424 PropertyAttributes attributes =
2417 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); 2425 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
2418 2426
2419 // Lookup the property locally in the global object. If it isn't 2427 // Lookup the property locally in the global object. If it isn't
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 2481
2474 // Use the set value as the result of the operation. 2482 // Use the set value as the result of the operation.
2475 return *value; 2483 return *value;
2476 } 2484 }
2477 2485
2478 2486
2479 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InitializeConstContextSlot) { 2487 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InitializeConstContextSlot) {
2480 HandleScope scope(isolate); 2488 HandleScope scope(isolate);
2481 ASSERT(args.length() == 3); 2489 ASSERT(args.length() == 3);
2482 2490
2483 Handle<Object> value(args[0], isolate); 2491 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0);
2484 ASSERT(!value->IsTheHole()); 2492 ASSERT(!value->IsTheHole());
2485
2486 // Initializations are always done in a function or native context. 2493 // Initializations are always done in a function or native context.
2487 RUNTIME_ASSERT(args[1]->IsContext()); 2494 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 1);
2488 Handle<Context> context(Context::cast(args[1])->declaration_context()); 2495 Handle<Context> context(context_arg->declaration_context());
2489 2496 CONVERT_ARG_HANDLE_CHECKED(String, name, 2);
2490 Handle<String> name(String::cast(args[2]));
2491 2497
2492 int index; 2498 int index;
2493 PropertyAttributes attributes; 2499 PropertyAttributes attributes;
2494 ContextLookupFlags flags = FOLLOW_CHAINS; 2500 ContextLookupFlags flags = FOLLOW_CHAINS;
2495 BindingFlags binding_flags; 2501 BindingFlags binding_flags;
2496 Handle<Object> holder = 2502 Handle<Object> holder =
2497 context->Lookup(name, flags, &index, &attributes, &binding_flags); 2503 context->Lookup(name, flags, &index, &attributes, &binding_flags);
2498 2504
2499 if (index >= 0) { 2505 if (index >= 0) {
2500 ASSERT(holder->IsContext()); 2506 ASSERT(holder->IsContext());
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2606 RETURN_IF_EMPTY_HANDLE(isolate, result); 2612 RETURN_IF_EMPTY_HANDLE(isolate, result);
2607 return *result; 2613 return *result;
2608 } 2614 }
2609 2615
2610 2616
2611 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpConstructResult) { 2617 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpConstructResult) {
2612 HandleScope handle_scope(isolate); 2618 HandleScope handle_scope(isolate);
2613 ASSERT(args.length() == 3); 2619 ASSERT(args.length() == 3);
2614 CONVERT_SMI_ARG_CHECKED(size, 0); 2620 CONVERT_SMI_ARG_CHECKED(size, 0);
2615 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); 2621 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength);
2622 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1);
2623 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2);
2616 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); 2624 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size);
2617 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); 2625 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map());
2618 Handle<JSObject> object = 2626 Handle<JSObject> object =
2619 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false); 2627 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false);
2620 Handle<JSArray> array = Handle<JSArray>::cast(object); 2628 Handle<JSArray> array = Handle<JSArray>::cast(object);
2621 array->set_elements(*elements); 2629 array->set_elements(*elements);
2622 array->set_length(Smi::FromInt(size)); 2630 array->set_length(Smi::FromInt(size));
2623 // Write in-object properties after the length of the array. 2631 // Write in-object properties after the length of the array.
2624 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); 2632 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index);
2625 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); 2633 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input);
2626 return *array; 2634 return *array;
2627 } 2635 }
2628 2636
2629 2637
2630 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { 2638 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) {
2631 HandleScope scope(isolate); 2639 HandleScope scope(isolate);
2632 ASSERT(args.length() == 5); 2640 ASSERT(args.length() == 5);
2633 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); 2641 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0);
2634 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); 2642 CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
2635 // If source is the empty string we set it to "(?:)" instead as 2643 // If source is the empty string we set it to "(?:)" instead as
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2776 Context* native_context = 2784 Context* native_context =
2777 function->context()->global_object()->native_context(); 2785 function->context()->global_object()->native_context();
2778 return native_context->global_object()->global_receiver(); 2786 return native_context->global_object()->global_receiver();
2779 } 2787 }
2780 2788
2781 2789
2782 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MaterializeRegExpLiteral) { 2790 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MaterializeRegExpLiteral) {
2783 HandleScope scope(isolate); 2791 HandleScope scope(isolate);
2784 ASSERT(args.length() == 4); 2792 ASSERT(args.length() == 4);
2785 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 2793 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
2786 int index = args.smi_at(1); 2794 CONVERT_SMI_ARG_CHECKED(index, 1);
2787 Handle<String> pattern = args.at<String>(2); 2795 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2);
2788 Handle<String> flags = args.at<String>(3); 2796 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3);
2789 2797
2790 // Get the RegExp function from the context in the literals array. 2798 // Get the RegExp function from the context in the literals array.
2791 // This is the RegExp function from the context in which the 2799 // This is the RegExp function from the context in which the
2792 // function was created. We do not use the RegExp function from the 2800 // function was created. We do not use the RegExp function from the
2793 // current native context because this might be the RegExp function 2801 // current native context because this might be the RegExp function
2794 // from another context which we should not have access to. 2802 // from another context which we should not have access to.
2795 Handle<JSFunction> constructor = 2803 Handle<JSFunction> constructor =
2796 Handle<JSFunction>( 2804 Handle<JSFunction>(
2797 JSFunction::NativeContextFromLiterals(*literals)->regexp_function()); 2805 JSFunction::NativeContextFromLiterals(*literals)->regexp_function());
2798 // Compute the regular expression literal. 2806 // Compute the regular expression literal.
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
3001 CONVERT_ARG_CHECKED(JSFunction, f, 0); 3009 CONVERT_ARG_CHECKED(JSFunction, f, 0);
3002 return isolate->heap()->ToBoolean(f->IsBuiltin()); 3010 return isolate->heap()->ToBoolean(f->IsBuiltin());
3003 } 3011 }
3004 3012
3005 3013
3006 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { 3014 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) {
3007 HandleScope scope(isolate); 3015 HandleScope scope(isolate);
3008 ASSERT(args.length() == 2); 3016 ASSERT(args.length() == 2);
3009 3017
3010 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); 3018 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0);
3011 Handle<Object> code = args.at<Object>(1); 3019 CONVERT_ARG_HANDLE_CHECKED(Object, code, 1);
3012 3020
3013 if (code->IsNull()) return *target; 3021 if (code->IsNull()) return *target;
3014 RUNTIME_ASSERT(code->IsJSFunction()); 3022 RUNTIME_ASSERT(code->IsJSFunction());
3015 Handle<JSFunction> source = Handle<JSFunction>::cast(code); 3023 Handle<JSFunction> source = Handle<JSFunction>::cast(code);
3016 Handle<SharedFunctionInfo> target_shared(target->shared()); 3024 Handle<SharedFunctionInfo> target_shared(target->shared());
3017 Handle<SharedFunctionInfo> source_shared(source->shared()); 3025 Handle<SharedFunctionInfo> source_shared(source->shared());
3018 3026
3019 if (!Compiler::EnsureCompiled(source, KEEP_EXCEPTION)) { 3027 if (!Compiler::EnsureCompiled(source, KEEP_EXCEPTION)) {
3020 return Failure::Exception(); 3028 return Failure::Exception();
3021 } 3029 }
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3256 } 3264 }
3257 3265
3258 return Smi::FromInt(subject->Get(i)); 3266 return Smi::FromInt(subject->Get(i));
3259 } 3267 }
3260 3268
3261 3269
3262 RUNTIME_FUNCTION(MaybeObject*, Runtime_CharFromCode) { 3270 RUNTIME_FUNCTION(MaybeObject*, Runtime_CharFromCode) {
3263 HandleScope handlescope(isolate); 3271 HandleScope handlescope(isolate);
3264 ASSERT(args.length() == 1); 3272 ASSERT(args.length() == 1);
3265 if (args[0]->IsNumber()) { 3273 if (args[0]->IsNumber()) {
3266 uint32_t code = NumberToUint32(args[0]) & 0xffff; 3274 CONVERT_NUMBER_CHECKED(uint32_t, code, Uint32, args[0]);
3275 code &= 0xffff;
3267 return *isolate->factory()->LookupSingleCharacterStringFromCode(code); 3276 return *isolate->factory()->LookupSingleCharacterStringFromCode(code);
3268 } 3277 }
3269 return isolate->heap()->empty_string(); 3278 return isolate->heap()->empty_string();
3270 } 3279 }
3271 3280
3272 3281
3273 class FixedArrayBuilder { 3282 class FixedArrayBuilder {
3274 public: 3283 public:
3275 explicit FixedArrayBuilder(Isolate* isolate, int initial_capacity) 3284 explicit FixedArrayBuilder(Isolate* isolate, int initial_capacity)
3276 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)), 3285 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)),
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
4354 start_index); 4363 start_index);
4355 } 4364 }
4356 4365
4357 4366
4358 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringIndexOf) { 4367 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringIndexOf) {
4359 HandleScope scope(isolate); 4368 HandleScope scope(isolate);
4360 ASSERT(args.length() == 3); 4369 ASSERT(args.length() == 3);
4361 4370
4362 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); 4371 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0);
4363 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); 4372 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1);
4373 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2);
4364 4374
4365 Object* index = args[2];
4366 uint32_t start_index; 4375 uint32_t start_index;
4367 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); 4376 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1);
4368 4377
4369 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length())); 4378 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length()));
4370 int position = Runtime::StringMatch(isolate, sub, pat, start_index); 4379 int position = Runtime::StringMatch(isolate, sub, pat, start_index);
4371 return Smi::FromInt(position); 4380 return Smi::FromInt(position);
4372 } 4381 }
4373 4382
4374 4383
4375 template <typename schar, typename pchar> 4384 template <typename schar, typename pchar>
(...skipping 30 matching lines...) Expand all
4406 return -1; 4415 return -1;
4407 } 4416 }
4408 4417
4409 4418
4410 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) { 4419 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) {
4411 HandleScope scope(isolate); 4420 HandleScope scope(isolate);
4412 ASSERT(args.length() == 3); 4421 ASSERT(args.length() == 3);
4413 4422
4414 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); 4423 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0);
4415 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); 4424 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1);
4425 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2);
4416 4426
4417 Object* index = args[2];
4418 uint32_t start_index; 4427 uint32_t start_index;
4419 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); 4428 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1);
4420 4429
4421 uint32_t pat_length = pat->length(); 4430 uint32_t pat_length = pat->length();
4422 uint32_t sub_length = sub->length(); 4431 uint32_t sub_length = sub->length();
4423 4432
4424 if (start_index + pat_length > sub_length) { 4433 if (start_index + pat_length > sub_length) {
4425 start_index = sub_length - pat_length; 4434 start_index = sub_length - pat_length;
4426 } 4435 }
4427 4436
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
4533 RUNTIME_ASSERT(start >= 0); 4542 RUNTIME_ASSERT(start >= 0);
4534 RUNTIME_ASSERT(end <= string->length()); 4543 RUNTIME_ASSERT(end <= string->length());
4535 isolate->counters()->sub_string_runtime()->Increment(); 4544 isolate->counters()->sub_string_runtime()->Increment();
4536 4545
4537 return *isolate->factory()->NewSubString(string, start, end); 4546 return *isolate->factory()->NewSubString(string, start, end);
4538 } 4547 }
4539 4548
4540 4549
4541 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { 4550 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) {
4542 HandleScope handles(isolate); 4551 HandleScope handles(isolate);
4543 ASSERT_EQ(3, args.length()); 4552 ASSERT(args.length() == 3);
4544 4553
4545 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 4554 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
4546 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); 4555 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
4547 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); 4556 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2);
4548 4557
4549 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); 4558 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate);
4550 if (global_cache.HasException()) return Failure::Exception(); 4559 if (global_cache.HasException()) return Failure::Exception();
4551 4560
4552 int capture_count = regexp->CaptureCount(); 4561 int capture_count = regexp->CaptureCount();
4553 4562
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
4961 } else { 4970 } else {
4962 return Object::GetProperty(object, name); 4971 return Object::GetProperty(object, name);
4963 } 4972 }
4964 } 4973 }
4965 4974
4966 4975
4967 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { 4976 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) {
4968 HandleScope scope(isolate); 4977 HandleScope scope(isolate);
4969 ASSERT(args.length() == 2); 4978 ASSERT(args.length() == 2);
4970 4979
4971 Handle<Object> object = args.at<Object>(0); 4980 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
4972 Handle<Object> key = args.at<Object>(1); 4981 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
4973 Handle<Object> result; 4982 Handle<Object> result;
4974 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 4983 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
4975 isolate, result, 4984 isolate, result,
4976 Runtime::GetObjectProperty(isolate, object, key)); 4985 Runtime::GetObjectProperty(isolate, object, key));
4977 return *result; 4986 return *result;
4978 } 4987 }
4979 4988
4980 4989
4981 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. 4990 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric.
4982 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { 4991 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) {
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
5454 JSFunction* func = JSFunction::cast(object); 5463 JSFunction* func = JSFunction::cast(object);
5455 func->shared()->set_native(true); 5464 func->shared()->set_native(true);
5456 } 5465 }
5457 return isolate->heap()->undefined_value(); 5466 return isolate->heap()->undefined_value();
5458 } 5467 }
5459 5468
5460 5469
5461 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInlineBuiltinFlag) { 5470 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInlineBuiltinFlag) {
5462 SealHandleScope shs(isolate); 5471 SealHandleScope shs(isolate);
5463 RUNTIME_ASSERT(args.length() == 1); 5472 RUNTIME_ASSERT(args.length() == 1);
5464 5473 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
5465 Handle<Object> object = args.at<Object>(0);
5466 5474
5467 if (object->IsJSFunction()) { 5475 if (object->IsJSFunction()) {
5468 JSFunction* func = JSFunction::cast(*object); 5476 JSFunction* func = JSFunction::cast(*object);
5469 func->shared()->set_inline_builtin(true); 5477 func->shared()->set_inline_builtin(true);
5470 } 5478 }
5471 return isolate->heap()->undefined_value(); 5479 return isolate->heap()->undefined_value();
5472 } 5480 }
5473 5481
5474 5482
5475 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) { 5483 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) {
5476 HandleScope scope(isolate); 5484 HandleScope scope(isolate);
5477 RUNTIME_ASSERT(args.length() == 5); 5485 RUNTIME_ASSERT(args.length() == 5);
5478 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 5486 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
5479 CONVERT_SMI_ARG_CHECKED(store_index, 1); 5487 CONVERT_SMI_ARG_CHECKED(store_index, 1);
5480 Handle<Object> value = args.at<Object>(2); 5488 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
5481 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3); 5489 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3);
5482 CONVERT_SMI_ARG_CHECKED(literal_index, 4); 5490 CONVERT_SMI_ARG_CHECKED(literal_index, 4);
5483 5491
5484 Object* raw_literal_cell = literals->get(literal_index); 5492 Object* raw_literal_cell = literals->get(literal_index);
5485 JSArray* boilerplate = NULL; 5493 JSArray* boilerplate = NULL;
5486 if (raw_literal_cell->IsAllocationSite()) { 5494 if (raw_literal_cell->IsAllocationSite()) {
5487 AllocationSite* site = AllocationSite::cast(raw_literal_cell); 5495 AllocationSite* site = AllocationSite::cast(raw_literal_cell);
5488 boilerplate = JSArray::cast(site->transition_info()); 5496 boilerplate = JSArray::cast(site->transition_info());
5489 } else { 5497 } else {
5490 boilerplate = JSArray::cast(raw_literal_cell); 5498 boilerplate = JSArray::cast(raw_literal_cell);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
5527 } 5535 }
5528 return *object; 5536 return *object;
5529 } 5537 }
5530 5538
5531 5539
5532 // Check whether debugger and is about to step into the callback that is passed 5540 // Check whether debugger and is about to step into the callback that is passed
5533 // to a built-in function such as Array.forEach. 5541 // to a built-in function such as Array.forEach.
5534 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugCallbackSupportsStepping) { 5542 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugCallbackSupportsStepping) {
5535 SealHandleScope shs(isolate); 5543 SealHandleScope shs(isolate);
5536 #ifdef ENABLE_DEBUGGER_SUPPORT 5544 #ifdef ENABLE_DEBUGGER_SUPPORT
5545 ASSERT(args.length() == 1);
5537 if (!isolate->IsDebuggerActive() || !isolate->debug()->StepInActive()) { 5546 if (!isolate->IsDebuggerActive() || !isolate->debug()->StepInActive()) {
5538 return isolate->heap()->false_value(); 5547 return isolate->heap()->false_value();
5539 } 5548 }
5540 CONVERT_ARG_CHECKED(Object, callback, 0); 5549 CONVERT_ARG_CHECKED(Object, callback, 0);
5541 // We do not step into the callback if it's a builtin or not even a function. 5550 // We do not step into the callback if it's a builtin or not even a function.
5542 if (!callback->IsJSFunction() || JSFunction::cast(callback)->IsBuiltin()) { 5551 if (!callback->IsJSFunction() || JSFunction::cast(callback)->IsBuiltin()) {
5543 return isolate->heap()->false_value(); 5552 return isolate->heap()->false_value();
5544 } 5553 }
5545 return isolate->heap()->true_value(); 5554 return isolate->heap()->true_value();
5546 #else 5555 #else
5547 return isolate->heap()->false_value(); 5556 return isolate->heap()->false_value();
5548 #endif // ENABLE_DEBUGGER_SUPPORT 5557 #endif // ENABLE_DEBUGGER_SUPPORT
5549 } 5558 }
5550 5559
5551 5560
5552 // Set one shot breakpoints for the callback function that is passed to a 5561 // Set one shot breakpoints for the callback function that is passed to a
5553 // built-in function such as Array.forEach to enable stepping into the callback. 5562 // built-in function such as Array.forEach to enable stepping into the callback.
5554 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrepareStepInIfStepping) { 5563 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrepareStepInIfStepping) {
5555 SealHandleScope shs(isolate); 5564 SealHandleScope shs(isolate);
5556 #ifdef ENABLE_DEBUGGER_SUPPORT 5565 #ifdef ENABLE_DEBUGGER_SUPPORT
5566 ASSERT(args.length() == 1);
5557 Debug* debug = isolate->debug(); 5567 Debug* debug = isolate->debug();
5558 if (!debug->IsStepping()) return isolate->heap()->undefined_value(); 5568 if (!debug->IsStepping()) return isolate->heap()->undefined_value();
5559 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0); 5569 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0);
5560 HandleScope scope(isolate); 5570 HandleScope scope(isolate);
5561 // When leaving the callback, step out has been activated, but not performed 5571 // When leaving the callback, step out has been activated, but not performed
5562 // if we do not leave the builtin. To be able to step into the callback 5572 // if we do not leave the builtin. To be able to step into the callback
5563 // again, we need to clear the step out at this point. 5573 // again, we need to clear the step out at this point.
5564 debug->ClearStepOut(); 5574 debug->ClearStepOut();
5565 debug->FloodWithOneShot(callback); 5575 debug->FloodWithOneShot(callback);
5566 #endif // ENABLE_DEBUGGER_SUPPORT 5576 #endif // ENABLE_DEBUGGER_SUPPORT
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
5627 key); 5637 key);
5628 } 5638 }
5629 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5639 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5630 return isolate->heap()->false_value(); 5640 return isolate->heap()->false_value();
5631 } 5641 }
5632 5642
5633 5643
5634 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { 5644 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) {
5635 HandleScope scope(isolate); 5645 HandleScope scope(isolate);
5636 ASSERT(args.length() == 2); 5646 ASSERT(args.length() == 2);
5647 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0)
5637 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); 5648 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
5638 Handle<Object> object = args.at<Object>(0);
5639 5649
5640 uint32_t index; 5650 uint32_t index;
5641 const bool key_is_array_index = key->AsArrayIndex(&index); 5651 const bool key_is_array_index = key->AsArrayIndex(&index);
5642 5652
5643 // Only JS objects can have properties. 5653 // Only JS objects can have properties.
5644 if (object->IsJSObject()) { 5654 if (object->IsJSObject()) {
5645 Handle<JSObject> js_obj = Handle<JSObject>::cast(object); 5655 Handle<JSObject> js_obj = Handle<JSObject>::cast(object);
5646 // Fast case: either the key is a real named property or it is not 5656 // Fast case: either the key is a real named property or it is not
5647 // an array index and there are no interceptors or hidden 5657 // an array index and there are no interceptors or hidden
5648 // prototypes. 5658 // prototypes.
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
5946 if (obj->HasIndexedInterceptor()) { 5956 if (obj->HasIndexedInterceptor()) {
5947 v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj); 5957 v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj);
5948 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); 5958 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result);
5949 } 5959 }
5950 return isolate->heap()->undefined_value(); 5960 return isolate->heap()->undefined_value();
5951 } 5961 }
5952 5962
5953 5963
5954 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) { 5964 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) {
5955 HandleScope scope(isolate); 5965 HandleScope scope(isolate);
5956 ASSERT_EQ(args.length(), 1); 5966 ASSERT(args.length() == 1);
5957 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); 5967 CONVERT_ARG_CHECKED(JSObject, raw_object, 0);
5958 Handle<JSObject> object(raw_object); 5968 Handle<JSObject> object(raw_object);
5959 5969
5960 if (object->IsJSGlobalProxy()) { 5970 if (object->IsJSGlobalProxy()) {
5961 // Do access checks before going to the global object. 5971 // Do access checks before going to the global object.
5962 if (object->IsAccessCheckNeeded() && 5972 if (object->IsAccessCheckNeeded() &&
5963 !isolate->MayNamedAccess( 5973 !isolate->MayNamedAccess(
5964 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { 5974 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) {
5965 isolate->ReportFailedAccessCheck(object, v8::ACCESS_KEYS); 5975 isolate->ReportFailedAccessCheck(object, v8::ACCESS_KEYS);
5966 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5976 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
(...skipping 28 matching lines...) Expand all
5995 copy->set(i, *entry_str); 6005 copy->set(i, *entry_str);
5996 } 6006 }
5997 } 6007 }
5998 return *isolate->factory()->NewJSArrayWithElements(copy); 6008 return *isolate->factory()->NewJSArrayWithElements(copy);
5999 } 6009 }
6000 6010
6001 6011
6002 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) { 6012 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) {
6003 SealHandleScope shs(isolate); 6013 SealHandleScope shs(isolate);
6004 ASSERT(args.length() == 1); 6014 ASSERT(args.length() == 1);
6015 CONVERT_ARG_HANDLE_CHECKED(Object, raw_key, 0);
6005 6016
6006 // Compute the frame holding the arguments. 6017 // Compute the frame holding the arguments.
6007 JavaScriptFrameIterator it(isolate); 6018 JavaScriptFrameIterator it(isolate);
6008 it.AdvanceToArgumentsFrame(); 6019 it.AdvanceToArgumentsFrame();
6009 JavaScriptFrame* frame = it.frame(); 6020 JavaScriptFrame* frame = it.frame();
6010 6021
6011 // Get the actual number of provided arguments. 6022 // Get the actual number of provided arguments.
6012 const uint32_t n = frame->ComputeParametersCount(); 6023 const uint32_t n = frame->ComputeParametersCount();
6013 6024
6014 // Try to convert the key to an index. If successful and within 6025 // Try to convert the key to an index. If successful and within
6015 // index return the the argument from the frame. 6026 // index return the the argument from the frame.
6016 uint32_t index; 6027 uint32_t index;
6017 if (args[0]->ToArrayIndex(&index) && index < n) { 6028 if (raw_key->ToArrayIndex(&index) && index < n) {
6018 return frame->GetParameter(index); 6029 return frame->GetParameter(index);
6019 } 6030 }
6020 6031
6021 HandleScope scope(isolate); 6032 HandleScope scope(isolate);
6022 if (args[0]->IsSymbol()) { 6033 if (raw_key->IsSymbol()) {
6023 // Lookup in the initial Object.prototype object. 6034 // Lookup in the initial Object.prototype object.
6024 Handle<Object> result; 6035 Handle<Object> result;
6025 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 6036 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
6026 isolate, result, 6037 isolate, result,
6027 Object::GetProperty( 6038 Object::GetProperty(isolate->initial_object_prototype(),
6028 isolate->initial_object_prototype(), args.at<Symbol>(0))); 6039 Handle<Symbol>::cast(raw_key)));
6029 return *result; 6040 return *result;
6030 } 6041 }
6031 6042
6032 // Convert the key to a string. 6043 // Convert the key to a string.
6033 Handle<Object> converted; 6044 Handle<Object> converted;
6034 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 6045 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
6035 isolate, converted, Execution::ToString(isolate, args.at<Object>(0))); 6046 isolate, converted, Execution::ToString(isolate, raw_key));
6036 Handle<String> key = Handle<String>::cast(converted); 6047 Handle<String> key = Handle<String>::cast(converted);
6037 6048
6038 // Try to convert the string key into an array index. 6049 // Try to convert the string key into an array index.
6039 if (key->AsArrayIndex(&index)) { 6050 if (key->AsArrayIndex(&index)) {
6040 if (index < n) { 6051 if (index < n) {
6041 return frame->GetParameter(index); 6052 return frame->GetParameter(index);
6042 } else { 6053 } else {
6043 Handle<Object> initial_prototype(isolate->initial_object_prototype()); 6054 Handle<Object> initial_prototype(isolate->initial_object_prototype());
6044 Handle<Object> result; 6055 Handle<Object> result;
6045 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 6056 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
6078 if (object->IsJSObject() && !object->IsGlobalObject()) { 6089 if (object->IsJSObject() && !object->IsGlobalObject()) {
6079 JSObject::TransformToFastProperties(Handle<JSObject>::cast(object), 0); 6090 JSObject::TransformToFastProperties(Handle<JSObject>::cast(object), 0);
6080 } 6091 }
6081 return *object; 6092 return *object;
6082 } 6093 }
6083 6094
6084 6095
6085 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { 6096 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) {
6086 SealHandleScope shs(isolate); 6097 SealHandleScope shs(isolate);
6087 ASSERT(args.length() == 1); 6098 ASSERT(args.length() == 1);
6099 CONVERT_ARG_CHECKED(Object, object, 0);
6088 6100
6089 return isolate->heap()->ToBoolean(args[0]->BooleanValue()); 6101 return isolate->heap()->ToBoolean(object->BooleanValue());
6090 } 6102 }
6091 6103
6092 6104
6093 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). 6105 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47).
6094 // Possible optimizations: put the type string into the oddballs. 6106 // Possible optimizations: put the type string into the oddballs.
6095 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { 6107 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) {
6096 SealHandleScope shs(isolate); 6108 SealHandleScope shs(isolate);
6097 6109 ASSERT(args.length() == 1);
6098 Object* obj = args[0]; 6110 CONVERT_ARG_CHECKED(Object, obj, 0);
6099 if (obj->IsNumber()) return isolate->heap()->number_string(); 6111 if (obj->IsNumber()) return isolate->heap()->number_string();
6100 HeapObject* heap_obj = HeapObject::cast(obj); 6112 HeapObject* heap_obj = HeapObject::cast(obj);
6101 6113
6102 // typeof an undetectable object is 'undefined' 6114 // typeof an undetectable object is 'undefined'
6103 if (heap_obj->map()->is_undetectable()) { 6115 if (heap_obj->map()->is_undetectable()) {
6104 return isolate->heap()->undefined_string(); 6116 return isolate->heap()->undefined_string();
6105 } 6117 }
6106 6118
6107 InstanceType instance_type = heap_obj->map()->instance_type(); 6119 InstanceType instance_type = heap_obj->map()->instance_type();
6108 if (instance_type < FIRST_NONSTRING_TYPE) { 6120 if (instance_type < FIRST_NONSTRING_TYPE) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
6214 flags |= ALLOW_OCTAL | ALLOW_BINARY; 6226 flags |= ALLOW_OCTAL | ALLOW_BINARY;
6215 } 6227 }
6216 6228
6217 return *isolate->factory()->NewNumber(StringToDouble( 6229 return *isolate->factory()->NewNumber(StringToDouble(
6218 isolate->unicode_cache(), *subject, flags)); 6230 isolate->unicode_cache(), *subject, flags));
6219 } 6231 }
6220 6232
6221 6233
6222 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewString) { 6234 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewString) {
6223 SealHandleScope shs(isolate); 6235 SealHandleScope shs(isolate);
6236 ASSERT(args.length() == 2);
6224 CONVERT_SMI_ARG_CHECKED(length, 0); 6237 CONVERT_SMI_ARG_CHECKED(length, 0);
6225 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1); 6238 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1);
6226 if (length == 0) return isolate->heap()->empty_string(); 6239 if (length == 0) return isolate->heap()->empty_string();
6227 if (is_one_byte) { 6240 if (is_one_byte) {
6228 return isolate->heap()->AllocateRawOneByteString(length); 6241 return isolate->heap()->AllocateRawOneByteString(length);
6229 } else { 6242 } else {
6230 return isolate->heap()->AllocateRawTwoByteString(length); 6243 return isolate->heap()->AllocateRawTwoByteString(length);
6231 } 6244 }
6232 } 6245 }
6233 6246
6234 6247
6235 RUNTIME_FUNCTION(MaybeObject*, Runtime_TruncateString) { 6248 RUNTIME_FUNCTION(MaybeObject*, Runtime_TruncateString) {
6236 HandleScope scope(isolate); 6249 HandleScope scope(isolate);
6250 ASSERT(args.length() == 2);
6237 CONVERT_ARG_HANDLE_CHECKED(SeqString, string, 0); 6251 CONVERT_ARG_HANDLE_CHECKED(SeqString, string, 0);
6238 CONVERT_SMI_ARG_CHECKED(new_length, 1); 6252 CONVERT_SMI_ARG_CHECKED(new_length, 1);
6239 return *SeqString::Truncate(string, new_length); 6253 return *SeqString::Truncate(string, new_length);
6240 } 6254 }
6241 6255
6242 6256
6243 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) { 6257 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) {
6244 HandleScope scope(isolate); 6258 HandleScope scope(isolate);
6245 ASSERT(args.length() == 1); 6259 ASSERT(args.length() == 1);
6246 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); 6260 CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
(...skipping 29 matching lines...) Expand all
6276 HandleScope scope(isolate); 6290 HandleScope scope(isolate);
6277 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); 6291 CONVERT_ARG_HANDLE_CHECKED(String, string, 0);
6278 ASSERT(args.length() == 1); 6292 ASSERT(args.length() == 1);
6279 return BasicJsonStringifier::StringifyString(isolate, string); 6293 return BasicJsonStringifier::StringifyString(isolate, string);
6280 } 6294 }
6281 6295
6282 6296
6283 RUNTIME_FUNCTION(MaybeObject*, Runtime_BasicJSONStringify) { 6297 RUNTIME_FUNCTION(MaybeObject*, Runtime_BasicJSONStringify) {
6284 HandleScope scope(isolate); 6298 HandleScope scope(isolate);
6285 ASSERT(args.length() == 1); 6299 ASSERT(args.length() == 1);
6300 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
6286 BasicJsonStringifier stringifier(isolate); 6301 BasicJsonStringifier stringifier(isolate);
6287 return stringifier.Stringify(Handle<Object>(args[0], isolate)); 6302 return stringifier.Stringify(object);
6288 } 6303 }
6289 6304
6290 6305
6291 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { 6306 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) {
6292 HandleScope handle_scope(isolate); 6307 HandleScope handle_scope(isolate);
6308 ASSERT(args.length() == 2);
6293 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 6309 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
6294 CONVERT_NUMBER_CHECKED(int, radix, Int32, args[1]); 6310 CONVERT_NUMBER_CHECKED(int, radix, Int32, args[1]);
6295 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); 6311 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36));
6296 6312
6297 subject = String::Flatten(subject); 6313 subject = String::Flatten(subject);
6298 double value; 6314 double value;
6299 6315
6300 { DisallowHeapAllocation no_gc; 6316 { DisallowHeapAllocation no_gc;
6301 String::FlatContent flat = subject->GetFlatContent(); 6317 String::FlatContent flat = subject->GetFlatContent();
6302 6318
6303 // ECMA-262 section 15.1.2.3, empty string is NaN 6319 // ECMA-262 section 15.1.2.3, empty string is NaN
6304 if (flat.IsAscii()) { 6320 if (flat.IsAscii()) {
6305 value = StringToInt( 6321 value = StringToInt(
6306 isolate->unicode_cache(), flat.ToOneByteVector(), radix); 6322 isolate->unicode_cache(), flat.ToOneByteVector(), radix);
6307 } else { 6323 } else {
6308 value = StringToInt( 6324 value = StringToInt(
6309 isolate->unicode_cache(), flat.ToUC16Vector(), radix); 6325 isolate->unicode_cache(), flat.ToUC16Vector(), radix);
6310 } 6326 }
6311 } 6327 }
6312 6328
6313 return *isolate->factory()->NewNumber(value); 6329 return *isolate->factory()->NewNumber(value);
6314 } 6330 }
6315 6331
6316 6332
6317 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { 6333 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) {
6318 HandleScope shs(isolate); 6334 HandleScope shs(isolate);
6335 ASSERT(args.length() == 1);
6319 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 6336 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
6320 6337
6321 subject = String::Flatten(subject); 6338 subject = String::Flatten(subject);
6322 double value = StringToDouble( 6339 double value = StringToDouble(
6323 isolate->unicode_cache(), *subject, ALLOW_TRAILING_JUNK, OS::nan_value()); 6340 isolate->unicode_cache(), *subject, ALLOW_TRAILING_JUNK, OS::nan_value());
6324 6341
6325 return *isolate->factory()->NewNumber(value); 6342 return *isolate->factory()->NewNumber(value);
6326 } 6343 }
6327 6344
6328 6345
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
6553 6570
6554 *changed_out = changed; 6571 *changed_out = changed;
6555 return true; 6572 return true;
6556 } 6573 }
6557 6574
6558 } // namespace 6575 } // namespace
6559 6576
6560 6577
6561 template <class Converter> 6578 template <class Converter>
6562 MUST_USE_RESULT static MaybeObject* ConvertCase( 6579 MUST_USE_RESULT static MaybeObject* ConvertCase(
6563 Arguments args, 6580 Handle<String> s,
6564 Isolate* isolate, 6581 Isolate* isolate,
6565 unibrow::Mapping<Converter, 128>* mapping) { 6582 unibrow::Mapping<Converter, 128>* mapping) {
6566 HandleScope handle_scope(isolate);
6567 CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
6568 s = String::Flatten(s); 6583 s = String::Flatten(s);
6569 int length = s->length(); 6584 int length = s->length();
6570 // Assume that the string is not empty; we need this assumption later 6585 // Assume that the string is not empty; we need this assumption later
6571 if (length == 0) return *s; 6586 if (length == 0) return *s;
6572 6587
6573 // Simpler handling of ASCII strings. 6588 // Simpler handling of ASCII strings.
6574 // 6589 //
6575 // NOTE: This assumes that the upper/lower case of an ASCII 6590 // NOTE: This assumes that the upper/lower case of an ASCII
6576 // character is also ASCII. This is currently the case, but it 6591 // character is also ASCII. This is currently the case, but it
6577 // might break in the future if we implement more context and locale 6592 // might break in the future if we implement more context and locale
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6613 } else { 6628 } else {
6614 if (length < 0) length = -length; 6629 if (length < 0) length = -length;
6615 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 6630 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
6616 isolate, result, isolate->factory()->NewRawTwoByteString(length)); 6631 isolate, result, isolate->factory()->NewRawTwoByteString(length));
6617 } 6632 }
6618 return ConvertCaseHelper(isolate, *s, *result, length, mapping); 6633 return ConvertCaseHelper(isolate, *s, *result, length, mapping);
6619 } 6634 }
6620 6635
6621 6636
6622 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToLowerCase) { 6637 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToLowerCase) {
6638 HandleScope scope(isolate);
6639 ASSERT(args.length() == 1);
6640 CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
6623 return ConvertCase( 6641 return ConvertCase(
6624 args, isolate, isolate->runtime_state()->to_lower_mapping()); 6642 s, isolate, isolate->runtime_state()->to_lower_mapping());
6625 } 6643 }
6626 6644
6627 6645
6628 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToUpperCase) { 6646 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToUpperCase) {
6647 HandleScope scope(isolate);
6648 ASSERT(args.length() == 1);
6649 CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
6629 return ConvertCase( 6650 return ConvertCase(
6630 args, isolate, isolate->runtime_state()->to_upper_mapping()); 6651 s, isolate, isolate->runtime_state()->to_upper_mapping());
6631 } 6652 }
6632 6653
6633 6654
6634 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { 6655 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) {
6635 HandleScope scope(isolate); 6656 HandleScope scope(isolate);
6636 ASSERT(args.length() == 3); 6657 ASSERT(args.length() == 3);
6637 6658
6638 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); 6659 CONVERT_ARG_HANDLE_CHECKED(String, string, 0);
6639 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); 6660 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1);
6640 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); 6661 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
6853 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { 6874 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) {
6854 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; 6875 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth];
6855 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); 6876 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars);
6856 return char_length == 0; 6877 return char_length == 0;
6857 } 6878 }
6858 6879
6859 6880
6860 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToString) { 6881 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToString) {
6861 HandleScope scope(isolate); 6882 HandleScope scope(isolate);
6862 ASSERT(args.length() == 1); 6883 ASSERT(args.length() == 1);
6863 6884 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0);
6864 Handle<Object> number = args.at<Object>(0);
6865 RUNTIME_ASSERT(number->IsNumber());
6866 6885
6867 return *isolate->factory()->NumberToString(number); 6886 return *isolate->factory()->NumberToString(number);
6868 } 6887 }
6869 6888
6870 6889
6871 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToStringSkipCache) { 6890 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToStringSkipCache) {
6872 HandleScope scope(isolate); 6891 HandleScope scope(isolate);
6873 ASSERT(args.length() == 1); 6892 ASSERT(args.length() == 1);
6874 6893 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0);
6875 Handle<Object> number = args.at<Object>(0);
6876 RUNTIME_ASSERT(number->IsNumber());
6877 6894
6878 return *isolate->factory()->NumberToString(number, false); 6895 return *isolate->factory()->NumberToString(number, false);
6879 } 6896 }
6880 6897
6881 6898
6882 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { 6899 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) {
6883 HandleScope scope(isolate); 6900 HandleScope scope(isolate);
6884 ASSERT(args.length() == 1); 6901 ASSERT(args.length() == 1);
6885 6902
6886 CONVERT_DOUBLE_ARG_CHECKED(number, 0); 6903 CONVERT_DOUBLE_ARG_CHECKED(number, 0);
(...skipping 30 matching lines...) Expand all
6917 CONVERT_DOUBLE_ARG_CHECKED(number, 0); 6934 CONVERT_DOUBLE_ARG_CHECKED(number, 0);
6918 return *isolate->factory()->NewNumberFromInt(DoubleToInt32(number)); 6935 return *isolate->factory()->NewNumberFromInt(DoubleToInt32(number));
6919 } 6936 }
6920 6937
6921 6938
6922 // Converts a Number to a Smi, if possible. Returns NaN if the number is not 6939 // Converts a Number to a Smi, if possible. Returns NaN if the number is not
6923 // a small integer. 6940 // a small integer.
6924 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToSmi) { 6941 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToSmi) {
6925 SealHandleScope shs(isolate); 6942 SealHandleScope shs(isolate);
6926 ASSERT(args.length() == 1); 6943 ASSERT(args.length() == 1);
6927 6944 CONVERT_ARG_CHECKED(Object, obj, 0);
6928 Object* obj = args[0];
6929 if (obj->IsSmi()) { 6945 if (obj->IsSmi()) {
6930 return obj; 6946 return obj;
6931 } 6947 }
6932 if (obj->IsHeapNumber()) { 6948 if (obj->IsHeapNumber()) {
6933 double value = HeapNumber::cast(obj)->value(); 6949 double value = HeapNumber::cast(obj)->value();
6934 int int_value = FastD2I(value); 6950 int int_value = FastD2I(value);
6935 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { 6951 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) {
6936 return Smi::FromInt(int_value); 6952 return Smi::FromInt(int_value);
6937 } 6953 }
6938 } 6954 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
7066 } 7082 }
7067 } 7083 }
7068 } 7084 }
7069 7085
7070 7086
7071 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { 7087 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) {
7072 HandleScope scope(isolate); 7088 HandleScope scope(isolate);
7073 ASSERT(args.length() == 3); 7089 ASSERT(args.length() == 3);
7074 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); 7090 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
7075 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); 7091 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength();
7076 int array_length = args.smi_at(1); 7092 CONVERT_SMI_ARG_CHECKED(array_length, 1);
7077 CONVERT_ARG_HANDLE_CHECKED(String, special, 2); 7093 CONVERT_ARG_HANDLE_CHECKED(String, special, 2);
7078 7094
7079 // This assumption is used by the slice encoding in one or two smis. 7095 // This assumption is used by the slice encoding in one or two smis.
7080 ASSERT(Smi::kMaxValue >= String::kMaxLength); 7096 ASSERT(Smi::kMaxValue >= String::kMaxLength);
7081 7097
7082 JSObject::EnsureCanContainHeapObjectElements(array); 7098 JSObject::EnsureCanContainHeapObjectElements(array);
7083 7099
7084 int special_length = special->length(); 7100 int special_length = special->length();
7085 if (!array->HasFastObjectElements()) { 7101 if (!array->HasFastObjectElements()) {
7086 return isolate->Throw(isolate->heap()->illegal_argument_string()); 7102 return isolate->Throw(isolate->heap()->illegal_argument_string());
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
7178 return answer; 7194 return answer;
7179 } 7195 }
7180 } 7196 }
7181 7197
7182 7198
7183 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { 7199 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) {
7184 HandleScope scope(isolate); 7200 HandleScope scope(isolate);
7185 ASSERT(args.length() == 3); 7201 ASSERT(args.length() == 3);
7186 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); 7202 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
7187 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); 7203 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength();
7188 int array_length = args.smi_at(1); 7204 CONVERT_SMI_ARG_CHECKED(array_length, 1);
7189 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); 7205 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2);
7190 RUNTIME_ASSERT(array->HasFastObjectElements()); 7206 RUNTIME_ASSERT(array->HasFastObjectElements());
7191 7207
7192 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements())); 7208 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements()));
7193 if (fixed_array->length() < array_length) { 7209 if (fixed_array->length() < array_length) {
7194 array_length = fixed_array->length(); 7210 array_length = fixed_array->length();
7195 } 7211 }
7196 7212
7197 if (array_length == 0) { 7213 if (array_length == 0) {
7198 return isolate->heap()->empty_string(); 7214 return isolate->heap()->empty_string();
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
7885 } 7901 }
7886 date->SetValue(*value, is_value_nan); 7902 date->SetValue(*value, is_value_nan);
7887 return *value; 7903 return *value;
7888 } 7904 }
7889 7905
7890 7906
7891 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewArgumentsFast) { 7907 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewArgumentsFast) {
7892 HandleScope scope(isolate); 7908 HandleScope scope(isolate);
7893 ASSERT(args.length() == 3); 7909 ASSERT(args.length() == 3);
7894 7910
7895 Handle<JSFunction> callee = args.at<JSFunction>(0); 7911 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0);
7896 Object** parameters = reinterpret_cast<Object**>(args[1]); 7912 Object** parameters = reinterpret_cast<Object**>(args[1]);
7897 const int argument_count = Smi::cast(args[2])->value(); 7913 CONVERT_SMI_ARG_CHECKED(argument_count, 2);
7898 7914
7899 Handle<JSObject> result = 7915 Handle<JSObject> result =
7900 isolate->factory()->NewArgumentsObject(callee, argument_count); 7916 isolate->factory()->NewArgumentsObject(callee, argument_count);
7901 // Allocate the elements if needed. 7917 // Allocate the elements if needed.
7902 int parameter_count = callee->shared()->formal_parameter_count(); 7918 int parameter_count = callee->shared()->formal_parameter_count();
7903 if (argument_count > 0) { 7919 if (argument_count > 0) {
7904 if (parameter_count > 0) { 7920 if (parameter_count > 0) {
7905 int mapped_count = Min(argument_count, parameter_count); 7921 int mapped_count = Min(argument_count, parameter_count);
7906 Handle<FixedArray> parameter_map = 7922 Handle<FixedArray> parameter_map =
7907 isolate->factory()->NewFixedArray(mapped_count + 2, NOT_TENURED); 7923 isolate->factory()->NewFixedArray(mapped_count + 2, NOT_TENURED);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
8287 isolate->counters()->constructed_objects()->Increment(); 8303 isolate->counters()->constructed_objects()->Increment();
8288 isolate->counters()->constructed_objects_runtime()->Increment(); 8304 isolate->counters()->constructed_objects_runtime()->Increment();
8289 8305
8290 return *result; 8306 return *result;
8291 } 8307 }
8292 8308
8293 8309
8294 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewObject) { 8310 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewObject) {
8295 HandleScope scope(isolate); 8311 HandleScope scope(isolate);
8296 ASSERT(args.length() == 1); 8312 ASSERT(args.length() == 1);
8297 8313 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0);
8298 Handle<Object> constructor = args.at<Object>(0);
8299 return Runtime_NewObjectHelper(isolate, 8314 return Runtime_NewObjectHelper(isolate,
8300 constructor, 8315 constructor,
8301 Handle<AllocationSite>::null()); 8316 Handle<AllocationSite>::null());
8302 } 8317 }
8303 8318
8304 8319
8305 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewObjectWithAllocationSite) { 8320 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewObjectWithAllocationSite) {
8306 HandleScope scope(isolate); 8321 HandleScope scope(isolate);
8307 ASSERT(args.length() == 2); 8322 ASSERT(args.length() == 2);
8308 8323 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 1);
8309 Handle<Object> constructor = args.at<Object>(1); 8324 CONVERT_ARG_HANDLE_CHECKED(Object, feedback, 0);
8310 Handle<Object> feedback = args.at<Object>(0);
8311 Handle<AllocationSite> site; 8325 Handle<AllocationSite> site;
8312 if (feedback->IsAllocationSite()) { 8326 if (feedback->IsAllocationSite()) {
8313 // The feedback can be an AllocationSite or undefined. 8327 // The feedback can be an AllocationSite or undefined.
8314 site = Handle<AllocationSite>::cast(feedback); 8328 site = Handle<AllocationSite>::cast(feedback);
8315 } 8329 }
8316 return Runtime_NewObjectHelper(isolate, 8330 return Runtime_NewObjectHelper(isolate,
8317 constructor, 8331 constructor,
8318 site); 8332 site);
8319 } 8333 }
8320 8334
8321 8335
8322 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_FinalizeInstanceSize) { 8336 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_FinalizeInstanceSize) {
8323 HandleScope scope(isolate); 8337 HandleScope scope(isolate);
8324 ASSERT(args.length() == 1); 8338 ASSERT(args.length() == 1);
8325 8339
8326 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8340 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8327 function->shared()->CompleteInobjectSlackTracking(); 8341 function->shared()->CompleteInobjectSlackTracking();
8328 8342
8329 return isolate->heap()->undefined_value(); 8343 return isolate->heap()->undefined_value();
8330 } 8344 }
8331 8345
8332 8346
8333 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CompileUnoptimized) { 8347 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CompileUnoptimized) {
8334 HandleScope scope(isolate); 8348 HandleScope scope(isolate);
8335 ASSERT(args.length() == 1); 8349 ASSERT(args.length() == 1);
8336 8350 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8337 Handle<JSFunction> function = args.at<JSFunction>(0);
8338 #ifdef DEBUG 8351 #ifdef DEBUG
8339 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { 8352 if (FLAG_trace_lazy && !function->shared()->is_compiled()) {
8340 PrintF("[unoptimized: "); 8353 PrintF("[unoptimized: ");
8341 function->PrintName(); 8354 function->PrintName();
8342 PrintF("]\n"); 8355 PrintF("]\n");
8343 } 8356 }
8344 #endif 8357 #endif
8345 8358
8346 // Compile the target function. 8359 // Compile the target function.
8347 ASSERT(function->shared()->allows_lazy_compilation()); 8360 ASSERT(function->shared()->allows_lazy_compilation());
8348 8361
8349 Handle<Code> code = Compiler::GetUnoptimizedCode(function); 8362 Handle<Code> code = Compiler::GetUnoptimizedCode(function);
8350 RETURN_IF_EMPTY_HANDLE(isolate, code); 8363 RETURN_IF_EMPTY_HANDLE(isolate, code);
8351 function->ReplaceCode(*code); 8364 function->ReplaceCode(*code);
8352 8365
8353 // All done. Return the compiled code. 8366 // All done. Return the compiled code.
8354 ASSERT(function->is_compiled()); 8367 ASSERT(function->is_compiled());
8355 ASSERT(function->code()->kind() == Code::FUNCTION || 8368 ASSERT(function->code()->kind() == Code::FUNCTION ||
8356 (FLAG_always_opt && 8369 (FLAG_always_opt &&
8357 function->code()->kind() == Code::OPTIMIZED_FUNCTION)); 8370 function->code()->kind() == Code::OPTIMIZED_FUNCTION));
8358 return *code; 8371 return *code;
8359 } 8372 }
8360 8373
8361 8374
8362 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CompileOptimized) { 8375 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CompileOptimized) {
8363 HandleScope scope(isolate); 8376 HandleScope scope(isolate);
8364 ASSERT(args.length() == 2); 8377 ASSERT(args.length() == 2);
8365 Handle<JSFunction> function = args.at<JSFunction>(0); 8378 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8366 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1); 8379 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1);
8367 8380
8368 Handle<Code> unoptimized(function->shared()->code()); 8381 Handle<Code> unoptimized(function->shared()->code());
8369 if (!function->shared()->is_compiled()) { 8382 if (!function->shared()->is_compiled()) {
8370 // If the function is not compiled, do not optimize. 8383 // If the function is not compiled, do not optimize.
8371 // This can happen if the debugger is activated and 8384 // This can happen if the debugger is activated and
8372 // the function is returned to the not compiled state. 8385 // the function is returned to the not compiled state.
8373 // TODO(yangguo): reconsider this. 8386 // TODO(yangguo): reconsider this.
8374 function->ReplaceCode(function->shared()->code()); 8387 function->ReplaceCode(function->shared()->code());
8375 } else if (!isolate->use_crankshaft() || 8388 } else if (!isolate->use_crankshaft() ||
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
8428 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); 8441 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
8429 ASSERT(AllowHeapAllocation::IsAllowed()); 8442 ASSERT(AllowHeapAllocation::IsAllowed());
8430 delete deoptimizer; 8443 delete deoptimizer;
8431 return isolate->heap()->undefined_value(); 8444 return isolate->heap()->undefined_value();
8432 } 8445 }
8433 8446
8434 8447
8435 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NotifyDeoptimized) { 8448 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NotifyDeoptimized) {
8436 HandleScope scope(isolate); 8449 HandleScope scope(isolate);
8437 ASSERT(args.length() == 1); 8450 ASSERT(args.length() == 1);
8438 RUNTIME_ASSERT(args[0]->IsSmi()); 8451 CONVERT_SMI_ARG_CHECKED(type_arg, 0);
8439 Deoptimizer::BailoutType type = 8452 Deoptimizer::BailoutType type =
8440 static_cast<Deoptimizer::BailoutType>(args.smi_at(0)); 8453 static_cast<Deoptimizer::BailoutType>(type_arg);
8441 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); 8454 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
8442 ASSERT(AllowHeapAllocation::IsAllowed()); 8455 ASSERT(AllowHeapAllocation::IsAllowed());
8443 8456
8444 Handle<JSFunction> function = deoptimizer->function(); 8457 Handle<JSFunction> function = deoptimizer->function();
8445 Handle<Code> optimized_code = deoptimizer->compiled_code(); 8458 Handle<Code> optimized_code = deoptimizer->compiled_code();
8446 8459
8447 ASSERT(optimized_code->kind() == Code::OPTIMIZED_FUNCTION); 8460 ASSERT(optimized_code->kind() == Code::OPTIMIZED_FUNCTION);
8448 ASSERT(type == deoptimizer->bailout_type()); 8461 ASSERT(type == deoptimizer->bailout_type());
8449 8462
8450 // Make sure to materialize objects before causing any allocation. 8463 // Make sure to materialize objects before causing any allocation.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
8511 if (unoptimized->kind() == Code::FUNCTION) { 8524 if (unoptimized->kind() == Code::FUNCTION) {
8512 unoptimized->ClearInlineCaches(); 8525 unoptimized->ClearInlineCaches();
8513 unoptimized->ClearTypeFeedbackInfo(isolate->heap()); 8526 unoptimized->ClearTypeFeedbackInfo(isolate->heap());
8514 } 8527 }
8515 return isolate->heap()->undefined_value(); 8528 return isolate->heap()->undefined_value();
8516 } 8529 }
8517 8530
8518 8531
8519 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) { 8532 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) {
8520 SealHandleScope shs(isolate); 8533 SealHandleScope shs(isolate);
8534 ASSERT(args.length() == 0);
8521 #if defined(USE_SIMULATOR) 8535 #if defined(USE_SIMULATOR)
8522 return isolate->heap()->true_value(); 8536 return isolate->heap()->true_value();
8523 #else 8537 #else
8524 return isolate->heap()->false_value(); 8538 return isolate->heap()->false_value();
8525 #endif 8539 #endif
8526 } 8540 }
8527 8541
8528 8542
8529 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsConcurrentRecompilationSupported) { 8543 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsConcurrentRecompilationSupported) {
8530 HandleScope scope(isolate); 8544 HandleScope scope(isolate);
8531 return isolate->concurrent_recompilation_enabled() 8545 ASSERT(args.length() == 0);
8532 ? isolate->heap()->true_value() : isolate->heap()->false_value(); 8546 return isolate->heap()->ToBoolean(
8547 isolate->concurrent_recompilation_enabled());
8533 } 8548 }
8534 8549
8535 8550
8536 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) { 8551 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) {
8537 HandleScope scope(isolate); 8552 HandleScope scope(isolate);
8538 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); 8553 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2);
8539 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8554 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8540 8555
8541 if (!function->IsOptimizable() && 8556 if (!function->IsOptimizable() &&
8542 !function->IsMarkedForConcurrentOptimization() && 8557 !function->IsMarkedForConcurrentOptimization() &&
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
8606 } 8621 }
8607 if (FLAG_deopt_every_n_times) { 8622 if (FLAG_deopt_every_n_times) {
8608 return Smi::FromInt(6); // 6 == "maybe deopted". 8623 return Smi::FromInt(6); // 6 == "maybe deopted".
8609 } 8624 }
8610 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". 8625 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes".
8611 : Smi::FromInt(2); // 2 == "no". 8626 : Smi::FromInt(2); // 2 == "no".
8612 } 8627 }
8613 8628
8614 8629
8615 RUNTIME_FUNCTION(MaybeObject*, Runtime_UnblockConcurrentRecompilation) { 8630 RUNTIME_FUNCTION(MaybeObject*, Runtime_UnblockConcurrentRecompilation) {
8631 ASSERT(args.length() == 0);
8616 RUNTIME_ASSERT(FLAG_block_concurrent_recompilation); 8632 RUNTIME_ASSERT(FLAG_block_concurrent_recompilation);
8617 RUNTIME_ASSERT(isolate->concurrent_recompilation_enabled()); 8633 RUNTIME_ASSERT(isolate->concurrent_recompilation_enabled());
8618 isolate->optimizing_compiler_thread()->Unblock(); 8634 isolate->optimizing_compiler_thread()->Unblock();
8619 return isolate->heap()->undefined_value(); 8635 return isolate->heap()->undefined_value();
8620 } 8636 }
8621 8637
8622 8638
8623 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) { 8639 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) {
8624 HandleScope scope(isolate); 8640 HandleScope scope(isolate);
8625 ASSERT(args.length() == 1); 8641 ASSERT(args.length() == 1);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
8777 isolate->heap()->DisableInlineAllocation(); 8793 isolate->heap()->DisableInlineAllocation();
8778 } 8794 }
8779 } 8795 }
8780 #endif 8796 #endif
8781 return isolate->heap()->undefined_value(); 8797 return isolate->heap()->undefined_value();
8782 } 8798 }
8783 8799
8784 8800
8785 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) { 8801 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) {
8786 SealHandleScope shs(isolate); 8802 SealHandleScope shs(isolate);
8803 ASSERT(args.length() == 0);
8787 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); 8804 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
8788 return isolate->heap()->undefined_value(); 8805 return isolate->heap()->undefined_value();
8789 } 8806 }
8790 8807
8791 8808
8792 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetRootNaN) { 8809 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetRootNaN) {
8793 SealHandleScope shs(isolate); 8810 SealHandleScope shs(isolate);
8811 ASSERT(args.length() == 0);
8794 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); 8812 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
8795 return isolate->heap()->nan_value(); 8813 return isolate->heap()->nan_value();
8796 } 8814 }
8797 8815
8798 8816
8799 RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) { 8817 RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) {
8800 HandleScope scope(isolate); 8818 HandleScope scope(isolate);
8801 ASSERT(args.length() >= 2); 8819 ASSERT(args.length() >= 2);
8802 int argc = args.length() - 2; 8820 int argc = args.length() - 2;
8803 CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1); 8821 CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1);
(...skipping 24 matching lines...) Expand all
8828 isolate, result, 8846 isolate, result,
8829 Execution::Call(isolate, hfun, hreceiver, argc, argv, true)); 8847 Execution::Call(isolate, hfun, hreceiver, argc, argv, true));
8830 return *result; 8848 return *result;
8831 } 8849 }
8832 8850
8833 8851
8834 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) { 8852 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) {
8835 HandleScope scope(isolate); 8853 HandleScope scope(isolate);
8836 ASSERT(args.length() == 5); 8854 ASSERT(args.length() == 5);
8837 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, fun, 0); 8855 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, fun, 0);
8838 Handle<Object> receiver = args.at<Object>(1); 8856 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1);
8839 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 2); 8857 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 2);
8840 CONVERT_SMI_ARG_CHECKED(offset, 3); 8858 CONVERT_SMI_ARG_CHECKED(offset, 3);
8841 CONVERT_SMI_ARG_CHECKED(argc, 4); 8859 CONVERT_SMI_ARG_CHECKED(argc, 4);
8842 RUNTIME_ASSERT(offset >= 0); 8860 RUNTIME_ASSERT(offset >= 0);
8843 RUNTIME_ASSERT(argc >= 0); 8861 RUNTIME_ASSERT(argc >= 0);
8844 8862
8845 // If there are too many arguments, allocate argv via malloc. 8863 // If there are too many arguments, allocate argv via malloc.
8846 const int argv_small_size = 10; 8864 const int argv_small_size = 10;
8847 Handle<Object> argv_small_buffer[argv_small_size]; 8865 Handle<Object> argv_small_buffer[argv_small_size];
8848 SmartArrayPointer<Handle<Object> > argv_large_buffer; 8866 SmartArrayPointer<Handle<Object> > argv_large_buffer;
(...skipping 14 matching lines...) Expand all
8863 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 8881 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
8864 isolate, result, 8882 isolate, result,
8865 Execution::Call(isolate, fun, receiver, argc, argv, true)); 8883 Execution::Call(isolate, fun, receiver, argc, argv, true));
8866 return *result; 8884 return *result;
8867 } 8885 }
8868 8886
8869 8887
8870 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionDelegate) { 8888 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionDelegate) {
8871 HandleScope scope(isolate); 8889 HandleScope scope(isolate);
8872 ASSERT(args.length() == 1); 8890 ASSERT(args.length() == 1);
8873 RUNTIME_ASSERT(!args[0]->IsJSFunction()); 8891 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
8874 return *Execution::GetFunctionDelegate(isolate, args.at<Object>(0)); 8892 RUNTIME_ASSERT(!object->IsJSFunction());
8893 return *Execution::GetFunctionDelegate(isolate, object);
8875 } 8894 }
8876 8895
8877 8896
8878 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { 8897 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) {
8879 HandleScope scope(isolate); 8898 HandleScope scope(isolate);
8880 ASSERT(args.length() == 1); 8899 ASSERT(args.length() == 1);
8881 RUNTIME_ASSERT(!args[0]->IsJSFunction()); 8900 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
8882 return *Execution::GetConstructorDelegate(isolate, args.at<Object>(0)); 8901 RUNTIME_ASSERT(!object->IsJSFunction());
8902 return *Execution::GetConstructorDelegate(isolate, object);
8883 } 8903 }
8884 8904
8885 8905
8886 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewGlobalContext) { 8906 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewGlobalContext) {
8887 HandleScope scope(isolate); 8907 HandleScope scope(isolate);
8888 ASSERT(args.length() == 2); 8908 ASSERT(args.length() == 2);
8889 8909
8890 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8910 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8891 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); 8911 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1);
8892 Handle<Context> result = 8912 Handle<Context> result =
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
8987 Handle<Context> context = isolate->factory()->NewBlockContext( 9007 Handle<Context> context = isolate->factory()->NewBlockContext(
8988 function, current, scope_info); 9008 function, current, scope_info);
8989 isolate->set_context(*context); 9009 isolate->set_context(*context);
8990 return *context; 9010 return *context;
8991 } 9011 }
8992 9012
8993 9013
8994 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSModule) { 9014 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSModule) {
8995 SealHandleScope shs(isolate); 9015 SealHandleScope shs(isolate);
8996 ASSERT(args.length() == 1); 9016 ASSERT(args.length() == 1);
8997 Object* obj = args[0]; 9017 CONVERT_ARG_CHECKED(Object, obj, 0);
8998 return isolate->heap()->ToBoolean(obj->IsJSModule()); 9018 return isolate->heap()->ToBoolean(obj->IsJSModule());
8999 } 9019 }
9000 9020
9001 9021
9002 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushModuleContext) { 9022 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushModuleContext) {
9003 SealHandleScope shs(isolate); 9023 SealHandleScope shs(isolate);
9004 ASSERT(args.length() == 2); 9024 ASSERT(args.length() == 2);
9005 CONVERT_SMI_ARG_CHECKED(index, 0); 9025 CONVERT_SMI_ARG_CHECKED(index, 0);
9006 9026
9007 if (!args[1]->IsScopeInfo()) { 9027 if (!args[1]->IsScopeInfo()) {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
9286 9306
9287 RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_LoadContextSlotNoReferenceError) { 9307 RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_LoadContextSlotNoReferenceError) {
9288 return LoadContextSlotHelper(args, isolate, false); 9308 return LoadContextSlotHelper(args, isolate, false);
9289 } 9309 }
9290 9310
9291 9311
9292 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StoreContextSlot) { 9312 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StoreContextSlot) {
9293 HandleScope scope(isolate); 9313 HandleScope scope(isolate);
9294 ASSERT(args.length() == 4); 9314 ASSERT(args.length() == 4);
9295 9315
9296 Handle<Object> value(args[0], isolate); 9316 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0);
9297 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1); 9317 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1);
9298 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); 9318 CONVERT_ARG_HANDLE_CHECKED(String, name, 2);
9299 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 3); 9319 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 3);
9300 9320
9301 int index; 9321 int index;
9302 PropertyAttributes attributes; 9322 PropertyAttributes attributes;
9303 ContextLookupFlags flags = FOLLOW_CHAINS; 9323 ContextLookupFlags flags = FOLLOW_CHAINS;
9304 BindingFlags binding_flags; 9324 BindingFlags binding_flags;
9305 Handle<Object> holder = context->Lookup(name, 9325 Handle<Object> holder = context->Lookup(name,
9306 flags, 9326 flags,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
9385 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ReThrow) { 9405 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ReThrow) {
9386 HandleScope scope(isolate); 9406 HandleScope scope(isolate);
9387 ASSERT(args.length() == 1); 9407 ASSERT(args.length() == 1);
9388 9408
9389 return isolate->ReThrow(args[0]); 9409 return isolate->ReThrow(args[0]);
9390 } 9410 }
9391 9411
9392 9412
9393 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PromoteScheduledException) { 9413 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PromoteScheduledException) {
9394 SealHandleScope shs(isolate); 9414 SealHandleScope shs(isolate);
9395 ASSERT_EQ(0, args.length()); 9415 ASSERT(args.length() == 0);
9396 return isolate->PromoteScheduledException(); 9416 return isolate->PromoteScheduledException();
9397 } 9417 }
9398 9418
9399 9419
9400 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowReferenceError) { 9420 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowReferenceError) {
9401 HandleScope scope(isolate); 9421 HandleScope scope(isolate);
9402 ASSERT(args.length() == 1); 9422 ASSERT(args.length() == 1);
9403 9423 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
9404 Handle<Object> name(args[0], isolate);
9405 Handle<Object> reference_error = 9424 Handle<Object> reference_error =
9406 isolate->factory()->NewReferenceError("not_defined", 9425 isolate->factory()->NewReferenceError("not_defined",
9407 HandleVector(&name, 1)); 9426 HandleVector(&name, 1));
9408 return isolate->Throw(*reference_error); 9427 return isolate->Throw(*reference_error);
9409 } 9428 }
9410 9429
9411 9430
9412 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowNotDateError) { 9431 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowNotDateError) {
9413 HandleScope scope(isolate); 9432 HandleScope scope(isolate);
9414 ASSERT(args.length() == 0); 9433 ASSERT(args.length() == 0);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
9499 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) { 9518 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) {
9500 SealHandleScope shs(isolate); 9519 SealHandleScope shs(isolate);
9501 ASSERT(args.length() == 0); 9520 ASSERT(args.length() == 0);
9502 PrintTransition(isolate, NULL); 9521 PrintTransition(isolate, NULL);
9503 return isolate->heap()->undefined_value(); 9522 return isolate->heap()->undefined_value();
9504 } 9523 }
9505 9524
9506 9525
9507 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) { 9526 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) {
9508 SealHandleScope shs(isolate); 9527 SealHandleScope shs(isolate);
9509 PrintTransition(isolate, args[0]); 9528 ASSERT(args.length() == 1);
9510 return args[0]; // return TOS 9529 CONVERT_ARG_CHECKED(Object, obj, 0);
9530 PrintTransition(isolate, obj);
9531 return obj; // return TOS
9511 } 9532 }
9512 9533
9513 9534
9514 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) { 9535 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) {
9515 SealHandleScope shs(isolate); 9536 SealHandleScope shs(isolate);
9516 ASSERT(args.length() == 1); 9537 ASSERT(args.length() == 1);
9517 9538
9518 #ifdef DEBUG 9539 #ifdef DEBUG
9519 if (args[0]->IsString()) { 9540 if (args[0]->IsString()) {
9520 // If we have a string, assume it's a code "marker" 9541 // If we have a string, assume it's a code "marker"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
9637 Handle<JSObject> result = 9658 Handle<JSObject> result =
9638 isolate->factory()->NewJSObject(isolate->array_function()); 9659 isolate->factory()->NewJSObject(isolate->array_function());
9639 JSArray::SetContent(Handle<JSArray>::cast(result), date_cache_version); 9660 JSArray::SetContent(Handle<JSArray>::cast(result), date_cache_version);
9640 return *result; 9661 return *result;
9641 } 9662 }
9642 9663
9643 9664
9644 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { 9665 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) {
9645 SealHandleScope shs(isolate); 9666 SealHandleScope shs(isolate);
9646 ASSERT(args.length() == 1); 9667 ASSERT(args.length() == 1);
9647 Object* global = args[0]; 9668 CONVERT_ARG_CHECKED(Object, global, 0);
9648 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); 9669 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value();
9649 return JSGlobalObject::cast(global)->global_receiver(); 9670 return JSGlobalObject::cast(global)->global_receiver();
9650 } 9671 }
9651 9672
9652 9673
9653 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAttachedGlobal) { 9674 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAttachedGlobal) {
9654 SealHandleScope shs(isolate); 9675 SealHandleScope shs(isolate);
9655 ASSERT(args.length() == 1); 9676 ASSERT(args.length() == 1);
9656 Object* global = args[0]; 9677 CONVERT_ARG_CHECKED(Object, global, 0);
9657 if (!global->IsJSGlobalObject()) return isolate->heap()->false_value(); 9678 if (!global->IsJSGlobalObject()) return isolate->heap()->false_value();
9658 return isolate->heap()->ToBoolean( 9679 return isolate->heap()->ToBoolean(
9659 !JSGlobalObject::cast(global)->IsDetached()); 9680 !JSGlobalObject::cast(global)->IsDetached());
9660 } 9681 }
9661 9682
9662 9683
9663 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { 9684 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) {
9664 HandleScope scope(isolate); 9685 HandleScope scope(isolate);
9665 ASSERT_EQ(1, args.length()); 9686 ASSERT(args.length() == 1);
9666 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); 9687 CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
9667 9688
9668 source = String::Flatten(source); 9689 source = String::Flatten(source);
9669 // Optimized fast case where we only have ASCII characters. 9690 // Optimized fast case where we only have ASCII characters.
9670 Handle<Object> result; 9691 Handle<Object> result;
9671 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 9692 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
9672 isolate, result, 9693 isolate, result,
9673 source->IsSeqOneByteString() ? JsonParser<true>::Parse(source) 9694 source->IsSeqOneByteString() ? JsonParser<true>::Parse(source)
9674 : JsonParser<false>::Parse(source)); 9695 : JsonParser<false>::Parse(source));
9675 return *result; 9696 return *result;
(...skipping 12 matching lines...) Expand all
9688 } else { 9709 } else {
9689 // Callback set. Let it decide if code generation is allowed. 9710 // Callback set. Let it decide if code generation is allowed.
9690 VMState<EXTERNAL> state(isolate); 9711 VMState<EXTERNAL> state(isolate);
9691 return callback(v8::Utils::ToLocal(context)); 9712 return callback(v8::Utils::ToLocal(context));
9692 } 9713 }
9693 } 9714 }
9694 9715
9695 9716
9696 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileString) { 9717 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileString) {
9697 HandleScope scope(isolate); 9718 HandleScope scope(isolate);
9698 ASSERT_EQ(2, args.length()); 9719 ASSERT(args.length() == 2);
9699 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); 9720 CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
9700 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1); 9721 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1);
9701 9722
9702 // Extract native context. 9723 // Extract native context.
9703 Handle<Context> context(isolate->context()->native_context()); 9724 Handle<Context> context(isolate->context()->native_context());
9704 9725
9705 // Check if native context allows code generation from 9726 // Check if native context allows code generation from
9706 // strings. Throw an exception if it doesn't. 9727 // strings. Throw an exception if it doesn't.
9707 if (context->allow_code_gen_from_strings()->IsFalse() && 9728 if (context->allow_code_gen_from_strings()->IsFalse() &&
9708 !CodeGenerationFromStringsAllowed(isolate, context)) { 9729 !CodeGenerationFromStringsAllowed(isolate, context)) {
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
10660 // Adds a JavaScript function as a debug event listener. 10681 // Adds a JavaScript function as a debug event listener.
10661 // args[0]: debug event listener function to set or null or undefined for 10682 // args[0]: debug event listener function to set or null or undefined for
10662 // clearing the event listener function 10683 // clearing the event listener function
10663 // args[1]: object supplied during callback 10684 // args[1]: object supplied during callback
10664 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDebugEventListener) { 10685 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDebugEventListener) {
10665 SealHandleScope shs(isolate); 10686 SealHandleScope shs(isolate);
10666 ASSERT(args.length() == 2); 10687 ASSERT(args.length() == 2);
10667 RUNTIME_ASSERT(args[0]->IsJSFunction() || 10688 RUNTIME_ASSERT(args[0]->IsJSFunction() ||
10668 args[0]->IsUndefined() || 10689 args[0]->IsUndefined() ||
10669 args[0]->IsNull()); 10690 args[0]->IsNull());
10670 Handle<Object> callback = args.at<Object>(0); 10691 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0);
10671 Handle<Object> data = args.at<Object>(1); 10692 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1);
10672 isolate->debugger()->SetEventListener(callback, data); 10693 isolate->debugger()->SetEventListener(callback, data);
10673 10694
10674 return isolate->heap()->undefined_value(); 10695 return isolate->heap()->undefined_value();
10675 } 10696 }
10676 10697
10677 10698
10678 RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) { 10699 RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) {
10679 SealHandleScope shs(isolate); 10700 SealHandleScope shs(isolate);
10680 ASSERT(args.length() == 0); 10701 ASSERT(args.length() == 0);
10681 isolate->stack_guard()->DebugBreak(); 10702 isolate->stack_guard()->DebugBreak();
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
12389 // args[5]: object: new value 12410 // args[5]: object: new value
12390 // 12411 //
12391 // Return true if success and false otherwise 12412 // Return true if success and false otherwise
12392 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScopeVariableValue) { 12413 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScopeVariableValue) {
12393 HandleScope scope(isolate); 12414 HandleScope scope(isolate);
12394 ASSERT(args.length() == 6); 12415 ASSERT(args.length() == 6);
12395 12416
12396 // Check arguments. 12417 // Check arguments.
12397 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); 12418 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]);
12398 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4); 12419 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4);
12399 Handle<Object> new_value = args.at<Object>(5); 12420 CONVERT_ARG_HANDLE_CHECKED(Object, new_value, 5);
12400 12421
12401 bool res; 12422 bool res;
12402 if (args[0]->IsNumber()) { 12423 if (args[0]->IsNumber()) {
12403 Object* check; 12424 Object* check;
12404 { MaybeObject* maybe_check = Runtime_CheckExecutionState( 12425 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
12405 RUNTIME_ARGUMENTS(isolate, args)); 12426 RUNTIME_ARGUMENTS(isolate, args));
12406 if (!maybe_check->ToObject(&check)) return maybe_check; 12427 if (!maybe_check->ToObject(&check)) return maybe_check;
12407 } 12428 }
12408 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); 12429 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
12409 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); 12430 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
12570 // Set a break point in a function. 12591 // Set a break point in a function.
12571 // args[0]: function 12592 // args[0]: function
12572 // args[1]: number: break source position (within the function source) 12593 // args[1]: number: break source position (within the function source)
12573 // args[2]: number: break point object 12594 // args[2]: number: break point object
12574 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFunctionBreakPoint) { 12595 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFunctionBreakPoint) {
12575 HandleScope scope(isolate); 12596 HandleScope scope(isolate);
12576 ASSERT(args.length() == 3); 12597 ASSERT(args.length() == 3);
12577 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 12598 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
12578 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); 12599 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
12579 RUNTIME_ASSERT(source_position >= 0); 12600 RUNTIME_ASSERT(source_position >= 0);
12580 Handle<Object> break_point_object_arg = args.at<Object>(2); 12601 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2);
12581 12602
12582 // Set break point. 12603 // Set break point.
12583 isolate->debug()->SetBreakPoint(function, break_point_object_arg, 12604 isolate->debug()->SetBreakPoint(function, break_point_object_arg,
12584 &source_position); 12605 &source_position);
12585 12606
12586 return Smi::FromInt(source_position); 12607 return Smi::FromInt(source_position);
12587 } 12608 }
12588 12609
12589 12610
12590 // Changes the state of a break point in a script and returns source position 12611 // Changes the state of a break point in a script and returns source position
12591 // where break point was set. NOTE: Regarding performance see the NOTE for 12612 // where break point was set. NOTE: Regarding performance see the NOTE for
12592 // GetScriptFromScriptData. 12613 // GetScriptFromScriptData.
12593 // args[0]: script to set break point in 12614 // args[0]: script to set break point in
12594 // args[1]: number: break source position (within the script source) 12615 // args[1]: number: break source position (within the script source)
12595 // args[2]: number, breakpoint position alignment 12616 // args[2]: number, breakpoint position alignment
12596 // args[3]: number: break point object 12617 // args[3]: number: break point object
12597 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) { 12618 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) {
12598 HandleScope scope(isolate); 12619 HandleScope scope(isolate);
12599 ASSERT(args.length() == 4); 12620 ASSERT(args.length() == 4);
12600 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); 12621 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0);
12601 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); 12622 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
12602 RUNTIME_ASSERT(source_position >= 0); 12623 RUNTIME_ASSERT(source_position >= 0);
12603 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]); 12624 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]);
12604 Handle<Object> break_point_object_arg = args.at<Object>(3); 12625 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 3);
12605 12626
12606 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { 12627 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) {
12607 return isolate->ThrowIllegalOperation(); 12628 return isolate->ThrowIllegalOperation();
12608 } 12629 }
12609 BreakPositionAlignment alignment = 12630 BreakPositionAlignment alignment =
12610 static_cast<BreakPositionAlignment>(statement_aligned_code); 12631 static_cast<BreakPositionAlignment>(statement_aligned_code);
12611 12632
12612 // Get the script from the script wrapper. 12633 // Get the script from the script wrapper.
12613 RUNTIME_ASSERT(wrapper->value()->IsScript()); 12634 RUNTIME_ASSERT(wrapper->value()->IsScript());
12614 Handle<Script> script(Script::cast(wrapper->value())); 12635 Handle<Script> script(Script::cast(wrapper->value()));
12615 12636
12616 // Set break point. 12637 // Set break point.
12617 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg, 12638 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg,
12618 &source_position, 12639 &source_position,
12619 alignment)) { 12640 alignment)) {
12620 return isolate->heap()->undefined_value(); 12641 return isolate->heap()->undefined_value();
12621 } 12642 }
12622 12643
12623 return Smi::FromInt(source_position); 12644 return Smi::FromInt(source_position);
12624 } 12645 }
12625 12646
12626 12647
12627 // Clear a break point 12648 // Clear a break point
12628 // args[0]: number: break point object 12649 // args[0]: number: break point object
12629 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearBreakPoint) { 12650 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearBreakPoint) {
12630 HandleScope scope(isolate); 12651 HandleScope scope(isolate);
12631 ASSERT(args.length() == 1); 12652 ASSERT(args.length() == 1);
12632 Handle<Object> break_point_object_arg = args.at<Object>(0); 12653 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 0);
12633 12654
12634 // Clear break point. 12655 // Clear break point.
12635 isolate->debug()->ClearBreakPoint(break_point_object_arg); 12656 isolate->debug()->ClearBreakPoint(break_point_object_arg);
12636 12657
12637 return isolate->heap()->undefined_value(); 12658 return isolate->heap()->undefined_value();
12638 } 12659 }
12639 12660
12640 12661
12641 // Change the state of break on exceptions. 12662 // Change the state of break on exceptions.
12642 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions. 12663 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions.
12643 // args[1]: Boolean indicating on/off. 12664 // args[1]: Boolean indicating on/off.
12644 RUNTIME_FUNCTION(MaybeObject*, Runtime_ChangeBreakOnException) { 12665 RUNTIME_FUNCTION(MaybeObject*, Runtime_ChangeBreakOnException) {
12645 HandleScope scope(isolate); 12666 HandleScope scope(isolate);
12646 ASSERT(args.length() == 2); 12667 ASSERT(args.length() == 2);
12647 RUNTIME_ASSERT(args[0]->IsNumber()); 12668 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]);
12648 CONVERT_BOOLEAN_ARG_CHECKED(enable, 1); 12669 CONVERT_BOOLEAN_ARG_CHECKED(enable, 1);
12649 12670
12650 // If the number doesn't match an enum value, the ChangeBreakOnException 12671 // If the number doesn't match an enum value, the ChangeBreakOnException
12651 // function will default to affecting caught exceptions. 12672 // function will default to affecting caught exceptions.
12652 ExceptionBreakType type = 12673 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg);
12653 static_cast<ExceptionBreakType>(NumberToUint32(args[0]));
12654 // Update break point state. 12674 // Update break point state.
12655 isolate->debug()->ChangeBreakOnException(type, enable); 12675 isolate->debug()->ChangeBreakOnException(type, enable);
12656 return isolate->heap()->undefined_value(); 12676 return isolate->heap()->undefined_value();
12657 } 12677 }
12658 12678
12659 12679
12660 // Returns the state of break on exceptions 12680 // Returns the state of break on exceptions
12661 // args[0]: boolean indicating uncaught exceptions 12681 // args[0]: boolean indicating uncaught exceptions
12662 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsBreakOnException) { 12682 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsBreakOnException) {
12663 HandleScope scope(isolate); 12683 HandleScope scope(isolate);
12664 ASSERT(args.length() == 1); 12684 ASSERT(args.length() == 1);
12665 RUNTIME_ASSERT(args[0]->IsNumber()); 12685 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]);
12666 12686
12667 ExceptionBreakType type = 12687 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg);
12668 static_cast<ExceptionBreakType>(NumberToUint32(args[0]));
12669 bool result = isolate->debug()->IsBreakOnException(type); 12688 bool result = isolate->debug()->IsBreakOnException(type);
12670 return Smi::FromInt(result); 12689 return Smi::FromInt(result);
12671 } 12690 }
12672 12691
12673 12692
12674 // Prepare for stepping 12693 // Prepare for stepping
12675 // args[0]: break id for checking execution state 12694 // args[0]: break id for checking execution state
12676 // args[1]: step action from the enumeration StepAction 12695 // args[1]: step action from the enumeration StepAction
12677 // args[2]: number of times to perform the step, for step out it is the number 12696 // args[2]: number of times to perform the step, for step out it is the number
12678 // of frames to step down. 12697 // of frames to step down.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
12816 ASSERT(args.length() == 6); 12835 ASSERT(args.length() == 6);
12817 Object* check_result; 12836 Object* check_result;
12818 { MaybeObject* maybe_result = Runtime_CheckExecutionState( 12837 { MaybeObject* maybe_result = Runtime_CheckExecutionState(
12819 RUNTIME_ARGUMENTS(isolate, args)); 12838 RUNTIME_ARGUMENTS(isolate, args));
12820 if (!maybe_result->ToObject(&check_result)) return maybe_result; 12839 if (!maybe_result->ToObject(&check_result)) return maybe_result;
12821 } 12840 }
12822 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); 12841 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
12823 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); 12842 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
12824 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); 12843 CONVERT_ARG_HANDLE_CHECKED(String, source, 3);
12825 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); 12844 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4);
12826 Handle<Object> context_extension(args[5], isolate); 12845 CONVERT_ARG_HANDLE_CHECKED(Object, context_extension, 5);
12827 12846
12828 // Handle the processing of break. 12847 // Handle the processing of break.
12829 DisableBreak disable_break_save(isolate, disable_break); 12848 DisableBreak disable_break_save(isolate, disable_break);
12830 12849
12831 // Get the frame where the debugging is performed. 12850 // Get the frame where the debugging is performed.
12832 StackFrame::Id id = UnwrapFrameId(wrapped_id); 12851 StackFrame::Id id = UnwrapFrameId(wrapped_id);
12833 JavaScriptFrameIterator it(isolate, id); 12852 JavaScriptFrameIterator it(isolate, id);
12834 JavaScriptFrame* frame = it.frame(); 12853 JavaScriptFrame* frame = it.frame();
12835 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); 12854 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate);
12836 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); 12855 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction()));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
12885 // Check the execution state and decode arguments frame and source to be 12904 // Check the execution state and decode arguments frame and source to be
12886 // evaluated. 12905 // evaluated.
12887 ASSERT(args.length() == 4); 12906 ASSERT(args.length() == 4);
12888 Object* check_result; 12907 Object* check_result;
12889 { MaybeObject* maybe_result = Runtime_CheckExecutionState( 12908 { MaybeObject* maybe_result = Runtime_CheckExecutionState(
12890 RUNTIME_ARGUMENTS(isolate, args)); 12909 RUNTIME_ARGUMENTS(isolate, args));
12891 if (!maybe_result->ToObject(&check_result)) return maybe_result; 12910 if (!maybe_result->ToObject(&check_result)) return maybe_result;
12892 } 12911 }
12893 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); 12912 CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
12894 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); 12913 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2);
12895 Handle<Object> context_extension(args[3], isolate); 12914 CONVERT_ARG_HANDLE_CHECKED(Object, context_extension, 3);
12896 12915
12897 // Handle the processing of break. 12916 // Handle the processing of break.
12898 DisableBreak disable_break_save(isolate, disable_break); 12917 DisableBreak disable_break_save(isolate, disable_break);
12899 12918
12900 // Enter the top context from before the debugger was invoked. 12919 // Enter the top context from before the debugger was invoked.
12901 SaveContext save(isolate); 12920 SaveContext save(isolate);
12902 SaveContext* top = &save; 12921 SaveContext* top = &save;
12903 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { 12922 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) {
12904 top = top->prev(); 12923 top = top->prev();
12905 } 12924 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
13024 // First perform a full GC in order to avoid references from dead objects. 13043 // First perform a full GC in order to avoid references from dead objects.
13025 Heap* heap = isolate->heap(); 13044 Heap* heap = isolate->heap();
13026 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugReferencedBy"); 13045 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugReferencedBy");
13027 // The heap iterator reserves the right to do a GC to make the heap iterable. 13046 // The heap iterator reserves the right to do a GC to make the heap iterable.
13028 // Due to the GC above we know it won't need to do that, but it seems cleaner 13047 // Due to the GC above we know it won't need to do that, but it seems cleaner
13029 // to get the heap iterator constructed before we start having unprotected 13048 // to get the heap iterator constructed before we start having unprotected
13030 // Object* locals that are not protected by handles. 13049 // Object* locals that are not protected by handles.
13031 13050
13032 // Check parameters. 13051 // Check parameters.
13033 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0); 13052 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0);
13034 Handle<Object> instance_filter = args.at<Object>(1); 13053 CONVERT_ARG_HANDLE_CHECKED(Object, instance_filter, 1);
13035 RUNTIME_ASSERT(instance_filter->IsUndefined() || 13054 RUNTIME_ASSERT(instance_filter->IsUndefined() ||
13036 instance_filter->IsJSObject()); 13055 instance_filter->IsJSObject());
13037 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); 13056 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]);
13038 RUNTIME_ASSERT(max_references >= 0); 13057 RUNTIME_ASSERT(max_references >= 0);
13039 13058
13040 13059
13041 // Get the constructor function for context extension and arguments array. 13060 // Get the constructor function for context extension and arguments array.
13042 Handle<JSObject> arguments_boilerplate( 13061 Handle<JSObject> arguments_boilerplate(
13043 isolate->context()->native_context()->sloppy_arguments_boilerplate()); 13062 isolate->context()->native_context()->sloppy_arguments_boilerplate());
13044 Handle<JSFunction> arguments_function( 13063 Handle<JSFunction> arguments_function(
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
13324 13343
13325 // Changes the source of the script to a new_source. 13344 // Changes the source of the script to a new_source.
13326 // If old_script_name is provided (i.e. is a String), also creates a copy of 13345 // If old_script_name is provided (i.e. is a String), also creates a copy of
13327 // the script with its original source and sends notification to debugger. 13346 // the script with its original source and sends notification to debugger.
13328 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) { 13347 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) {
13329 HandleScope scope(isolate); 13348 HandleScope scope(isolate);
13330 CHECK(isolate->debugger()->live_edit_enabled()); 13349 CHECK(isolate->debugger()->live_edit_enabled());
13331 ASSERT(args.length() == 3); 13350 ASSERT(args.length() == 3);
13332 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0); 13351 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0);
13333 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1); 13352 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1);
13334 Handle<Object> old_script_name(args[2], isolate); 13353 CONVERT_ARG_HANDLE_CHECKED(Object, old_script_name, 2);
13335 13354
13336 RUNTIME_ASSERT(original_script_value->value()->IsScript()); 13355 RUNTIME_ASSERT(original_script_value->value()->IsScript());
13337 Handle<Script> original_script(Script::cast(original_script_value->value())); 13356 Handle<Script> original_script(Script::cast(original_script_value->value()));
13338 13357
13339 Handle<Object> old_script = LiveEdit::ChangeScriptSource( 13358 Handle<Object> old_script = LiveEdit::ChangeScriptSource(
13340 original_script, new_source, old_script_name); 13359 original_script, new_source, old_script_name);
13341 13360
13342 if (old_script->IsScript()) { 13361 if (old_script->IsScript()) {
13343 Handle<Script> script_handle = Handle<Script>::cast(old_script); 13362 Handle<Script> script_handle = Handle<Script>::cast(old_script);
13344 return *(GetScriptWrapper(script_handle)); 13363 return *(GetScriptWrapper(script_handle));
(...skipping 27 matching lines...) Expand all
13372 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); 13391 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info);
13373 return isolate->heap()->undefined_value(); 13392 return isolate->heap()->undefined_value();
13374 } 13393 }
13375 13394
13376 13395
13377 // Connects SharedFunctionInfo to another script. 13396 // Connects SharedFunctionInfo to another script.
13378 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) { 13397 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) {
13379 HandleScope scope(isolate); 13398 HandleScope scope(isolate);
13380 CHECK(isolate->debugger()->live_edit_enabled()); 13399 CHECK(isolate->debugger()->live_edit_enabled());
13381 ASSERT(args.length() == 2); 13400 ASSERT(args.length() == 2);
13382 Handle<Object> function_object(args[0], isolate); 13401 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0);
13383 Handle<Object> script_object(args[1], isolate); 13402 CONVERT_ARG_HANDLE_CHECKED(Object, script_object, 1);
13384 13403
13385 if (function_object->IsJSValue()) { 13404 if (function_object->IsJSValue()) {
13386 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); 13405 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object);
13387 if (script_object->IsJSValue()) { 13406 if (script_object->IsJSValue()) {
13388 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript()); 13407 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript());
13389 Script* script = Script::cast(JSValue::cast(*script_object)->value()); 13408 Script* script = Script::cast(JSValue::cast(*script_object)->value());
13390 script_object = Handle<Object>(script, isolate); 13409 script_object = Handle<Object>(script, isolate);
13391 } 13410 }
13392 13411
13393 LiveEdit::SetFunctionScript(function_wrapper, script_object); 13412 LiveEdit::SetFunctionScript(function_wrapper, script_object);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
13566 } 13585 }
13567 Handle<Object> result; 13586 Handle<Object> result;
13568 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); 13587 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result);
13569 return *result; 13588 return *result;
13570 } 13589 }
13571 13590
13572 13591
13573 // Sets a v8 flag. 13592 // Sets a v8 flag.
13574 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { 13593 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) {
13575 SealHandleScope shs(isolate); 13594 SealHandleScope shs(isolate);
13595 ASSERT(args.length() == 1);
13576 CONVERT_ARG_CHECKED(String, arg, 0); 13596 CONVERT_ARG_CHECKED(String, arg, 0);
13577 SmartArrayPointer<char> flags = 13597 SmartArrayPointer<char> flags =
13578 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 13598 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
13579 FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get())); 13599 FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get()));
13580 return isolate->heap()->undefined_value(); 13600 return isolate->heap()->undefined_value();
13581 } 13601 }
13582 13602
13583 13603
13584 // Performs a GC. 13604 // Performs a GC.
13585 // Presently, it only does a full GC. 13605 // Presently, it only does a full GC.
13586 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) { 13606 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) {
13587 SealHandleScope shs(isolate); 13607 SealHandleScope shs(isolate);
13608 ASSERT(args.length() == 1);
13588 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); 13609 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage");
13589 return isolate->heap()->undefined_value(); 13610 return isolate->heap()->undefined_value();
13590 } 13611 }
13591 13612
13592 13613
13593 // Gets the current heap usage. 13614 // Gets the current heap usage.
13594 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHeapUsage) { 13615 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHeapUsage) {
13595 SealHandleScope shs(isolate); 13616 SealHandleScope shs(isolate);
13617 ASSERT(args.length() == 0);
13596 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); 13618 int usage = static_cast<int>(isolate->heap()->SizeOfObjects());
13597 if (!Smi::IsValid(usage)) { 13619 if (!Smi::IsValid(usage)) {
13598 return *isolate->factory()->NewNumberFromInt(usage); 13620 return *isolate->factory()->NewNumberFromInt(usage);
13599 } 13621 }
13600 return Smi::FromInt(usage); 13622 return Smi::FromInt(usage);
13601 } 13623 }
13602 13624
13603 #endif // ENABLE_DEBUGGER_SUPPORT 13625 #endif // ENABLE_DEBUGGER_SUPPORT
13604 13626
13605 13627
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
14376 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); 14398 Runtime_GetScriptFromScriptName(Handle<String>(script_name));
14377 return *result; 14399 return *result;
14378 } 14400 }
14379 14401
14380 14402
14381 // Collect the raw data for a stack trace. Returns an array of 4 14403 // Collect the raw data for a stack trace. Returns an array of 4
14382 // element segments each containing a receiver, function, code and 14404 // element segments each containing a receiver, function, code and
14383 // native code offset. 14405 // native code offset.
14384 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { 14406 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) {
14385 HandleScope scope(isolate); 14407 HandleScope scope(isolate);
14386 ASSERT_EQ(args.length(), 3); 14408 ASSERT(args.length() == 3);
14387 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); 14409 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0);
14388 Handle<Object> caller = args.at<Object>(1); 14410 CONVERT_ARG_HANDLE_CHECKED(Object, caller, 1);
14389 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]); 14411 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]);
14390 14412
14391 // Optionally capture a more detailed stack trace for the message. 14413 // Optionally capture a more detailed stack trace for the message.
14392 isolate->CaptureAndSetDetailedStackTrace(error_object); 14414 isolate->CaptureAndSetDetailedStackTrace(error_object);
14393 // Capture a simple stack trace for the stack property. 14415 // Capture a simple stack trace for the stack property.
14394 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit); 14416 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit);
14395 } 14417 }
14396 14418
14397 14419
14398 // Retrieve the stack trace. This is the raw stack trace that yet has to 14420 // Retrieve the stack trace. This is the raw stack trace that yet has to
14399 // be formatted. Since we only need this once, clear it afterwards. 14421 // be formatted. Since we only need this once, clear it afterwards.
14400 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAndClearOverflowedStackTrace) { 14422 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAndClearOverflowedStackTrace) {
14401 HandleScope scope(isolate); 14423 HandleScope scope(isolate);
14402 ASSERT_EQ(args.length(), 1); 14424 ASSERT(args.length() == 1);
14403 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); 14425 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0);
14404 Handle<String> key = isolate->factory()->hidden_stack_trace_string(); 14426 Handle<String> key = isolate->factory()->hidden_stack_trace_string();
14405 Handle<Object> result(error_object->GetHiddenProperty(*key), isolate); 14427 Handle<Object> result(error_object->GetHiddenProperty(*key), isolate);
14406 if (result->IsTheHole()) return isolate->heap()->undefined_value(); 14428 if (result->IsTheHole()) return isolate->heap()->undefined_value();
14407 RUNTIME_ASSERT(result->IsJSArray() || result->IsUndefined()); 14429 RUNTIME_ASSERT(result->IsJSArray() || result->IsUndefined());
14408 JSObject::DeleteHiddenProperty(error_object, key); 14430 JSObject::DeleteHiddenProperty(error_object, key);
14409 return *result; 14431 return *result;
14410 } 14432 }
14411 14433
14412 14434
14413 // Returns V8 version as a string. 14435 // Returns V8 version as a string.
14414 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { 14436 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) {
14415 SealHandleScope shs(isolate); 14437 SealHandleScope shs(isolate);
14416 ASSERT_EQ(args.length(), 0); 14438 ASSERT(args.length() == 0);
14417 14439
14418 const char* version_string = v8::V8::GetVersion(); 14440 const char* version_string = v8::V8::GetVersion();
14419 14441
14420 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), 14442 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string),
14421 NOT_TENURED); 14443 NOT_TENURED);
14422 } 14444 }
14423 14445
14424 14446
14425 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { 14447 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) {
14426 SealHandleScope shs(isolate); 14448 SealHandleScope shs(isolate);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
14491 Handle<Object> result = JSObject::TryMigrateInstance(js_object); 14513 Handle<Object> result = JSObject::TryMigrateInstance(js_object);
14492 if (result.is_null()) return Smi::FromInt(0); 14514 if (result.is_null()) return Smi::FromInt(0);
14493 return *object; 14515 return *object;
14494 } 14516 }
14495 14517
14496 14518
14497 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_GetFromCache) { 14519 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_GetFromCache) {
14498 SealHandleScope shs(isolate); 14520 SealHandleScope shs(isolate);
14499 // This is only called from codegen, so checks might be more lax. 14521 // This is only called from codegen, so checks might be more lax.
14500 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0); 14522 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0);
14501 Object* key = args[1]; 14523 CONVERT_ARG_CHECKED(Object, key, 1);
14502 14524
14503 { 14525 {
14504 DisallowHeapAllocation no_alloc; 14526 DisallowHeapAllocation no_alloc;
14505 14527
14506 int finger_index = cache->finger_index(); 14528 int finger_index = cache->finger_index();
14507 Object* o = cache->get(finger_index); 14529 Object* o = cache->get(finger_index);
14508 if (o == key) { 14530 if (o == key) {
14509 // The fastest case: hit the same place again. 14531 // The fastest case: hit the same place again.
14510 return cache->get(finger_index + 1); 14532 return cache->get(finger_index + 1);
14511 } 14533 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
14587 cache_handle->JSFunctionResultCacheVerify(); 14609 cache_handle->JSFunctionResultCacheVerify();
14588 } 14610 }
14589 #endif 14611 #endif
14590 14612
14591 return *value; 14613 return *value;
14592 } 14614 }
14593 14615
14594 14616
14595 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetStartPosition) { 14617 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetStartPosition) {
14596 SealHandleScope shs(isolate); 14618 SealHandleScope shs(isolate);
14619 ASSERT(args.length() == 1);
14597 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); 14620 CONVERT_ARG_CHECKED(JSMessageObject, message, 0);
14598 return Smi::FromInt(message->start_position()); 14621 return Smi::FromInt(message->start_position());
14599 } 14622 }
14600 14623
14601 14624
14602 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetScript) { 14625 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetScript) {
14603 SealHandleScope shs(isolate); 14626 SealHandleScope shs(isolate);
14627 ASSERT(args.length() == 1);
14604 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); 14628 CONVERT_ARG_CHECKED(JSMessageObject, message, 0);
14605 return message->script(); 14629 return message->script();
14606 } 14630 }
14607 14631
14608 14632
14609 #ifdef DEBUG 14633 #ifdef DEBUG
14610 // ListNatives is ONLY used by the fuzz-natives.js in debug mode 14634 // ListNatives is ONLY used by the fuzz-natives.js in debug mode
14611 // Exclude the code in release mode. 14635 // Exclude the code in release mode.
14612 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) { 14636 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) {
14613 HandleScope scope(isolate); 14637 HandleScope scope(isolate);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
14730 CONVERT_ARG_CHECKED(HeapObject, obj, 0); 14754 CONVERT_ARG_CHECKED(HeapObject, obj, 0);
14731 return isolate->heap()->ToBoolean(obj->IsAccessCheckNeeded()); 14755 return isolate->heap()->ToBoolean(obj->IsAccessCheckNeeded());
14732 } 14756 }
14733 14757
14734 14758
14735 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) { 14759 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) {
14736 SealHandleScope shs(isolate); 14760 SealHandleScope shs(isolate);
14737 ASSERT(args.length() == 1); 14761 ASSERT(args.length() == 1);
14738 14762
14739 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value(); 14763 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value();
14740 JSReceiver* obj = JSReceiver::cast(args[0]); 14764 CONVERT_ARG_CHECKED(JSReceiver, obj, 0);
14741 if (obj->IsJSGlobalProxy()) { 14765 if (obj->IsJSGlobalProxy()) {
14742 Object* proto = obj->GetPrototype(); 14766 Object* proto = obj->GetPrototype();
14743 if (proto->IsNull()) return isolate->heap()->false_value(); 14767 if (proto->IsNull()) return isolate->heap()->false_value();
14744 ASSERT(proto->IsJSGlobalObject()); 14768 ASSERT(proto->IsJSGlobalObject());
14745 obj = JSReceiver::cast(proto); 14769 obj = JSReceiver::cast(proto);
14746 } 14770 }
14747 return isolate->heap()->ToBoolean(obj->map()->is_observed()); 14771 return isolate->heap()->ToBoolean(obj->map()->is_observed());
14748 } 14772 }
14749 14773
14750 14774
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
14812 return WeakCollectionInitialize(isolate, weakmap); 14836 return WeakCollectionInitialize(isolate, weakmap);
14813 } 14837 }
14814 14838
14815 14839
14816 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessAllowedForObserver) { 14840 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessAllowedForObserver) {
14817 HandleScope scope(isolate); 14841 HandleScope scope(isolate);
14818 ASSERT(args.length() == 3); 14842 ASSERT(args.length() == 3);
14819 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); 14843 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0);
14820 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); 14844 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1);
14821 ASSERT(object->map()->is_access_check_needed()); 14845 ASSERT(object->map()->is_access_check_needed());
14822 Handle<Object> key = args.at<Object>(2); 14846 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2);
14823 SaveContext save(isolate); 14847 SaveContext save(isolate);
14824 isolate->set_context(observer->context()); 14848 isolate->set_context(observer->context());
14825 if (!isolate->MayNamedAccess( 14849 if (!isolate->MayNamedAccess(
14826 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { 14850 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) {
14827 return isolate->heap()->false_value(); 14851 return isolate->heap()->false_value();
14828 } 14852 }
14829 bool access_allowed = false; 14853 bool access_allowed = false;
14830 uint32_t index = 0; 14854 uint32_t index = 0;
14831 if (key->ToArrayIndex(&index) || 14855 if (key->ToArrayIndex(&index) ||
14832 (key->IsString() && String::cast(*key)->AsArrayIndex(&index))) { 14856 (key->IsString() && String::cast(*key)->AsArrayIndex(&index))) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
14975 } 14999 }
14976 #endif 15000 #endif
14977 return ArrayConstructorCommon(isolate, 15001 return ArrayConstructorCommon(isolate,
14978 constructor, 15002 constructor,
14979 Handle<AllocationSite>::null(), 15003 Handle<AllocationSite>::null(),
14980 caller_args); 15004 caller_args);
14981 } 15005 }
14982 15006
14983 15007
14984 RUNTIME_FUNCTION(MaybeObject*, Runtime_MaxSmi) { 15008 RUNTIME_FUNCTION(MaybeObject*, Runtime_MaxSmi) {
15009 ASSERT(args.length() == 0);
14985 return Smi::FromInt(Smi::kMaxValue); 15010 return Smi::FromInt(Smi::kMaxValue);
14986 } 15011 }
14987 15012
14988 15013
14989 // ---------------------------------------------------------------------------- 15014 // ----------------------------------------------------------------------------
14990 // Implementation of Runtime 15015 // Implementation of Runtime
14991 15016
14992 #define F(name, number_of_args, result_size) \ 15017 #define F(name, number_of_args, result_size) \
14993 { Runtime::k##name, Runtime::RUNTIME, #name, \ 15018 { Runtime::k##name, Runtime::RUNTIME, #name, \
14994 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, 15019 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size },
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
15077 } 15102 }
15078 } 15103 }
15079 15104
15080 15105
15081 void Runtime::OutOfMemory() { 15106 void Runtime::OutOfMemory() {
15082 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15107 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15083 UNREACHABLE(); 15108 UNREACHABLE();
15084 } 15109 }
15085 15110
15086 } } // namespace v8::internal 15111 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/v8conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698