Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Switched to intcode (each opcode is 32bits now)

  • Loading branch information...
commit b8728aba607a19d4a018c879ac9e141791e16ffe 1 parent 50a5d05
@evanphx evanphx authored
View
2  Rakefile
@@ -208,7 +208,7 @@ namespace :build do
task :loader do
i = "kernel/loader.rb"
- o = "runtime/loader.rbc"
+ o = ENV['OUTPUT'] || "runtime/loader.rbc"
if @compiler
system "shotgun/rubinius -I#{@compiler} compile #{i} #{o}"
View
15 kernel/bootstrap/bytearray.rb
@@ -28,4 +28,19 @@ def each
yield get_byte(i)
end
end
+
+ def dup_into(other)
+ Ruby.primitive 32 # :bytes_dup_into
+ end
+
+ def dup(cls=nil)
+ cls ||= self.class
+ obj = cls.new(self.size)
+ dup_into obj
+ return obj
+ end
+
+ def inspect
+ "#<#{self.class}:0x#{object_id.to_s(16)} #{size} bytes>"
+ end
end
View
2  kernel/core/compile.rb
@@ -2,7 +2,7 @@ module Rubinius
# This const controls what the lowest version of compiled methods we can
# allow is. This allows us to cut off compability at some point, or just
# increment when major changes are made to the compiler.
- CompiledMethodVersion = 3
+ CompiledMethodVersion = 4
end
module Compile
View
149 lib/bytecode/assembler.rb
@@ -41,6 +41,16 @@ def reset(literals=[], state=RsLocalState.new)
@state = state
end
+ def add(*args)
+ @current_op += args.size
+ if args.size == 1
+ @output << args.first
+ else
+ @output << args
+ end
+ end
+
+ # OpWidth = 4
CacheSlotsPerEntry = 4
CacheSlotsForConst = 1
@@ -51,13 +61,11 @@ def next_cache_index(count)
end
def add_cache_index
- @current_op += 5
- @output << [:set_cache_index, next_cache_index(CacheSlotsPerEntry)]
+ add :set_cache_index, next_cache_index(CacheSlotsPerEntry)
end
def add_const_cache_index
- @current_op += 5
- @output << [:set_cache_index, next_cache_index(CacheSlotsForConst)]
+ add :set_cache_index, next_cache_index(CacheSlotsForConst)
end
attr_reader :labels, :source_lines, :primitive, :literals
@@ -328,122 +336,100 @@ def parse_push(what)
if what[0] == ?&
lbl = @labels[what[1..-1].to_sym]
raise "Unknown label '#{lbl}'" unless lbl
- @output << [:push_int, lbl]
+ add :push_int, lbl
elsif what[0] == ?@
lit = find_literal(what.to_sym)
- @output << [:push_ivar, lit]
+ add :push_ivar, lit
elsif what.to_i.to_s == what
num = what.to_i
if num == -1
- @current_op += 1
- @output << :meta_push_neg_1
+ add :meta_push_neg_1
elsif num == 0
- @current_op += 1
- @output << :meta_push_0
+ add :meta_push_0
elsif num == 1
- @current_op += 1
- @output << :meta_push_1
+ add :meta_push_1
elsif num == 2
- @current_op += 1
- @output << :meta_push_2
+ add :meta_push_2
else
- @current_op += 5
- @output << [:push_int, num]
+ add :push_int, num
end
return
elsif idx = parse_aref(what)
- @output << [:push_int, idx]
- @output << :fetch_field
- @current_op += 1
+ add :push_int, idx
+ add :fetch_field
elsif what[0] == ?:
lit = find_literal(what[1..-1].to_sym)
- @output << [:push_literal, lit]
+ add :push_literal, lit
else
case what
when "true", true
- @output << :push_true
- @current_op += 1
+ add :push_true
return
when "false", false
- @output << :push_false
- @current_op += 1
+ add :push_false
return
when "nil", nil
- @output << :push_nil
- @current_op += 1
+ add :push_nil
return
when "self", :self
- @output << :push_self
- @current_op += 1
+ add :push_self
else
if cnt = parse_lvar(what)
if Array === cnt
- @output << [:push_local_depth, cnt[0], cnt[1]]
- @current_op += 9
+ add :push_local_depth, cnt[0], cnt[1]
else
- @output << [:push_local, cnt]
- @current_op += 5
+ add :push_local, cnt
end
elsif info = parse_ivar(what)
- @output << [:push_local, info.first]
- @output << [:push_ivar, info.last]
- @current_op += 10
+ add :push_local, info.first
+ add :push_ivar, info.last
elsif cnt = parse_const(what)
add_const_cache_index
- @output << [:push_const, cnt]
- @current_op += 5
+ add :push_const, cnt
else
raise "Unknown push argument '#{what}'"
end
end
return
end
- @current_op += 5
end
def parse_set(what)
if cnt = parse_lvar(what)
if Array === cnt
- @output << [:set_local_depth, cnt[0], cnt[1]]
- @current_op += 9
+ add :set_local_depth, cnt[0], cnt[1]
else
- @output << [:set_local, cnt]
- @current_op += 5
+ add :set_local, cnt
end
elsif info = parse_ivar(what)
- @output << [:push_local, info.first]
- @output << [:set_ivar, info.last]
- @current_op += 10
+ add :push_local, info.first
+ add :set_ivar, info.last
elsif what[0] == ?@
lit = find_literal(what.to_sym)
- @output << [:set_ivar, lit]
- @current_op += 5
+ add :set_ivar, lit
elsif idx = parse_aref(what)
- @output << [:push_int, idx]
- @output << :store_field
- @current_op += 6
+ add :push_int, idx
+ add :store_field
elsif cnt = parse_const(what)
- @output << [:set_const, cnt]
- @current_op += 5
+ add :set_const, cnt
elsif what.index("::")
parent, chld = what.split("::", 2)
if cnt = parse_const(parent)
add_const_cache_index
- @output << [:push_const, cnt]
+ add :push_const, cnt
else
raise "Invalid lhs to double colon (#{parent})"
end
if cnt = parse_const(chld)
- @output << [:set_const_at, cnt]
+ add :set_const_at, cnt
else
raise "Invalid rhs to double colon (#{chld})"
end
- @current_op += 10
elsif what.index("+") == 0
if cnt = parse_const(what[1..-1])
- @output << [:set_const_at, cnt]
+ add :set_const_at, cnt
else
raise "Unknown + argument (#{what})"
end
@@ -459,8 +445,7 @@ def parse_operation(*parts)
end
if Simple.include?(op)
- @output << op
- @current_op += 1
+ add op
return
end
@@ -469,8 +454,7 @@ def parse_operation(*parts)
return
elsif [:goto, :goto_if_true, :goto_if_false].include?(op)
label = parts.shift.to_sym
- @output << [op, @labels[label]]
- @current_op += 5
+ add op, @labels[label]
return
elsif op == :push
parse_push parts.shift
@@ -480,8 +464,7 @@ def parse_operation(*parts)
idx = find_literal(sym)
add_const_cache_index if op == :find_const
add_cache_index if op == :send_method
- @output << [op, idx]
- @current_op += 5
+ add op, idx
return
elsif op == :push
parse_push parts.shift
@@ -490,29 +473,26 @@ def parse_operation(*parts)
sym = parts.shift.to_sym
idx = find_literal(sym)
add_cache_index
- @output << [op, idx, parts.shift.to_i]
- @current_op += 9
+ add op, idx, parts.shift.to_i
return
elsif [:"&send", :send].include?(op)
sym = parts.shift.to_sym
idx = find_literal(sym)
add_cache_index
- @current_op += 5
if args = parts.shift
if args.to_i.to_s == args
meth = (op == :send ? :send_stack : :send_stack_with_block)
elsif args == "+"
meth = :send_with_arg_register
- @output << [meth, idx]
+ add meth, idx
return
else
raise "Unknown send argument type '#{args}'"
end
na = args.to_i
- @output << [meth, idx, na]
- @current_op += 4
+ add meth, idx, na
else
- @output << [:send_method, idx]
+ add :send_method, idx
end
return
elsif op == :super
@@ -521,36 +501,33 @@ def parse_operation(*parts)
add_cache_index
args = parts.shift
if args == "+"
- @current_op += 5
- @output << [:send_super_with_arg_register, idx]
- else
- @current_op += 9
- @output << [:send_super_stack_with_block, idx, args.to_i]
+ add :send_super_with_arg_register, idx
+ else
+ add :send_super_stack_with_block, idx, args.to_i
end
return
elsif op == :send_primitive
sym = parts.shift.to_sym
idx = primitive_to_index(sym)
num_args = parts.shift.to_i
- @current_op += 9
- @output << [:send_primitive, idx, num_args]
+ add :send_primitive, idx, num_args
return
elsif op == :check_argcount
- @output << [op, parts.shift.to_i, parts.shift.to_i]
- @current_op += 9
+ req = parts.shift.to_i
+ add op, req, parts.shift.to_i
return
end
if Bytecode::InstructionEncoder::OpCodes.include?(op)
- @current_op += 1
- if Bytecode::InstructionEncoder::TwoInt.include?(op)
- @current_op += 8
- @output << [op, parts.shift.to_i, parts.shift.to_i]
- elsif Bytecode::InstructionEncoder::IntArg.include?(op)
- @current_op += 4
- @output << [op, parts.first.to_i]
+ if Bytecode::InstructionEncoder::IntArg.include?(op)
+ if Bytecode::InstructionEncoder::TwoInt.include?(op)
+ fir = parts.shift.to_i
+ add op, fir, parts.shift.to_i
+ else
+ add op, parts.shift.to_i
+ end
else
- @output << op
+ add op
end
return
end
View
4 lib/bytecode/encoder.rb
@@ -286,7 +286,7 @@ def instruction_width(op)
op = OpCodes[op]
end
- width = 1
+ width = 4
if IntArg.include?(op)
width += 4
elsif TwoInt.include?(op)
@@ -330,7 +330,7 @@ def encode(kind, *args)
end
def process_args(kind, opcode, args)
- str = opcode.chr
+ str = [opcode].pack("N")
# puts "#{kind} args. (#{str.inspect})"
# puts args.inspect if ENV["DEBUG_ASSEMBLER"]
View
2  lib/bytecode/primitive_names.rb 100644 → 100755
@@ -32,7 +32,7 @@ class Compiler
:create_pipe,
:gettimeofday,
:strftime,
- nil,
+ :bytes_dup_into,
:activate_as_script,
:stat_file,
:io_open,
View
4 native/bytecode/rubinius.rb
@@ -28,8 +28,8 @@ def to_cmethod
enc = Bytecode::InstructionEncoder.new
bc = enc.encode_stream stream
lcls = @state.number_of_locals
-
- cmeth = CompiledMethod.new.from_string bc.data, lcls, @required
+ iseq = bc.data.dup(InstructionSequence)
+ cmeth = CompiledMethod.new.from_string iseq, lcls, @required
cmeth.exceptions = asm.exceptions_as_tuple
idx = nil
View
BIN  runtime/bootstrap.rba
Binary file not shown
View
BIN  runtime/compiler.rba
Binary file not shown
View
BIN  runtime/loader.rbc
Binary file not shown
View
5 shotgun/common.mk
@@ -10,10 +10,7 @@ MARCH=$(shell uname -m)
WARNINGS = -Wall
DEBUG = -g -ggdb3
-# basic optimizations should be overridable
-CFLAGS ?= -O2
-
-CFLAGS += $(WARNINGS) $(DEBUG)
+CFLAGS = $(WARNINGS) $(DEBUG)
CPPFLAGS += `pkg-config glib-2.0 --cflags`
View
2  shotgun/lib/Makefile
@@ -47,7 +47,7 @@ ifdef DEV
OPTIMIZATIONS=
else
INLINE_OPTS=-finline-limit=2000 --param max-inline-insns-single=3500 --param large-function-growth=2000 --param inline-unit-growth=1000
- OPTIMIZATIONS=-ffast-math -funroll-loops -finline-functions -fno-omit-frame-pointer $(INLINE_OPTS)
+ OPTIMIZATIONS=-O2 -ffast-math -funroll-loops -finline-functions -fno-omit-frame-pointer $(INLINE_OPTS)
endif
ifeq ($(CPU), powerpc)
OPTIMIZATIONS+=-falign-loops=16
View
1  shotgun/lib/bootstrap.c
@@ -508,6 +508,7 @@ void cpu_bootstrap(STATE) {
BC(undef_class) = rbs_class_new(state, "UndefClass", 0, obj);
BC(fastctx) = rbs_class_new(state, "FastMethodContext", 0, BC(methctx));
BC(task) = rbs_class_new(state, "Task", 0, obj);
+ BC(iseq) = rbs_class_new(state, "InstructionSequence", 0, BC(bytearray));
#define bcs(name, sup, string) BC(name) = _ ## name ## _class(state, sup); \
module_setup(state, BC(name), string);
View
44 shotgun/lib/bytearray.c
@@ -38,3 +38,47 @@ char *bytearray_as_string(STATE, OBJECT self) {
return out;
}
+
+OBJECT iseq_new(STATE, int fields) {
+ OBJECT obj;
+
+ obj = NEW_OBJECT(state->global->iseq, fields);
+ object_make_byte_storage(state, obj);
+
+ return obj;
+}
+
+static inline uint32_t read_int_big(uint8_t *str) {
+ return (uint32_t)((str[0] << 24)
+ | (str[1] << 16)
+ | (str[2] << 8 )
+ | str[3] );
+}
+
+static inline uint32_t read_int_little(uint8_t *str) {
+ return (uint32_t)(str[0]
+ | (str[1] << 8 )
+ | (str[2] << 26)
+ | (str[3] << 24));
+}
+
+#if defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
+#define read_int read_int_little
+#else
+#define read_int read_int_big
+#endif
+
+void iseq_flip(STATE, OBJECT self) {
+ uint8_t *buf;
+ uint32_t tmp;
+ uint32_t *ibuf;
+ int i, f;
+
+ f = NUM_FIELDS(self) * REFSIZE;
+ buf = (uint8_t*)bytearray_byte_address(state, self);
+ ibuf = (uint32_t*)bytearray_byte_address(state, self);
+
+ for(i = 0; i < f; i += 4, ibuf++) {
+ *ibuf = read_int(buf + i);
+ }
+}
View
3  shotgun/lib/bytearray.h
@@ -8,3 +8,6 @@ char *bytearray_as_string(STATE, OBJECT self);
#define bytearray_byte_address(st, self) BYTEARRAY_ADDRESS(self)
#define bytearray_bytes(st, self) BYTEARRAY_SIZE(self)
+
+OBJECT iseq_new(STATE, int fields);
+void iseq_flip(STATE, OBJECT self);
View
15 shotgun/lib/cpu.h
@@ -11,13 +11,24 @@
/* Enables the context cache. */
#define CTX_CACHE_ENABLED 0
+/* Enable intcode*/
+#define USE_INTCODE 1
+
+#if USE_INTCODE
+#define IP_TYPE uint32_t
+#define BS_JUMP 2
+#else
+#define IP_TYPE unsigned char
+#define BS_JUMP 5
+#endif
+
#define CPU_REGISTERS OBJECT sender; \
unsigned long int ip; \
unsigned long int sp; \
OBJECT block; \
unsigned long int raiseable; \
OBJECT method; \
- unsigned char *data; \
+ IP_TYPE *data; \
unsigned long int data_size; \
OBJECT literals; \
OBJECT self; \
@@ -59,7 +70,7 @@ struct fast_context {
GPtrArray *paths; \
unsigned int depth; \
OBJECT context_cache; \
- unsigned char *ip_ptr; \
+ IP_TYPE *ip_ptr; \
OBJECT *sp_ptr; \
int call_flags; \
OBJECT debug_channel; \
View
9 shotgun/lib/cpu_instructions.c
@@ -22,9 +22,12 @@
#define RISA(obj,cls) (REFERENCE_P(obj) && ISA(obj,BASIC_CLASS(cls)))
+#if USE_INTCODE
+#define next_int _int = *c->ip_ptr++;
+#else
#define set_int(i,s) ((i)=(((s)[0] << 24) | ((s)[1] << 16) | ((s)[2] << 8) | (s)[3]))
#define next_int set_int(_int,(c->ip_ptr)); c->ip_ptr += 4
-// #define next_int set_int(_int,(c->data + c->ip)); c->ip += 4; c->ip_ptr += 4
+#endif
/* #ifndef __BIG_ENDIAN__ */
/* #define next_int _int = swap32(*(int*)(c->data + c->ip)); c->ip += 4 */
@@ -36,7 +39,7 @@
OBJECT cpu_open_class(STATE, cpu c, OBJECT under, OBJECT sup) {
OBJECT sym, _lit, val, s1, s2, s3, s4, sup_itr;
- int _int;
+ uint32_t _int;
next_literal;
sym = _lit;
@@ -951,7 +954,7 @@ void state_collect(STATE, cpu c);
void state_major_collect(STATE, cpu c);
void cpu_run(STATE, cpu c) {
- unsigned char op;
+ IP_TYPE op;
g_use_firesuit = 1;
g_access_violation = 0;
View
47 shotgun/lib/cpu_marshal.c
@@ -270,6 +270,47 @@ static OBJECT unmarshal_bytes(STATE, struct marshal_state *ms) {
return obj;
}
+static void marshal_iseq(STATE, OBJECT obj, GString *buf) {
+ int i;
+ append_c('I');
+ /* Right now, an iseq is always stored as big endian, we need to
+ figure out how it knows the iseq is in little to use this code. */
+ append_c('b');
+/*
+#if defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
+ append_c('b');
+#else
+ append_c('l');
+#endif
+*/
+ i = NUM_FIELDS(obj) * REFSIZE;
+ append_sz(i);
+ append_str(bytearray_byte_address(state, obj), i);
+}
+
+static OBJECT unmarshal_iseq(STATE, struct marshal_state *ms) {
+ int sz;
+ char endian;
+ OBJECT obj;
+ endian = ms->buf[1];
+
+ sz = read_int(ms->buf + 2);
+
+ ms->consumed += 6;
+ ms->consumed += sz;
+ obj = iseq_new(state, sz / REFSIZE);
+
+ memcpy(bytearray_byte_address(state, obj), ms->buf + 6, sz);
+
+ #if defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
+ if(endian != 'b') iseq_flip(state, obj);
+ #else
+ if(endian != 'l') iseq_flip(state, obj);
+ #endif
+
+ return obj;
+}
+
static void marshal_cmethod(STATE, OBJECT obj, GString *buf, struct marshal_state *ms) {
marshal_fields_as(state, obj, buf, 'm', ms);
}
@@ -307,6 +348,10 @@ static OBJECT unmarshal(STATE, struct marshal_state *ms) {
o = unmarshal_bytes(state, ms);
_add_object(o, ms);
break;
+ case 'I':
+ o = unmarshal_iseq(state, ms);
+ _add_object(o, ms);
+ break;
case 'm':
o = unmarshal_cmethod(state, ms);
_add_object(o, ms);
@@ -370,6 +415,8 @@ static void marshal(STATE, OBJECT obj, GString *buf, struct marshal_state *ms) {
marshal_cmethod(state, obj, buf, ms);
} else if(kls == state->global->bytearray) {
marshal_bytes(state, obj, buf);
+ } else if(kls == state->global->iseq) {
+ marshal_iseq(state, obj, buf);
} else if(kls == BASIC_CLASS(bignum)) {
marshal_bignum(state, obj, buf);
} else if(kls == BASIC_CLASS(floatpoint)) {
View
1  shotgun/lib/cpu_primitives.c
@@ -45,6 +45,7 @@
extern char **environ;
OBJECT math_sqrt(STATE, OBJECT a);
+int _object_stores_bytes(OBJECT self);
#define STATIC_SIZE 100
View
27 shotgun/lib/grammar.c
@@ -586,7 +586,7 @@ typedef union YYSTYPE
int num;
var_table *vars;
}
-/* Line 187 of yacc.c. */
+/* Line 193 of yacc.c. */
#line 591 "grammar.c"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -9895,12 +9895,14 @@ fixpos(node, orig)
}
static void
-parser_warning(NODE *node, const char *mesg)
+parser_warning(rb_parse_state *parse_state, NODE *node, const char *mesg)
{
int line = ruby_sourceline;
- ruby_sourceline = nd_line(node);
- printf("%s:%i: warning: %s\n", ruby_sourcefile, ruby_sourceline, mesg);
- ruby_sourceline = line;
+ if(parse_state->emit_warnings) {
+ ruby_sourceline = nd_line(node);
+ printf("%s:%i: warning: %s\n", ruby_sourcefile, ruby_sourceline, mesg);
+ ruby_sourceline = line;
+ }
}
static NODE*
@@ -9921,7 +9923,7 @@ block_append(parse_state, head, tail)
case NODE_STR:
g_string_free(h->nd_str, TRUE);
case NODE_LIT:
- parser_warning(h, "unused literal ignored");
+ parser_warning(parse_state, h, "unused literal ignored");
return tail;
default:
h = end = NEW_BLOCK(head);
@@ -9943,7 +9945,7 @@ block_append(parse_state, head, tail)
case NODE_NEXT:
case NODE_REDO:
case NODE_RETRY:
- parser_warning(nd, "statement not reached");
+ parser_warning(parse_state, nd, "statement not reached");
break;
case NODE_NEWLINE:
@@ -10473,7 +10475,7 @@ value_expr0(node, parse_state)
switch (nd_type(node)) {
case NODE_DEFN:
case NODE_DEFS:
- parser_warning(node, "void value expression");
+ parser_warning(parse_state, node, "void value expression");
return FALSE;
case NODE_RETURN:
@@ -10689,7 +10691,7 @@ assign_in_cond(node, parse_state)
}
#if 0
if (assign_in_cond(node->nd_value) == 0) {
- parser_warning(node->nd_value, "assignment in condition");
+ parser_warning(parse_state, node->nd_value, "assignment in condition");
}
#endif
return 1;
@@ -10704,11 +10706,12 @@ e_option_supplied()
}
static void
-warn_unless_e_option(node, str)
+warn_unless_e_option(ps, node, str)
+ rb_parse_state *ps;
NODE *node;
const char *str;
{
- if (!e_option_supplied()) parser_warning(node, str);
+ if (!e_option_supplied()) parser_warning(ps, node, str);
}
static NODE *cond0();
@@ -10731,7 +10734,7 @@ range_op(node, parse_state)
type = nd_type(node);
}
if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) {
- warn_unless_e_option(node, "integer literal in conditional range");
+ warn_unless_e_option(parse_state, node, "integer literal in conditional range");
return call_op(node,tEQ,1,NEW_GVAR(rb_intern("$.")), parse_state);
}
return node;
View
25 shotgun/lib/grammar.y
@@ -4838,12 +4838,14 @@ fixpos(node, orig)
}
static void
-parser_warning(NODE *node, const char *mesg)
+parser_warning(rb_parse_state *parse_state, NODE *node, const char *mesg)
{
int line = ruby_sourceline;
- ruby_sourceline = nd_line(node);
- printf("%s:%i: warning: %s\n", ruby_sourcefile, ruby_sourceline, mesg);
- ruby_sourceline = line;
+ if(parse_state->emit_warnings) {
+ ruby_sourceline = nd_line(node);
+ printf("%s:%i: warning: %s\n", ruby_sourcefile, ruby_sourceline, mesg);
+ ruby_sourceline = line;
+ }
}
static NODE*
@@ -4864,7 +4866,7 @@ block_append(parse_state, head, tail)
case NODE_STR:
g_string_free(h->nd_str, TRUE);
case NODE_LIT:
- parser_warning(h, "unused literal ignored");
+ parser_warning(parse_state, h, "unused literal ignored");
return tail;
default:
h = end = NEW_BLOCK(head);
@@ -4886,7 +4888,7 @@ block_append(parse_state, head, tail)
case NODE_NEXT:
case NODE_REDO:
case NODE_RETRY:
- parser_warning(nd, "statement not reached");
+ parser_warning(parse_state, nd, "statement not reached");
break;
case NODE_NEWLINE:
@@ -5416,7 +5418,7 @@ value_expr0(node, parse_state)
switch (nd_type(node)) {
case NODE_DEFN:
case NODE_DEFS:
- parser_warning(node, "void value expression");
+ parser_warning(parse_state, node, "void value expression");
return FALSE;
case NODE_RETURN:
@@ -5632,7 +5634,7 @@ assign_in_cond(node, parse_state)
}
#if 0
if (assign_in_cond(node->nd_value) == 0) {
- parser_warning(node->nd_value, "assignment in condition");
+ parser_warning(parse_state, node->nd_value, "assignment in condition");
}
#endif
return 1;
@@ -5647,11 +5649,12 @@ e_option_supplied()
}
static void
-warn_unless_e_option(node, str)
+warn_unless_e_option(ps, node, str)
+ rb_parse_state *ps;
NODE *node;
const char *str;
{
- if (!e_option_supplied()) parser_warning(node, str);
+ if (!e_option_supplied()) parser_warning(ps, node, str);
}
static NODE *cond0();
@@ -5674,7 +5677,7 @@ range_op(node, parse_state)
type = nd_type(node);
}
if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) {
- warn_unless_e_option(node, "integer literal in conditional range");
+ warn_unless_e_option(parse_state, node, "integer literal in conditional range");
return call_op(node,tEQ,1,NEW_GVAR(rb_intern("$.")), parse_state);
}
return node;
View
2  shotgun/lib/grammar_internal.h
@@ -44,7 +44,7 @@ typedef struct rb_parse_state {
char *token_buffer;
int tokidx;
int toksiz;
-
+ int emit_warnings;
/* Mirror'ing the 1.8 parser, There are 2 input methods,
from IO and directly from a string. */
View
1  shotgun/lib/grammar_runtime.c
@@ -35,6 +35,7 @@ rb_parse_state *alloc_parse_state() {
parse_state->pool_size = 0;
parse_state->memory_size = 204800;
parse_state->memory_pools = NULL;
+ parse_state->emit_warnings = 0;
return parse_state;
}
View
2  shotgun/lib/instructions.rb
@@ -953,7 +953,7 @@ def create_block
} else {
cpu_flush_sp(c);
cpu_flush_ip(c);
- j = c->ip + 5;
+ j = c->ip + BS_JUMP;
t2 = blokenv_s_under_context(state, t3, t4, j, t1, t2, _int);
stack_push(t2);
}
View
18 shotgun/lib/machine.c
@@ -445,6 +445,11 @@ int machine_run(machine m) {
int machine_run_file(machine m, const char *path) {
OBJECT meth;
+ int out;
+
+ if(m->s->excessive_tracing) {
+ printf("[ Loading file %s]\n", path);
+ }
meth = machine_load_file(m, path);
if(!RTEST(meth)) {
@@ -454,7 +459,11 @@ int machine_run_file(machine m, const char *path) {
cpu_stack_push(m->s, m->c, meth, FALSE);
cpu_run_script(m->s, m->c, meth);
- return machine_run(m);
+ out = machine_run(m);
+ if(m->s->excessive_tracing) {
+ printf("[ Finished loading file %s]\n", path);
+ }
+ return out;
}
void machine_set_const_under(machine m, const char *str, OBJECT val, OBJECT under) {
@@ -737,6 +746,10 @@ OBJECT machine_load_archive(machine m, const char *path) {
OBJECT order, cm, ret = Qfalse;
archive_handle_t *archive;
char *files, *nxt, *top;
+
+ if(m->s->excessive_tracing) {
+ printf("[ Loading archive %s]\n", path);
+ }
archive = archive_open(m->s, path);
if(!archive) {
@@ -779,6 +792,9 @@ OBJECT machine_load_archive(machine m, const char *path) {
out:
archive_close(m->s, archive);
+ if(m->s->excessive_tracing) {
+ printf("[ Finished loading archive %s]\n", path);
+ }
return ret;
}
View
22 shotgun/lib/primitives.rb
@@ -253,7 +253,7 @@ def create_block
} else {
cpu_flush_sp(c);
cpu_flush_ip(c);
- j = c->ip + 5;
+ j = c->ip + BS_JUMP;
t2 = blokenv_s_under_context(state, t3, c->block, j, t1, t2, 0);
stack_push(t2);
}
@@ -716,6 +716,26 @@ def dup_into
CODE
end
+ def bytes_dup_into
+ <<-CODE
+ POP(self, REFERENCE);
+ POP(t1, REFERENCE);
+
+ GUARD(_object_stores_bytes(self));
+ GUARD(_object_stores_bytes(t1));
+
+ k = bytearray_bytes(state, self);
+ j = bytearray_bytes(state, t1);
+
+ if(j < k) { k = j; }
+
+ memcpy(bytearray_byte_address(state, t1),
+ bytearray_byte_address(state, self), k);
+
+ stack_push(t1);
+ CODE
+ end
+
def fastctx_dup
<<-CODE
POP(self, REFERENCE);
View
2  shotgun/lib/state.h
@@ -32,7 +32,7 @@ struct rubinius_globals {
OBJECT external_ivars, scheduled_threads, errno_mapping;
OBJECT recent_children, config, ffi_ptr, ffi_func, sym_send;
OBJECT functions, sym_public, sym_private, sym_protected, sym_const_missing;
- OBJECT exception;
+ OBJECT exception, iseq;
};
#define GLOBAL_cmethod
View
4 shotgun/lib/string.c
@@ -83,6 +83,10 @@ char *string_byte_address(STATE, OBJECT self) {
assert(STRING_P(self));
data = string_get_data(self);
+ if(NIL_P(data)) {
+ return "";
+ }
+
return bytearray_byte_address(state, data);
}
Please sign in to comment.
Something went wrong with that request. Please try again.