| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/bootstrap_natives.h" | 6 #include "vm/bootstrap_natives.h" |
| 7 #include "vm/exceptions.h" | 7 #include "vm/exceptions.h" |
| 8 #include "vm/native_entry.h" | 8 #include "vm/native_entry.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/regexp_parser.h" | 10 #include "vm/regexp_parser.h" |
| 11 #include "vm/regexp_assembler_ir.h" | 11 #include "vm/regexp_assembler_ir.h" |
| 12 #include "vm/regexp_assembler_bytecode.h" | 12 #include "vm/regexp_assembler_bytecode.h" |
| 13 #include "vm/thread.h" | 13 #include "vm/thread.h" |
| 14 | 14 |
| 15 namespace dart { | 15 namespace dart { |
| 16 | 16 |
| 17 DECLARE_FLAG(bool, trace_irregexp); | 17 DEFINE_FLAG(bool, trace_irregexp, false, "Trace irregexps"); |
| 18 | 18 |
| 19 | 19 |
| 20 DEFINE_NATIVE_ENTRY(RegExp_factory, 4) { | 20 DEFINE_NATIVE_ENTRY(RegExp_factory, 4) { |
| 21 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); | 21 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); |
| 22 GET_NON_NULL_NATIVE_ARGUMENT(String, pattern, arguments->NativeArgAt(1)); | 22 GET_NON_NULL_NATIVE_ARGUMENT(String, pattern, arguments->NativeArgAt(1)); |
| 23 GET_NON_NULL_NATIVE_ARGUMENT(Instance, handle_multi_line, | 23 GET_NON_NULL_NATIVE_ARGUMENT(Instance, handle_multi_line, |
| 24 arguments->NativeArgAt(2)); | 24 arguments->NativeArgAt(2)); |
| 25 GET_NON_NULL_NATIVE_ARGUMENT(Instance, handle_case_sensitive, | 25 GET_NON_NULL_NATIVE_ARGUMENT(Instance, handle_case_sensitive, |
| 26 arguments->NativeArgAt(3)); | 26 arguments->NativeArgAt(3)); |
| 27 bool ignore_case = handle_case_sensitive.raw() != Bool::True().raw(); | 27 bool ignore_case = handle_case_sensitive.raw() != Bool::True().raw(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 | 80 |
| 81 static RawObject* ExecuteMatch(Zone* zone, | 81 static RawObject* ExecuteMatch(Zone* zone, |
| 82 NativeArguments* arguments, | 82 NativeArguments* arguments, |
| 83 bool sticky) { | 83 bool sticky) { |
| 84 const RegExp& regexp = RegExp::CheckedHandle(arguments->NativeArgAt(0)); | 84 const RegExp& regexp = RegExp::CheckedHandle(arguments->NativeArgAt(0)); |
| 85 ASSERT(!regexp.IsNull()); | 85 ASSERT(!regexp.IsNull()); |
| 86 GET_NON_NULL_NATIVE_ARGUMENT(String, subject, arguments->NativeArgAt(1)); | 86 GET_NON_NULL_NATIVE_ARGUMENT(String, subject, arguments->NativeArgAt(1)); |
| 87 GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2)); | 87 GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2)); |
| 88 | 88 |
| 89 if (FLAG_interpret_irregexp) { | 89 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 90 return BytecodeRegExpMacroAssembler::Interpret(regexp, subject, start_index, | 90 if (!FLAG_interpret_irregexp) { |
| 91 /*sticky=*/sticky, zone); | 91 return IRRegExpMacroAssembler::Execute(regexp, subject, start_index, |
| 92 /*sticky=*/sticky, zone); |
| 92 } | 93 } |
| 93 | 94 #endif |
| 94 return IRRegExpMacroAssembler::Execute(regexp, subject, start_index, | 95 return BytecodeRegExpMacroAssembler::Interpret(regexp, subject, start_index, |
| 95 /*sticky=*/sticky, zone); | 96 /*sticky=*/sticky, zone); |
| 96 } | 97 } |
| 97 | 98 |
| 98 | 99 |
| 99 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatch, 3) { | 100 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatch, 3) { |
| 100 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatch. | 101 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatch. |
| 101 return ExecuteMatch(zone, arguments, /*sticky=*/false); | 102 return ExecuteMatch(zone, arguments, /*sticky=*/false); |
| 102 } | 103 } |
| 103 | 104 |
| 104 | 105 |
| 105 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatchSticky, 3) { | 106 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatchSticky, 3) { |
| 106 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatchSticky. | 107 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatchSticky. |
| 107 return ExecuteMatch(zone, arguments, /*sticky=*/true); | 108 return ExecuteMatch(zone, arguments, /*sticky=*/true); |
| 108 } | 109 } |
| 109 | 110 |
| 110 | 111 |
| 111 } // namespace dart | 112 } // namespace dart |
| OLD | NEW |