line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
// Copyright (c) 2023 Yuki Kimoto |
2
|
|
|
|
|
|
|
// MIT License |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#include |
5
|
|
|
|
|
|
|
#include |
6
|
|
|
|
|
|
|
#include |
7
|
|
|
|
|
|
|
#include |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#include "spvm_allocator.h" |
10
|
|
|
|
|
|
|
#include "spvm_runtime.h" |
11
|
|
|
|
|
|
|
#include "spvm_hash.h" |
12
|
|
|
|
|
|
|
#include "spvm_runtime_string.h" |
13
|
|
|
|
|
|
|
#include "spvm_runtime_basic_type.h" |
14
|
|
|
|
|
|
|
#include "spvm_runtime_field.h" |
15
|
|
|
|
|
|
|
#include "spvm_runtime_class_var.h" |
16
|
|
|
|
|
|
|
#include "spvm_runtime_method.h" |
17
|
|
|
|
|
|
|
#include "spvm_runtime_arg.h" |
18
|
|
|
|
|
|
|
#include "spvm_opcode.h" |
19
|
|
|
|
|
|
|
#include "spvm_mutex.h" |
20
|
|
|
|
|
|
|
|
21
|
1481
|
|
|
|
|
|
SPVM_RUNTIME* SPVM_RUNTIME_new() { |
22
|
1481
|
|
|
|
|
|
SPVM_RUNTIME* runtime = SPVM_ALLOCATOR_alloc_memory_block_unmanaged(sizeof(SPVM_RUNTIME)); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
// Allocator |
25
|
1481
|
|
|
|
|
|
SPVM_ALLOCATOR* allocator = SPVM_ALLOCATOR_new(); |
26
|
1481
|
|
|
|
|
|
runtime->allocator = allocator; |
27
|
|
|
|
|
|
|
|
28
|
1481
|
|
|
|
|
|
runtime->basic_type_symtable = SPVM_HASH_new_hash_permanent(runtime->allocator, 0); |
29
|
|
|
|
|
|
|
|
30
|
1481
|
|
|
|
|
|
runtime->assignability_symtable = SPVM_HASH_new_hash_permanent(runtime->allocator, 0); |
31
|
|
|
|
|
|
|
|
32
|
1481
|
|
|
|
|
|
int32_t mutex_assignability_symtable_size = SPVM_MUTEX_size(); |
33
|
1481
|
|
|
|
|
|
void* mutex_assignability_symtable = SPVM_ALLOCATOR_alloc_memory_block_permanent(runtime->allocator, mutex_assignability_symtable_size); |
34
|
1481
|
|
|
|
|
|
SPVM_MUTEX_init(mutex_assignability_symtable); |
35
|
1481
|
|
|
|
|
|
runtime->mutex_assignability_symtable = mutex_assignability_symtable; |
36
|
|
|
|
|
|
|
|
37
|
1481
|
|
|
|
|
|
int32_t mutex_update_object_size = SPVM_MUTEX_size(); |
38
|
1481
|
|
|
|
|
|
void* mutex_update_object = SPVM_ALLOCATOR_alloc_memory_block_permanent(runtime->allocator, mutex_update_object_size); |
39
|
1481
|
|
|
|
|
|
SPVM_MUTEX_init(mutex_update_object); |
40
|
1481
|
|
|
|
|
|
runtime->mutex_update_object = mutex_update_object; |
41
|
|
|
|
|
|
|
|
42
|
1481
|
|
|
|
|
|
return runtime; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
1145
|
|
|
|
|
|
void SPVM_RUNTIME_free(SPVM_RUNTIME* runtime) { |
46
|
|
|
|
|
|
|
|
47
|
1145
|
100
|
|
|
|
|
if (runtime->basic_types) { |
48
|
597
|
|
|
|
|
|
SPVM_ALLOCATOR_free_memory_block_tmp(runtime->allocator, runtime->basic_types); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
1145
|
|
|
|
|
|
SPVM_MUTEX_destroy(runtime->mutex_assignability_symtable); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
// Free allocator |
54
|
1145
|
|
|
|
|
|
SPVM_ALLOCATOR_free(runtime->allocator); |
55
|
1145
|
|
|
|
|
|
runtime->allocator = NULL; |
56
|
1145
|
|
|
|
|
|
} |