Skip to content

Commit 7557771

Browse files
committed
Fix style and copyrights.
1 parent 1a12f84 commit 7557771

File tree

15 files changed

+45
-92
lines changed

15 files changed

+45
-92
lines changed

graalpython/com.oracle.graal.python.cext/src/capi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,12 @@ allocfunc get_tp_alloc(PyTypeObject* obj) {
339339
}
340340

341341
/** to be used from Java code only; reads native 'tp_dealloc' field */
342-
allocfunc get_tp_dealloc(PyTypeObject* obj) {
342+
destructor get_tp_dealloc(PyTypeObject* obj) {
343343
return obj->tp_dealloc;
344344
}
345345

346346
/** to be used from Java code only; reads native 'tp_free' field */
347-
allocfunc get_tp_free(PyTypeObject* obj) {
347+
freefunc get_tp_free(PyTypeObject* obj) {
348348
return obj->tp_free;
349349
}
350350

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PythonCextBuiltins.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
import com.oracle.graal.python.builtins.objects.cext.CArrayWrappers.CByteArrayWrapper;
100100
import com.oracle.graal.python.builtins.objects.cext.CArrayWrappers.CStringWrapper;
101101
import com.oracle.graal.python.builtins.objects.cext.CExtNodes;
102+
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.AddRefCntNode;
102103
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.AllToSulongNode;
103104
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.AsPythonObjectNode;
104105
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.AsPythonObjectStealingNode;
@@ -117,7 +118,6 @@
117118
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.MayRaiseUnaryNode;
118119
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.PCallCapiFunction;
119120
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.PRaiseNativeNode;
120-
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.RefCntNode;
121121
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.ResolveHandleNode;
122122
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.TernaryFirstSecondToSulongNode;
123123
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.TernaryFirstThirdToSulongNode;
@@ -2561,7 +2561,7 @@ abstract static class PyNumberFloat extends NativeBuiltin {
25612561

25622562
@Specialization(guards = "object.isDouble()")
25632563
static Object doDoubleNativeWrapper(@SuppressWarnings("unused") Object module, PrimitiveNativeWrapper object,
2564-
@Cached RefCntNode refCntNode) {
2564+
@Cached AddRefCntNode refCntNode) {
25652565
return refCntNode.inc(object);
25662566
}
25672567

@@ -3242,8 +3242,8 @@ abstract static class PyTruffleTraceMallocTrack extends PythonBuiltinNode {
32423242
private static final TruffleLogger LOGGER = PythonLanguage.getLogger(PyTruffleTraceMallocTrack.class);
32433243

32443244
@Specialization(guards = {"domain == cachedDomain"}, limit = "3")
3245-
int doCachedDomainIdx(VirtualFrame frame, long domain, Object pointerObject, long size,
3246-
@Cached("domain") long cachedDomain,
3245+
int doCachedDomainIdx(VirtualFrame frame, @SuppressWarnings("unused") long domain, Object pointerObject, long size,
3246+
@Cached("domain") @SuppressWarnings("unused") long cachedDomain,
32473247
@Cached("lookupDomain(domain)") int cachedDomainIdx) {
32483248

32493249
CApiContext cApiContext = getContext().getCApiContext();
@@ -3310,7 +3310,7 @@ static int doCachedDomainIdx(Object pointerObject) {
33103310
abstract static class PyTruffleGcTracingNode extends PythonUnaryBuiltinNode {
33113311

33123312
@Specialization(guards = {"!traceCalls(context)", "traceMem(context)"})
3313-
int doNativeWrapper(VirtualFrame frame, Object ptr,
3313+
int doNativeWrapper(Object ptr,
33143314
@Shared("context") @CachedContext(PythonLanguage.class) PythonContext context,
33153315
@Shared("lib") @CachedLibrary(limit = "3") InteropLibrary lib) {
33163316
trace(context, CApiContext.asPointer(ptr, lib), null, null);
@@ -3329,7 +3329,7 @@ int doNativeWrapperTraceCall(VirtualFrame frame, Object ptr,
33293329
}
33303330

33313331
@Specialization(guards = "!traceMem(context)")
3332-
static int doNothing(VirtualFrame frame, Object ptr,
3332+
static int doNothing(@SuppressWarnings("unused") Object ptr,
33333333
@Shared("context") @CachedContext(PythonLanguage.class) @SuppressWarnings("unused") PythonContext context) {
33343334
// do nothing
33353335
return 0;
@@ -3343,6 +3343,7 @@ static boolean traceCalls(PythonContext context) {
33433343
return context.getOption(PythonOptions.TraceNativeMemoryCalls);
33443344
}
33453345

3346+
@SuppressWarnings("unused")
33463347
protected void trace(PythonContext context, Object ptr, Reference ref, String className) {
33473348
CompilerDirectives.transferToInterpreter();
33483349
throw new IllegalStateException("should not reach");

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,17 @@ private static class SignalTriggerAction extends AsyncHandler.AsyncPythonAction
129129
this.signum = signum;
130130
}
131131

132+
@Override
132133
public Object callable() {
133134
return callableObject;
134135
}
135136

137+
@Override
136138
public Object[] arguments() {
137139
return new Object[]{signum, null};
138140
}
139141

142+
@Override
140143
public int frameIndex() {
141144
return 1;
142145
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WeakRefModuleBuiltins.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ public WeakrefCallbackAction(PReferenceType.WeakRefStorage reference) {
9393
this.reference = reference;
9494
}
9595

96+
@Override
9697
public Object callable() {
9798
return reference.getCallback();
9899
}
99100

101+
@Override
100102
public Object[] arguments() {
101103
return new Object[]{reference.getRef()};
102104
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/CExtNodes.java

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@
136136
import com.oracle.truffle.api.CompilerAsserts;
137137
import com.oracle.truffle.api.CompilerDirectives;
138138
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
139-
import com.oracle.truffle.api.TruffleLogger;
140139
import com.oracle.truffle.api.dsl.Cached;
141140
import com.oracle.truffle.api.dsl.Cached.Exclusive;
142141
import com.oracle.truffle.api.dsl.Cached.Shared;
@@ -550,7 +549,7 @@ static Object doDouble(@SuppressWarnings("unused") CExtContext cextContext, @Sup
550549

551550
@Specialization
552551
static Object doNativeObject(CExtContext cextContext, PythonAbstractNativeObject nativeObject,
553-
@Cached RefCntNode refCntNode) {
552+
@Cached AddRefCntNode refCntNode) {
554553
Object res = ToSulongNode.doNativeObject(cextContext, nativeObject);
555554
refCntNode.inc(res);
556555
return res;
@@ -2684,7 +2683,6 @@ public static void raiseNative(Frame frame, LazyPythonClass errType, String form
26842683
@GenerateUncached
26852684
@ImportStatic(CApiGuards.class)
26862685
public abstract static class AddRefCntNode extends PNodeWithContext {
2687-
private static final TruffleLogger LOGGER = PythonLanguage.getLogger(AddRefCntNode.class);
26882686

26892687
public abstract Object execute(Object object, long value);
26902688

@@ -2734,7 +2732,6 @@ static Object doNativeObject(Object object, long value,
27342732
@GenerateUncached
27352733
@ImportStatic(CApiGuards.class)
27362734
public abstract static class SubRefCntNode extends PNodeWithContext {
2737-
private static final TruffleLogger LOGGER = PythonLanguage.getLogger(SubRefCntNode.class);
27382735

27392736
public abstract Object execute(Object object, long value);
27402737

@@ -2758,54 +2755,15 @@ static Object doNativeObject(Object object, long value,
27582755
}
27592756
}
27602757

2761-
@GenerateUncached
2762-
@ImportStatic(CApiGuards.class)
2763-
public abstract static class RefCntNode extends PNodeWithContext {
2764-
private static final TruffleLogger LOGGER = PythonLanguage.getLogger(RefCntNode.class);
2765-
2766-
/**
2767-
* Do not use directly! Use {@link #inc(Object)} or {@link #dec(Object)};
2768-
*/
2769-
abstract Object execute(String fun, Object object);
2770-
2771-
public final Object inc(Object object) {
2772-
return execute(NativeCAPISymbols.FUN_INCREF, object);
2773-
}
2774-
2775-
public final Object dec(Object object) {
2776-
return execute(NativeCAPISymbols.FUN_DECREF, object);
2777-
}
2778-
2779-
@Specialization
2780-
static Object doNativeWrapper(@SuppressWarnings("unused") String fun, PythonNativeWrapper nativeWrapper) {
2781-
nativeWrapper.increaseRefCount();
2782-
return nativeWrapper;
2783-
}
2784-
2785-
@Specialization(guards = "!isNativeWrapper(object)", limit = "2")
2786-
static Object doNativeObject(String fun, Object object,
2787-
@CachedContext(PythonLanguage.class) PythonContext context,
2788-
@Cached PCallCapiFunction callIncRefNode,
2789-
@CachedLibrary("object") InteropLibrary lib) {
2790-
CApiContext cApiContext = context.getCApiContext();
2791-
if (!lib.isNull(object) && cApiContext != null) {
2792-
cApiContext.checkAccess(object, lib);
2793-
CompilerAsserts.partialEvaluationConstant(fun);
2794-
callIncRefNode.call(fun, object);
2795-
}
2796-
return object;
2797-
}
2798-
}
2799-
28002758
@GenerateUncached
28012759
@ImportStatic(PGuards.class)
28022760
public abstract static class ClearNativeWrapperNode extends Node {
2761+
28032762
public abstract void execute(Object delegate, PythonNativeWrapper nativeWrapper);
28042763

28052764
@Specialization(guards = "!isPrimitiveNativeWrapper(nativeWrapper)")
28062765
static void doPythonAbstractObject(PythonAbstractObject delegate, PythonNativeWrapper nativeWrapper) {
2807-
// If this assertion fails, it indicates that the native code still uses a free'd
2808-
// native
2766+
// If this assertion fails, it indicates that the native code still uses a free'd native
28092767
// wrapper.
28102768
assert delegate.getNativeWrapper() == nativeWrapper : "inconsistent native wrappers";
28112769
delegate.clearNativeWrapper();
@@ -2831,7 +2789,6 @@ static boolean isPrimitiveNativeWrapper(PythonNativeWrapper nativeWrapper) {
28312789

28322790
@GenerateUncached
28332791
public abstract static class GetRefCntNode extends PNodeWithContext {
2834-
private static final TruffleLogger LOGGER = PythonLanguage.getLogger(GetRefCntNode.class);
28352792

28362793
public abstract long execute(Object ptrObject);
28372794

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/DynamicObjectNativeWrapper.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,6 @@ protected static boolean isObBase(String key) {
257257
protected static boolean isObRefcnt(String key) {
258258
return OB_REFCNT.getMemberName().equals(key);
259259
}
260-
261-
protected static boolean isObType(String key) {
262-
return OB_TYPE.getMemberName().equals(key);
263-
}
264260
}
265261

266262
@GenerateUncached
@@ -1167,12 +1163,12 @@ static Object doMemoryview(PMemoryView object, @SuppressWarnings("unused") Pytho
11671163

11681164
@Specialization(guards = "eq(F_LINENO, key)")
11691165
static int doFLineno(PFrame object, @SuppressWarnings("unused") PythonNativeWrapper nativeWrapper, @SuppressWarnings("unused") String key, Object value,
1170-
@Cached(value = "createLossy()", uncached = "getLossyUncached()") CastToJavaIntNode castToJavaIntNode) {
1166+
@Cached(value = "createLossy()", uncached = "getLossyUncached()") CastToJavaIntNode castToJavaIntNode) {
11711167
try {
11721168
int lineno = castToJavaIntNode.execute(value);
11731169
object.setLine(lineno);
11741170
return lineno;
1175-
} catch(PException e) {
1171+
} catch (PException e) {
11761172
return -1;
11771173
}
11781174
}
@@ -1796,7 +1792,7 @@ static long doPInt(PInt object) {
17961792
return object.bitCount() / 32;
17971793
}
17981794

1799-
@Specialization(limit = "getCallSiteInlineCacheMaxDepth()")
1795+
@Specialization(limit = "getCallSiteInlineCacheMaxDepth()", guards = "isFallback(object)")
18001796
static long doOther(Object object,
18011797
@CachedLibrary("object") PythonObjectLibrary lib) {
18021798
try {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PyDateTimeCAPIWrapper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,31 +123,37 @@ public PyDateTimeCAPIWrapper(Object delegate) {
123123
}
124124

125125
@ExportMessage
126+
@SuppressWarnings("static-method")
126127
boolean hasMembers() {
127128
return true;
128129
}
129130

130131
@ExportMessage
132+
@SuppressWarnings({"static-method", "unused"})
131133
Object getMembers(boolean includeInternal) {
132134
return new InteropArray(new String[0]);
133135
}
134136

135137
@ExportMessage
138+
@SuppressWarnings("static-method")
136139
boolean isMemberReadable(String member) {
137140
return indexOf(member) != -1;
138141
}
139142

140143
@ExportMessage
144+
@SuppressWarnings("static-method")
141145
boolean isMemberInvocable(String member) {
142146
return indexOf(member) >= INVOCABLE_MEMBER_START_IDX;
143147
}
144148

145149
@ExportMessage
150+
@SuppressWarnings("static-method")
146151
boolean isMemberModifiable(String member) {
147152
return isMemberReadable(member);
148153
}
149154

150155
@ExportMessage
156+
@SuppressWarnings({"static-method", "unused"})
151157
boolean isMemberInsertable(String member) {
152158
return false;
153159
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PyGetSetDefWrapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
import com.oracle.truffle.api.dsl.ImportStatic;
5858
import com.oracle.truffle.api.dsl.Specialization;
5959
import com.oracle.truffle.api.interop.InteropLibrary;
60-
import com.oracle.truffle.api.interop.UnknownIdentifierException;
6160
import com.oracle.truffle.api.interop.UnsupportedMessageException;
6261
import com.oracle.truffle.api.library.CachedLibrary;
6362
import com.oracle.truffle.api.library.ExportLibrary;
@@ -161,7 +160,7 @@ protected boolean isMemberInsertable(String member) {
161160
protected void writeMember(String member, Object value,
162161
@CachedLibrary("this") PythonNativeWrapperLibrary lib,
163162
@Exclusive @Cached WriteAttributeToDynamicObjectNode writeAttrToDynamicObjectNode,
164-
@Exclusive @Cached CExtNodes.FromCharPointerNode fromCharPointerNode) throws UnsupportedMessageException, UnknownIdentifierException {
163+
@Exclusive @Cached CExtNodes.FromCharPointerNode fromCharPointerNode) throws UnsupportedMessageException {
165164
if (!DOC.equals(member)) {
166165
throw UnsupportedMessageException.create();
167166
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PyProcsWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
*/
4141
package com.oracle.graal.python.builtins.objects.cext;
4242

43+
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.AddRefCntNode;
4344
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.GetNativeNullNode;
44-
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.RefCntNode;
4545
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.ToJavaNode;
4646
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.ToNewRefNode;
4747
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.ToSulongNode;
@@ -135,7 +135,7 @@ protected Object execute(Object[] arguments,
135135
@Cached ToJavaNode toJavaNode,
136136
@Exclusive @Cached IsBuiltinClassProfile errProfile,
137137
@Cached GetNativeNullNode getNativeNullNode,
138-
@Cached RefCntNode incRefNode,
138+
@Cached AddRefCntNode incRefNode,
139139
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) throws ArityException {
140140
if (arguments.length != 2) {
141141
throw ArityException.create(2, arguments.length);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PythonNativeWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public final Assumption getHandleValidAssumption() {
104104

105105
public final Assumption ensureHandleValidAssumption() {
106106
CompilerAsserts.neverPartOfCompilation();
107-
if(handleValidAssumption == null) {
107+
if (handleValidAssumption == null) {
108108
handleValidAssumption = Truffle.getRuntime().createAssumption();
109109
}
110110
return handleValidAssumption;

0 commit comments

Comments
 (0)