• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "include/object_header.h"
17 #include "intrinsics.h"
18 #include "libpandabase/utils/logger.h"
19 #include "runtime/handle_scope-inl.h"
20 
21 namespace panda::ets::intrinsics {
22 
StdCoreRuntimeIsSameReference(ObjectHeader * header,EtsObject * source,EtsObject * target)23 uint8_t StdCoreRuntimeIsSameReference([[maybe_unused]] ObjectHeader *header, EtsObject *source, EtsObject *target)
24 {
25     return (source == target) ? UINT8_C(1) : UINT8_C(0);
26 }
27 
StdCoreRuntimeGetHashCode(ObjectHeader * header,EtsObject * source)28 EtsInt StdCoreRuntimeGetHashCode([[maybe_unused]] ObjectHeader *header, EtsObject *source)
29 {
30     ASSERT(source != nullptr);
31     if (source->IsHashed()) {
32         return source->GetInteropHash();
33     }
34     auto hash = ObjectHeader::GenerateHashCode();
35     source->SetInteropHash(hash);
36     return bit_cast<EtsInt>(hash);
37 }
38 
39 }  // namespace panda::ets::intrinsics
40