OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/jsregexp-inl.h" | 8 #include "src/jsregexp-inl.h" |
9 #include "src/jsregexp.h" | 9 #include "src/jsregexp.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 RUNTIME_ASSERT(index <= subject->length()); | 777 RUNTIME_ASSERT(index <= subject->length()); |
778 isolate->counters()->regexp_entry_runtime()->Increment(); | 778 isolate->counters()->regexp_entry_runtime()->Increment(); |
779 Handle<Object> result; | 779 Handle<Object> result; |
780 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 780 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
781 isolate, result, | 781 isolate, result, |
782 RegExpImpl::Exec(regexp, subject, index, last_match_info)); | 782 RegExpImpl::Exec(regexp, subject, index, last_match_info)); |
783 return *result; | 783 return *result; |
784 } | 784 } |
785 | 785 |
786 | 786 |
787 RUNTIME_FUNCTION(Runtime_RegExpConstructResultRT) { | 787 RUNTIME_FUNCTION(Runtime_RegExpConstructResult) { |
788 HandleScope handle_scope(isolate); | 788 HandleScope handle_scope(isolate); |
789 DCHECK(args.length() == 3); | 789 DCHECK(args.length() == 3); |
790 CONVERT_SMI_ARG_CHECKED(size, 0); | 790 CONVERT_SMI_ARG_CHECKED(size, 0); |
791 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); | 791 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); |
792 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); | 792 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); |
793 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); | 793 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); |
794 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); | 794 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); |
795 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); | 795 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); |
796 Handle<JSObject> object = | 796 Handle<JSObject> object = |
797 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED); | 797 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED); |
798 Handle<JSArray> array = Handle<JSArray>::cast(object); | 798 Handle<JSArray> array = Handle<JSArray>::cast(object); |
799 array->set_elements(*elements); | 799 array->set_elements(*elements); |
800 array->set_length(Smi::FromInt(size)); | 800 array->set_length(Smi::FromInt(size)); |
801 // Write in-object properties after the length of the array. | 801 // Write in-object properties after the length of the array. |
802 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); | 802 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); |
803 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); | 803 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); |
804 return *array; | 804 return *array; |
805 } | 805 } |
806 | 806 |
807 | 807 |
808 RUNTIME_FUNCTION(Runtime_RegExpConstructResult) { | |
809 SealHandleScope shs(isolate); | |
810 return __RT_impl_Runtime_RegExpConstructResultRT(args, isolate); | |
811 } | |
812 | |
813 | |
814 static JSRegExp::Flags RegExpFlagsFromString(Handle<String> flags, | 808 static JSRegExp::Flags RegExpFlagsFromString(Handle<String> flags, |
815 bool* success) { | 809 bool* success) { |
816 uint32_t value = JSRegExp::NONE; | 810 uint32_t value = JSRegExp::NONE; |
817 int length = flags->length(); | 811 int length = flags->length(); |
818 // A longer flags string cannot be valid. | 812 // A longer flags string cannot be valid. |
819 if (length > 5) return JSRegExp::Flags(0); | 813 if (length > 5) return JSRegExp::Flags(0); |
820 for (int i = 0; i < length; i++) { | 814 for (int i = 0; i < length; i++) { |
821 uint32_t flag = JSRegExp::NONE; | 815 uint32_t flag = JSRegExp::NONE; |
822 switch (flags->Get(i)) { | 816 switch (flags->Get(i)) { |
823 case 'g': | 817 case 'g': |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 | 1178 |
1185 | 1179 |
1186 RUNTIME_FUNCTION(Runtime_IsRegExp) { | 1180 RUNTIME_FUNCTION(Runtime_IsRegExp) { |
1187 SealHandleScope shs(isolate); | 1181 SealHandleScope shs(isolate); |
1188 DCHECK(args.length() == 1); | 1182 DCHECK(args.length() == 1); |
1189 CONVERT_ARG_CHECKED(Object, obj, 0); | 1183 CONVERT_ARG_CHECKED(Object, obj, 0); |
1190 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); | 1184 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); |
1191 } | 1185 } |
1192 } // namespace internal | 1186 } // namespace internal |
1193 } // namespace v8 | 1187 } // namespace v8 |
OLD | NEW |