Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
9fc62d28
Commit
9fc62d28
authored
Nov 28, 2016
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pre-allocate arena overflow error
parent
27ceb848
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
2 deletions
+11
-2
include/mruby.h
include/mruby.h
+3
-0
src/error.c
src/error.c
+4
-1
src/gc.c
src/gc.c
+4
-1
No files found.
include/mruby.h
View file @
9fc62d28
...
...
@@ -221,6 +221,9 @@ typedef struct mrb_state {
struct
RClass
*
eException_class
;
struct
RClass
*
eStandardError_class
;
struct
RObject
*
nomem_err
;
/* pre-allocated NoMemoryError */
#ifdef MRB_GC_FIXED_ARENA
struct
RObject
*
arena_err
;
/* pre-allocated arena overfow error */
#endif
void
*
ud
;
/* auxiliary data */
...
...
src/error.c
View file @
9fc62d28
...
...
@@ -465,7 +465,7 @@ exception_call:
}
if
(
argc
>
0
)
{
if
(
!
mrb_obj_is_kind_of
(
mrb
,
mesg
,
mrb
->
eException_class
))
mrb_raise
(
mrb
,
E_TYPE_ERROR
,
"exception object expected"
);
mrb_raise
(
mrb
,
mrb
->
eException_class
,
"exception object expected"
);
if
(
argc
>
2
)
set_backtrace
(
mrb
,
mesg
,
argv
[
2
]);
}
...
...
@@ -532,6 +532,9 @@ mrb_init_exception(mrb_state *mrb)
mrb
->
eStandardError_class
=
mrb_define_class
(
mrb
,
"StandardError"
,
mrb
->
eException_class
);
/* 15.2.23 */
runtime_error
=
mrb_define_class
(
mrb
,
"RuntimeError"
,
mrb
->
eStandardError_class
);
/* 15.2.28 */
mrb
->
nomem_err
=
mrb_obj_ptr
(
mrb_exc_new_str_lit
(
mrb
,
runtime_error
,
"Out of memory"
));
#ifdef MRB_GC_FIXED_ARENA
mrb
->
arena_err
=
mrb_obj_ptr
(
mrb_exc_new_str_lit
(
mrb
,
runtime_error
,
"arena overflow error"
));
#endif
script_error
=
mrb_define_class
(
mrb
,
"ScriptError"
,
mrb
->
eException_class
);
/* 15.2.37 */
mrb_define_class
(
mrb
,
"SyntaxError"
,
script_error
);
/* 15.2.38 */
mrb_define_class
(
mrb
,
"SystemStackError"
,
exception
);
...
...
src/gc.c
View file @
9fc62d28
...
...
@@ -403,7 +403,7 @@ gc_protect(mrb_state *mrb, mrb_gc *gc, struct RBasic *p)
if
(
gc
->
arena_idx
>=
MRB_GC_ARENA_SIZE
)
{
/* arena overflow error */
gc
->
arena_idx
=
MRB_GC_ARENA_SIZE
-
4
;
/* force room in arena */
mrb_
raise
(
mrb
,
E_RUNTIME_ERROR
,
"arena overflow error"
);
mrb_
exc_raise
(
mrb
,
mrb_obj_value
(
mrb
->
arena_err
)
);
}
#else
if
(
gc
->
arena_idx
>=
gc
->
arena_capa
)
{
...
...
@@ -816,6 +816,9 @@ root_scan_phase(mrb_state *mrb, mrb_gc *gc)
mrb_gc_mark
(
mrb
,
(
struct
RBasic
*
)
mrb
->
exc
);
/* mark pre-allocated exception */
mrb_gc_mark
(
mrb
,
(
struct
RBasic
*
)
mrb
->
nomem_err
);
#ifdef MRB_GC_FIXED_ARENA
mrb_gc_mark
(
mrb
,
(
struct
RBasic
*
)
mrb
->
arena_err
);
#endif
mark_context
(
mrb
,
mrb
->
root_c
);
if
(
mrb
->
root_c
->
fib
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment