Class: CodeTools::AST::SendFastNew
- Inherits:
-
SendWithArguments
- Object
- Node
- Send
- SendWithArguments
- CodeTools::AST::SendFastNew
- Defined in:
- lib/rubinius/code/ast/transforms.rb
Overview
Emits a fast path for #new
Instance Attribute Summary
Attributes inherited from SendWithArguments
Attributes inherited from Send
#block, #name, #privately, #receiver, #variable, #vcall_style
Attributes inherited from Node
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from SendWithArguments
Methods inherited from Send
#arguments_sexp, #check_local_reference, #defined, #initialize, #receiver_sexp, #sexp_name, #to_sexp, #value_defined
Methods inherited from Node
#ascii_graph, #attributes, #children, #defined, #initialize, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, #or_bytecode, #pos, #set_child, #to_sexp, #transform, transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk
Constructor Details
This class inherits a constructor from CodeTools::AST::SendWithArguments
Class Method Details
.match?(line, receiver, name, arguments, privately) ⇒ Boolean
252 253 254 255 256 |
# File 'lib/rubinius/code/ast/transforms.rb', line 252 def self.match?(line, receiver, name, arguments, privately) # ignore vcall style return false if !arguments and privately name == :new end |
Instance Method Details
#bytecode(g) ⇒ Object
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/rubinius/code/ast/transforms.rb', line 258 def bytecode(g) return super(g) if @block or @arguments.splat? pos(g) slow = g.new_label done = g.new_label @receiver.bytecode(g) g.dup if @privately g.check_serial_private :new, Rubinius::CompiledCode::KernelMethodSerial else g.check_serial :new, Rubinius::CompiledCode::KernelMethodSerial end g.goto_if_false slow # fast path g.send :allocate, 0, true g.dup @arguments.bytecode(g) g.send :initialize, @arguments.size, true g.pop g.goto done # slow path slow.set! @arguments.bytecode(g) g.send :new, @arguments.size, @privately done.set! end |