Skip to content

Commit 35e3dcd

Browse files
committedMar 6, 2018
Old logic. Going back to Strings as id instead of ByteList.
1 parent c94eeb8 commit 35e3dcd

File tree

9 files changed

+24
-46
lines changed

9 files changed

+24
-46
lines changed
 

Diff for: ‎core/src/main/java/org/jruby/Ruby.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -4509,13 +4509,13 @@ public List<StrptimeToken> getCachedStrptimePattern(String pattern) {
45094509
/**
45104510
* Add a method, so it can be printed out later.
45114511
*
4512-
* @param name the name of the method
4512+
* @param id raw name String of the method to be profiled
45134513
* @param method
45144514
*/
4515-
void addProfiledMethod(final ByteList name, final DynamicMethod method) {
4515+
void addProfiledMethod(final String id, final DynamicMethod method) {
45164516
if (!config.isProfiling() || method.isUndefined()) return;
45174517

4518-
getProfilingService().addProfiledMethod(name, method);
4518+
getProfilingService().addProfiledMethod(id, method);
45194519
}
45204520

45214521
/**

Diff for: ‎core/src/main/java/org/jruby/RubyModule.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ private DynamicMethod putMethod(Ruby runtime, ByteList name, DynamicMethod metho
497497

498498
methodLocation.getMethodsForWrite().put(name, method);
499499

500-
runtime.addProfiledMethod(name, method);
500+
runtime.addProfiledMethod(name.toString(), method);
501501
return method;
502502
}
503503

@@ -1581,7 +1581,7 @@ public CacheEntry newCacheEntry(ByteList name, DynamicMethod method, int token)
15811581
if (method.isUndefined()) return new CacheEntry(method, token);
15821582

15831583
CacheEntry delegated = previous.newCacheEntry(name, method, token);
1584-
DynamicMethod enhancedMethod = getMethodEnhancer().enhance(name, delegated.method);
1584+
DynamicMethod enhancedMethod = getMethodEnhancer().enhance(name.toString(), delegated.method);
15851585

15861586
return new CacheEntry(enhancedMethod, delegated.token);
15871587
}

Diff for: ‎core/src/main/java/org/jruby/runtime/profile/MethodEnhancer.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
package org.jruby.runtime.profile;
2727

2828
import org.jruby.internal.runtime.methods.DynamicMethod;
29-
import org.jruby.util.ByteList;
3029

3130
/**
3231
* Implementations of this interface will be used to enhance methods with profiling information/ callbacks.
@@ -48,9 +47,9 @@ public interface MethodEnhancer {
4847
* return delegate;
4948
* }
5049
* </pre>
51-
* @param name the name of the given delegate
50+
* @param id the name of the given delegate
5251
* @param delegate the method to enhance
5352
* @return the enhanced method. if nothing is to be done, the delegate itself can be returned
5453
*/
55-
public DynamicMethod enhance(ByteList name, DynamicMethod delegate);
54+
public DynamicMethod enhance(String id, DynamicMethod delegate);
5655
}

Diff for: ‎core/src/main/java/org/jruby/runtime/profile/ProfilingService.java

-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.jruby.Ruby;
2929
import org.jruby.internal.runtime.methods.DynamicMethod;
3030
import org.jruby.runtime.ThreadContext;
31-
import org.jruby.util.ByteList;
3231

3332
/**
3433
* A ProfilingService is used to profile jruby programs.
@@ -67,8 +66,5 @@ public interface ProfilingService {
6766
* @param name the name
6867
* @param method the method
6968
*/
70-
@Deprecated
7169
public void addProfiledMethod(String name, DynamicMethod method);
72-
73-
public void addProfiledMethod(ByteList name, DynamicMethod method);
7470
}

Diff for: ‎core/src/main/java/org/jruby/runtime/profile/builtin/BuiltinProfilingService.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import org.jruby.runtime.profile.ProfileCollection;
3535
import org.jruby.runtime.profile.ProfileReporter;
3636
import org.jruby.runtime.profile.ProfilingService;
37-
import org.jruby.util.ByteList;
38-
import org.jruby.util.StringSupport;
3937

