Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: runtime/vm/regexp.cc

Issue 2947143002: Revert "VM(RegExp): Allow OSR optimization of RegExp :matcher functions." (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/regexp.h ('k') | runtime/vm/regexp_assembler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 5 #include "vm/regexp.h"
6 6
7 #include "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/regexp_assembler.h" 8 #include "vm/regexp_assembler.h"
9 #include "vm/regexp_assembler_bytecode.h" 9 #include "vm/regexp_assembler_bytecode.h"
10 #include "vm/regexp_assembler_ir.h" 10 #include "vm/regexp_assembler_ir.h"
(...skipping 3011 matching lines...) Expand 10 before | Expand all | Expand 10 after
3022 const TypedData& boolean_skip_table = TypedData::ZoneHandle( 3022 const TypedData& boolean_skip_table = TypedData::ZoneHandle(
3023 compiler_->zone(), 3023 compiler_->zone(),
3024 TypedData::New(kTypedDataUint8ArrayCid, kSize, Heap::kOld)); 3024 TypedData::New(kTypedDataUint8ArrayCid, kSize, Heap::kOld));
3025 intptr_t skip_distance = 3025 intptr_t skip_distance =
3026 GetSkipTable(min_lookahead, max_lookahead, boolean_skip_table); 3026 GetSkipTable(min_lookahead, max_lookahead, boolean_skip_table);
3027 ASSERT(skip_distance != 0); 3027 ASSERT(skip_distance != 0);
3028 3028
3029 BlockLabel cont, again; 3029 BlockLabel cont, again;
3030 3030
3031 masm->BindBlock(&again); 3031 masm->BindBlock(&again);
3032 masm->CheckPreemption(/*is_backtrack=*/false);
3033 masm->LoadCurrentCharacter(max_lookahead, &cont, true); 3032 masm->LoadCurrentCharacter(max_lookahead, &cont, true);
3034 masm->CheckBitInTable(boolean_skip_table, &cont); 3033 masm->CheckBitInTable(boolean_skip_table, &cont);
3035 masm->AdvanceCurrentPosition(skip_distance); 3034 masm->AdvanceCurrentPosition(skip_distance);
3036 masm->GoTo(&again); 3035 masm->GoTo(&again);
3037 masm->BindBlock(&cont); 3036 masm->BindBlock(&cont);
3038 3037
3039 return; 3038 return;
3040 } 3039 }
3041 3040
3042 3041
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
3229 // information for each iteration of the loop, which could take up a lot of 3228 // information for each iteration of the loop, which could take up a lot of
3230 // space. 3229 // space.
3231 ASSERT(trace->stop_node() == NULL); 3230 ASSERT(trace->stop_node() == NULL);
3232 macro_assembler->PushCurrentPosition(); 3231 macro_assembler->PushCurrentPosition();
3233 BlockLabel greedy_match_failed; 3232 BlockLabel greedy_match_failed;
3234 Trace greedy_match_trace; 3233 Trace greedy_match_trace;
3235 if (not_at_start()) greedy_match_trace.set_at_start(false); 3234 if (not_at_start()) greedy_match_trace.set_at_start(false);
3236 greedy_match_trace.set_backtrack(&greedy_match_failed); 3235 greedy_match_trace.set_backtrack(&greedy_match_failed);
3237 BlockLabel loop_label; 3236 BlockLabel loop_label;
3238 macro_assembler->BindBlock(&loop_label); 3237 macro_assembler->BindBlock(&loop_label);
3239 macro_assembler->CheckPreemption(/*is_backtrack=*/false);
3240 greedy_match_trace.set_stop_node(this); 3238 greedy_match_trace.set_stop_node(this);
3241 greedy_match_trace.set_loop_label(&loop_label); 3239 greedy_match_trace.set_loop_label(&loop_label);
3242 (*alternatives_)[0].node()->Emit(compiler, &greedy_match_trace); 3240 (*alternatives_)[0].node()->Emit(compiler, &greedy_match_trace);
3243 macro_assembler->BindBlock(&greedy_match_failed); 3241 macro_assembler->BindBlock(&greedy_match_failed);
3244 3242
3245 BlockLabel second_choice; // For use in greedy matches. 3243 BlockLabel second_choice; // For use in greedy matches.
3246 macro_assembler->BindBlock(&second_choice); 3244 macro_assembler->BindBlock(&second_choice);
3247 3245
3248 Trace* new_trace = greedy_loop_state->counter_backtrack_trace(); 3246 Trace* new_trace = greedy_loop_state->counter_backtrack_trace();
3249 3247
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after
4813 } 4811 }
4814 on_success()->FillInBMInfo(offset, budget - 1, bm, 4812 on_success()->FillInBMInfo(offset, budget - 1, bm,
4815 true); // Not at start after a text node. 4813 true); // Not at start after a text node.
4816 if (initial_offset == 0) set_bm_info(not_at_start, bm); 4814 if (initial_offset == 0) set_bm_info(not_at_start, bm);
4817 } 4815 }
4818 4816
4819 4817
4820 RegExpEngine::CompilationResult RegExpEngine::CompileIR( 4818 RegExpEngine::CompilationResult RegExpEngine::CompileIR(
4821 RegExpCompileData* data, 4819 RegExpCompileData* data,
4822 const ParsedFunction* parsed_function, 4820 const ParsedFunction* parsed_function,
4823 const ZoneGrowableArray<const ICData*>& ic_data_array, 4821 const ZoneGrowableArray<const ICData*>& ic_data_array) {
4824 intptr_t osr_id) {
4825 ASSERT(!FLAG_interpret_irregexp); 4822 ASSERT(!FLAG_interpret_irregexp);
4826 Zone* zone = Thread::Current()->zone(); 4823 Zone* zone = Thread::Current()->zone();
4827 4824
4828 const Function& function = parsed_function->function(); 4825 const Function& function = parsed_function->function();
4829 const intptr_t specialization_cid = function.string_specialization_cid(); 4826 const intptr_t specialization_cid = function.string_specialization_cid();
4830 const intptr_t is_sticky = function.is_sticky_specialization(); 4827 const intptr_t is_sticky = function.is_sticky_specialization();
4831 const bool is_one_byte = (specialization_cid == kOneByteStringCid || 4828 const bool is_one_byte = (specialization_cid == kOneByteStringCid ||
4832 specialization_cid == kExternalOneByteStringCid); 4829 specialization_cid == kExternalOneByteStringCid);
4833 RegExp& regexp = RegExp::Handle(zone, function.regexp()); 4830 RegExp& regexp = RegExp::Handle(zone, function.regexp());
4834 const String& pattern = String::Handle(zone, regexp.pattern()); 4831 const String& pattern = String::Handle(zone, regexp.pattern());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4890 data->node = node; 4887 data->node = node;
4891 Analysis analysis(ignore_case, is_one_byte); 4888 Analysis analysis(ignore_case, is_one_byte);
4892 analysis.EnsureAnalyzed(node); 4889 analysis.EnsureAnalyzed(node);
4893 if (analysis.has_failed()) { 4890 if (analysis.has_failed()) {
4894 const char* error_message = analysis.error_message(); 4891 const char* error_message = analysis.error_message();
4895 return CompilationResult(error_message); 4892 return CompilationResult(error_message);
4896 } 4893 }
4897 4894
4898 // Native regexp implementation. 4895 // Native regexp implementation.
4899 4896
4900 IRRegExpMacroAssembler* macro_assembler = new (zone) 4897 IRRegExpMacroAssembler* macro_assembler =
4901 IRRegExpMacroAssembler(specialization_cid, data->capture_count, 4898 new (zone) IRRegExpMacroAssembler(specialization_cid, data->capture_count,
4902 parsed_function, ic_data_array, osr_id, zone); 4899 parsed_function, ic_data_array, zone);
4903 4900
4904 // Inserted here, instead of in Assembler, because it depends on information 4901 // Inserted here, instead of in Assembler, because it depends on information
4905 // in the AST that isn't replicated in the Node structure. 4902 // in the AST that isn't replicated in the Node structure.
4906 static const intptr_t kMaxBacksearchLimit = 1024; 4903 static const intptr_t kMaxBacksearchLimit = 1024;
4907 if (is_end_anchored && !is_start_anchored && !is_sticky && 4904 if (is_end_anchored && !is_start_anchored && !is_sticky &&
4908 max_length < kMaxBacksearchLimit) { 4905 max_length < kMaxBacksearchLimit) {
4909 macro_assembler->SetCurrentPositionFromEnd(max_length); 4906 macro_assembler->SetCurrentPositionFromEnd(max_length);
4910 } 4907 }
4911 4908
4912 if (is_global) { 4909 if (is_global) {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
5111 CreateSpecializedFunction(thread, zone, regexp, cid, /*sticky=*/true, 5108 CreateSpecializedFunction(thread, zone, regexp, cid, /*sticky=*/true,
5112 owner); 5109 owner);
5113 } 5110 }
5114 } 5111 }
5115 5112
5116 return regexp.raw(); 5113 return regexp.raw();
5117 } 5114 }
5118 5115
5119 5116
5120 } // namespace dart 5117 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/regexp.h ('k') | runtime/vm/regexp_assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698