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" |
| 12 #include "vm/regexp_assembler_bytecode.h" |
11 #include "vm/thread.h" | 13 #include "vm/thread.h" |
12 | 14 |
13 namespace dart { | 15 namespace dart { |
14 | 16 |
15 DECLARE_FLAG(bool, trace_irregexp); | 17 DECLARE_FLAG(bool, trace_irregexp); |
| 18 DECLARE_FLAG(bool, interpret_irregexp); |
16 | 19 |
17 | 20 |
18 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_factory, 4) { | 21 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_factory, 4) { |
19 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); | 22 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); |
20 GET_NON_NULL_NATIVE_ARGUMENT(String, pattern, arguments->NativeArgAt(1)); | 23 GET_NON_NULL_NATIVE_ARGUMENT(String, pattern, arguments->NativeArgAt(1)); |
21 GET_NON_NULL_NATIVE_ARGUMENT( | 24 GET_NON_NULL_NATIVE_ARGUMENT( |
22 Instance, handle_multi_line, arguments->NativeArgAt(2)); | 25 Instance, handle_multi_line, arguments->NativeArgAt(2)); |
23 GET_NON_NULL_NATIVE_ARGUMENT( | 26 GET_NON_NULL_NATIVE_ARGUMENT( |
24 Instance, handle_case_sensitive, arguments->NativeArgAt(3)); | 27 Instance, handle_case_sensitive, arguments->NativeArgAt(3)); |
25 bool ignore_case = handle_case_sensitive.raw() != Bool::True().raw(); | 28 bool ignore_case = handle_case_sensitive.raw() != Bool::True().raw(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 const Array& args = Array::Handle(Array::New(1)); | 78 const Array& args = Array::Handle(Array::New(1)); |
76 args.SetAt(0, message); | 79 args.SetAt(0, message); |
77 Exceptions::ThrowByType(Exceptions::kFormat, args); | 80 Exceptions::ThrowByType(Exceptions::kFormat, args); |
78 return Object::null(); | 81 return Object::null(); |
79 } | 82 } |
80 | 83 |
81 | 84 |
82 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_ExecuteMatch, 3) { | 85 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_ExecuteMatch, 3) { |
83 const JSRegExp& regexp = JSRegExp::CheckedHandle(arguments->NativeArgAt(0)); | 86 const JSRegExp& regexp = JSRegExp::CheckedHandle(arguments->NativeArgAt(0)); |
84 ASSERT(!regexp.IsNull()); | 87 ASSERT(!regexp.IsNull()); |
85 GET_NON_NULL_NATIVE_ARGUMENT(String, str, arguments->NativeArgAt(1)); | 88 GET_NON_NULL_NATIVE_ARGUMENT(String, subject, arguments->NativeArgAt(1)); |
86 GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2)); | 89 GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2)); |
87 | 90 |
| 91 if (FLAG_interpret_irregexp) { |
| 92 return BytecodeRegExpMacroAssembler::Interpret(regexp, subject, start_index, |
| 93 zone); |
| 94 } |
| 95 |
88 // This function is intrinsified. See Intrinsifier::JSRegExp_ExecuteMatch. | 96 // This function is intrinsified. See Intrinsifier::JSRegExp_ExecuteMatch. |
89 const intptr_t cid = str.GetClassId(); | 97 const intptr_t cid = subject.GetClassId(); |
90 | 98 |
91 // Retrieve the cached function. | 99 // Retrieve the cached function. |
92 const Function& fn = Function::Handle(regexp.function(cid)); | 100 const Function& fn = Function::Handle(regexp.function(cid)); |
93 ASSERT(!fn.IsNull()); | 101 ASSERT(!fn.IsNull()); |
94 | 102 |
95 // And finally call the generated code. | 103 // And finally call the generated code. |
96 return IRRegExpMacroAssembler::Execute(fn, str, start_index, zone); | 104 return IRRegExpMacroAssembler::Execute(fn, subject, start_index, zone); |
97 } | 105 } |
98 | 106 |
99 } // namespace dart | 107 } // namespace dart |
OLD | NEW |