Commit Graph

826 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 8bcf44669c Merge pull request #4835 from shuujii/introduce-mrb_ssize-type-for-buffer-size-on-memory
Introduce `mrb_ssize` type for buffer size on memory; ref #4483
2019-11-22 19:40:19 +09:00
KOBAYASHI Shuji a2df247063 Introduce mrb_ssize type for buffer size on memory; ref #4483
Previously, `mrb_int` was used as the type that represents the buffer size
on memory, but the sizes of `RString` and `RArray` exceed 6 words when
`MRB_INT64` is enabled on 32-bit CPU.

I don't think it is necessary to be able to represent the buffer size on
memory that exceeds the virtual address space. Therefore, for this purpose,
introduce `mrb_ssize` which doesn't exceed the sizes of `mrb_int` and
pointer.

I think all `mrb_int` used for this purpose should be changed to
`mrb_ssize`, but currently only the members of the structures (`RString`,
`mrb_shared_string`, `RArray` and `mrb_shared_array`) are changed.
2019-11-21 19:34:02 +09:00
Hiroshi Mimaki 57a56ddaa2 Release mruby 2.1.0. 2019-11-19 18:58:11 +09:00
Hiroshi Mimaki 4eb8fca140 Merge branch 'master' into stable 2019-10-23 15:44:21 +09:00
Yukihiro "Matz" Matsumoto fa85f91e0e Add type cast to avoid an error from int and enum mixture; fix #4786 2019-10-23 14:47:55 +09:00
Hiroshi Mimaki 4c91adc4b2 Update version to 2.1.0. (mruby 2.1.0 RC) 2019-10-18 14:59:27 +09:00
Hirohito Higashi 63496a6730 Fix opcode semantics comment miss. (op_jmpnil) 2019-10-03 15:06:06 +09:00
Hirohito Higashi b4bf7a2282 Fix opcode semantics comment miss. 2019-10-03 14:44:47 +09:00
KOBAYASHI Shuji 482d0626b8 Remove a trailing space in MRUBY_DESCRIPTION 2019-09-30 21:39:13 +09:00
dearblue 40e8a90e89 Remove unnecessary type mrb_hash_value
The type `mrb_hash_value` is no longer used by the segmented list
implementation (ref e8dcfe1 and e65d426).
2019-09-29 23:55:38 +09:00
Yukihiro "Matz" Matsumoto bbfd64d01b Add an annotation of the return value from mrb_delete_key; #4737
The return value from `mrb_delete_key` needs to be protected from GC in
some cases.
2019-09-29 13:53:45 +09:00
KOBAYASHI Shuji feaf80d899 Use type predicate macros instead of mrb_type if possible
For efficiency with `MRB_WORD_BOXING` (implement type predicate macros for
all `enum mrb_vtype`).
2019-09-26 22:23:27 +09:00
Yukihiro "Matz" Matsumoto 184aeb0694 Merge pull request #4732 from dearblue/inttypes
Use inttypes for `snprintf()`
2019-09-26 06:31:07 +09:00
dearblue 84d9296c05 Use inttypes for snprintf() 2019-09-25 23:28:05 +09:00
KOBAYASHI Shuji 27e8ea4ea2 Remove MRB_TT_HAS_BASIC macro
The value of `MRB_TT_HAS_BASIC` is meaningless because `MRB_TT_HAS_BASIC` is
no longer used with `MRB_WORD_BOXING` at b2c3d88f.
2019-09-25 18:17:01 +09:00
KOBAYASHI Shuji 5dda4f5da3 Implement all type predicate macros for MRB_WORD_BOXING
The default implementations of type predicate macros use `mrb_type`.
But `mrb_type` with `MRB_WORD_BOXING` isn't very efficient, so the new
implementations avoid `mrb_type`.
2019-09-22 22:36:12 +09:00
Fangrui Song 7f044341f9 Rename MRB_USE_ETEXT_EDATA to MRB_USE_LINK_TIME_RO_DATA_P and support lld linked programs
In lld linked programs, .rodata comes before .text, thus mrb_ro_data_p
will return false for strings in .rodata. Change the lower bound from
_etext to __ehdr_start to catch these cases. This works for ld.bfd, gold
and lld, and it does not have false positives even if .init_array does
not exist.

