@@ -139,24 +139,29 @@ pub(super) fn emit_guarded_direct_method_call(
139139 direct_fn : & str ,
140140 direct_arg_slices : & [ ( crate :: types:: LlvmType , & str ) ] ,
141141 fallback_user_args : & [ String ] ,
142+ shape_only_guard : bool ,
142143) -> Option < String > {
143144 let expected_class_id = * ctx. class_ids . get ( receiver_class_name) ?;
144145 let keys_global_name = ctx. class_keys_globals . get ( receiver_class_name) ?. clone ( ) ;
145146
147+ let expected_class_id_str = expected_class_id. to_string ( ) ;
148+ let expected_keys_slot = ctx. func . entry_init_load_global ( & keys_global_name, I64 ) ;
149+ let expected_keys = ctx. block ( ) . load ( I64 , & expected_keys_slot) ;
150+
146151 let key_idx = ctx. strings . intern ( property) ;
147152 let entry = ctx. strings . entry ( key_idx) ;
148153 let bytes_global = format ! ( "@{}" , entry. bytes_global) ;
149154 let name_len_str = entry. byte_len . to_string ( ) ;
150- let expected_class_id_str = expected_class_id . to_string ( ) ;
151-
152- let site_id = emit_typed_feedback_register_site (
153- ctx ,
154- TypedFeedbackKind :: MethodCall ,
155- property ,
156- TypedFeedbackContract :: method_direct_call ( ) ,
157- ) ;
158- let expected_keys_slot = ctx . func . entry_init_load_global ( & keys_global_name , I64 ) ;
159- let expected_keys = ctx . block ( ) . load ( I64 , & expected_keys_slot ) ;
155+ let site_id = if shape_only_guard {
156+ None
157+ } else {
158+ Some ( emit_typed_feedback_register_site (
159+ ctx ,
160+ TypedFeedbackKind :: MethodCall ,
161+ property ,
162+ TypedFeedbackContract :: method_direct_call ( ) ,
163+ ) )
164+ } ;
160165
161166 let guard_idx = ctx. new_block ( "method_direct.guard" ) ;
162167 let fast_idx = ctx. new_block ( "method_direct.fast" ) ;
@@ -169,19 +174,34 @@ pub(super) fn emit_guarded_direct_method_call(
169174 ctx. block ( ) . br ( & guard_label) ;
170175
171176 ctx. current_block = guard_idx;
172- let guard_ok = ctx. block ( ) . call (
173- I32 ,
174- "js_typed_feedback_method_direct_call_guard" ,
175- & [
176- ( I64 , & site_id) ,
177- ( DOUBLE , recv_box) ,
178- ( I32 , & expected_class_id_str) ,
179- ( I64 , & expected_keys) ,
180- ( crate :: types:: PTR , & bytes_global) ,
181- ( I64 , & name_len_str) ,
182- ( crate :: types:: PTR , & format ! ( "@{}" , direct_fn) ) ,
183- ] ,
184- ) ;
177+ let guard_ok = if shape_only_guard {
178+ ctx. block ( ) . call (
179+ I32 ,
180+ "js_method_direct_shape_guard" ,
181+ & [
182+ ( DOUBLE , recv_box) ,
183+ ( I32 , & expected_class_id_str) ,
184+ ( I64 , & expected_keys) ,
185+ ] ,
186+ )
187+ } else {
188+ ctx. block ( ) . call (
189+ I32 ,
190+ "js_typed_feedback_method_direct_call_guard" ,
191+ & [
192+ (
193+ I64 ,
194+ site_id. as_deref ( ) . expect ( "typed-feedback method site id" ) ,
195+ ) ,
196+ ( DOUBLE , recv_box) ,
197+ ( I32 , & expected_class_id_str) ,
198+ ( I64 , & expected_keys) ,
199+ ( crate :: types:: PTR , & bytes_global) ,
200+ ( I64 , & name_len_str) ,
201+ ( crate :: types:: PTR , & format ! ( "@{}" , direct_fn) ) ,
202+ ] ,
203+ )
204+ } ;
185205 let guard_pass = ctx. block ( ) . icmp_ne ( I32 , & guard_ok, "0" ) ;
186206 ctx. block ( )
187207 . cond_br ( & guard_pass, & fast_label, & fallback_label) ;
@@ -212,8 +232,10 @@ pub(super) fn emit_guarded_direct_method_call(
212232 ) ) ;
213233 ( ptr_reg, n. to_string ( ) )
214234 } ;
215- ctx. block ( )
216- . call_void ( "js_typed_feedback_record_fallback_call" , & [ ( I64 , & site_id) ] ) ;
235+ if let Some ( site_id) = site_id {
236+ ctx. block ( )
237+ . call_void ( "js_typed_feedback_record_fallback_call" , & [ ( I64 , & site_id) ] ) ;
238+ }
217239 let fallback_value = ctx. block ( ) . call (
218240 DOUBLE ,
219241 "js_native_call_method" ,
0 commit comments