Class: Rubinius::ToolSet.current::TS::AST::SendFastNew
- Inherits:
-
SendWithArguments
- Object
- Node
- Send
- SendWithArguments
- Rubinius::ToolSet.current::TS::AST::SendFastNew
- Defined in:
- lib/rubinius/ast/transforms.rb
Overview
Emits a fast path for #new
Constant Summary collapse
- KernelMethodSerial =
FIXME duplicated from kernel/common/compiled_code.rb
47
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 Rubinius::ToolSet.current::TS::AST::SendWithArguments
Class Method Details
.match?(line, receiver, name, arguments, privately) ⇒ Boolean
255 256 257 258 259 |
# File 'lib/rubinius/ast/transforms.rb', line 255 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
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 292 293 294 |
# File 'lib/rubinius/ast/transforms.rb', line 261 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, KernelMethodSerial else g.check_serial :new, KernelMethodSerial end g.gif 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 |