Remove the branch that uses _edata: strings in .data can be modified so
this is semantically incorrect. Delete the __APPLE__ branch (its
manpages say get_etext() and get_edata() are strongly discouraged).
.init_array has been adopted by most ELF platforms to supersede .ctors.

Neither _etext nor _edata is used, so rename MRB_USE_ETEXT_EDATA to
MRB_USE_EHDR_START.
2019-09-21 17:55:14 -07:00
Yukihiro "Matz" Matsumoto 2256bb07b0 Remove MRB_METHOD_TABLE_INLINE.
`MRB_METHOD_TABLE_INLINE` was fragile. It requires `-falign-functions=n`.
On platform that uses higher bits of function pointers, you can use new
`MRB_METHOD_T_STRUCT` configuration macro.
2019-09-16 11:14:13 +09:00
Yukihiro "Matz" Matsumoto 30f3787248 Raise ArgumentError by aspec check; ref #4688
This is partial `aspec` check that only checks `MRB_ARGS_NONE()`.
2019-09-16 10:50:31 +09:00
Yukihiro "Matz" Matsumoto 2764fdf9f0 Share common definition of MRB_METHOD_FUNC_FL. 2019-09-16 10:10:09 +09:00
Yukihiro "Matz" Matsumoto 0eb9355acd Use bit shifting to pack function pointers to mrb_method_t.
So you don't need `-falign-functions=2` anymore. Instead your platform
must not use higher bits of the pointer (true for most platforms).
If not, you have to use `struct mrb_method_t` version.
2019-09-16 10:10:09 +09:00
Yukihiro "Matz" Matsumoto 743d480fba Refactor mrb_method_t. 2019-09-16 10:10:09 +09:00
KOBAYASHI Shuji 7fcda585bc Refactor mrb_type in include/mruby/boxing_word.h 2019-09-15 18:11:16 +09:00
Yukihiro "Matz" Matsumoto 28bbd3e7d9 Add argument names to C function prototypes. 2019-09-14 23:21:44 +09:00
Yukihiro "Matz" Matsumoto 57d7fe94a9 Add a macro mrb_frozen_p that points to MRB_FROZEN_P. 2019-09-14 23:21:44 +09:00
KOBAYASHI Shuji d47bd0a2cd Optimize mrb_bool() with MRB_WORD_BOXING 2019-09-08 12:17:25 +09:00
KOBAYASHI Shuji 17c53040ab Increase symbol bit size on 32-bit mode with MRB_WORD_BOXING
This change increases the max length of lower inline symbols to 5 bytes.
2019-09-07 21:38:11 +09:00
KOBAYASHI Shuji 19e2cc187b Avoid bit fields in mrb_value; ref b2c3d88f
The changes at b2c3d88f were inappropriate because the memory layout of bit
fields are implementation defined. Therefor, I fixed it not to use bit
fields.
2019-09-06 13:24:35 +09:00
Yukihiro "Matz" Matsumoto 5cd52d2d69 Fix an error in refactoring; fix #4682 2019-09-02 08:41:44 +09:00
Yukihiro "Matz" Matsumoto 1a4ea94bc7 Fix mrb_immediate_p(MRB_TT_FREE) to return false; ref #4679 2019-08-31 23:19:08 +09:00
Yukihiro "Matz" Matsumoto d48a2190bf Refactor #4662 with different names. 2019-08-31 22:14:25 +09:00
KOBAYASHI Shuji b2c3d88fbf Implement mrb_immediate_p macro for MRB_WORD_BOXING
The default implementation of `mrb_immediate_p` uses `mrb_type`. However,
in `MRB_WORD_BOXING`, `mrb_type` has many branches and is inefficient, so
provide an implementation that does not use `mrb_type`.
2019-08-31 16:55:57 +09:00
David Siaw 6375639917 fix lots of warnings and make logo not so big 2019-08-26 02:08:33 +09:00
David Siaw e1e96c0cf4 change doc directory and reduce warnings 2019-08-26 00:23:28 +09:00
KOBAYASHI Shuji be78b5d8f7 Fix RBreak exceeding 6 words on 32-bit mode w/o boxing and MRB_USE_FLOAT
ref: https://github.com/mruby/mruby/pull/4483#issuecomment-498001736

