jdk

Форк
0
/
downcallLinker.cpp 
72 строки · 2.5 Кб
1
/*
2
 * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
 *
5
 * This code is free software; you can redistribute it and/or modify it
6
 * under the terms of the GNU General Public License version 2 only, as
7
 * published by the Free Software Foundation.
8
 *
9
 * This code is distributed in the hope that it will be useful, but WITHOUT
10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
 * version 2 for more details (a copy is included in the LICENSE file that
13
 * accompanied this code).
14
 *
15
 * You should have received a copy of the GNU General Public License version
16
 * 2 along with this work; if not, write to the Free Software Foundation,
17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
 *
19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
 * or visit www.oracle.com if you need additional information or have any
21
 * questions.
22
 */
23

24
#include "precompiled.hpp"
25
#include "downcallLinker.hpp"
26
#include "gc/shared/gcLocker.inline.hpp"
27
#include "runtime/interfaceSupport.inline.hpp"
28

29
#include <cerrno>
30
#ifdef _WIN64
31
#include <Windows.h>
32
#include <Winsock2.h>
33
#endif
34

35
// We call this from _thread_in_native, right after a downcall
36
JVM_LEAF(void, DowncallLinker::capture_state(int32_t* value_ptr, int captured_state_mask))
37
  // keep in synch with jdk.internal.foreign.abi.PreservableValues
38
  enum PreservableValues {
39
    NONE = 0,
40
    GET_LAST_ERROR = 1,
41
    WSA_GET_LAST_ERROR = 1 << 1,
42
    ERRNO = 1 << 2
43
  };
44
#ifdef _WIN64
45
  if (captured_state_mask & GET_LAST_ERROR) {
46
    *value_ptr = GetLastError();
47
  }
48
  value_ptr++;
49
  if (captured_state_mask & WSA_GET_LAST_ERROR) {
50
    *value_ptr = WSAGetLastError();
51
  }
52
  value_ptr++;
53
#endif
54
  if (captured_state_mask & ERRNO) {
55
    *value_ptr = errno;
56
  }
57
JVM_END
58

59
void DowncallLinker::StubGenerator::add_offsets_to_oops(GrowableArray<VMStorage>& java_regs, VMStorage tmp1, VMStorage tmp2) const {
60
  int reg_idx = 0;
61
  for (int sig_idx = 0; sig_idx < _num_args; sig_idx++) {
62
    if (_signature[sig_idx] == T_OBJECT) {
63
      assert(_signature[sig_idx + 1] == T_LONG, "expected offset after oop");
64
      VMStorage reg_oop = java_regs.at(reg_idx++);
65
      VMStorage reg_offset = java_regs.at(reg_idx++);
66
      sig_idx++; // skip offset
67
      pd_add_offset_to_oop(reg_oop, reg_offset, tmp1, tmp2);
68
    } else if (_signature[sig_idx] != T_VOID) {
69
      reg_idx++;
70
    }
71
  }
72
}
73

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.