@@ -86,21 +86,7 @@ RubyProc procSpecial(VirtualFrame frame, RubyClass procClass, Object[] args, Rub
86
86
@ Cached DispatchNode initialize ) {
87
87
// Instantiate a new instance of procClass as classes do not correspond
88
88
89
- final RubyProc proc = new RubyProc (
90
- procClass ,
91
- getLanguage ().procShape ,
92
- block .type ,
93
- block .arity ,
94
- block .argumentDescriptors ,
95
- block .callTargets ,
96
- block .callTarget ,
97
- block .declarationFrame ,
98
- block .declarationVariables ,
99
- block .declaringMethod ,
100
- block .frameOnStackMarker ,
101
- block .declarationContext );
102
-
103
- AllocationTracing .trace (proc , this );
89
+ final RubyProc proc = ProcOperations .duplicate (procClass , getLanguage ().procShape , block , this );
104
90
initialize .callWithDescriptor (proc , "initialize" , block , RubyArguments .getDescriptor (frame ), args );
105
91
return proc ;
106
92
}
@@ -110,27 +96,26 @@ protected RubyClass metaClass(RubyProc object) {
110
96
}
111
97
}
112
98
113
- @ CoreMethod (names = { "dup" , "clone" })
99
+ @ CoreMethod (names = "clone" )
100
+ public abstract static class CloneNode extends CoreMethodArrayArgumentsNode {
101
+
102
+ @ Specialization
103
+ RubyProc clone (RubyProc proc ,
104
+ @ Cached DispatchNode initializeCopyNode ) {
105
+ final RubyProc copy = ProcOperations .duplicate (proc .getLogicalClass (), getLanguage ().procShape , proc , this );
106
+ initializeCopyNode .call (copy , "initialize_copy" , proc );
107
+ return copy ;
108
+ }
109
+ }
110
+
111
+ @ CoreMethod (names = "dup" )
114
112
public abstract static class DupNode extends CoreMethodArrayArgumentsNode {
115
113
116
114
@ Specialization
117
- RubyProc dup (RubyProc proc ) {
118
- final RubyClass logicalClass = proc .getLogicalClass ();
119
- final RubyProc copy = new RubyProc (
120
- logicalClass ,
121
- getLanguage ().procShape ,
122
- proc .type ,
123
- proc .arity ,
124
- proc .argumentDescriptors ,
125
- proc .callTargets ,
126
- proc .callTarget ,
127
- proc .declarationFrame ,
128
- proc .declarationVariables ,
129
- proc .declaringMethod ,
130
- proc .frameOnStackMarker ,
131
- proc .declarationContext );
132
-
133
- AllocationTracing .trace (copy , this );
115
+ RubyProc dup (RubyProc proc ,
116
+ @ Cached DispatchNode initializeDupNode ) {
117
+ final RubyProc copy = ProcOperations .duplicate (proc .getLogicalClass (), getLanguage ().procShape , proc , this );
118
+ initializeDupNode .call (copy , "initialize_dup" , proc );
134
119
return copy ;
135
120
}
136
121
}
0 commit comments