4038
/**
4139
* This implementation of {@link org.jruby.runtime.profile.ProfilingService} will be used for all profiling methods
@@ -68,22 +66,19 @@ public DefaultProfileReporter newProfileReporter(ThreadContext context) {
6866
}
6967

7068
@Override
71-
public void addProfiledMethod(String name, DynamicMethod method) {
72-
addProfiledMethod(StringSupport.stringAsUTF8ByteList(name), method);
69+
public void addProfiledMethod(String id, DynamicMethod method) {
70+
profiledMethods.addProfiledMethod(id, method);
7371
}
7472

75-
@Override
76-
public void addProfiledMethod(ByteList name, DynamicMethod method) {
77-
profiledMethods.addProfiledMethod(name, method);
78-
}
7973
/**
8074
* @author Andre Kullmann
8175
*/
8276
private final class DefaultMethodEnhancer implements MethodEnhancer {
8377
@Override
8478
@SuppressWarnings("deprecation")
85-
public DynamicMethod enhance(ByteList name, DynamicMethod delegate) {
86-
profiledMethods.addProfiledMethod(name, delegate);
79+
public DynamicMethod enhance(String id, DynamicMethod delegate) {
80+
profiledMethods.addProfiledMethod(id, delegate);
81+
8782
return new ProfilingDynamicMethod(delegate);
8883
}
8984
}

Diff for: ‎core/src/main/java/org/jruby/runtime/profile/builtin/ProfilePrinter.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,10 @@ static String methodName(ProfiledMethod profileMethod) {
132132
final String displayName;
133133
if (profileMethod != null) {
134134
DynamicMethod method = profileMethod.getMethod();
135-
ByteList name = profileMethod.getName();
136-
// FIXME: bytelist_love: replace with just bytelist once we process Method to be ByteList.
137-
if (name == null) name = StringSupport.stringAsUTF8ByteList(method.getName());
138-
// FIXME: bytelist_love: consider all bytelist version of moduleHashMethod once name in Module is ByteList.
139-
displayName = moduleHashMethod(method.getImplementationClass(), name.toString());
135+
String id = profileMethod.getName();
136+
if (id == null) id = method.getName();
137+
// FIXME: bytelist_love: we are still using id here but methodName should return either id or encoded name depending on how it is used.
138+
displayName = moduleHashMethod(method.getImplementationClass(), id.toString());
140139
} else {
141140
displayName = "<unknown>";
142141
}

Diff for: ‎core/src/main/java/org/jruby/runtime/profile/builtin/ProfiledMethod.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@
77
* A dynamic method + it's invocation name holder for profiling purposes.
88
*/
99
public class ProfiledMethod {
10-
11-
final ByteList name;
10+
final String id;
1211
final DynamicMethod method;
1312

14-
public ProfiledMethod(ByteList name, DynamicMethod method) {
15-
this.name = name;
13+
public ProfiledMethod(String id, DynamicMethod method) {
14+
this.id = id;
1615
this.method = method;
1716
}
1817

19-
public ByteList getName() {
20-
return name;
18+
public String getName() {
19+
return id;
2120
}
2221

2322
public DynamicMethod getMethod() {

Diff for: ‎core/src/main/java/org/jruby/runtime/profile/builtin/ProfiledMethods.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,10 @@ private ConcurrentMap<Long,ProfiledMethod> getMethods() {
7979
return methods;
8080
}
8181

82-
public void addProfiledMethod(final String name, final DynamicMethod method) {
83-
addProfiledMethod(StringSupport.stringAsUTF8ByteList(name), method);
84-
}
85-
86-
public void addProfiledMethod(ByteList name, DynamicMethod method ) {
82+
public void addProfiledMethod(String name, DynamicMethod method ) {
8783
final long serial = method.getSerialNumber();
8884

89-
if ( getMethods().size() >= getProfileMaxMethods()) {
85+
if (getMethods().size() >= getProfileMaxMethods()) {
9086
getWarnings().warnOnce(IRubyWarnings.ID.PROFILE_MAX_METHODS_EXCEEDED, "method count exceeds max of " + getConfig().getProfileMaxMethods() + "; no new methods will be profiled");
9187
return;
9288
}

Diff for: ‎core/src/test/java/org/jruby/runtime/profile/TestProfilingService.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.jruby.Ruby;
44
import org.jruby.internal.runtime.methods.DynamicMethod;
55
import org.jruby.runtime.ThreadContext;
6-
import org.jruby.util.ByteList;
76

87
/**
98
* @author Andre Kullmann
@@ -21,7 +20,7 @@ public ProfileCollection newProfileCollection(ThreadContext context) {
2120
public MethodEnhancer newMethodEnhancer(Ruby runtime) {
2221
return new MethodEnhancer() {
2322
@Override
24-
public DynamicMethod enhance(ByteList name, DynamicMethod delegate) {
23+
public DynamicMethod enhance(String id, DynamicMethod delegate) {
2524
return delegate;
2625
}
2726
};
@@ -35,9 +34,4 @@ public ProfileReporter newProfileReporter(ThreadContext context) {
3534
@Override
3635
public void addProfiledMethod(String name, DynamicMethod method) {
3736
}
38-
39-
@Override
40-
public void addProfiledMethod(ByteList name, DynamicMethod method) {
41-
42-
}
4337
}

0 commit comments

Comments
 (0)
Please sign in to comment.