In this configuration, `tt` of `RBreak::val` is set into `RBreak::flags`.
2019-08-23 22:15:42 +09:00
Yukihiro "Matz" Matsumoto 4c001673b6 Avoid C++ strict aliasing warning.
Based on code proposed by @dearblue to avoid the warning:
`dereferencing type-punned pointer will break strict-aliasing rules`.
2019-08-20 22:50:21 +09:00
KOBAYASHI Shuji 8157672a29 Use RBasic padding for embedded string on 64-bit CPU
On 64-bit CPU, there is padding in `RBasic`, so reorder the fields and use
it as buffer of embedded string. This change allows 4 more bytes to be
embedded on 64-bit CPU.

However, an incompatibility will occur if `RString::as::ary` is accessed
directly because `RString` structure has changed.
2019-08-20 18:49:55 +09:00
Ryan Lopopolo b5662c87c8 Allow external definition of MRB_API macro
When building WebAssembly targets with clang (e.g. wasm32-unknown-unknown), all
symbols are hidden by default. To export a symbol, it must be marked with

    __attribute__((visibility(default)))

Rather than detecting this exotic target in mruby, allow MRB_API to be defined
externally.
2019-08-18 19:40:12 -07:00
Yukihiro "Matz" Matsumoto b5e2d208b9 Merge pull request #4636 from davidsiaw/doxygen
Generate doxygen docs for mruby
2019-08-19 07:29:46 +09:00
David Siaw b5299b1c58 fix up documentation for values 2019-08-18 20:12:44 +09:00
dearblue 279c21b816 Prohibit changes to iseq in principle 2019-08-18 15:00:32 +09:00
David Siaw 2c86895468 fix up markdown display in doxygen 2019-08-18 13:59:29 +09:00
David Siaw 8d70a9b1b5 first bit of doc generation 2019-08-18 13:07:24 +09:00
Yukihiro "Matz" Matsumoto 83dab1ee0d Merge pull request #4634 from shuujii/refactor-set-unset-string-type-flags
Refactor set/unset string type flags
2019-08-17 23:41:52 +09:00
KOBAYASHI Shuji caba5fef27 Refactor set/unset string type flags
Introduce `RSTR_SET_TYPE_FLAG` macro to set the specified string type flag and
clear the others.
2019-08-17 21:24:08 +09:00
Yukihiro "Matz" Matsumoto b55e72b2d6 Resolve conflict between #4582 and C++ warning. 2019-08-17 15:47:14 +09:00
Yukihiro "Matz" Matsumoto c1a0a99309 Update struct RArray union to silence C++ warning. 2019-08-16 22:51:07 +09:00
Yukihiro "Matz" Matsumoto 9f6328d499 Remove MRB_API from functions only called from vm.c.
* `mrb_vm_define_class`
* `mrb_vm_define_module`

Only functions called from user code requires `MRB_API`.
2019-08-14 09:33:23 +09:00
KOBAYASHI Shuji 450684ab33 mrb_str_modify_keep_ascii can embed one more byte
The condition to make an embedded string was incorrect. Because there were
several similar codes, extracted into `RSTR_EMBEDDABLE_P` macro.
2019-08-11 20:48:37 +09:00
Yukihiro "Matz" Matsumoto 98fc887cb3 Reorganize mrb_string_value_cstr and related functions.
`mrb_string_value_cstr` and `mrb_string_value_len`: obsolete
`mrb_string_cstr`: new function to retrieve NULL terminated C string
`RSTRING_CSTR`: wrapper macro of `mrb_string_cstr`
2019-08-07 15:52:10 +09:00