@@ -569,6 +569,46 @@ aot_gen_commit_values(AOTCompFrame *frame)
569
569
return true;
570
570
}
571
571
572
+ bool
573
+ aot_gen_commit_ip (AOTCompContext * comp_ctx , AOTFuncContext * func_ctx ,
574
+ LLVMValueRef ip_value , bool is_64bit )
575
+ {
576
+ LLVMValueRef cur_frame = func_ctx -> cur_frame ;
577
+ LLVMValueRef value_offset , value_addr , value_ptr ;
578
+ uint32 offset_ip ;
579
+
580
+ if (!comp_ctx -> is_jit_mode )
581
+ offset_ip = comp_ctx -> pointer_size * 4 ;
582
+ else
583
+ offset_ip = offsetof(WASMInterpFrame , ip );
584
+
585
+ if (!(value_offset = I32_CONST (offset_ip ))) {
586
+ aot_set_last_error ("llvm build const failed" );
587
+ return false;
588
+ }
589
+
590
+ if (!(value_addr =
591
+ LLVMBuildInBoundsGEP2 (comp_ctx -> builder , INT8_TYPE , cur_frame ,
592
+ & value_offset , 1 , "ip_addr" ))) {
593
+ aot_set_last_error ("llvm build in bounds gep failed" );
594
+ return false;
595
+ }
596
+
597
+ if (!(value_ptr = LLVMBuildBitCast (
598
+ comp_ctx -> builder , value_addr ,
599
+ is_64bit ? INT64_PTR_TYPE : INT32_PTR_TYPE , "ip_ptr" ))) {
600
+ aot_set_last_error ("llvm build bit cast failed" );
601
+ return false;
602
+ }
603
+
604
+ if (!LLVMBuildStore (comp_ctx -> builder , ip_value , value_ptr )) {
605
+ aot_set_last_error ("llvm build store failed" );
606
+ return false;
607
+ }
608
+
609
+ return true;
610
+ }
611
+
572
612
bool
573
613
aot_gen_commit_sp_ip (AOTCompFrame * frame , bool commit_sp , bool commit_ip )
574
614
{
@@ -577,40 +617,19 @@ aot_gen_commit_sp_ip(AOTCompFrame *frame, bool commit_sp, bool commit_ip)
577
617
LLVMValueRef cur_frame = func_ctx -> cur_frame ;
578
618
LLVMValueRef value_offset , value_addr , value_ptr , value ;
579
619
LLVMTypeRef int8_ptr_ptr_type ;
580
- uint32 offset_ip , offset_sp , n ;
620
+ uint32 offset_sp , n ;
581
621
bool is_64bit = (comp_ctx -> pointer_size == sizeof (uint64 )) ? true : false;
582
622
const AOTValueSlot * sp = frame -> sp ;
583
623
const uint8 * ip = frame -> frame_ip ;
584
624
585
625
if (!comp_ctx -> is_jit_mode ) {
586
- offset_ip = frame -> comp_ctx -> pointer_size * 4 ;
587
626
offset_sp = frame -> comp_ctx -> pointer_size * 5 ;
588
627
}
589
628
else {
590
- offset_ip = offsetof(WASMInterpFrame , ip );
591
629
offset_sp = offsetof(WASMInterpFrame , sp );
592
630
}
593
631
594
632
if (commit_ip ) {
595
- if (!(value_offset = I32_CONST (offset_ip ))) {
596
- aot_set_last_error ("llvm build const failed" );
597
- return false;
598
- }
599
-
600
- if (!(value_addr =
601
- LLVMBuildInBoundsGEP2 (comp_ctx -> builder , INT8_TYPE , cur_frame ,
602
- & value_offset , 1 , "ip_addr" ))) {
603
- aot_set_last_error ("llvm build in bounds gep failed" );
604
- return false;
605
- }
606
-
607
- if (!(value_ptr = LLVMBuildBitCast (
608
- comp_ctx -> builder , value_addr ,
609
- is_64bit ? INT64_PTR_TYPE : INT32_PTR_TYPE , "ip_ptr" ))) {
610
- aot_set_last_error ("llvm build bit cast failed" );
611
- return false;
612
- }
613
-
614
633
if (!comp_ctx -> is_jit_mode ) {
615
634
WASMModule * module = comp_ctx -> comp_data -> wasm_module ;
616
635
if (is_64bit )
@@ -630,8 +649,7 @@ aot_gen_commit_sp_ip(AOTCompFrame *frame, bool commit_sp, bool commit_ip)
630
649
return false;
631
650
}
632
651
633
- if (!LLVMBuildStore (comp_ctx -> builder , value , value_ptr )) {
634
- aot_set_last_error ("llvm build store failed" );
652
+ if (!aot_gen_commit_ip (comp_ctx , func_ctx , value , is_64bit )) {
635
653
return false;
636
654
}
637
655
}
0 commit comments