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/runtime/runtime-utils.h" | 10 #include "src/runtime/runtime-utils.h" |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 RUNTIME_ASSERT(index <= subject->length()); | 772 RUNTIME_ASSERT(index <= subject->length()); |
773 isolate->counters()->regexp_entry_runtime()->Increment(); | 773 isolate->counters()->regexp_entry_runtime()->Increment(); |
774 Handle<Object> result; | 774 Handle<Object> result; |
775 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 775 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
776 isolate, result, | 776 isolate, result, |
777 RegExpImpl::Exec(regexp, subject, index, last_match_info)); | 777 RegExpImpl::Exec(regexp, subject, index, last_match_info)); |
778 return *result; | 778 return *result; |
779 } | 779 } |
780 | 780 |
781 | 781 |
782 RUNTIME_FUNCTION(Runtime_RegExpConstructResult) { | 782 RUNTIME_FUNCTION(Runtime_RegExpConstructResultRT) { |
783 HandleScope handle_scope(isolate); | 783 HandleScope handle_scope(isolate); |
784 DCHECK(args.length() == 3); | 784 DCHECK(args.length() == 3); |
785 CONVERT_SMI_ARG_CHECKED(size, 0); | 785 CONVERT_SMI_ARG_CHECKED(size, 0); |
786 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); | 786 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); |
787 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); | 787 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); |
788 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); | 788 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); |
789 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); | 789 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); |
790 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); | 790 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); |
791 Handle<JSObject> object = | 791 Handle<JSObject> object = |
792 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false); | 792 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false); |
793 Handle<JSArray> array = Handle<JSArray>::cast(object); | 793 Handle<JSArray> array = Handle<JSArray>::cast(object); |
794 array->set_elements(*elements); | 794 array->set_elements(*elements); |
795 array->set_length(Smi::FromInt(size)); | 795 array->set_length(Smi::FromInt(size)); |
796 // Write in-object properties after the length of the array. | 796 // Write in-object properties after the length of the array. |
797 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); | 797 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); |
798 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); | 798 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); |
799 return *array; | 799 return *array; |
800 } | 800 } |
801 | 801 |
802 | 802 |
| 803 RUNTIME_FUNCTION(Runtime_RegExpConstructResult) { |
| 804 SealHandleScope shs(isolate); |
| 805 return __RT_impl_Runtime_RegExpConstructResultRT(args, isolate); |
| 806 } |
| 807 |
| 808 |
803 static JSRegExp::Flags RegExpFlagsFromString(Handle<String> flags, | 809 static JSRegExp::Flags RegExpFlagsFromString(Handle<String> flags, |
804 bool* success) { | 810 bool* success) { |
805 uint32_t value = JSRegExp::NONE; | 811 uint32_t value = JSRegExp::NONE; |
806 int length = flags->length(); | 812 int length = flags->length(); |
807 // A longer flags string cannot be valid. | 813 // A longer flags string cannot be valid. |
808 if (length > 5) return JSRegExp::Flags(0); | 814 if (length > 5) return JSRegExp::Flags(0); |
809 for (int i = 0; i < length; i++) { | 815 for (int i = 0; i < length; i++) { |
810 uint32_t flag = JSRegExp::NONE; | 816 uint32_t flag = JSRegExp::NONE; |
811 switch (flags->Get(i)) { | 817 switch (flags->Get(i)) { |
812 case 'g': | 818 case 'g': |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 | 1117 |
1112 | 1118 |
1113 RUNTIME_FUNCTION(Runtime_IsRegExp) { | 1119 RUNTIME_FUNCTION(Runtime_IsRegExp) { |
1114 SealHandleScope shs(isolate); | 1120 SealHandleScope shs(isolate); |
1115 DCHECK(args.length() == 1); | 1121 DCHECK(args.length() == 1); |
1116 CONVERT_ARG_CHECKED(Object, obj, 0); | 1122 CONVERT_ARG_CHECKED(Object, obj, 0); |
1117 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); | 1123 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); |
1118 } | 1124 } |
1119 } | 1125 } |
1120 } // namespace v8::internal | 1126 } // namespace v8::internal |
OLD | NEW |