annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeLibraryHandle.java @ 13905:3089e9a7cf44

fixed bug in passing primitive arrays through native function handles
author Doug Simon <doug.simon@oracle.com>
date Fri, 07 Feb 2014 01:08:35 +0100
parents d6e2511cea77
children dd8449afc086
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13837
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
1 /*
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
4 *
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
8 *
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
13 * accompanied this code).
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
14 *
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
18 *
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
21 * questions.
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
22 */
13895
4731c1a0b1f3 consolidated GNFI code into graal.hotspot project and cleaned up the documentation and code
Doug Simon <doug.simon@oracle.com>
parents: 13872
diff changeset
23 package com.oracle.graal.hotspot.nfi;
13837
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
24
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
25 import com.oracle.graal.api.code.*;
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
26
13895
4731c1a0b1f3 consolidated GNFI code into graal.hotspot project and cleaned up the documentation and code
Doug Simon <doug.simon@oracle.com>
parents: 13872
diff changeset
27 public class HotSpotNativeLibraryHandle implements NativeLibraryHandle {
13837
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
28
13895
4731c1a0b1f3 consolidated GNFI code into graal.hotspot project and cleaned up the documentation and code
Doug Simon <doug.simon@oracle.com>
parents: 13872
diff changeset
29 final long value;
4731c1a0b1f3 consolidated GNFI code into graal.hotspot project and cleaned up the documentation and code
Doug Simon <doug.simon@oracle.com>
parents: 13872
diff changeset
30 final String name;
13837
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
31
13895
4731c1a0b1f3 consolidated GNFI code into graal.hotspot project and cleaned up the documentation and code
Doug Simon <doug.simon@oracle.com>
parents: 13872
diff changeset
32 public HotSpotNativeLibraryHandle(String name, long handle) {
4731c1a0b1f3 consolidated GNFI code into graal.hotspot project and cleaned up the documentation and code
Doug Simon <doug.simon@oracle.com>
parents: 13872
diff changeset
33 this.name = name;
4731c1a0b1f3 consolidated GNFI code into graal.hotspot project and cleaned up the documentation and code
Doug Simon <doug.simon@oracle.com>
parents: 13872
diff changeset
34 this.value = handle;
13837
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
35 }
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
36
13898
d6e2511cea77 added NativeLibraryHandle.getName()
Doug Simon <doug.simon@oracle.com>
parents: 13895
diff changeset
37 public String getName() {
d6e2511cea77 added NativeLibraryHandle.getName()
Doug Simon <doug.simon@oracle.com>
parents: 13895
diff changeset
38 return name;
d6e2511cea77 added NativeLibraryHandle.getName()
Doug Simon <doug.simon@oracle.com>
parents: 13895
diff changeset
39 }
d6e2511cea77 added NativeLibraryHandle.getName()
Doug Simon <doug.simon@oracle.com>
parents: 13895
diff changeset
40
13895
4731c1a0b1f3 consolidated GNFI code into graal.hotspot project and cleaned up the documentation and code
Doug Simon <doug.simon@oracle.com>
parents: 13872
diff changeset
41 @Override
13905
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
42 public boolean equals(Object obj) {
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
43 if (obj instanceof HotSpotNativeLibraryHandle) {
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
44 HotSpotNativeLibraryHandle that = (HotSpotNativeLibraryHandle) obj;
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
45 return that.value == value;
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
46 }
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
47 return false;
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
48 }
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
49
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
50 @Override
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
51 public int hashCode() {
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
52 return (int) value;
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
53 }
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
54
3089e9a7cf44 fixed bug in passing primitive arrays through native function handles
Doug Simon <doug.simon@oracle.com>
parents: 13898
diff changeset
55 @Override
13895
4731c1a0b1f3 consolidated GNFI code into graal.hotspot project and cleaned up the documentation and code
Doug Simon <doug.simon@oracle.com>
parents: 13872
diff changeset
56 public String toString() {
4731c1a0b1f3 consolidated GNFI code into graal.hotspot project and cleaned up the documentation and code
Doug Simon <doug.simon@oracle.com>
parents: 13872
diff changeset
57 return name + "@" + value;
13837
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
58 }
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
59 }