rubinius-compiler 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubinius/compiler/compiled_file.rb +2 -1
- data/lib/rubinius/compiler/compiler.rb +1 -1
- data/lib/rubinius/compiler/evaluator.rb +1 -1
- data/lib/rubinius/compiler/generator.rb +10 -2
- data/lib/rubinius/compiler/generator_methods.rb +272 -188
- data/lib/rubinius/compiler/locals.rb +1 -1
- data/lib/rubinius/compiler/opcodes.rb +100 -94
- data/lib/rubinius/compiler/printers.rb +1 -1
- data/lib/rubinius/compiler/runtime.rb +1 -1
- data/lib/rubinius/compiler/stages.rb +6 -6
- data/lib/rubinius/compiler/version.rb +2 -2
- data/rubinius-compiler.gemspec +1 -2
- metadata +2 -2
@@ -19,132 +19,138 @@ module Rubinius
|
|
19
19
|
opcode 8, :goto, :stack => [0, 0], :args => [:location], :control_flow => :branch
|
20
20
|
opcode 9, :goto_if_false, :stack => [1, 0], :args => [:location], :control_flow => :branch
|
21
21
|
opcode 10, :goto_if_true, :stack => [1, 0], :args => [:location], :control_flow => :branch
|
22
|
-
opcode 11, :
|
22
|
+
opcode 11, :goto_if_nil, :stack => [1, 0], :args => [:location], :control_flow => :branch
|
23
|
+
opcode 12, :goto_if_not_nil, :stack => [1, 0], :args => [:location], :control_flow => :branch
|
24
|
+
opcode 13, :goto_if_undefined, :stack => [1, 0], :args => [:location], :control_flow => :branch
|
25
|
+
opcode 14, :goto_if_not_undefined, :stack => [1, 0], :args => [:location], :control_flow => :branch
|
26
|
+
opcode 15, :goto_if_equal, :stack => [2, 0], :args => [:location], :control_flow => :branch
|
27
|
+
opcode 16, :goto_if_not_equal, :stack => [2, 0], :args => [:location], :control_flow => :branch
|
28
|
+
opcode 17, :ret, :stack => [1, 1], :args => [], :control_flow => :return
|
23
29
|
|
24
30
|
# Stack manipulations
|
25
|
-
opcode
|
26
|
-
opcode
|
27
|
-
opcode
|
28
|
-
opcode
|
29
|
-
opcode
|
30
|
-
opcode
|
31
|
-
opcode
|
31
|
+
opcode 18, :swap_stack, :stack => [2, 2], :args => [], :control_flow => :next
|
32
|
+
opcode 19, :dup_top, :stack => [1, 2], :args => [], :control_flow => :next
|
33
|
+
opcode 20, :dup_many, :stack => [[0,1], [0, 1, 2]],:args => [:count], :control_flow => :next
|
34
|
+
opcode 21, :pop, :stack => [1, 0], :args => [], :control_flow => :next
|
35
|
+
opcode 22, :pop_many, :stack => [[0,1], 0], :args => [:count], :control_flow => :next
|
36
|
+
opcode 23, :rotate, :stack => [[0,1], [0, 1, 1]],:args => [:count], :control_flow => :next
|
37
|
+
opcode 24, :move_down, :stack => [[0,1], [0, 1, 1]],:args => [:positions], :control_flow => :next
|
32
38
|
|
33
39
|
# Manipulate local variables
|
34
|
-
opcode
|
35
|
-
opcode
|
36
|
-
opcode
|
37
|
-
opcode
|
38
|
-
opcode
|
40
|
+
opcode 25, :set_local, :stack => [1, 1], :args => [:local], :control_flow => :next
|
41
|
+
opcode 26, :push_local, :stack => [0, 1], :args => [:local], :control_flow => :next
|
42
|
+
opcode 27, :push_local_depth, :stack => [0, 1], :args => [:depth, :index], :control_flow => :next
|
43
|
+
opcode 28, :set_local_depth, :stack => [1, 1], :args => [:depth, :index], :control_flow => :next
|
44
|
+
opcode 29, :passed_arg, :stack => [0, 1], :args => [:index], :control_flow => :next
|
39
45
|
|
40
46
|
# Manipulate exceptions
|
41
|
-
opcode
|
42
|
-
opcode
|
43
|
-
opcode
|
44
|
-
opcode
|
45
|
-
opcode
|
46
|
-
opcode
|
47
|
-
opcode
|
48
|
-
opcode
|
49
|
-
opcode
|
50
|
-
opcode
|
51
|
-
opcode
|
47
|
+
opcode 30, :push_current_exception, :stack => [0, 1], :args => [], :control_flow => :next
|
48
|
+
opcode 31, :clear_exception, :stack => [0, 0], :args => [], :control_flow => :next
|
49
|
+
opcode 32, :push_exception_state, :stack => [0, 1], :args => [], :control_flow => :next
|
50
|
+
opcode 33, :restore_exception_state, :stack => [1, 0], :args => [], :control_flow => :next
|
51
|
+
opcode 34, :raise_exc, :stack => [1, 0], :args => [], :control_flow => :raise
|
52
|
+
opcode 35, :setup_unwind, :stack => [0, 0], :args => [:ip, :type], :control_flow => :handler
|
53
|
+
opcode 36, :pop_unwind, :stack => [0, 0], :args => [], :control_flow => :next
|
54
|
+
opcode 37, :raise_return, :stack => [1, 1], :args => [], :control_flow => :raise
|
55
|
+
opcode 38, :ensure_return, :stack => [1, 1], :args => [], :control_flow => :raise
|
56
|
+
opcode 39, :raise_break, :stack => [1, 1], :args => [], :control_flow => :raise
|
57
|
+
opcode 40, :reraise, :stack => [0, 0], :args => [], :control_flow => :raise
|
52
58
|
|
53
59
|
# Manipulate arrays
|
54
|
-
opcode
|
55
|
-
opcode
|
56
|
-
opcode
|
60
|
+
opcode 41, :make_array, :stack => [[0,1], 1], :args => [:count], :control_flow => :next
|
61
|
+
opcode 42, :cast_array, :stack => [1, 1], :args => [], :control_flow => :next
|
62
|
+
opcode 43, :shift_array, :stack => [1, 2], :args => [], :control_flow => :next
|
57
63
|
|
58
64
|
# Manipulate instance variables
|
59
|
-
opcode
|
60
|
-
opcode
|
65
|
+
opcode 44, :set_ivar, :stack => [1, 1], :args => [:literal], :control_flow => :next
|
66
|
+
opcode 45, :push_ivar, :stack => [0, 1], :args => [:literal], :control_flow => :next
|
61
67
|
|
62
68
|
# Manipulate constants
|
63
|
-
opcode
|
64
|
-
opcode
|
65
|
-
opcode
|
66
|
-
opcode
|
67
|
-
opcode
|
68
|
-
opcode
|
69
|
-
opcode
|
69
|
+
opcode 46, :push_const, :stack => [0, 1], :args => [:literal], :control_flow => :next
|
70
|
+
opcode 47, :set_const, :stack => [1, 1], :args => [:literal], :control_flow => :next
|
71
|
+
opcode 48, :set_const_at, :stack => [2, 1], :args => [:literal], :control_flow => :next
|
72
|
+
opcode 49, :find_const, :stack => [1, 1], :args => [:literal], :control_flow => :next
|
73
|
+
opcode 50, :push_cpath_top, :stack => [0, 1], :args => [], :control_flow => :next
|
74
|
+
opcode 51, :push_const_fast, :stack => [0, 1], :args => [:literal], :control_flow => :next
|
75
|
+
opcode 52, :find_const_fast, :stack => [1, 1], :args => [:literal], :control_flow => :next
|
70
76
|
|
71
77
|
# Send messages
|
72
|
-
opcode
|
73
|
-
opcode
|
74
|
-
opcode
|
75
|
-
opcode
|
76
|
-
opcode
|
78
|
+
opcode 53, :set_call_flags, :stack => [0, 0], :args => [:flags], :control_flow => :next
|
79
|
+
opcode 54, :allow_private, :stack => [0, 0], :args => [], :control_flow => :next
|
80
|
+
opcode 55, :send_method, :stack => [1, 1], :args => [:literal], :control_flow => :send
|
81
|
+
opcode 56, :send_stack, :stack => [[1,2], 1], :args => [:literal, :count], :control_flow => :send
|
82
|
+
opcode 57, :send_stack_with_block, :stack => [[2,2], 1], :args => [:literal, :count], :control_flow => :send
|
77
83
|
|
78
84
|
CALL_FLAG_CONCAT = 2
|
79
85
|
|
80
|
-
opcode
|
81
|
-
opcode
|
82
|
-
opcode
|
86
|
+
opcode 58, :send_stack_with_splat, :stack => [[3,2], 1], :args => [:literal, :count], :control_flow => :send
|
87
|
+
opcode 59, :send_super_stack_with_block, :stack => [[1,2], 1], :args => [:literal, :count], :control_flow => :send
|
88
|
+
opcode 60, :send_super_stack_with_splat, :stack => [[2,2], 1], :args => [:literal, :count], :control_flow => :send
|
83
89
|
|
84
90
|
# Manipulate blocks
|
85
|
-
opcode
|
86
|
-
opcode
|
87
|
-
opcode
|
88
|
-
opcode
|
89
|
-
opcode
|
90
|
-
opcode
|
91
|
-
opcode
|
92
|
-
opcode
|
91
|
+
opcode 61, :push_block, :stack => [0, 1], :args => [], :control_flow => :next
|
92
|
+
opcode 62, :passed_blockarg, :stack => [0, 1], :args => [:count], :control_flow => :next
|
93
|
+
opcode 63, :create_block, :stack => [0, 1], :args => [:literal], :control_flow => :next
|
94
|
+
opcode 64, :cast_for_single_block_arg, :stack => [0, 1], :args => [], :control_flow => :next
|
95
|
+
opcode 65, :cast_for_multi_block_arg, :stack => [0, 1], :args => [], :control_flow => :next
|
96
|
+
opcode 66, :cast_for_splat_block_arg, :stack => [0, 1], :args => [], :control_flow => :next
|
97
|
+
opcode 67, :yield_stack, :stack => [[0,1], 1], :args => [:count], :control_flow => :yield
|
98
|
+
opcode 68, :yield_splat, :stack => [[1,1], 1], :args => [:count], :control_flow => :yield
|
93
99
|
|
94
100
|
# Manipulate strings
|
95
|
-
opcode
|
96
|
-
opcode
|
97
|
-
opcode
|
101
|
+
opcode 69, :string_append, :stack => [2, 1], :args => [], :control_flow => :next
|
102
|
+
opcode 70, :string_build, :stack => [[0,1], 1], :args => [:count], :control_flow => :next
|
103
|
+
opcode 71, :string_dup, :stack => [1, 1], :args => [], :control_flow => :next
|
98
104
|
|
99
105
|
# Manipulate scope
|
100
|
-
opcode
|
101
|
-
opcode
|
102
|
-
opcode
|
106
|
+
opcode 72, :push_scope, :stack => [0, 1], :args => [], :control_flow => :next
|
107
|
+
opcode 73, :add_scope, :stack => [1, 0], :args => [], :control_flow => :next
|
108
|
+
opcode 74, :push_variables, :stack => [0, 1], :args => [], :control_flow => :next
|
103
109
|
|
104
110
|
# Miscellaneous. TODO: better categorize these
|
105
|
-
opcode
|
106
|
-
opcode
|
107
|
-
opcode
|
108
|
-
opcode
|
109
|
-
opcode
|
111
|
+
opcode 75, :check_interrupts, :stack => [0, 0], :args => [], :control_flow => :next
|
112
|
+
opcode 76, :yield_debugger, :stack => [0, 0], :args => [], :control_flow => :next
|
113
|
+
opcode 77, :is_nil, :stack => [1, 1], :args => [], :control_flow => :next
|
114
|
+
opcode 78, :check_serial, :stack => [1, 1], :args => [:literal, :serial], :control_flow => :next
|
115
|
+
opcode 79, :check_serial_private, :stack => [1, 1], :args => [:literal, :serial], :control_flow => :next
|
110
116
|
|
111
117
|
# Access object fields
|
112
|
-
opcode
|
113
|
-
opcode
|
118
|
+
opcode 80, :push_my_field, :stack => [0, 1], :args => [:index], :control_flow => :next
|
119
|
+
opcode 81, :store_my_field, :stack => [1, 1], :args => [:index], :control_flow => :next
|
114
120
|
|
115
121
|
# Type checks
|
116
|
-
opcode
|
117
|
-
opcode
|
122
|
+
opcode 82, :kind_of, :stack => [2, 1], :args => [], :control_flow => :next
|
123
|
+
opcode 83, :instance_of, :stack => [2, 1], :args => [], :control_flow => :next
|
118
124
|
|
119
125
|
# Optimizations
|
120
|
-
opcode
|
121
|
-
opcode
|
122
|
-
opcode
|
123
|
-
opcode
|
124
|
-
opcode
|
125
|
-
opcode
|
126
|
-
opcode
|
127
|
-
opcode
|
128
|
-
opcode
|
129
|
-
opcode
|
130
|
-
opcode
|
126
|
+
opcode 84, :meta_push_neg_1, :stack => [0, 1], :args => [], :control_flow => :next
|
127
|
+
opcode 85, :meta_push_0, :stack => [0, 1], :args => [], :control_flow => :next
|
128
|
+
opcode 86, :meta_push_1, :stack => [0, 1], :args => [], :control_flow => :next
|
129
|
+
opcode 87, :meta_push_2, :stack => [0, 1], :args => [], :control_flow => :next
|
130
|
+
opcode 88, :meta_send_op_plus, :stack => [2, 1], :args => [:literal], :control_flow => :send
|
131
|
+
opcode 89, :meta_send_op_minus, :stack => [2, 1], :args => [:literal], :control_flow => :send
|
132
|
+
opcode 90, :meta_send_op_equal, :stack => [2, 1], :args => [:literal], :control_flow => :send
|
133
|
+
opcode 91, :meta_send_op_lt, :stack => [2, 1], :args => [:literal], :control_flow => :next
|
134
|
+
opcode 92, :meta_send_op_gt, :stack => [2, 1], :args => [:literal], :control_flow => :next
|
135
|
+
opcode 93, :meta_send_op_tequal, :stack => [2, 1], :args => [:literal], :control_flow => :send
|
136
|
+
opcode 94, :meta_send_call, :stack => [[1,2], 1], :args => [:literal, :count], :control_flow => :send
|
131
137
|
|
132
138
|
# More misc
|
133
|
-
opcode
|
134
|
-
opcode
|
135
|
-
opcode
|
136
|
-
opcode
|
137
|
-
opcode
|
138
|
-
opcode
|
139
|
-
opcode
|
140
|
-
opcode
|
141
|
-
opcode
|
142
|
-
opcode
|
143
|
-
opcode
|
144
|
-
opcode
|
145
|
-
opcode
|
146
|
-
opcode
|
147
|
-
opcode
|
148
|
-
opcode
|
139
|
+
opcode 95, :push_my_offset, :stack => [0, 1], :args => [:index], :control_flow => :next
|
140
|
+
opcode 96, :zsuper, :stack => [1, 1], :args => [:literal], :control_flow => :next
|
141
|
+
opcode 97, :push_block_arg, :stack => [0, 1], :args => [], :control_flow => :next
|
142
|
+
opcode 98, :push_undef, :stack => [0, 1], :args => [], :control_flow => :next
|
143
|
+
opcode 99, :push_stack_local, :stack => [0, 1], :args => [:which], :control_flow => :next
|
144
|
+
opcode 100, :set_stack_local, :stack => [1, 1], :args => [:which], :control_flow => :next
|
145
|
+
opcode 101, :push_has_block, :stack => [0, 1], :args => [], :control_flow => :next
|
146
|
+
opcode 102, :push_proc, :stack => [0, 1], :args => [], :control_flow => :next
|
147
|
+
opcode 103, :check_frozen, :stack => [1, 1], :args => [], :control_flow => :next
|
148
|
+
opcode 104, :cast_multi_value, :stack => [1, 1], :args => [], :control_flow => :next
|
149
|
+
opcode 105, :invoke_primitive, :stack => [[0,2], 1], :args => [:literal, :count], :control_flow => :next
|
150
|
+
opcode 106, :push_rubinius, :stack => [0, 1], :args => [], :control_flow => :next
|
151
|
+
opcode 107, :call_custom, :stack => [[1,2], 1], :args => [:literal, :count], :control_flow => :send
|
152
|
+
opcode 108, :meta_to_s, :stack => [1, 1], :args => [:literal], :control_flow => :send
|
153
|
+
opcode 109, :push_type, :stack => [0, 1], :args => [], :control_flow => :next
|
154
|
+
opcode 110, :push_mirror, :stack => [0, 1], :args => [], :control_flow => :next
|
149
155
|
end
|
150
156
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: us-ascii -*-
|
2
2
|
|
3
|
-
module
|
3
|
+
module CodeTools
|
4
4
|
class Compiler
|
5
5
|
Stages = { }
|
6
6
|
|
@@ -134,7 +134,7 @@ module Rubinius::ToolSets.current::ToolSet
|
|
134
134
|
end
|
135
135
|
|
136
136
|
# AST -> symbolic bytecode
|
137
|
-
class
|
137
|
+
class Bytecode < Stage
|
138
138
|
stage :bytecode
|
139
139
|
next_stage Encoder
|
140
140
|
|
@@ -144,7 +144,7 @@ module Rubinius::ToolSets.current::ToolSet
|
|
144
144
|
super
|
145
145
|
@variable_scope = nil
|
146
146
|
compiler.generator = self
|
147
|
-
@processor =
|
147
|
+
@processor = Generator
|
148
148
|
end
|
149
149
|
|
150
150
|
def run
|
@@ -214,7 +214,7 @@ module Rubinius::ToolSets.current::ToolSet
|
|
214
214
|
# source file -> AST
|
215
215
|
class FileParser < Parser
|
216
216
|
stage :file
|
217
|
-
next_stage
|
217
|
+
next_stage Bytecode
|
218
218
|
|
219
219
|
def input(file, line=1)
|
220
220
|
@file = file
|
@@ -229,7 +229,7 @@ module Rubinius::ToolSets.current::ToolSet
|
|
229
229
|
# source string -> AST
|
230
230
|
class StringParser < Parser
|
231
231
|
stage :string
|
232
|
-
next_stage
|
232
|
+
next_stage Bytecode
|
233
233
|
|
234
234
|
def input(string, name="(eval)", line=1)
|
235
235
|
@input = string
|
@@ -244,7 +244,7 @@ module Rubinius::ToolSets.current::ToolSet
|
|
244
244
|
|
245
245
|
class EvalParser < StringParser
|
246
246
|
stage :eval
|
247
|
-
next_stage
|
247
|
+
next_stage Bytecode
|
248
248
|
|
249
249
|
def should_cache?
|
250
250
|
@output.should_cache?
|
data/rubinius-compiler.gemspec
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
require 'rubinius/toolset'
|
3
2
|
require './lib/rubinius/compiler/version'
|
4
3
|
|
5
4
|
Gem::Specification.new do |spec|
|
6
5
|
spec.name = "rubinius-compiler"
|
7
|
-
spec.version =
|
6
|
+
spec.version = CodeTools::Compiler::VERSION
|
8
7
|
spec.authors = ["Brian Shirai"]
|
9
8
|
spec.email = ["brixen@gmail.com"]
|
10
9
|
spec.description = %q{Rubinius bytecode compiler.}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubinius-compiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Shirai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|