Browse Source

added exception_stack_raw / call_stack_raw (required for faster haxe throw)

Nicolas Cannasse 4 years ago
parent
commit
0d34a1582a
1 changed files with 12 additions and 0 deletions
  1. 12 0
      src/std/error.c

+ 12 - 0
src/std/error.c

@@ -156,6 +156,16 @@ HL_PRIM varray *hl_exception_stack() {
 	return a;
 }
 
+HL_PRIM int hl_exception_stack_raw( varray *arr ) {
+	hl_thread_info *t = hl_get_thread();
+	if( arr ) memcpy(hl_aptr(arr,void*), t->exc_stack_trace, t->exc_stack_count*sizeof(void*));
+	return t->exc_stack_count;
+}
+
+HL_PRIM int hl_call_stack_raw( varray *arr ) {
+	return capture_stack_func(hl_aptr(arr,void*), arr->size);
+}
+
 HL_PRIM void hl_rethrow( vdynamic *v ) {
 	hl_get_thread()->flags |= HL_EXC_RETHROW;
 	hl_throw(v);
@@ -246,6 +256,8 @@ HL_PRIM HL_NO_OPT void hl_assert() {
 #define _SYMBOL _ABSTRACT(hl_symbol)
 
 DEFINE_PRIM(_ARR,exception_stack,_NO_ARG);
+DEFINE_PRIM(_I32,exception_stack_raw,_ARR);
+DEFINE_PRIM(_I32,call_stack_raw,_ARR);
 DEFINE_PRIM(_VOID,set_error_handler,_FUN(_VOID,_DYN));
 DEFINE_PRIM(_VOID,breakpoint,_NO_ARG);
 DEFINE_PRIM(_BYTES,resolve_symbol, _SYMBOL _BYTES _REF(_I32));