aboutsummaryrefslogtreecommitdiffstats
path: root/symbol.c
Commit message (Collapse)AuthorAgeFilesLines
* symbol.c: more informative error messagenobu2016-01-251-1/+2
| | | | | | | | * symbol.c (sym_check_asciionly): more informative error message with the encoding name and the inspected content. [ruby-core:73398] [Feature #12016] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: rb_sym_internnobu2015-11-301-1/+30
| | | | | | | * symbol.c (rb_sym_intern): rename from rb_cstr_intern and add variants. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: not freeze the receivernobu2015-11-201-7/+8
| | | | | | | * symbol.c (rb_str_intern): should not freeze the receiver itself unexpectedly. [ruby-core:71611] [Bug #11721] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: rb_cstr_internnobu2015-11-081-0/+8
| | | | | | | | * symbol.c (rb_cstr_intern): new function to make Symbol object like as rb_str_intern() but from pointer to the name, its length and its encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* id.def: token_opsnobu2015-11-051-49/+0
| | | | | | | * defs/id.def (token_ops): gather associations between IDs, operators, and parser tokens. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RUBY_DTRACE_CREATE_HOOKnobu2015-10-291-6/+2
| | | | | | | | | | * internal.h (RUBY_DTRACE_CREATE_HOOK): macro to call hook at object creation. * vm.c (rb_source_location, rb_source_loc): retrieve source path and line number at once. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: dotq in rippernobu2015-10-251-0/+2
| | | | | | * symbol.c (op_tbl): add DOTQ for ripper. [Feature #11537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52276 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: suppress warningsnobu2015-08-261-0/+3
| | | | | | | * symbol.c (rb_id_serial_to_id): suppress unused-function warnings where ID_TABLE_IMPL is 0, 1, or 11. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/objspace/objspace.c: add a new method ObjectSpace.count_symbols.ko12015-08-211-0/+6
| | | | | | | | | | | | [Feature #11158] * symbol.c (rb_sym_immortal_count): added to count immortal symbols. * symbol.h: ditto. * test/objspace/test_objspace.rb: add a test for this method. * NEWS: describe about this method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * id_table.h: introduce ID key table.ko12015-08-121-10/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | [Feature #11420] This table only manage ID->VALUE table to reduce overhead of st. Some functions prefixed rb_id_table_* are provided. * id_table.c: implement rb_id_table_*. There are several algorithms to implement it. Now, there are roughly 4 types: * st * array * hash (implemented by Yura Sokolov) * mix of array and hash The macro ID_TABLE_IMPL can choose implementation. You can see detailes about them at the head of id_table.c. At the default, I choose 34 (mix of list and hash). This is not final decision. Please report your suitable parameters or your data structure. * symbol.c: introduce rb_id_serial_t and rb_id_to_serial() to represent ID by serial number. * internal.h: use id_table for method tables. * class.c, gc.c, marshal.c, vm.c, vm_method.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: fix dynamic symbol hash valuenobu2015-07-291-4/+3
| | | | | | | * hash.c (any_hash), symbol.c (dsymbol_alloc): fix dynamic symbol hash value by restricting in Fixnum range, that is `long`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.h: memoize hashval for RSymbolnormal2015-07-271-0/+6
| | | | | | | | | | | | | | | | | | | | | | This speeds up the hash function for dynamic symbols. [ruby-core:70129] [Bug #11396], nearly up to Ruby 2.1 levels Power-of-two hash sizing [Feature #9425] speeds up cases where we have a good hash, but this means we can no longer hide behind weak hashes. Unfortunately, object IDs do not hash well, but we may use the extra space in the RSymbol struct to memoize the hash value. Further optimizations should be possible. For now, the st.c APIs force us to calculate rb_str_hash redundantly at dsym registration. * symbol.h (struct RSymbol): add hashval field * symbol.c (dsymbol_alloc): setup hashval field once * hash.c (rb_any_hash): return RSymbol->hashval directly * common.mk: hash.o depends on symbol.h Thanks to Bruno Escherl <bruno@escherl.net> for the bug report [ruby-core:70129] [Bug #11396] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: preserve encodingnobu2015-07-071-6/+4
| | | | | | | * symbol.c (rb_check_id, rb_check_symbol): preserve encoding of the given name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * load.c: removed unused header file "node.h".ko12015-03-111-1/+0
| | | | | | | | | * method.h: ditto. * symbol.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: make dsym_fstrs an identity hashnobu2015-03-041-1/+1
| | | | | | | | | * symbol.c (Init_sym): make dsym_fstrs a hash compared by identity as the keys are unique fstrings, to get rid of running hash and compare methods and causing new object allocation during garbage collection phase. [ruby-dev:48891] [Bug #10933] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: fix memory leak from global fstr hashnormal2015-01-011-0/+1
| | | | | | | | * symbol.c (rb_gc_free_dsymbol): delete from global fstr hash * test/ruby/test_symbol.rb (test_symbol_fstr_leak): test for bug [ruby-core:67268] [Bug #10686] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * hash.c (rb_hash_delete): return Qnil if there are no correspondingko12014-12-241-1/+1
| | | | | | | | | | | | | | entry. [Bug #10623] * hash.c (rb_hash_delete_entry): try delete and return Qundef if there are no corresponding entry. * internal.h: add rb_hash_delete_entry()'s declaration. * symbol.c: use rb_hash_delete_entry(). * thread.c: use rb_hash_delete_entry(). * ext/-test-/hash/delete.c: use rb_hash_delete_entry(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: symbol type predicate functionsnobu2014-11-171-0/+42
| | | | | | | * symbol.h (is_{local,global,instance,attrset,const,class,junk}_sym): fix ID type names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Include ruby.h and ruby/encoding.h to beakr2014-11-151-3/+1
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* id.h.tmpl: ANDOP and OROPnobu2014-10-271-0/+4
| | | | | | * template/id.h.tmpl (token_op_ids): define && and || for ripper. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: optimize IDs in rippernobu2014-10-271-0/+2
| | | | | | | | | * parse.y: optimize ripper_intern calls, ::, **, -@, +@, <=>, >=, <=, ==, ===, !=, =~, !~, <<, >>, and call. * parse.y: use initialized IDs, warn and warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.h: optimize ID2SYMnobu2014-10-271-2/+1
| | | | | | * symbol.h (rb_id2sym): optimize for predefined IDs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c (register_sym): debug codenobu2014-10-171-0/+22
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: ids arraynobu2014-10-141-36/+27
| | | | | | | * symbol.c (global_symbols): make ids two-dimensional array of strings and symbols, for write-barrier. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: immortal IDsnobu2014-10-141-306/+187
| | | | | | | * symbol.c (global_symbols): make IDs immortal always, instead of treating dynamic symbols as IDs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: rename rb_str_dynamic_internnobu2014-10-141-2/+2
| | | | | | | | * iseq.c, marshal.c, string.c: use rb_str_intern instead of rb_str_dynamic_intern. * symbol.c (rb_str_intern): rename rb_str_dynamic_intern. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: junk-base attrsetnobu2014-10-061-3/+11
| | | | | | | * symbol.c (rb_enc_symname_type): allow junk-base attrset ID unless the stem is not an attrset name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: fix dynamic attrset IDnobu2014-09-191-17/+35
| | | | | | | | * symbol.c (rb_str_dynamic_intern): check if the stem ID of attrset ID is already registered as a static ID. [ruby-dev:48559] [Bug #10259] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c (rb_intern_cstr_without_pindown): check dsymbol on returnnormal2014-09-081-0/+3
| | | | | | | This is not a complete fix for bug 10206, but seems to reduce that crash and also looks correct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: WARN_UNUSED_RESULTnobu2014-08-301-2/+7
| | | | | | | | | * internal.h (WARN_UNUSED_RESULT): warn unused result by gcc 3.4 or later. * symbol.c: declare some functions with WARN_UNUSED_RESULT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c (rb_sym2id): do not return garbage objectnormal2014-08-301-1/+1
| | | | | | | | | | The dynamic sym passed to rb_sym2id may be a garbage object (as accounted for by dsymbol_check). This fixes an occasional segfault in "make test-all" for me. No need to backport, this is from the new symbol GC feature. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: rb_setup_fake_strnobu2014-08-161-19/+6
| | | | | | | * string.c (rb_setup_fake_str): setup fake string from C pointer, length, and encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (setup_fake_str): fake strings should not set class byko12014-08-151-1/+1
| | | | | | | | | | | | RBASIC_SET_CLASS() because it insert write barriers to fake (non-RVALUE) structure. It can cause unexpected behaviour. Ruby 2.1 also have a same problem (setup_fake_str() in parse.y). * symbol.c (setup_fake_str): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: move macrosnobu2014-08-041-0/+7
| | | | | | | | * symbol.c (SYMBOL_PINNED, SYMBOL_PINNED_P, ID_DYNAMIC_SYM_P), (STATIC_SYM2ID, STATIC_ID2SYM): move from symbol.h as these macros are used only in symbol.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: wrap global_symbols tablesnobu2014-07-271-22/+40
| | | | | | | * symbol.c (register_symid_direct, unregister_sym): extract to wrap global_symbols tables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: return the results directlynobu2014-07-271-60/+52
| | | | | | | | * symbol.c (lookup_str_id, lookup_str_sym, lookup_id_str): return the result ID, Symbol, and string directly instead of returning via a pointer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c (dsymbol_check): remove unneeded semi-colonnormal2014-07-251-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: remove dependency on parse.hnobu2014-07-111-5/+20
| | | | | | | | | | | * symbol.c (op_tbl): remove non-regular symbols. * symbol.c (global_symbols): start from the next of the preserved ID. * symbol.c: (rb_id2str): op_tbl does not exceed tLAST_OP_ID. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * symbol.c: remove rb_gc_mark_symbols().ko12014-07-091-12/+12
| | | | | | | | | | | | | | | | | | fstrings refered by static symbols and pinned dynamic symbols are registerd by rb_gc_register_mark_object(). frstring refered by dynamic symbols (not pinned symbols) are refered from global_symbols.dsymbol_fstr_hash (Hash object). Note that fstrings refered from dynamic symbols must live loger than symbol objects themselves because rb_gc_free_dsymbol() uses fstring to remove from symbol tables. This is why we can not mark fstrings from dynamic symbols. This technique reduces root objects for GC marking. * gc.c (gc_mark_roots): ditto. * internal.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c, symbol.h: split from parse.ynobu2014-07-091-0/+1129
* symbol.c, symbol.h: Symbol class implementation and internals, split from parse.y. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e