Skip to content

Commit b0490b8

Browse files
joshuawarner32Joshua Warner
authored and
Joshua Warner
committed
finish using setters
1 parent 4367867 commit b0490b8

File tree

14 files changed

+146
-136
lines changed

14 files changed

+146
-136
lines changed

classpath/avian/ClassAddendum.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public class ClassAddendum extends Addendum {
2121
* extended by that class.
2222
*/
2323
public int declaredMethodCount;
24+
25+
// Either a byte[] or a Pair, apparently...
26+
// TODO: make it monomorphic
2427
public Object enclosingClass;
28+
2529
public Object enclosingMethod;
2630
}

src/avian/machine.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@ class GcJfield;
15391539

15401540
class Classpath {
15411541
public:
1542-
virtual object
1542+
virtual GcJclass*
15431543
makeJclass(Thread* t, GcClass* class_) = 0;
15441544

15451545
virtual GcString*
@@ -1871,14 +1871,14 @@ mark(Thread* t, object o, unsigned offset)
18711871
}
18721872

18731873
inline void
1874-
set(Thread* t, object target, unsigned offset, object value)
1874+
setField(Thread* t, object target, unsigned offset, object value)
18751875
{
18761876
fieldAtOffset<object>(target, offset) = value;
18771877
mark(t, target, offset);
18781878
}
18791879

18801880
inline void
1881-
set(Thread* t, GcObject* target, unsigned offset, GcObject* value)
1881+
setField(Thread* t, GcObject* target, unsigned offset, GcObject* value)
18821882
{
18831883
fieldAtOffset<GcObject*>(target, offset) = value;
18841884
mark(t, reinterpret_cast<object>(target), offset);
@@ -1887,7 +1887,7 @@ set(Thread* t, GcObject* target, unsigned offset, GcObject* value)
18871887
inline void
18881888
setObject(Thread* t, GcObject* target, unsigned offset, GcObject* value)
18891889
{
1890-
set(t, target, offset, value);
1890+
setField(t, target, offset, value);
18911891
}
18921892

18931893
inline void
@@ -3612,7 +3612,7 @@ resolveClassInObject(Thread* t, GcClassLoader* loader, object container,
36123612
if (c) {
36133613
storeStoreMemoryBarrier();
36143614

3615-
set(t, container, classOffset, reinterpret_cast<object>(c));
3615+
setField(t, container, classOffset, reinterpret_cast<object>(c));
36163616
}
36173617

36183618
return c;
@@ -3894,7 +3894,7 @@ getJClass(Thread* t, GcClass* c)
38943894

38953895
jclass = cast<GcJclass>(t, getClassRuntimeData(t, c)->jclass());
38963896
if (jclass == 0) {
3897-
jclass = cast<GcJclass>(t, t->m->classpath->makeJclass(t, c));
3897+
jclass = t->m->classpath->makeJclass(t, c);
38983898

38993899
storeStoreMemoryBarrier();
39003900

src/avian/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ hashMapInsertOrReplace(Thread* t, GcHashMap* map, object key, object value,
4848
hashMapInsert(t, map, key, value, hash);
4949
return true;
5050
} else {
51-
set(t, reinterpret_cast<object>(n), TripleSecond, value);
51+
n->setSecond(t, value);
5252
return false;
5353
}
5454
}

src/builtin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ Avian_sun_misc_Unsafe_putObject
765765
int64_t offset; memcpy(&offset, arguments + 2, 8);
766766
uintptr_t value = arguments[4];
767767

768-
set(t, o, offset, reinterpret_cast<object>(value));
768+
setField(t, o, offset, reinterpret_cast<object>(value));
769769
}
770770

771771
extern "C" AVIAN_EXPORT void JNICALL
@@ -777,7 +777,7 @@ Avian_sun_misc_Unsafe_putObjectVolatile
777777
object value = reinterpret_cast<object>(arguments[4]);
778778

779779
storeStoreMemoryBarrier();
780-
set(t, o, offset, reinterpret_cast<object>(value));
780+
setField(t, o, offset, reinterpret_cast<object>(value));
781781
storeLoadMemoryBarrier();
782782
}
783783

