| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 "vm/regexp_assembler_ir.h" | 5 #include "vm/regexp_assembler_ir.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 string_param_length_ = Local(Symbols::string_param_length()); | 154 string_param_length_ = Local(Symbols::string_param_length()); |
| 155 capture_length_ = Local(Symbols::capture_length()); | 155 capture_length_ = Local(Symbols::capture_length()); |
| 156 match_start_index_ = Local(Symbols::match_start_index()); | 156 match_start_index_ = Local(Symbols::match_start_index()); |
| 157 capture_start_index_ = Local(Symbols::capture_start_index()); | 157 capture_start_index_ = Local(Symbols::capture_start_index()); |
| 158 match_end_index_ = Local(Symbols::match_end_index()); | 158 match_end_index_ = Local(Symbols::match_end_index()); |
| 159 char_in_capture_ = Local(Symbols::char_in_capture()); | 159 char_in_capture_ = Local(Symbols::char_in_capture()); |
| 160 char_in_match_ = Local(Symbols::char_in_match()); | 160 char_in_match_ = Local(Symbols::char_in_match()); |
| 161 index_temp_ = Local(Symbols::index_temp()); | 161 index_temp_ = Local(Symbols::index_temp()); |
| 162 result_ = Local(Symbols::result()); | 162 result_ = Local(Symbols::result()); |
| 163 | 163 |
| 164 string_param_ = Parameter(Symbols::string_param(), 0); | 164 string_param_ = Parameter(Symbols::string_param(), |
| 165 start_index_param_ = Parameter(Symbols::start_index_param(), 1); | 165 RegExpMacroAssembler::kParamStringIndex); |
| 166 start_index_param_ = Parameter(Symbols::start_index_param(), |
| 167 RegExpMacroAssembler::kParamStartOffsetIndex); |
| 166 } | 168 } |
| 167 | 169 |
| 168 | 170 |
| 169 void IRRegExpMacroAssembler::GenerateEntryBlock() { | 171 void IRRegExpMacroAssembler::GenerateEntryBlock() { |
| 170 set_current_instruction(entry_block_->normal_entry()); | 172 set_current_instruction(entry_block_->normal_entry()); |
| 171 TAG(); | 173 TAG(); |
| 172 | 174 |
| 173 // Store string.length. | 175 // Store string.length. |
| 174 PushArgumentInstr* string_push = PushLocal(string_param_); | 176 PushArgumentInstr* string_push = PushLocal(string_param_); |
| 175 | 177 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 static const bool kEnableUnalignedAccesses = false; | 301 static const bool kEnableUnalignedAccesses = false; |
| 300 #else | 302 #else |
| 301 static const bool kEnableUnalignedAccesses = true; | 303 static const bool kEnableUnalignedAccesses = true; |
| 302 #endif | 304 #endif |
| 303 bool IRRegExpMacroAssembler::CanReadUnaligned() { | 305 bool IRRegExpMacroAssembler::CanReadUnaligned() { |
| 304 return kEnableUnalignedAccesses && !slow_safe(); | 306 return kEnableUnalignedAccesses && !slow_safe(); |
| 305 } | 307 } |
| 306 | 308 |
| 307 | 309 |
| 308 RawArray* IRRegExpMacroAssembler::Execute( | 310 RawArray* IRRegExpMacroAssembler::Execute( |
| 309 const Function& function, | 311 const JSRegExp& regexp, |
| 310 const String& input, | 312 const String& input, |
| 311 const Smi& start_offset, | 313 const Smi& start_offset, |
| 312 Zone* zone) { | 314 Zone* zone) { |
| 315 const intptr_t cid = input.GetClassId(); |
| 316 const Function& fun = Function::Handle(regexp.function(cid)); |
| 317 ASSERT(!fun.IsNull()); |
| 313 // Create the argument list. | 318 // Create the argument list. |
| 314 const Array& args = Array::Handle(Array::New(2)); | 319 const Array& args = |
| 315 args.SetAt(0, input); | 320 Array::Handle(Array::New(RegExpMacroAssembler::kParamCount)); |
| 316 args.SetAt(1, start_offset); | 321 args.SetAt(RegExpMacroAssembler::kParamRegExpIndex, regexp); |
| 322 args.SetAt(RegExpMacroAssembler::kParamStringIndex, input); |
| 323 args.SetAt(RegExpMacroAssembler::kParamStartOffsetIndex, start_offset); |
| 317 | 324 |
| 318 // And finally call the generated code. | 325 // And finally call the generated code. |
| 319 | 326 |
| 320 const Object& retval = | 327 const Object& retval = |
| 321 Object::Handle(zone, DartEntry::InvokeFunction(function, args)); | 328 Object::Handle(zone, DartEntry::InvokeFunction(fun, args)); |
| 322 if (retval.IsError()) { | 329 if (retval.IsError()) { |
| 323 const Error& error = Error::Cast(retval); | 330 const Error& error = Error::Cast(retval); |
| 324 OS::Print("%s\n", error.ToErrorCString()); | 331 OS::Print("%s\n", error.ToErrorCString()); |
| 325 // Should never happen. | 332 // Should never happen. |
| 326 UNREACHABLE(); | 333 UNREACHABLE(); |
| 327 } | 334 } |
| 328 | 335 |
| 329 if (retval.IsNull()) { | 336 if (retval.IsNull()) { |
| 330 return Array::null(); | 337 return Array::null(); |
| 331 } | 338 } |
| (...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1914 index_val, | 1921 index_val, |
| 1915 characters, | 1922 characters, |
| 1916 specialization_cid_, | 1923 specialization_cid_, |
| 1917 Scanner::kNoSourcePos)); | 1924 Scanner::kNoSourcePos)); |
| 1918 } | 1925 } |
| 1919 | 1926 |
| 1920 | 1927 |
| 1921 #undef __ | 1928 #undef __ |
| 1922 | 1929 |
| 1923 } // namespace dart | 1930 } // namespace dart |
| OLD | NEW |