Repository navigation
Expand file tree
/
Copy pathRuntimeCache.java
More file actions
676 lines (593 loc) · 28.1 KB
/
Copy pathRuntimeCache.java
File metadata and controls
676 lines (593 loc) · 28.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
package org.jruby.ast.executable;
import java.math.BigInteger;
import java.util.Arrays;
import org.jcodings.Encoding;
import org.jruby.Ruby;
import org.jruby.RubyClass;
import org.jruby.RubyClass.VariableAccessor;
import org.jruby.RubyFixnum;
import org.jruby.RubyFloat;
import org.jruby.RubyModule;
import org.jruby.RubyRegexp;
import org.jruby.RubyString;
import org.jruby.RubySymbol;
import org.jruby.common.IRubyWarnings.ID;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.internal.runtime.methods.UndefinedMethod;
import org.jruby.javasupport.util.RuntimeHelpers;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.BlockBody;
import org.jruby.runtime.CallSite;
import org.jruby.runtime.CallType;
import org.jruby.runtime.CompiledBlockCallback;
import org.jruby.runtime.MethodIndex;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.callsite.CacheEntry;
import org.jruby.util.ByteList;
import org.jruby.util.DefinedMessage;
import org.jruby.util.RegexpOptions;
public class RuntimeCache {
public RuntimeCache() {
}
public final StaticScope getScope(ThreadContext context, StaticScope parent, String varNamesDescriptor, int index) {
StaticScope scope = scopes[index];
if (scope == null) {
scopes[index] = scope = RuntimeHelpers.decodeScopeAndDetermineModule(context, parent, varNamesDescriptor);
}
return scope;
}
public final StaticScope getScope(int index) {
return scopes[index];
}
public final CallSite getCallSite(int index) {
return callSites[index];
}
/**
* descriptor format is
*
* closure_method_name,arity,varname1;varname2;varname3,has_multi_args_head,arg_type,light
*
* @param context
* @param index
* @param descriptor
* @return
*/
public final BlockBody getBlockBody(Object scriptObject, ThreadContext context, StaticScope scope, int index, String descriptor) {
BlockBody body = blockBodies[index];
if (body == null) {
return createBlockBody(scriptObject, context, scope, index, descriptor);
}
return body;
}
/**
* descriptor format is
*
* closure_method_name,arity,varname1;varname2;varname3,has_multi_args_head,arg_type,light
*
* @param context
* @param index
* @param descriptor
* @return
*/
public final BlockBody getBlockBody19(Object scriptObject, ThreadContext context, StaticScope scope, int index, String descriptor) {
BlockBody body = blockBodies[index];
if (body == null) {
return createBlockBody19(scriptObject, context, scope, index, descriptor);
}
return body;
}
public final CompiledBlockCallback getBlockCallback(Object scriptObject, int index, String method) {
CompiledBlockCallback callback = blockCallbacks[index];
if (callback == null) {
return createCompiledBlockCallback(scriptObject, index, method);
}
return callback;
}
public final RubySymbol getSymbol(ThreadContext context, int index, String name) {
RubySymbol symbol = symbols[index];
if (symbol == null) {
return symbols[index] = context.runtime.newSymbol(name);
}
return symbol;
}
public final RubyString getString(ThreadContext context, int index, int codeRange) {
return RubyString.newStringShared(context.runtime, getByteList(index), codeRange);
}
public final ByteList getByteList(int index) {
return byteLists[index];
}
public final Encoding getEncoding(int index) {
return encodings[index];
}
public final RubyFixnum getFixnum(ThreadContext context, int index, int value) {
RubyFixnum fixnum = fixnums[index];
if (fixnum == null) {
return fixnums[index] = RubyFixnum.newFixnum(context.runtime, value);
}
return fixnum;
}
public final RubyFixnum getFixnum(ThreadContext context, int index, long value) {
RubyFixnum fixnum = fixnums[index];
if (fixnum == null) {
return fixnums[index] = RubyFixnum.newFixnum(context.runtime, value);
}
return fixnum;
}
public final RubyFloat getFloat(ThreadContext context, int index, double value) {
RubyFloat flote = floats[index];
if (flote == null) {
return floats[index] = RubyFloat.newFloat(context.runtime, value);
}
return flote;
}
public final RubyRegexp getRegexp(ThreadContext context, int index, ByteList pattern, int options) {
RubyRegexp regexp = regexps[index];
if (regexp == null || context.runtime.getKCode() != regexp.getKCode()) {
regexp = RubyRegexp.newRegexp(context.runtime, pattern, RegexpOptions.fromEmbeddedOptions(options));
regexp.setLiteral();
regexps[index] = regexp;
}
return regexp;
}
public final RubyRegexp getRegexp(int index) {
return regexps[index];
}
public final RubyRegexp cacheRegexp(int index, RubyString pattern, int options) {
RubyRegexp regexp = regexps[index];
Ruby runtime = pattern.getRuntime();
if (regexp == null || runtime.getKCode() != regexp.getKCode()) {
regexp = RubyRegexp.newRegexp(runtime, pattern.getByteList(), RegexpOptions.fromEmbeddedOptions(options));
regexps[index] = regexp;
}
return regexp;
}
public final RubyRegexp cacheRegexp(int index, RubyRegexp regexp) {
regexps[index] = regexp;
return regexp;
}
public final BigInteger getBigInteger(int index, String pattern) {
BigInteger bigint = bigIntegers[index];
if (bigint == null) {
return bigIntegers[index] = new BigInteger(pattern, 16);
}
return bigint;
}
public final IRubyObject getVariable(ThreadContext context, int index, String name, IRubyObject object) {
IRubyObject value = getValue(context, index, name, object);
if (value != null) return value;
Ruby runtime = context.runtime;
if (runtime.isVerbose()) {
warnAboutUninitializedIvar(runtime, name);
}
return runtime.getNil();
}
public final IRubyObject getVariableDefined(ThreadContext context, int index, String name, IRubyObject object) {
return getValue(context, index, name, object) == null ? null : context.runtime.getDefinedMessage(DefinedMessage.INSTANCE_VARIABLE);
}
private final IRubyObject getValue(ThreadContext context, int index, String name, IRubyObject object) {
VariableAccessor variableAccessor = variableReaders[index];
RubyClass cls = object.getMetaClass().getRealClass();
if (variableAccessor.getClassId() != cls.hashCode()) {
variableReaders[index] = variableAccessor = cls.getVariableAccessorForRead(name);
}
return (IRubyObject)variableAccessor.get(object);
}
private void warnAboutUninitializedIvar(Ruby runtime, String name) {
runtime.getWarnings().warning(ID.IVAR_NOT_INITIALIZED, "instance variable " + name + " not initialized");
}
public final IRubyObject setVariable(int index, String name, IRubyObject object, IRubyObject value) {
VariableAccessor variableAccessor = variableWriters[index];
RubyClass cls = object.getMetaClass().getRealClass();
if (variableAccessor.getClassId() != cls.hashCode()) {
variableWriters[index] = variableAccessor = cls.getVariableAccessorForWrite(name);
}
variableAccessor.set(object, value);
return value;
}
public final void initScopes(int size) {
scopes = new StaticScope[size];
}
public final void initCallSites(int size) {
callSites = new CallSite[size];
}
/**
* Given a packed descriptor listing methods and their type, populate the
* call site cache.
*
* The format of the methods portion of the descriptor is
* name1;type1;name2;type2 where type1 and type2 are a single capital letter
* N, F, V, or S for the four main call types. After the method portion,
* the other cache sizes are provided as a packed String of char values
* representing the numeric sizes. @see RuntimeCache#initOthers.
*
* @param descriptor The descriptor to use for populating call sites and caches
*/
public final void initFromDescriptor(String descriptor) {
String[] pieces = descriptor.split("\uFFFF");
CallSite[] sites = new CallSite[pieces.length - 1 / 2];
// if there's no call sites, don't process it
if (pieces[0].length() != 0) {
for (int i = 0; i < pieces.length - 1; i+=2) {
switch (pieces[i + 1].charAt(0)) {
case 'N':
sites[i/2] = MethodIndex.getCallSite(pieces[i]);
break;
case 'F':
sites[i/2] = MethodIndex.getFunctionalCallSite(pieces[i]);
break;
case 'V':
sites[i/2] = MethodIndex.getVariableCallSite(pieces[i]);
break;
case 'S':
sites[i/2] = MethodIndex.getSuperCallSite();
break;
default:
throw new RuntimeException("Unknown call type: " + pieces[i + 1] + " for method " + pieces[i]);
}
}
this.callSites = sites;
}
initOthers(pieces[pieces.length - 1]);
}
private static final int SCOPE = 0;
private static final int SYMBOL = SCOPE + 1;
private static final int FIXNUM = SYMBOL + 1;
private static final int FLOAT = FIXNUM + 1;
private static final int CONSTANT = FLOAT + 1;
private static final int REGEXP = CONSTANT + 1;
private static final int BIGINTEGER = REGEXP + 1;
private static final int VARIABLEREADER = BIGINTEGER + 1;
private static final int VARIABLEWRITER = VARIABLEREADER + 1;
private static final int BLOCKBODY = VARIABLEWRITER + 1;
private static final int BLOCKCALLBACK = BLOCKBODY + 1;
private static final int METHOD = BLOCKCALLBACK + 1;
private static final int STRING = METHOD + 1;
private static final int ENCODING = STRING + 1;
/**
* Given a packed descriptor of other cache sizes, construct the cache arrays
*
* The format of the descriptor is the actual size cast to char in this order:
* <ol>
<li>scopeCount</li>
<li>inheritedSymbolCount</li>
<li>inheritedFixnumCount</li>
<li>inheritedConstantCount</li>
<li>inheritedRegexpCount</li>
<li>inheritedBigIntegerCount</li>
<li>inheritedVariableReaderCount</li>
<li>inheritedVariableWriterCount</li>
<li>inheritedBlockBodyCount</li>
<li>inheritedBlockCallbackCount</li>
<li>inheritedMethodCount</li>
<li>inheritedStringCount</li>
* </ul>
*
* @param descriptor The descriptor to use for preparing caches
*/
public final void initOthers(String descriptor) {
int scopeCount = getDescriptorValue(descriptor, SCOPE);
if (scopeCount > 0) initScopes(scopeCount);
int symbolCount = getDescriptorValue(descriptor, SYMBOL);
if (symbolCount > 0) initSymbols(symbolCount);
int fixnumCount = getDescriptorValue(descriptor, FIXNUM);
if (fixnumCount > 0) initFixnums(fixnumCount);
int floatCount = getDescriptorValue(descriptor, FLOAT);
if (floatCount > 0) initFloats(floatCount);
int constantCount = getDescriptorValue(descriptor, CONSTANT);
if (constantCount > 0) initConstants(constantCount);
int regexpCount = getDescriptorValue(descriptor, REGEXP);
if (regexpCount > 0) initRegexps(regexpCount);
int bigIntegerCount = getDescriptorValue(descriptor, BIGINTEGER);
if (bigIntegerCount > 0) initBigIntegers(bigIntegerCount);
int variableReaderCount = getDescriptorValue(descriptor, VARIABLEREADER);
if (variableReaderCount > 0) initVariableReaders(variableReaderCount);
int variableWriterCount = getDescriptorValue(descriptor, VARIABLEWRITER);
if (variableWriterCount > 0) initVariableWriters(variableWriterCount);
int blockBodyCount = getDescriptorValue(descriptor, BLOCKBODY);
if (blockBodyCount > 0) initBlockBodies(blockBodyCount);
int blockCallbackCount = getDescriptorValue(descriptor, BLOCKCALLBACK);
if (blockCallbackCount > 0) initBlockCallbacks(blockCallbackCount);
int methodCount = getDescriptorValue(descriptor, METHOD);
if (methodCount > 0) initMethodCache(methodCount);
int stringCount = getDescriptorValue(descriptor, STRING);
if (stringCount > 0) initStrings(stringCount);
int encodingCount = getDescriptorValue(descriptor, ENCODING);
if (encodingCount > 0) initEncodings(encodingCount);
}
private static int getDescriptorValue(String descriptor, int type) {
return descriptor.charAt(type);
}
public final void initBlockBodies(int size) {
blockBodies = new BlockBody[size];
}
public final void initBlockCallbacks(int size) {
blockCallbacks = new CompiledBlockCallback[size];
}
public final void initSymbols(int size) {
symbols = new RubySymbol[size];
}
public final ByteList[] initStrings(int size) {
return byteLists = new ByteList[size];
}
public final Encoding[] initEncodings(int size) {
return encodings = new Encoding[size];
}
public final void initFixnums(int size) {
fixnums = new RubyFixnum[size];
}
public final void initFloats(int size) {
floats = new RubyFloat[size];
}
public final void initRegexps(int size) {
regexps = new RubyRegexp[size];
}
public final void initBigIntegers(int size) {
bigIntegers = new BigInteger[size];
}
public final void initConstants(int size) {
constants = new IRubyObject[size];
constantTargetHashes = new int[size];
constantGenerations = new Object[size];
Arrays.fill(constantGenerations, -1);
Arrays.fill(constantTargetHashes, -1);
}
public final void initVariableReaders(int size) {
variableReaders = new VariableAccessor[size];
Arrays.fill(variableReaders, VariableAccessor.DUMMY_ACCESSOR);
}
public final void initVariableWriters(int size) {
variableWriters = new VariableAccessor[size];
Arrays.fill(variableWriters, VariableAccessor.DUMMY_ACCESSOR);
}
public final void initMethodCache(int size) {
methodCache = new CacheEntry[size];
Arrays.fill(methodCache, CacheEntry.NULL_CACHE);
}
public final IRubyObject getConstant(ThreadContext context, StaticScope scope, String name, int index) {
IRubyObject value = getValue(context, scope, name, index);
// We can callsite cache const_missing if we want
return value != null ? value : scope.getModule().callMethod(context, "const_missing", context.runtime.fastNewSymbol(name));
}
public final IRubyObject getConstantDefined(ThreadContext context, StaticScope scope, String name, int index) {
IRubyObject value = getValue(context, scope, name, index);
return value == null ? null : context.runtime.getDefinedMessage(DefinedMessage.CONSTANT);
}
public IRubyObject getValue(ThreadContext context, StaticScope scope, String name, int index) {
IRubyObject value = constants[index]; // Store to temp so it does null out on us mid-stream
return isCached(context, value, index) ? value : reCache(context, scope, name, index);
}
private boolean isCached(ThreadContext context, IRubyObject value, int index) {
return value != null && constantGenerations[index] == context.runtime.getConstantInvalidator().getData();
}
public IRubyObject reCache(ThreadContext context, StaticScope scope, String name, int index) {
Object newGeneration = context.runtime.getConstantInvalidator().getData();
IRubyObject value = scope.getConstant(name);
constants[index] = value;
if (value != null) {
constantGenerations[index] = newGeneration;
}
return value;
}
public final IRubyObject getConstantFrom(RubyModule target, ThreadContext context, String name, int index) {
IRubyObject value = getValueFrom(target, context, name, index);
// We can callsite cache const_missing if we want
return value != null ? value : target.getConstantFromConstMissing(name);
}
public IRubyObject getValueFrom(RubyModule target, ThreadContext context, String name, int index) {
IRubyObject value = constants[index]; // Store to temp so it does null out on us mid-stream
return isCachedFrom(target, context, value, index) ? value : reCacheFrom(target, context, name, index);
}
private boolean isCachedFrom(RubyModule target, ThreadContext context, IRubyObject value, int index) {
return value != null && constantGenerations[index] == context.runtime.getConstantInvalidator().getData() && constantTargetHashes[index] == target.hashCode();
}
public IRubyObject reCacheFrom(RubyModule target, ThreadContext context, String name, int index) {
Object newGeneration = context.runtime.getConstantInvalidator().getData();
IRubyObject value = target.getConstantFromNoConstMissing(name, false);
constants[index] = value;
if (value != null) {
constantGenerations[index] = newGeneration;
constantTargetHashes[index] = target.hashCode();
}
return value;
}
private BlockBody createBlockBody(Object scriptObject, ThreadContext context, StaticScope scope, int index, String descriptor) throws NumberFormatException {
BlockBody body = RuntimeHelpers.createCompiledBlockBody(context, scriptObject, scope, descriptor);
return blockBodies[index] = body;
}
private BlockBody createBlockBody19(Object scriptObject, ThreadContext context, StaticScope scope, int index, String descriptor) throws NumberFormatException {
BlockBody body = RuntimeHelpers.createCompiledBlockBody19(context, scriptObject, scope, descriptor);
return blockBodies[index] = body;
}
private CompiledBlockCallback createCompiledBlockCallback(Object scriptObject, int index, String method) {
CompiledBlockCallback callback = RuntimeHelpers.createBlockCallback(scriptObject, method, "(internal)", -1);
return blockCallbacks[index] = callback;
}
public DynamicMethod getMethod(ThreadContext context, RubyClass selfType, int index, String methodName) {
CacheEntry myCache = getCacheEntry(index);
if (CacheEntry.typeOk(myCache, selfType)) {
return myCache.method;
}
return cacheAndGet(context, selfType, index, methodName);
}
public DynamicMethod getMethod(ThreadContext context, IRubyObject self, int index, String methodName) {
return getMethod(context, pollAndGetClass(context, self), index, methodName);
}
private DynamicMethod cacheAndGet(ThreadContext context, RubyClass selfType, int index, String methodName) {
CacheEntry entry = selfType.searchWithCache(methodName);
DynamicMethod method = entry.method;
if (method.isUndefined()) {
return RuntimeHelpers.selectMethodMissing(context, selfType, method.getVisibility(), methodName, CallType.FUNCTIONAL);
}
methodCache[index] = entry;
return method;
}
public DynamicMethod searchWithCache(RubyClass clazz, int index, String name1) {
CacheEntry entry = clazz.searchWithCache(name1);
DynamicMethod method = entry.method;
if (entry.method == UndefinedMethod.INSTANCE) {
return RuntimeHelpers.selectMethodMissing(clazz, method.getVisibility(), name1, CallType.FUNCTIONAL);
}
methodCache[index] = entry;
return method;
}
public DynamicMethod searchWithCache(RubyClass clazz, int index, String name1, String name2) {
CacheEntry entry = clazz.searchWithCache(name1);
DynamicMethod method = entry.method;
if (entry.method == UndefinedMethod.INSTANCE) {
return searchWithCache(clazz, index, name2);
}
methodCache[index] = entry;
return method;
}
public DynamicMethod searchWithCache(RubyClass clazz, int index, String name1, String name2, String name3) {
CacheEntry entry = clazz.searchWithCache(name1);
DynamicMethod method = entry.method;
if (entry.method == UndefinedMethod.INSTANCE) {
return searchWithCache(clazz, index, name2, name3);
}
methodCache[index] = entry;
return method;
}
public DynamicMethod searchWithCache(RubyClass clazz, int index, String name1, String name2, String name3, String name4) {
CacheEntry entry = clazz.searchWithCache(name1);
DynamicMethod method = entry.method;
if (entry.method == UndefinedMethod.INSTANCE) {
return searchWithCache(clazz, index, name2, name3, name4);
}
methodCache[index] = entry;
return method;
}
public DynamicMethod searchWithCache(RubyClass clazz, int index, String name1, String name2, String name3, String name4, String name5) {
CacheEntry entry = clazz.searchWithCache(name1);
DynamicMethod method = entry.method;
if (entry.method == UndefinedMethod.INSTANCE) {
return searchWithCache(clazz, index, name2, name3, name4, name5);
}
methodCache[index] = entry;
return method;
}
public DynamicMethod searchWithCache(RubyClass clazz, int index, String name1, String name2, String name3, String name4, String name5, String name6) {
CacheEntry entry = clazz.searchWithCache(name1);
DynamicMethod method = entry.method;
if (entry.method == UndefinedMethod.INSTANCE) {
return searchWithCache(clazz, index, name2, name3, name4, name5, name6);
}
methodCache[index] = entry;
return method;
}
public DynamicMethod searchWithCache(RubyClass clazz, int index, String name1, String name2, String name3, String name4, String name5, String name6, String name7) {
CacheEntry entry = clazz.searchWithCache(name1);
DynamicMethod method = entry.method;
if (entry.method == UndefinedMethod.INSTANCE) {
return searchWithCache(clazz, index, name2, name3, name4, name5, name6, name7);
}
methodCache[index] = entry;
return method;
}
public DynamicMethod searchWithCache(RubyClass clazz, int index, String name1, String name2, String name3, String name4, String name5, String name6, String name7, String name8) {
CacheEntry entry = clazz.searchWithCache(name1);
DynamicMethod method = entry.method;
if (entry.method == UndefinedMethod.INSTANCE) {
return searchWithCache(clazz, index, name2, name3, name4, name5, name6, name7, name8);
}
methodCache[index] = entry;
return method;
}
public DynamicMethod searchWithCache(IRubyObject obj, int index, String name1) {
CacheEntry myCache = getCacheEntry(index);
if (CacheEntry.typeOk(myCache, obj.getMetaClass())) {
return myCache.method;
}
return searchWithCache(obj.getMetaClass(), index, name1);
}
public DynamicMethod searchWithCache(IRubyObject obj, int index, String name1, String name2) {
CacheEntry myCache = getCacheEntry(index);
if (CacheEntry.typeOk(myCache, obj.getMetaClass())) {
return myCache.method;
}
return searchWithCache(obj.getMetaClass(), index, name1, name2);
}
public DynamicMethod searchWithCache(IRubyObject obj, int index, String name1, String name2, String name3) {
CacheEntry myCache = getCacheEntry(index);
if (CacheEntry.typeOk(myCache, obj.getMetaClass())) {
return myCache.method;
}
return searchWithCache(obj.getMetaClass(), index, name1, name2, name3);
}
public DynamicMethod searchWithCache(IRubyObject obj, int index, String name1, String name2, String name3, String name4) {
CacheEntry myCache = getCacheEntry(index);
if (CacheEntry.typeOk(myCache, obj.getMetaClass())) {
return myCache.method;
}
return searchWithCache(obj.getMetaClass(), index, name1, name2, name3, name4);
}
public DynamicMethod searchWithCache(IRubyObject obj, int index, String name1, String name2, String name3, String name4, String name5) {
CacheEntry myCache = getCacheEntry(index);
if (CacheEntry.typeOk(myCache, obj.getMetaClass())) {
return myCache.method;
}
return searchWithCache(obj.getMetaClass(), index, name1, name2, name3, name4, name5);
}
public DynamicMethod searchWithCache(IRubyObject obj, int index, String name1, String name2, String name3, String name4, String name5, String name6) {
CacheEntry myCache = getCacheEntry(index);
if (CacheEntry.typeOk(myCache, obj.getMetaClass())) {
return myCache.method;
}
return searchWithCache(obj.getMetaClass(), index, name1, name2, name3, name4, name5, name6);
}
public DynamicMethod searchWithCache(IRubyObject obj, int index, String name1, String name2, String name3, String name4, String name5, String name6, String name7) {
CacheEntry myCache = getCacheEntry(index);
if (CacheEntry.typeOk(myCache, obj.getMetaClass())) {
return myCache.method;
}
return searchWithCache(obj.getMetaClass(), index, name1, name2, name3, name4, name5, name6, name7);
}
public DynamicMethod searchWithCache(IRubyObject obj, int index, String name1, String name2, String name3, String name4, String name5, String name6, String name7, String name8) {
CacheEntry myCache = getCacheEntry(index);
if (CacheEntry.typeOk(myCache, obj.getMetaClass())) {
return myCache.method;
}
return searchWithCache(obj.getMetaClass(), index, name1, name2, name3, name4, name5, name6, name7, name8);
}
private static RubyClass pollAndGetClass(ThreadContext context, IRubyObject self) {
context.callThreadPoll();
RubyClass selfType = self.getMetaClass();
return selfType;
}
private CacheEntry getCacheEntry(int index) {
return methodCache[index];
}
private static final StaticScope[] EMPTY_SCOPES = {};
public StaticScope[] scopes = EMPTY_SCOPES;
private static final CallSite[] EMPTY_CALLSITES = {};
public CallSite[] callSites = EMPTY_CALLSITES;
private static final CacheEntry[] EMPTY_CACHEENTRIES = {};
public CacheEntry[] methodCache = EMPTY_CACHEENTRIES;
private static final BlockBody[] EMPTY_BLOCKBODIES = {};
public BlockBody[] blockBodies = EMPTY_BLOCKBODIES;
private static final CompiledBlockCallback[] EMPTY_COMPILEDBLOCKCALLBACKS = {};
public CompiledBlockCallback[] blockCallbacks = EMPTY_COMPILEDBLOCKCALLBACKS;
private static final RubySymbol[] EMPTY_RUBYSYMBOLS = {};
public RubySymbol[] symbols = EMPTY_RUBYSYMBOLS;
private static final ByteList[] EMPTY_BYTELISTS = {};
public ByteList[] byteLists = EMPTY_BYTELISTS;
private static final Encoding[] EMPTY_ENCODINGS = {};
public Encoding[] encodings = EMPTY_ENCODINGS;
private static final RubyFixnum[] EMPTY_FIXNUMS = {};
public RubyFixnum[] fixnums = EMPTY_FIXNUMS;
private static final RubyFloat[] EMPTY_FLOATS = {};
public RubyFloat[] floats = EMPTY_FLOATS;
private static final RubyRegexp[] EMPTY_RUBYREGEXPS = {};
public RubyRegexp[] regexps = EMPTY_RUBYREGEXPS;
private static final BigInteger[] EMPTY_BIGINTEGERS = {};
public BigInteger[] bigIntegers = EMPTY_BIGINTEGERS;
private static final VariableAccessor[] EMPTY_VARIABLE_ACCESSORS = {};
public VariableAccessor[] variableReaders = EMPTY_VARIABLE_ACCESSORS;
public VariableAccessor[] variableWriters = EMPTY_VARIABLE_ACCESSORS;
public IRubyObject[] constants = IRubyObject.NULL_ARRAY;
private static final int[] EMPTY_INTS = {};
private static final Object[] EMPTY_OBJS = {};
public Object[] constantGenerations = EMPTY_OBJS;
public int[] constantTargetHashes = EMPTY_INTS;
}