Skip to content

Commit

Permalink
[maglev][arm] Implement BuiltinStringPrototypeCharCodeOrCodePointAt
Browse files Browse the repository at this point in the history
Bug: v8:7700
Change-Id: I1424987e6170f47aec947c992d8123c9de91e619
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4642191
Commit-Queue: Leszek Swirski <[email protected]>
Auto-Submit: Victor Gomes <[email protected]>
Commit-Queue: Victor Gomes <[email protected]>
Reviewed-by: Leszek Swirski <[email protected]>
Cr-Commit-Position: refs/heads/main@{#88488}
  • Loading branch information
victorgomes authored and V8 LUCI CQ committed Jun 26, 2023
1 parent 6361d7e commit b084a99
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/maglev/arm/maglev-ir-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,33 @@ void BuiltinStringFromCharCode::SetValueLocationConstraints() {
}
void BuiltinStringFromCharCode::GenerateCode(MaglevAssembler* masm,
const ProcessingState& state) {
MAGLEV_NODE_NOT_IMPLEMENTED(BuiltinStringFromCharCode);
MaglevAssembler::ScratchRegisterScope temps(masm);
Register scratch = temps.Acquire();
Register result_string = ToRegister(result());
if (Int32Constant* constant = code_input().node()->TryCast<Int32Constant>()) {
int32_t char_code = constant->value();
if (0 <= char_code && char_code < String::kMaxOneByteCharCode) {
__ LoadSingleCharacterString(result_string, char_code);
} else {
// Ensure that {result_string} never aliases {scratch}, otherwise the
// store will fail.
bool reallocate_result = (scratch == result_string);
if (reallocate_result) {
result_string = temps.Acquire();
}
DCHECK(scratch != result_string);
__ AllocateTwoByteString(register_snapshot(), result_string, 1);
__ Move(scratch, char_code & 0xFFFF);
__ strh(scratch,
FieldMemOperand(result_string, SeqTwoByteString::kHeaderSize));
if (reallocate_result) {
__ Move(ToRegister(result()), result_string);
}
}
} else {
__ StringFromCharCode(register_snapshot(), nullptr, result_string,
ToRegister(code_input()), scratch);
}
}

int BuiltinStringPrototypeCharCodeOrCodePointAt::MaxCallStackArgs() const {
Expand Down

0 comments on commit b084a99

Please sign in to comment.