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