Created
December 6, 2017 16:08
-
-
Save mraleph/ba92961dddfcb668b8ca84fc9cf0cb36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define __ f+= | |
struct Bind { | |
Bind(BlockEntryInstr* block) : block(block) { } | |
BlockEntryInstr* block; | |
} | |
Fragment operator + (const Fragment& f, const Bind& bind) { | |
return Fragment(f.entry, bind.block); | |
} | |
Fragment PrologueBuilder::BuildTypeArgumentsLengthCheck(bool strong, | |
JoinEntryInstr* nsm, | |
bool expect_type_args) { | |
Fragment f; | |
JoinEntryInstr* done = BuildJoinEntry(); | |
// Type args are always optional, so length can always be zero. | |
// If expect_type_args, a non-zero length must match the declaration length. | |
TargetEntryInstr *then, *fail; | |
__ LoadArgDescriptor(); | |
__ LoadField(ArgumentsDescriptor::type_args_len_offset()); | |
if (strong) { | |
__ IntConstant(ArgumentsDescriptor::TypeArgsLenField::mask()); | |
__ SmiBinaryOp(Token::kBIT_AND, true); | |
} | |
if (expect_type_args) { | |
LocalVariable* len = MakeTemporary(); | |
TargetEntryInstr *otherwise, *then2; | |
__ LoadLocal(len); | |
__ IntConstant(0); | |
__ BranchIfEqual(&then, &otherwise); | |
__ Bind(otherwise); | |
__ IntConstant(function_.NumTypeParameters()); | |
__ BranchIfEqual(&then2, &fail); | |
__ Bind(then2); | |
__ Goto(done); | |
} else { | |
__ IntConstant(0); | |
__ BranchIfEqual(&then, &fail); | |
} | |
__ Bind(then) | |
__ Goto(done); | |
__ Bind(fail); | |
__ Goto(nsm); | |
return f; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment