| 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); | |
| 18 | |
| 19 | |
| 20 DEFINE_NATIVE_ENTRY(RegExp_factory, 4) { | 17 DEFINE_NATIVE_ENTRY(RegExp_factory, 4) { |
| 21 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); | 18 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); |
| 22 GET_NON_NULL_NATIVE_ARGUMENT(String, pattern, arguments->NativeArgAt(1)); | 19 GET_NON_NULL_NATIVE_ARGUMENT(String, pattern, arguments->NativeArgAt(1)); |
| 23 GET_NON_NULL_NATIVE_ARGUMENT(Instance, handle_multi_line, | 20 GET_NON_NULL_NATIVE_ARGUMENT(Instance, handle_multi_line, |
| 24 arguments->NativeArgAt(2)); | 21 arguments->NativeArgAt(2)); |
| 25 GET_NON_NULL_NATIVE_ARGUMENT(Instance, handle_case_sensitive, | 22 GET_NON_NULL_NATIVE_ARGUMENT(Instance, handle_case_sensitive, |
| 26 arguments->NativeArgAt(3)); | 23 arguments->NativeArgAt(3)); |
| 27 bool ignore_case = handle_case_sensitive.raw() != Bool::True().raw(); | 24 bool ignore_case = handle_case_sensitive.raw() != Bool::True().raw(); |
| 28 bool multi_line = handle_multi_line.raw() == Bool::True().raw(); | 25 bool multi_line = handle_multi_line.raw() == Bool::True().raw(); |
| 29 | 26 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 76 |
| 80 | 77 |
| 81 static RawObject* ExecuteMatch(Zone* zone, | 78 static RawObject* ExecuteMatch(Zone* zone, |
| 82 NativeArguments* arguments, | 79 NativeArguments* arguments, |
| 83 bool sticky) { | 80 bool sticky) { |
| 84 const RegExp& regexp = RegExp::CheckedHandle(arguments->NativeArgAt(0)); | 81 const RegExp& regexp = RegExp::CheckedHandle(arguments->NativeArgAt(0)); |
| 85 ASSERT(!regexp.IsNull()); | 82 ASSERT(!regexp.IsNull()); |
| 86 GET_NON_NULL_NATIVE_ARGUMENT(String, subject, arguments->NativeArgAt(1)); | 83 GET_NON_NULL_NATIVE_ARGUMENT(String, subject, arguments->NativeArgAt(1)); |
| 87 GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2)); | 84 GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2)); |
| 88 | 85 |
| 89 if (FLAG_interpret_irregexp) { | 86 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 90 return BytecodeRegExpMacroAssembler::Interpret(regexp, subject, start_index, | 87 if (!FLAG_interpret_irregexp) { |
| 91 /*sticky=*/sticky, zone); | 88 return IRRegExpMacroAssembler::Execute(regexp, subject, start_index, |
| 89 /*sticky=*/sticky, zone); |
| 92 } | 90 } |
| 93 | 91 #endif |
| 94 return IRRegExpMacroAssembler::Execute(regexp, subject, start_index, | 92 return BytecodeRegExpMacroAssembler::Interpret(regexp, subject, start_index, |
| 95 /*sticky=*/sticky, zone); | 93 /*sticky=*/sticky, zone); |
| 96 } | 94 } |
| 97 | 95 |
| 98 | 96 |
| 99 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatch, 3) { | 97 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatch, 3) { |
| 100 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatch. | 98 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatch. |
| 101 return ExecuteMatch(zone, arguments, /*sticky=*/false); | 99 return ExecuteMatch(zone, arguments, /*sticky=*/false); |
| 102 } | 100 } |
| 103 | 101 |
| 104 | 102 |
| 105 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatchSticky, 3) { | 103 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatchSticky, 3) { |
| 106 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatchSticky. | 104 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatchSticky. |
| 107 return ExecuteMatch(zone, arguments, /*sticky=*/true); | 105 return ExecuteMatch(zone, arguments, /*sticky=*/true); |
| 108 } | 106 } |
| 109 | 107 |
| 110 | 108 |
| 111 } // namespace dart | 109 } // namespace dart |
| OLD | NEW |