Revert "VM(RegExp): Allow OSR optimization of RegExp :matcher functions."

This reverts commit d87cc52c3e.

TBR=vegorov@google.com

Review-Url: https://codereview.chromium.org/2947143002 .
This commit is contained in:
Dmitry Stefantsov 2017-06-21 14:17:19 +02:00
parent d03a0d798e
commit 8d583bde5b
8 changed files with 16 additions and 62 deletions

View file

@ -168,9 +168,8 @@ FlowGraph* IrregexpCompilationPipeline::BuildFlowGraph(
const ZoneGrowableArray<const ICData*>& ic_data_array,
intptr_t osr_id) {
// Compile to the dart IR.
RegExpEngine::CompilationResult result =
RegExpEngine::CompileIR(parsed_function->regexp_compile_data(),
parsed_function, ic_data_array, osr_id);
RegExpEngine::CompilationResult result = RegExpEngine::CompileIR(
parsed_function->regexp_compile_data(), parsed_function, ic_data_array);
backtrack_goto_ = result.backtrack_goto;
// Allocate variables now that we know the number of locals.

View file

@ -2066,17 +2066,6 @@ Definition* RedefinitionInstr::Canonicalize(FlowGraph* flow_graph) {
}
Instruction* CheckStackOverflowInstr::Canonicalize(FlowGraph* flow_graph) {
switch (kind_) {
case kOsrAndPreemption:
return this;
case kOsrOnly:
// Don't need OSR entries in the optimized code.
return NULL;
}
}
bool LoadFieldInstr::IsImmutableLengthLoad() const {
switch (recognized_kind()) {
case MethodRecognizer::kObjectArrayLength:

View file

@ -7287,27 +7287,12 @@ class UnaryDoubleOpInstr : public TemplateDefinition<1, NoThrow, Pure> {
class CheckStackOverflowInstr : public TemplateInstruction<0, NoThrow> {
public:
enum Kind {
// kOsrAndPreemption stack overflow checks are emitted in both unoptimized
// and optimized versions of the code and they serve as both preemption and
// OSR entry points.
kOsrAndPreemption,
// kOsrOnly stack overflow checks are only needed in the unoptimized code
// because we can't OSR optimized code.
kOsrOnly,
};
CheckStackOverflowInstr(TokenPosition token_pos,
intptr_t loop_depth,
intptr_t deopt_id,
Kind kind = kOsrAndPreemption)
intptr_t deopt_id)
: TemplateInstruction(deopt_id),
token_pos_(token_pos),
loop_depth_(loop_depth),
kind_(kind) {
ASSERT(kind != kOsrOnly || loop_depth > 0);
}
loop_depth_(loop_depth) {}
virtual TokenPosition token_pos() const { return token_pos_; }
bool in_loop() const { return loop_depth_ > 0; }
@ -7317,8 +7302,6 @@ class CheckStackOverflowInstr : public TemplateInstruction<0, NoThrow> {
virtual bool ComputeCanDeoptimize() const { return true; }
virtual Instruction* Canonicalize(FlowGraph* flow_graph);
virtual EffectSet Effects() const { return EffectSet::None(); }
PRINT_OPERANDS_TO_SUPPORT
@ -7326,7 +7309,6 @@ class CheckStackOverflowInstr : public TemplateInstruction<0, NoThrow> {
private:
const TokenPosition token_pos_;
const intptr_t loop_depth_;
const Kind kind_;
DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr);
};

View file

@ -3029,7 +3029,6 @@ void BoyerMooreLookahead::EmitSkipInstructions(RegExpMacroAssembler* masm) {
BlockLabel cont, again;
masm->BindBlock(&again);
masm->CheckPreemption(/*is_backtrack=*/false);
masm->LoadCurrentCharacter(max_lookahead, &cont, true);
masm->CheckBitInTable(boolean_skip_table, &cont);
masm->AdvanceCurrentPosition(skip_distance);
@ -3236,7 +3235,6 @@ Trace* ChoiceNode::EmitGreedyLoop(RegExpCompiler* compiler,
greedy_match_trace.set_backtrack(&greedy_match_failed);
BlockLabel loop_label;
macro_assembler->BindBlock(&loop_label);
macro_assembler->CheckPreemption(/*is_backtrack=*/false);
greedy_match_trace.set_stop_node(this);
greedy_match_trace.set_loop_label(&loop_label);
(*alternatives_)[0].node()->Emit(compiler, &greedy_match_trace);
@ -4820,8 +4818,7 @@ void TextNode::FillInBMInfo(intptr_t initial_offset,
RegExpEngine::CompilationResult RegExpEngine::CompileIR(
RegExpCompileData* data,
const ParsedFunction* parsed_function,
const ZoneGrowableArray<const ICData*>& ic_data_array,
intptr_t osr_id) {
const ZoneGrowableArray<const ICData*>& ic_data_array) {
ASSERT(!FLAG_interpret_irregexp);
Zone* zone = Thread::Current()->zone();
@ -4897,9 +4894,9 @@ RegExpEngine::CompilationResult RegExpEngine::CompileIR(
// Native regexp implementation.
IRRegExpMacroAssembler* macro_assembler = new (zone)
IRRegExpMacroAssembler(specialization_cid, data->capture_count,
parsed_function, ic_data_array, osr_id, zone);
IRRegExpMacroAssembler* macro_assembler =
new (zone) IRRegExpMacroAssembler(specialization_cid, data->capture_count,
parsed_function, ic_data_array, zone);
// Inserted here, instead of in Assembler, because it depends on information
// in the AST that isn't replicated in the Node structure.

View file

@ -1393,8 +1393,7 @@ class RegExpEngine : public AllStatic {
static CompilationResult CompileIR(
RegExpCompileData* input,
const ParsedFunction* parsed_function,
const ZoneGrowableArray<const ICData*>& ic_data_array,
intptr_t osr_id);
const ZoneGrowableArray<const ICData*>& ic_data_array);
static CompilationResult CompileBytecode(RegExpCompileData* data,
const RegExp& regexp,

View file

@ -153,9 +153,6 @@ class RegExpMacroAssembler : public ZoneAllocated {
virtual void CheckBitInTable(const TypedData& table,
BlockLabel* on_bit_set) = 0;
// Checks for pre-emption and serves as an OSR entry.
virtual void CheckPreemption(bool is_backtrack) {}
// Checks whether the given offset from the current position is before
// the end of the string. May overwrite the current character.
virtual void CheckPosition(intptr_t cp_offset, BlockLabel* on_outside_input) {

View file

@ -78,7 +78,6 @@ IRRegExpMacroAssembler::IRRegExpMacroAssembler(
intptr_t capture_count,
const ParsedFunction* parsed_function,
const ZoneGrowableArray<const ICData*>& ic_data_array,
intptr_t osr_id,
Zone* zone)
: RegExpMacroAssembler(zone),
thread_(Thread::Current()),
@ -126,7 +125,7 @@ IRRegExpMacroAssembler::IRRegExpMacroAssembler(
*parsed_function_,
new (zone) TargetEntryInstr(block_id_.Alloc(), kInvalidTryIndex,
GetNextDeoptId()),
osr_id);
Compiler::kNoOSRDeoptId);
start_block_ = new (zone)
JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex, GetNextDeoptId());
success_block_ = new (zone)
@ -224,7 +223,7 @@ void IRRegExpMacroAssembler::GenerateEntryBlock() {
void IRRegExpMacroAssembler::GenerateBacktrackBlock() {
set_current_instruction(backtrack_block_);
TAG();
CheckPreemption(/*is_backtrack=*/true);
CheckPreemption();
const intptr_t entries_count = entry_block_->indirect_entries().length();
@ -1768,17 +1767,10 @@ IndirectEntryInstr* IRRegExpMacroAssembler::IndirectWithJoinGoto(
}
void IRRegExpMacroAssembler::CheckPreemption(bool is_backtrack) {
void IRRegExpMacroAssembler::CheckPreemption() {
TAG();
// We don't have the loop_depth available when compiling regexps, but
// we set loop_depth to a non-zero value because this instruction does
// not act as an OSR entry outside loops.
AppendInstruction(new (Z) CheckStackOverflowInstr(
TokenPosition::kNoSource,
/*loop_depth=*/1, GetNextDeoptId(),
is_backtrack ? CheckStackOverflowInstr::kOsrAndPreemption
: CheckStackOverflowInstr::kOsrOnly));
AppendInstruction(new (Z) CheckStackOverflowInstr(TokenPosition::kNoSource, 0,
GetNextDeoptId()));
}

View file

@ -32,7 +32,6 @@ class IRRegExpMacroAssembler : public RegExpMacroAssembler {
intptr_t capture_count,
const ParsedFunction* parsed_function,
const ZoneGrowableArray<const ICData*>& ic_data_array,
intptr_t osr_id,
Zone* zone);
virtual ~IRRegExpMacroAssembler();
@ -285,8 +284,8 @@ class IRRegExpMacroAssembler : public RegExpMacroAssembler {
// Load a number of characters starting from index in the pattern string.
Value* LoadCodeUnitsAt(LocalVariable* index, intptr_t character_count);
// Check whether preemption has been requested. Also serves as an OSR entry.
void CheckPreemption(bool is_backtrack);
// Check whether preemption has been requested.
void CheckPreemption();
// Byte size of chars in the string to match (decided by the Mode argument)
inline intptr_t char_size() { return static_cast<int>(mode_); }