Skip to content

Commit

Permalink
[VM] Make FlowGraphCompiler::EmitTestAndCallCheckCid static and there…
Browse files Browse the repository at this point in the history
…fore usable from stubs

Issue #31798

Change-Id: I375cc01bf59d848a203dbcdbd59377d55e9aafe4
Reviewed-on: https://dart-review.googlesource.com/44540
Commit-Queue: Martin Kustermann <[email protected]>
Reviewed-by: Vyacheslav Egorov <[email protected]>
  • Loading branch information
mkustermann authored and [email protected] committed Mar 2, 2018
1 parent 9cfd721 commit 80805ff
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 13 deletions.
6 changes: 4 additions & 2 deletions runtime/vm/compiler/backend/flow_graph_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,8 @@ void FlowGraphCompiler::EmitTestAndCall(const CallTargets& targets,
}
Label next_test;
if (!complete || !is_last_check) {
bias = EmitTestAndCallCheckCid(is_last_check ? failed : &next_test,
bias = EmitTestAndCallCheckCid(assembler(),
is_last_check ? failed : &next_test,
EmitTestCidRegister(), targets[i], bias,
/*jump_on_miss =*/true);
}
Expand Down Expand Up @@ -1871,7 +1872,8 @@ bool FlowGraphCompiler::GenerateSubclassTypeCheck(Register class_id_reg,
for (intptr_t i = 0; i < ranges.length(); ++i) {
const CidRange& range = ranges[i];
if (!range.IsIllegalRange()) {
bias = EmitTestAndCallCheckCid(is_subtype, class_id_reg, range, bias,
bias = EmitTestAndCallCheckCid(assembler(), is_subtype, class_id_reg,
range, bias,
/*jump_on_miss=*/false);
}
}
Expand Down
17 changes: 10 additions & 7 deletions runtime/vm/compiler/backend/flow_graph_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,16 @@ class FlowGraphCompiler : public ValueObject {
void RecordAfterCall(Instruction* instr, CallResult result);
#endif

// Returns new class-id bias.
//
// TODO(kustermann): We should move this code out of the [FlowGraphCompiler]!
static int EmitTestAndCallCheckCid(Assembler* assembler,
Label* label,
Register class_id_reg,
const CidRange& range,
int bias,
bool jump_on_miss = true);

private:
friend class CheckStackOverflowSlowPath; // For pending_deoptimization_env_.
friend class CheckedSmiSlowPath; // Same.
Expand Down Expand Up @@ -668,13 +678,6 @@ class FlowGraphCompiler : public ValueObject {

void EmitTestAndCallLoadCid(Register class_id_reg);

// Returns new class-id bias.
int EmitTestAndCallCheckCid(Label* label,
Register class_id_reg,
const CidRange& range,
int bias,
bool jump_on_miss = true);

// DBC handles type tests differently from all other architectures due
// to its interpreted nature.
#if !defined(TARGET_ARCH_DBC)
Expand Down
6 changes: 5 additions & 1 deletion runtime/vm/compiler/backend/flow_graph_compiler_arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,11 @@ void FlowGraphCompiler::EmitTestAndCallLoadCid(Register class_id_reg) {
__ LoadClassId(class_id_reg, R0);
}

int FlowGraphCompiler::EmitTestAndCallCheckCid(Label* label,
#undef __
#define __ assembler->

int FlowGraphCompiler::EmitTestAndCallCheckCid(Assembler* assembler,
Label* label,
Register class_id_reg,
const CidRange& range,
int bias,
Expand Down
6 changes: 5 additions & 1 deletion runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,11 @@ void FlowGraphCompiler::EmitTestAndCallLoadCid(Register class_id_reg) {
__ LoadClassId(class_id_reg, R0);
}

int FlowGraphCompiler::EmitTestAndCallCheckCid(Label* label,
#undef __
#define __ assembler->

int FlowGraphCompiler::EmitTestAndCallCheckCid(Assembler* assembler,
Label* label,
Register class_id_reg,
const CidRange& range,
int bias,
Expand Down
6 changes: 5 additions & 1 deletion runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,11 @@ void FlowGraphCompiler::EmitTestAndCallLoadCid(Register class_id_reg) {
__ LoadClassId(class_id_reg, EAX);
}

int FlowGraphCompiler::EmitTestAndCallCheckCid(Label* label,
#undef __
#define __ assembler->

int FlowGraphCompiler::EmitTestAndCallCheckCid(Assembler* assembler,
Label* label,
Register class_id_reg,
const CidRange& range,
int bias,
Expand Down
6 changes: 5 additions & 1 deletion runtime/vm/compiler/backend/flow_graph_compiler_x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,11 @@ void FlowGraphCompiler::EmitTestAndCallLoadCid(Register class_id_reg) {
__ LoadClassId(class_id_reg, RAX);
}

int FlowGraphCompiler::EmitTestAndCallCheckCid(Label* label,
#undef __
#define __ assembler->

int FlowGraphCompiler::EmitTestAndCallCheckCid(Assembler* assembler,
Label* label,
Register class_id_reg,
const CidRange& range,
int bias,
Expand Down

0 comments on commit 80805ff

Please sign in to comment.