| Age | Commit message (Collapse) | Author |
|
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.
|
|
- Keep `MRB_STR_ASCII` flag.
- Avoid a string object creation.
|
|
Fix argument specs to `Kernel`
|
|
This feature was reverted from Ruby 2.7.
|
|
|
|
|
|
|
|
|
|
On cases like `a.unshift(*a)`.
|
|
|
|
|
|
|
|
|
|
|
|
### Benchmark (with `MRB_UTF8_STRING`)
```
$ mruby -e '
COUNT = 150000
SIZE = 10000
strs = Array.new(COUNT) do
s = "a" * SIZE
s.size # set `MRB_STR_ASCII` flag
s
end
i = 0
t = Time.now
while i < COUNT
strs[i][-2..-1] = ""
i += 1
end
printf "%.2f sec\n", Time.now - t
'
1.10 sec # before
0.07 sec # after
```
|
|
|
|
### Benchmark (with `MRB_UTF8_STRING`)
```ruby
# benchmark.rb
COUNT = 300000
SIZE = 10000
s = "a" * SIZE
s.size # set `MRB_STR_ASCII` flag
i = 0
while i < COUNT
s[-1]
i += 1
end
```
#### Before this patch:
```
$ time mruby benchmark.rb
2.06 real 2.05 user 0.00 sys
```
#### After this patch:
```
$ time mruby benchmark.rb
0.05 real 0.04 user 0.00 sys
```
|
|
### Example (with `MRB_UTF8_STRING`)
```ruby
s = "\u3042"
p s.size
s.dump
p s.size
```
#### Before this patch:
```
1
3
```
#### After this patch:
```
1
1
```
|
|
|
|
|
|
|
|
|
|
|
|
- Use `mrb_sym_name_len` instead of `mrb_sym_name` (class name should not
be escaped).
- Avoid `mrb_str_dup` (it is unnecessary to be shared string because it is
changed).
|
|
shuujii/sHARED-string-is-not-required-when-sharing-POOL-string
SHARED string is not required when sharing POOL string
|
|
The heap string buffer of POOL string always exists, does not need to be
released, and read only, so it can be shared as NOFREE string.
|
|
Because it may not create `struct mrb_shared_string`.
|
|
|
|
|
|
|
|
Keyword arguments can now be retrieved with the `:` specifier and
`mrb_kwargs` data.
For the interface, I referred to CRuby's `rb_get_kwargs()`.
For implementation, I referred to `OP_KARG` or etc.
|
|
This is an experimental changes in Ruby 2.7.
|
|
|
|
These are included in `mruby.h`.
As a background, if `enable_cxx_abi` is specified, the macro that
defines the maximum value in `stdint.h` is undefined depending on the
environment.
- Confirmed with gcc on FreeBSD 12.0 and mingw32-gcc available on
FreeBSD.
- `INTPTR_MAX`, `INT64_MAX` and `UINT64_MAX` are defined by `cstdint`
added in C++11. But `toolchains :gcc` adds `-std=c++03`, so the macros
are not defined.
- To have these defined in `C++03`, `__STDC_CONSTANT_MACROS` must be
defined in advance. This is already done by `mruby.h`.
|
|
|
|
|
|
Also fix document about type of the first argument.
|
|
shuujii/use-type-predicate-macros-instead-of-mrb_type-if-possible
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`).
|
|
* mrb_sym2name -> mrb_sym_name
* mrb_sym2name_len -> mrb_sym_name_len
* mrb_sym2str -> mrb_sym_str
|
|
|
|
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.
|
|
Singleton class definition do not introduce its own class variable scope
in CRuby/JRuby. So should mruby.
```
module Mod1
class << Object.new
C = 1
@@cv = 1
p Module.nesting, # => [#<Class:#<Object:0x55cb16e60a50>>, Mod1]
constants, # => [:C]
class_variables, # => []
Mod1.class_variables # => [:@@cv]
end
end
```
|
|
|
|
Also fix document about type of the first argument.
|
|
|
|
We needed to preserve the original method name somewhere. We kept it in
the `env` structure pointed from aliased methods. #1457 and #1531 tried
to address this issue. But this patch is more memory efficient.
Limitation: this fix does not support `super` from methods defined by
`define_method`. This limitation may be addressed in the future, but
it's low priority.
|
|
Fix `Fixnum#(to_s|inspect)` argument specs
|
|
Before this patch:
$ bin/mruby -e 'p 3.to_s(2)'
trace (most recent call last):
[0] -e:1
-e:1: 'to_s': wrong number of arguments (1 for 0) (ArgumentError)
After this patch:
$ bin/mruby -e 'p 3.to_s(2)'
"11"
|