remove class_resolver_memoize_string_type
This was a decent idea, but it is not flexible enough to allow for correct superclass type comparisons.
This commit is contained in:
parent
895646c25a
commit
ab75598043
@ -665,37 +665,3 @@ bool class_resolver_instanceof(int class_hash_table_length,
|
|||||||
class_entry->class_file->super_class);
|
class_entry->class_file->super_class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hash_table_entry * class_resolver_init_string_hash_table(int length)
|
|
||||||
{
|
|
||||||
assert((length & (length - 1)) == 0); // length must be a power of two
|
|
||||||
int hash_table_length = length;
|
|
||||||
uint32_t hash_table_size = (sizeof (struct hash_table_entry)) * hash_table_length;
|
|
||||||
struct hash_table_entry * hash_table = malloc_class_arena(hash_table_size);
|
|
||||||
hash_table_init(hash_table_length, hash_table);
|
|
||||||
|
|
||||||
return hash_table;
|
|
||||||
}
|
|
||||||
|
|
||||||
void * class_resolver_memoize_string_type(int string_hash_table_length,
|
|
||||||
struct hash_table_entry * string_hash_table,
|
|
||||||
const uint8_t * type,
|
|
||||||
int length)
|
|
||||||
{
|
|
||||||
struct hash_table_entry * e = hash_table_find(string_hash_table_length,
|
|
||||||
string_hash_table,
|
|
||||||
type,
|
|
||||||
length);
|
|
||||||
if (e != nullptr) {
|
|
||||||
assert(e->value == (void *)0x12345678);
|
|
||||||
return e;
|
|
||||||
} else {
|
|
||||||
struct hash_table_entry * e = hash_table_add(string_hash_table_length,
|
|
||||||
string_hash_table,
|
|
||||||
type,
|
|
||||||
length,
|
|
||||||
(void *)0x12345678);
|
|
||||||
assert(e != nullptr);
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -95,10 +95,3 @@ bool class_resolver_instanceof(int class_hash_table_length,
|
|||||||
struct class_entry * origin_class_entry,
|
struct class_entry * origin_class_entry,
|
||||||
const int class_index,
|
const int class_index,
|
||||||
struct objectref * objectref);
|
struct objectref * objectref);
|
||||||
|
|
||||||
struct hash_table_entry * class_resolver_init_string_hash_table(int length);
|
|
||||||
|
|
||||||
void * class_resolver_memoize_string_type(int string_hash_table_length,
|
|
||||||
struct hash_table_entry * string_hash_table,
|
|
||||||
const uint8_t * type,
|
|
||||||
int length);
|
|
||||||
|
16
c/execute.c
16
c/execute.c
@ -1663,21 +1663,7 @@ static struct arrayref * _multiarray(struct vm * vm, int32_t * dims, int num_dim
|
|||||||
struct arrayref * arrayref = memory_allocate(size);
|
struct arrayref * arrayref = memory_allocate(size);
|
||||||
assert(arrayref != nullptr);
|
assert(arrayref != nullptr);
|
||||||
arrayref->length = count;
|
arrayref->length = count;
|
||||||
{ // generate/recall unique pointer for type string
|
arrayref->class_entry = nullptr;
|
||||||
uint8_t * array_type = type - 1;
|
|
||||||
assert(*array_type == '[');
|
|
||||||
int type_length = type_end - array_type;
|
|
||||||
assert(type_length > 0);
|
|
||||||
void * type = class_resolver_memoize_string_type(vm->string_hash_table.length,
|
|
||||||
vm->string_hash_table.entry,
|
|
||||||
array_type,
|
|
||||||
type_length);
|
|
||||||
debugf("memoized string type: %d %p: ", count, type);
|
|
||||||
print_string((const char *)array_type, type_length);
|
|
||||||
debugc('\n');
|
|
||||||
assert(type != nullptr);
|
|
||||||
arrayref->class_entry = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t array_element_size = count * element_size; // bytes
|
int32_t array_element_size = count * element_size; // bytes
|
||||||
int32_t u32_count = (array_element_size + 3) / 4; // u32 units
|
int32_t u32_count = (array_element_size + 3) / 4; // u32 units
|
||||||
|
@ -612,9 +612,6 @@ struct vm * vm_start(int class_hash_table_length,
|
|||||||
vm.class_hash_table.length = class_hash_table_length;
|
vm.class_hash_table.length = class_hash_table_length;
|
||||||
vm.class_hash_table.entry = class_hash_table;
|
vm.class_hash_table.entry = class_hash_table;
|
||||||
|
|
||||||
vm.string_hash_table.length = 128;
|
|
||||||
vm.string_hash_table.entry = class_resolver_init_string_hash_table(vm.string_hash_table.length);
|
|
||||||
|
|
||||||
vm.frame_stack.ix = 0;
|
vm.frame_stack.ix = 0;
|
||||||
vm.frame_stack.capacity = 1024;
|
vm.frame_stack.capacity = 1024;
|
||||||
struct frame frames[vm.frame_stack.capacity];
|
struct frame frames[vm.frame_stack.capacity];
|
||||||
|
@ -35,10 +35,6 @@ struct vm {
|
|||||||
int length;
|
int length;
|
||||||
struct hash_table_entry * entry;
|
struct hash_table_entry * entry;
|
||||||
} class_hash_table;
|
} class_hash_table;
|
||||||
struct {
|
|
||||||
int length;
|
|
||||||
struct hash_table_entry * entry;
|
|
||||||
} string_hash_table;
|
|
||||||
};
|
};
|
||||||
static inline struct frame * stack_push_frame(struct stack * stack, int num_frames)
|
static inline struct frame * stack_push_frame(struct stack * stack, int num_frames)
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ class TestMultiArray {
|
|||||||
return a instanceof Object[][];
|
return a instanceof Object[][];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main() {
|
||||||
System.out.print("testInstanceof: ");
|
System.out.print("testInstanceof: ");
|
||||||
System.out.println(testInstanceof());
|
System.out.println(testInstanceof());
|
||||||
System.out.print("testInstanceof2: ");
|
System.out.print("testInstanceof2: ");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user