| 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 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 | 918 |
| 919 | 919 |
| 920 RUNTIME_FUNCTION(Runtime_MaterializeRegExpLiteral) { | 920 RUNTIME_FUNCTION(Runtime_MaterializeRegExpLiteral) { |
| 921 HandleScope scope(isolate); | 921 HandleScope scope(isolate); |
| 922 DCHECK(args.length() == 4); | 922 DCHECK(args.length() == 4); |
| 923 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 923 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 924 CONVERT_SMI_ARG_CHECKED(index, 1); | 924 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 925 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); | 925 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); |
| 926 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); | 926 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); |
| 927 | 927 |
| 928 // Get the RegExp function from the context in the literals array. | 928 Handle<JSFunction> constructor = isolate->regexp_function(); |
| 929 // This is the RegExp function from the context in which the | |
| 930 // function was created. We do not use the RegExp function from the | |
| 931 // current native context because this might be the RegExp function | |
| 932 // from another context which we should not have access to. | |
| 933 Handle<JSFunction> constructor = Handle<JSFunction>( | |
| 934 JSFunction::NativeContextFromLiterals(*literals)->regexp_function()); | |
| 935 // Compute the regular expression literal. | 929 // Compute the regular expression literal. |
| 936 Handle<Object> regexp; | 930 Handle<Object> regexp; |
| 937 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 931 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 938 isolate, regexp, | 932 isolate, regexp, |
| 939 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags)); | 933 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags)); |
| 940 literals->set(index, *regexp); | 934 literals->set(index, *regexp); |
| 941 return *regexp; | 935 return *regexp; |
| 942 } | 936 } |
| 943 | 937 |
| 944 | 938 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 | 1117 |
| 1124 | 1118 |
| 1125 RUNTIME_FUNCTION(RuntimeReference_IsRegExp) { | 1119 RUNTIME_FUNCTION(RuntimeReference_IsRegExp) { |
| 1126 SealHandleScope shs(isolate); | 1120 SealHandleScope shs(isolate); |
| 1127 DCHECK(args.length() == 1); | 1121 DCHECK(args.length() == 1); |
| 1128 CONVERT_ARG_CHECKED(Object, obj, 0); | 1122 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 1129 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); | 1123 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); |
| 1130 } | 1124 } |
| 1131 } | 1125 } |
| 1132 } // namespace v8::internal | 1126 } // namespace v8::internal |
| OLD | NEW |