src/classpath-android.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class MyClasspath : public Classpath {
232232
: allocator(allocator), tzdata(0), mayInitClasses_(false)
233233
{ }
234234

235-
virtual object
235+
virtual GcJclass*
236236
makeJclass(Thread* t, GcClass* class_)
237237
{
238238
PROTECT(t, class_);
@@ -241,7 +241,7 @@ class MyClasspath : public Classpath {
241241
setObjectClass(t, reinterpret_cast<object>(c), type(t, GcJclass::Type));
242242
c->setVmClass(t, class_);
243243

244-
return reinterpret_cast<object>(c);
244+
return c;
245245
}
246246

247247
virtual GcString*

src/classpath-avian.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class MyClasspath : public Classpath {
2626
allocator(allocator)
2727
{ }
2828

29-
virtual object
29+
virtual GcJclass*
3030
makeJclass(Thread* t, GcClass* class_)
3131
{
32-
return reinterpret_cast<object>(vm::makeJclass(t, class_));
32+
return vm::makeJclass(t, class_);
3333
}
3434

3535
virtual GcString*
@@ -228,11 +228,11 @@ class MyClasspath : public Classpath {
228228
};
229229

230230
void
231-
enumerateThreads(Thread* t, Thread* x, object array, unsigned* index,
231+
enumerateThreads(Thread* t, Thread* x, GcArray* array, unsigned* index,
232232
unsigned limit)
233233
{
234234
if (*index < limit) {
235-
set(t, array, ArrayBody + (*index * BytesPerWord), reinterpret_cast<object>(x->javaThread));
235+
array->setBodyElement(t, *index, reinterpret_cast<object>(x->javaThread));
236236
++ (*index);
237237

238238
if (x->peer) enumerateThreads(t, x->peer, array, index, limit);
@@ -427,7 +427,7 @@ Avian_java_lang_reflect_Field_setObject
427427
int offset = arguments[1];
428428
object value = reinterpret_cast<object>(arguments[2]);
429429

430-
set(t, instance, offset, value);
430+
setField(t, instance, offset, value);
431431
}
432432

433433
extern "C" AVIAN_EXPORT int64_t JNICALL
@@ -547,7 +547,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
547547

548548
for (unsigned i = 0; i < t->m->propertyCount; ++i) {
549549
GcString* s = makeString(t, "%s", t->m->properties[i]);
550-
set(t, array, ArrayBody + (i * BytesPerWord), reinterpret_cast<object>(s));
550+
reinterpret_cast<GcArray*>(array)->setBodyElement(t, i, reinterpret_cast<object>(s));
551551
}
552552

553553
return reinterpret_cast<int64_t>(array);
@@ -619,7 +619,8 @@ Avian_java_lang_Runtime_addShutdownHook
619619
ACQUIRE(t, t->m->shutdownLock);
620620

621621
GcPair* p = makePair(t, hook, reinterpret_cast<object>(roots(t)->shutdownHooks()));
622-
set(t, roots(t), RootsShutdownHooks, p);
622+
// sequence point, for gc (don't recombine statements)
623+
roots(t)->setShutdownHooks(t, p);
623624
}
624625

625626
extern "C" AVIAN_EXPORT int64_t JNICALL
@@ -643,7 +644,7 @@ Avian_java_lang_Throwable_resolveTrace
643644

644645
for (unsigned i = 0; i < length; ++i) {
645646
GcStackTraceElement* ste = makeStackTraceElement(t, cast<GcTraceElement>(t, objectArrayBody(t, trace, i)));
646-
set(t, array, ArrayBody + (i * BytesPerWord), reinterpret_cast<object>(ste));
647+
reinterpret_cast<GcArray*>(array)->setBodyElement(t, i, reinterpret_cast<object>(ste));
647648
}
648649

649650
return reinterpret_cast<int64_t>(array);
@@ -714,7 +715,7 @@ Avian_java_lang_Thread_enumerate
714715

715716
unsigned count = min(t->m->liveCount, objectArrayLength(t, reinterpret_cast<object>(array)));
716717
unsigned index = 0;
717-
local::enumerateThreads(t, t->m->rootThread, reinterpret_cast<object>(array), &index, count);
718+
local::enumerateThreads(t, t->m->rootThread, array, &index, count);
718719
return count;
719720
}
720721

0 commit comments

Comments
 (0)