Flutter Engine
The Flutter Engine
asm_intrinsifier.cc
Go to the documentation of this file.
1// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
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.
4// Class for intrinsifying functions.
5#define SHOULD_NOT_INCLUDE_RUNTIME
6
8
9namespace dart {
10namespace compiler {
11
12void AsmIntrinsifier::String_identityHash(Assembler* assembler,
13 Label* normal_ir_body) {
14 String_getHashCode(assembler, normal_ir_body);
15}
16
17void AsmIntrinsifier::RegExp_ExecuteMatch(Assembler* assembler,
18 Label* normal_ir_body) {
19 AsmIntrinsifier::IntrinsifyRegExpExecuteMatch(assembler, normal_ir_body,
20 /*sticky=*/false);
21}
22
23void AsmIntrinsifier::RegExp_ExecuteMatchSticky(Assembler* assembler,
24 Label* normal_ir_body) {
25 AsmIntrinsifier::IntrinsifyRegExpExecuteMatch(assembler, normal_ir_body,
26 /*sticky=*/true);
27}
28
29#define __ assembler->
30
31// TODO(srdjan): Add combinations (one-byte/two-byte/external strings).
32void AsmIntrinsifier::StringEquality(Assembler* assembler,
33 Register obj1,
34 Register obj2,
35 Register temp1,
36 Register temp2,
38 Label* normal_ir_body,
39 intptr_t string_cid) {
40 Label is_true, is_false, loop;
41
42 __ CompareRegisters(obj1, obj2);
43 __ BranchIf(EQUAL, &is_true, AssemblerBase::kNearJump);
44 __ BranchIfSmi(obj2, &is_false, AssemblerBase::kNearJump);
45 __ CompareClassId(obj2, string_cid, temp1);
46 __ BranchIf(NOT_EQUAL, normal_ir_body, AssemblerBase::kNearJump);
47
48 __ LoadFieldFromOffset(temp1, obj1, target::String::length_offset());
49 __ CompareWithMemoryValue(
50 temp1, FieldAddress(obj2, target::String::length_offset()));
51 __ BranchIf(NOT_EQUAL, &is_false, AssemblerBase::kNearJump);
52
53 // Ensure temp1 has length in bytes
54 if (string_cid == kOneByteStringCid) {
55 __ ArithmeticShiftRightImmediate(temp1, 1);
56 }
57 // Rounding up to word boundary
58 __ AddImmediate(temp1, target::kWordSize - 1);
59 __ ArithmeticShiftRightImmediate(temp1, target::kWordSizeLog2);
60 __ CompareWords(obj1, obj2,
62 temp2, &is_true);
63
64 __ Bind(&is_false);
65 __ LoadObject(result, CastHandle<Object>(FalseObject()));
66 __ Ret();
67
68 __ Bind(&is_true);
69 __ LoadObject(result, CastHandle<Object>(TrueObject()));
70 __ Ret();
71
72 __ Bind(normal_ir_body);
73}
74
75} // namespace compiler
76} // namespace dart
#define __
GAsyncResult * result
static constexpr intptr_t kWordSize
Definition: runtime_api.h:274
const Bool & TrueObject()
Definition: runtime_api.cc:157
const Bool & FalseObject()
Definition: runtime_api.cc:161
Definition: dart_vm.cc:33
constexpr intptr_t kWordSizeLog2
Definition: globals.h:507
@ NOT_EQUAL
static bool Bind(PassBindingsCacheMTL &pass, ShaderStage stage, size_t bind_index, const BufferView &view)