OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions-inl.h" | 8 #include "src/conversions-inl.h" |
9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
790 } | 790 } |
791 | 791 |
792 | 792 |
793 RUNTIME_FUNCTION(Runtime_RegExpSource) { | 793 RUNTIME_FUNCTION(Runtime_RegExpSource) { |
794 SealHandleScope shs(isolate); | 794 SealHandleScope shs(isolate); |
795 DCHECK(args.length() == 1); | 795 DCHECK(args.length() == 1); |
796 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); | 796 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); |
797 return regexp->source(); | 797 return regexp->source(); |
798 } | 798 } |
799 | 799 |
800 | |
801 RUNTIME_FUNCTION(Runtime_RegExpConstructResult) { | 800 RUNTIME_FUNCTION(Runtime_RegExpConstructResult) { |
802 HandleScope handle_scope(isolate); | 801 HandleScope handle_scope(isolate); |
803 DCHECK(args.length() == 3); | 802 DCHECK(args.length() == 3); |
804 CONVERT_SMI_ARG_CHECKED(size, 0); | 803 CONVERT_SMI_ARG_CHECKED(size, 0); |
805 CHECK(size >= 0 && size <= FixedArray::kMaxLength); | 804 CHECK(size >= 0 && size <= FixedArray::kMaxLength); |
806 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); | 805 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); |
807 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); | 806 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); |
808 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); | 807 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); |
809 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); | 808 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); |
810 Handle<JSObject> object = | 809 Handle<JSObject> object = |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1007 | 1006 |
1008 | 1007 |
1009 RUNTIME_FUNCTION(Runtime_RegExpExecReThrow) { | 1008 RUNTIME_FUNCTION(Runtime_RegExpExecReThrow) { |
1010 SealHandleScope shs(isolate); | 1009 SealHandleScope shs(isolate); |
1011 DCHECK(args.length() == 4); | 1010 DCHECK(args.length() == 4); |
1012 Object* exception = isolate->pending_exception(); | 1011 Object* exception = isolate->pending_exception(); |
1013 isolate->clear_pending_exception(); | 1012 isolate->clear_pending_exception(); |
1014 return isolate->ReThrow(exception); | 1013 return isolate->ReThrow(exception); |
1015 } | 1014 } |
1016 | 1015 |
1016 RUNTIME_FUNCTION(Runtime_RegExpResultAttachNamedCaptures) { | |
1017 HandleScope handle_scope(isolate); | |
1018 DCHECK(args.length() == 2); | |
1019 CONVERT_ARG_CHECKED(JSArray, result, 0); | |
1020 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1); | |
1021 | |
1022 if (regexp->TypeTag() != JSRegExp::IRREGEXP || | |
Yang
2016/06/13 10:54:53
We don't actually have to check this, right? We ca
jgruber
2016/06/13 13:10:00
I think we need to check, as ATOM JSRegExps have a
| |
1023 !regexp->DataAt(JSRegExp::kIrregexpCaptureNameMapIndex)->IsFixedArray()) | |
Yang
2016/06/13 10:54:53
Please add brackets around the then-block.
jgruber
2016/06/13 13:10:00
Done.
| |
1024 return isolate->heap()->undefined_value(); | |
1025 | |
1026 FixedArray* captures = | |
1027 FixedArray::cast(regexp->DataAt(JSRegExp::kIrregexpCaptureNameMapIndex)); | |
1028 DCHECK(captures->length() > 0); | |
1029 | |
1030 Handle<JSArray> result_handle = handle(result, isolate); | |
1031 | |
1032 for (int i = 0; i < captures->length(); i += 2) { | |
1033 Handle<String> name = handle(String::cast(captures->get(i)), isolate); | |
1034 const int ix = Smi::cast(captures->get(i + 1))->value(); | |
Yang
2016/06/13 10:54:53
Accessing captures like this is not GC-safe. You n
jgruber
2016/06/13 13:10:00
Done.
| |
1035 | |
1036 MaybeHandle<Object> existing = Object::GetProperty(result_handle, name); | |
1037 if (!existing.ToHandleChecked()->IsUndefined()) { | |
1038 continue; // Skip conflicts. | |
Yang
2016/06/13 10:54:53
I don't think this can actually happen unless the
jgruber
2016/06/13 13:10:00
This happens for regexp properties 'index' and 'in
Yang
2016/06/13 13:38:00
I see. Can we use JSReceiver::HasOwnProperty for t
jgruber
2016/06/14 07:53:12
Sounds good, will change this when we look at addi
| |
1039 } | |
1040 | |
1041 Handle<Object> value = | |
1042 Object::GetElement(isolate, result_handle, ix).ToHandleChecked(); | |
1043 JSObject::AddProperty(result_handle, name, value, NONE); | |
1044 } | |
1045 | |
1046 return isolate->heap()->undefined_value(); | |
1047 } | |
1017 | 1048 |
1018 RUNTIME_FUNCTION(Runtime_IsRegExp) { | 1049 RUNTIME_FUNCTION(Runtime_IsRegExp) { |
1019 SealHandleScope shs(isolate); | 1050 SealHandleScope shs(isolate); |
1020 DCHECK(args.length() == 1); | 1051 DCHECK(args.length() == 1); |
1021 CONVERT_ARG_CHECKED(Object, obj, 0); | 1052 CONVERT_ARG_CHECKED(Object, obj, 0); |
1022 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); | 1053 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); |
1023 } | 1054 } |
1024 } // namespace internal | 1055 } // namespace internal |
1025 } // namespace v8 | 1056 } // namespace v8 |
OLD | NEW |