Skip to content

Commit 745fac0

Browse files
committed
refactor: @Others move_instructions.patch, PR #26
1 parent b1b7894 commit 745fac0

File tree

4 files changed

+16
-33
lines changed

4 files changed

+16
-33
lines changed

runtime/libc/env.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,3 @@ env_getcycles(void)
145145

146146
#endif
147147
}
148-
149-
// Floating point routines
150-
// TODO: Do a fair comparison between musl and wasm-musl
151-
INLINE double
152-
env_sin(double d) {
153-
return sin(d);
154-
}
155-
156-
INLINE double
157-
env_cos(double d) {
158-
return cos(d);
159-
}

runtime/libc/wasmception_backing.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,3 +627,15 @@ void env___unmapself(u32 base, u32 size) {
627627
// Just do some no op
628628
}
629629

630+
// Floating point routines
631+
// TODO: Do a fair comparison between musl and wasm-musl
632+
INLINE double
633+
env_sin(double d) {
634+
return sin(d);
635+
}
636+
637+
INLINE double
638+
env_cos(double d) {
639+
return cos(d);
640+
}
641+

runtime/runtime.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -207,27 +207,7 @@ INLINE double f64_copysign(double a, double b) {
207207
return copysign(a, b);
208208
}
209209

210-
// Memory related instructions
211-
/* instruction_memory_size and instruction_memory_grow are identical in this
212-
* translation unit and all of the runtime/memory translation units. This is
213-
* causing linking errors because multiple translation units are trying to
214-
* define the same global symbol. I've set these functions to static for a
215-
* temporary fix pending a discussion of possible refactors. */
216-
static i32 instruction_memory_size() {
217-
return memory_size / WASM_PAGE_SIZE;
218-
}
219-
220-
static i32 instruction_memory_grow(i32 count) {
221-
i32 prev_size = instruction_memory_size();
222-
for (int i = 0; i < count; i++) {
223-
expand_memory();
224-
}
225-
226-
return prev_size;
227-
}
228-
229-
230-
// We want to have some allocation logic
210+
// We want to have some allocation logic here, so we can use it to implement libc
231211
WEAK u32 wasmg___heap_base = 0;
232212
u32 runtime_heap_base;
233213

runtime/runtime.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ INLINE double get_f64(u32 offset);
113113
INLINE void set_f32(u32 offset, float);
114114
INLINE void set_f64(u32 offset, double);
115115

116+
i32 instruction_memory_size();
117+
i32 instruction_memory_grow();
118+
116119
static inline void* get_memory_ptr_void(u32 offset, u32 bounds_check) {
117120
return (void*) get_memory_ptr_for_runtime(offset, bounds_check);
118121
}

0 commit comments

Comments
 (0)