Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Speed up String#inspect, implement KCode support

  • Loading branch information...
commit d25e54bebf9ecab853bd18e4383d85e6c8a708a6 1 parent 4f8a239
Evan Phoenix authored
View
4 benchmark/core/methods/string/inspect.rb
@@ -1,8 +1,8 @@
def Bench.run
i = 0
+ str = random_string
while @should_run
- # string#inspect(...)
- raise "string#inspect(...) benchmark is not implemented"
+ str.inspect
i += 1
end
View
10 kernel/bootstrap/rubinius.rb
@@ -80,4 +80,14 @@ def self.set_class(obj, cls)
raise ArgumentError, "Class #{cls} is not compatible with #{obj.inspect}"
end
end
+
+ def self.kcode=(str)
+ Ruby.primitive :vm_set_kcode
+ raise PrimitiveFailure, "Rubinius.kcode= failed"
+ end
+
+ def self.kcode
+ Ruby.primitive :vm_get_kcode
+ raise PrimitiveFailure, "Rubinius.kcode failed"
+ end
end
View
7 kernel/bootstrap/string.rb
@@ -76,4 +76,11 @@ def length
end
alias_method :size, :length
+
+ def escape(tbl, respect_kcode)
+ Ruby.primitive :string_escape
+ raise PrimitiveFailure, "String#escape failed"
+ end
+
+ private :escape
end
View
28 kernel/common/ctype.rb
@@ -46,32 +46,4 @@ def tolower
self.isupper ? self.tolower! : self
end
- def toprint
- if self == ?"
- "\\\""
- elsif self == ?\\
- "\\\\"
- elsif self == ?#
- "\\#"
- elsif isctrl
- case self
- when ?\n: "\\n"
- when ?\t: "\\t"
- when ?\a: "\\a"
- when ?\v: "\\v"
- when ?\f: "\\f"
- when ?\r: "\\r"
- when ?\e: "\\e"
- when ?\b: "\\b"
- end
- elsif self < 32 || self > 126
- str = "\\000"
- str.modify!
-
- c = self.to_s 8
- str.copy_from c, 0, c.size, 4-c.size
- else
- self.chr
- end
- end
end
View
23 kernel/common/string.rb
@@ -1049,15 +1049,9 @@ def insert(index, other)
# str[3] = 8
# str.inspect #=> "hel\010o"
def inspect
- if $KCODE == "UTF-8"
- str = "\"#{self}\""
- else
- str = "\""
- i = -1
- str << @data[i].toprint while (i += 1) < @num_bytes
- str << "\""
- end
- str.taint if tainted?
+ str = '"'
+ str << escape(CType::Printed, true)
+ str << '"'
str
end
@@ -1908,7 +1902,7 @@ def to_i(base = 10)
# Returns self if self is an instance of String,
# else returns self converted to a String instance.
def to_s
- self.class == String ? self : "".replace(self)
+ instance_of?(String) ? self : "".replace(self)
end
alias_method :to_str, :to_s
@@ -2368,13 +2362,10 @@ def shorten!(size)
@num_bytes = @characters = @num_bytes - size
end
- # TODO: inspect is NOT dump!
def dump
- kcode = $KCODE
- $KCODE = "NONE"
- str = self.class.new self.inspect
- $KCODE = kcode
- str.taint if tainted?
+ str = self.class.new '"'
+ str << escape(CType::Printed, false)
+ str << '"'
str
end
View
38 kernel/delta/ctype.rb
@@ -0,0 +1,38 @@
+module CType
+ def self.toprint(num)
+ case num
+ when ?\n: "\\n"
+ when ?\t: "\\t"
+ when ?\a: "\\a"
+ when ?\v: "\\v"
+ when ?\f: "\\f"
+ when ?\r: "\\r"
+ when ?\e: "\\e"
+ when ?\b: "\\b"
+ when ?": "\\\""
+ when ?\\: "\\\\"
+ when ?#: "\\#"
+ else
+ if num < 32 || num > 126
+ str = "\\000"
+ str.modify!
+
+ c = num.to_s 8
+ str.copy_from c, 0, c.size, 4-c.size
+ else
+ num.chr
+ end
+ end
+ end
+
+ Printed = Rubinius::Tuple.new 256
+ i = 0
+ while i < 256
+ Printed[i] = toprint(i)
+ i += 1
+ end
+
+ def toprint
+ Printed[self]
+ end
+end
View
5 kernel/delta/kernel.rb
@@ -110,6 +110,11 @@ def method_missing(meth, *args)
end
Rubinius::Globals.set_hook(:$stderr, get, set)
+ # Proper kcode support
+ get = proc { Rubinius.kcode.to_s }
+ set = proc { |val| Rubinius.kcode = val }
+ Rubinius::Globals.set_hook(:$KCODE, get, set)
+
# Implements rb_path2name. Based on code from wycats
def const_lookup(name)
names = name.split '::'
View
1  kernel/delta/load_order.txt
@@ -1,5 +1,6 @@
ar.rbc
breakpoint.rbc
+ctype.rbc
class.rbc
exception.rbc
file.rbc
View
3  kernel/loader.rb
@@ -1,5 +1,8 @@
TOPLEVEL_BINDING = binding()
+# Default kcode
+Rubinius.kcode = "ASCII"
+
module Rubinius
class Loader
def initialize
View
108 vm/builtin/string.cpp
@@ -6,6 +6,7 @@
#include "builtin/symbol.hpp"
#include "builtin/float.hpp"
#include "builtin/integer.hpp"
+#include "builtin/tuple.hpp"
#include "vm.hpp"
#include "object_utils.hpp"
@@ -16,6 +17,7 @@
#include <unistd.h>
#include <iostream>
+#include <ctype.h>
namespace rubinius {
@@ -24,15 +26,6 @@ namespace rubinius {
G(string)->set_object_type(state, StringType);
}
- /* String::size returns the number of actual bytes in the string NOT
- * including the trailing NULL byte.
- *
- * String::create(state, "foo")->size() is 3.
- */
- size_t String::size() {
- return num_bytes_->to_native();
- }
-
/* Creates a String instance with +num_bytes+ == +size+ and
* having a ByteArray with at least (size + 1) bytes.
*/
@@ -56,6 +49,25 @@ namespace rubinius {
return so;
}
+ String* String::create_reserved(STATE, size_t bytes) {
+ String *so;
+
+ so = state->new_object<String>(G(string));
+
+ so->num_bytes(state, Fixnum::from(0));
+ so->characters(state, Fixnum::from(0));
+ so->encoding(state, Qnil);
+ so->hash_value(state, (Integer*)Qnil);
+ so->shared(state, Qfalse);
+
+ ByteArray* ba = ByteArray::create(state, bytes);
+ ba->raw_bytes()[bytes-1] = 0;
+
+ so->data(state, ba);
+
+ return so;
+ }
+
/*
* Creates a String instance with +num_bytes+ bytes of storage.
* It also pins the ByteArray used for storage, so it can be passed
@@ -431,6 +443,84 @@ namespace rubinius {
return Fixnum::from(tr_data->steps);
}
+ String* String::escape(STATE, Tuple* tbl, Object* respect_kcode) {
+ uint8_t* cur = byte_address();
+ uint8_t* fin = cur + size();
+
+ if(tbl->num_fields() < 256) {
+ return (String*)Primitives::failure();
+ }
+
+ Object** tbl_ptr = tbl->field;
+
+ kcode::table* kcode_tbl = 0;
+ if(RTEST(respect_kcode)) {
+ kcode_tbl = state->shared.kcode_table();
+ } else {
+ kcode_tbl = kcode::null_table();
+ }
+
+ // Calculate the final size of result
+ size_t size = 0;
+
+ while(cur < fin) {
+ uint8_t byte = *cur;
+ if(kcode::mbchar_p(kcode_tbl, byte)) {
+ size_t clen = kcode::mbclen(kcode_tbl, byte);
+ size += clen;
+ cur += clen;
+ continue;
+ } else {
+ size += as<String>(tbl_ptr[byte])->size();
+ }
+ cur++;
+ }
+
+ cur = byte_address();
+ String* result = String::create(state, Fixnum::from(size));
+
+ // Since we precalculated the size, we can write directly into result
+ uint8_t* output = result->byte_address();
+
+ while(cur < fin) {
+ uint8_t byte = *cur;
+ if(kcode::mbchar_p(kcode_tbl, byte)) {
+ size_t len = kcode::mbclen(kcode_tbl, byte);
+ memcpy(output, cur, len);
+ output += len;
+ cur += len;
+ continue;
+ } else {
+ // Not unsafe, because we've type checked tbl_ptr above
+ String* what = force_as<String>(tbl_ptr[byte]);
+ uint8_t* what_buf = what->byte_address();
+
+ switch(what->size()) {
+ case 1:
+ *output++ = *what_buf;
+ break;
+ case 2:
+ *output++ = *what_buf++;
+ *output++ = *what_buf;
+ break;
+ case 3:
+ *output++ = *what_buf++;
+ *output++ = *what_buf++;
+ *output++ = *what_buf;
+ break;
+ default:
+ memcpy(output, what_buf, what->size());
+ output += what->size();
+ break;
+ }
+ }
+ cur++;
+ }
+
+ if(tainted_p(state)) result->taint(state);
+ return result;
+ }
+
String* String::copy_from(STATE, String* other, Fixnum* start, Fixnum* size, Fixnum* dest) {
native_int src = start->to_native();
native_int dst = dest->to_native();
View
8 vm/builtin/string.hpp
@@ -62,6 +62,7 @@ namespace rubinius {
static String* create(STATE, const char* str);
static String* create(STATE, const char* str, size_t bytes);
static String* create_pinned(STATE, Fixnum* size);
+ static String* create_reserved(STATE, size_t bytes);
// Hash the NUL-terminated string _bp_.
static hashval hash_str(const char *bp);
@@ -74,7 +75,9 @@ namespace rubinius {
Object* equal(STATE, String* other);
// Returns the number of bytes this String contains
- size_t size();
+ size_t size() {
+ return num_bytes_->to_native();
+ }
// Access the String as a char* directly. WARNING: doesn't necessarily
// return a null terminated char*, so be sure to use size() with it.
@@ -162,6 +165,9 @@ namespace rubinius {
// Ruby.primitive :string_rindex
Fixnum* rindex(STATE, String* pattern, Fixnum* start);
+ // Ruby.primitive :string_escape
+ String* escape(STATE, Tuple* table, Object* respect_kcode);
+
class Info : public TypeInfo {
public:
BASIC_TYPEINFO(TypeInfo)
View
41 vm/builtin/system.cpp
@@ -693,4 +693,45 @@ namespace rubinius {
return Qnil;
}
+ Symbol* System::vm_get_kcode(STATE) {
+ switch(state->shared.kcode_page()) {
+ case kcode::eEUC:
+ return state->symbol("EUC");
+ case kcode::eSJIS:
+ return state->symbol("SJIS");
+ case kcode::eUTF8:
+ return state->symbol("UTF8");
+ default:
+ return state->symbol("NONE");
+ }
+ }
+
+ Object* System::vm_set_kcode(STATE, String* what) {
+ if(what->size() < 1) {
+ kcode::set(state, kcode::eAscii);
+ } else {
+ const char* str = what->c_str();
+
+ switch(str[0]) {
+ case 'E':
+ case 'e':
+ kcode::set(state, kcode::eEUC);
+ break;
+ case 'S':
+ case 's':
+ kcode::set(state, kcode::eSJIS);
+ break;
+ case 'U':
+ case 'u':
+ kcode::set(state, kcode::eUTF8);
+ break;
+ default:
+ kcode::set(state, kcode::eAscii);
+ break;
+ }
+ }
+
+ return vm_get_kcode(state);
+ }
+
}
View
6 vm/builtin/system.hpp
@@ -235,6 +235,12 @@ namespace rubinius {
// Ruby.primitive :vm_find_object
static Object* vm_find_object(STATE, Array* arg, Object* callable, CallFrame* calling_environment);
+ // Ruby.primitive :vm_set_kcode
+ static Object* vm_set_kcode(STATE, String* what);
+
+ // Ruby.primitive :vm_get_kcode
+ static Symbol* vm_get_kcode(STATE);
+
public: /* Type info */
class Info : public TypeInfo {
View
130 vm/kcode.cpp
@@ -0,0 +1,130 @@
+#include "vm.hpp"
+#include "kcode.hpp"
+
+namespace rubinius {
+namespace kcode {
+
+ /* Extracted from MRI, 1.8.7-p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0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 0, 0,
+ };
+
+ void init(STATE) {
+ state->shared.set_kcode_table(mbctab_ascii, kcode::eAscii);
+ }
+
+ void set(STATE, CodePage page) {
+ switch(page) {
+ case eAscii:
+ state->shared.set_kcode_table(mbctab_ascii, kcode::eAscii);
+ break;
+ case eEUC:
+ state->shared.set_kcode_table(mbctab_euc, kcode::eEUC);
+ break;
+ case eSJIS:
+ state->shared.set_kcode_table(mbctab_sjis, kcode::eSJIS);
+ break;
+ case eUTF8:
+ state->shared.set_kcode_table(mbctab_utf8, kcode::eUTF8);
+ break;
+ }
+ }
+
+ table* null_table() {
+ return mbctab_ascii;
+ }
+}}
View
27 vm/kcode.hpp
@@ -0,0 +1,27 @@
+#ifndef RBX_KCODE_HPP
+#define RBX_KCODE_HPP
+
+namespace rubinius {
+namespace kcode {
+
+ typedef const uint8_t table;
+
+ enum CodePage {
+ eAscii, eEUC, eSJIS, eUTF8
+ };
+
+ static inline bool mbchar_p(table* tbl, uint8_t c) {
+ return tbl[c] != 0;
+ }
+
+ static inline size_t mbclen(table* tbl, uint8_t c) {
+ return tbl[c] + 1;
+ }
+
+ void init(STATE);
+ table* null_table();
+ void set(STATE, CodePage page);
+
+}}
+
+#endif
View
1  vm/ontology.cpp
@@ -223,6 +223,7 @@ namespace rubinius {
ArrayIterator::init(this);
ByteArray::init(this);
String::init(this);
+ kcode::init(this);
Executable::init(this);
CompiledMethod::init(this);
IO::init(this);
View
1  vm/shared_state.cpp
@@ -1,3 +1,4 @@
+#include "vm.hpp"
#include "shared_state.hpp"
#include "config_parser.hpp"
#include "config.h"
View
17 vm/shared_state.hpp
@@ -6,6 +6,7 @@
#include "maps.hpp"
#include "call_frame_list.hpp"
#include "gc/variable_buffer.hpp"
+#include "kcode.hpp"
#include "globals.hpp"
#include "symboltable.hpp"
@@ -78,6 +79,9 @@ namespace rubinius {
unsigned int class_count_;
std::list<ManagedThread*> threads_;
+ kcode::CodePage kcode_page_;
+ kcode::table* kcode_table_;
+
int primitive_hits_[Primitives::cTotalPrimitives];
public:
@@ -177,6 +181,19 @@ namespace rubinius {
return primitive_hits_[primitive];
}
+ kcode::table* kcode_table() {
+ return kcode_table_;
+ }
+
+ kcode::CodePage kcode_page() {
+ return kcode_page_;
+ }
+
+ void set_kcode_table(kcode::table* tbl, kcode::CodePage page) {
+ kcode_table_ = tbl;
+ kcode_page_ = page;
+ }
+
void enable_profiling(VM* vm);
LookupTable* disable_profiling(VM* vm);
void add_profiler(VM* vm, profiler::Profiler* profiler);
Please sign in to comment.
Something went wrong with that request. Please try again.