< prev index next >

src/hotspot/share/c1/c1_GraphBuilder.cpp

Print this page


 965       // ret.
 966       for (ScopeData* cur_scope_data = scope_data()->parent();
 967            cur_scope_data != NULL && cur_scope_data->parsing_jsr() && cur_scope_data->scope() == scope();
 968            cur_scope_data = cur_scope_data->parent()) {
 969         if (cur_scope_data->jsr_return_address_local() == index) {
 970           BAILOUT("subroutine overwrites return address from previous subroutine");
 971         }
 972       }
 973     } else if (index == scope_data()->jsr_return_address_local()) {
 974       scope_data()->set_jsr_return_address_local(-1);
 975     }
 976   }
 977 
 978   state->store_local(index, round_fp(x));
 979 }
 980 
 981 
 982 void GraphBuilder::load_indexed(BasicType type) {
 983   // In case of in block code motion in range check elimination
 984   ValueStack* state_before = copy_state_indexed_access();

 985   compilation()->set_has_access_indexed(true);
 986   Value index = ipop();
 987   Value array = apop();
 988   Value length = NULL;
 989   if (CSEArrayLength ||
 990       (array->as_AccessField() && array->as_AccessField()->field()->is_constant()) ||
 991       (array->as_NewArray() && array->as_NewArray()->length() && array->as_NewArray()->length()->type()->is_constant())) {
 992     length = append(new ArrayLength(array, state_before));
 993   }
 994 
 995   if (array->is_flattened_array()) {

 996     ciType* array_type = array->declared_type();
 997     ciValueKlass* elem_klass = array_type->as_value_array_klass()->element_klass()->as_value_klass();
 998     NewValueTypeInstance* new_instance = new NewValueTypeInstance(elem_klass, state_before, false);
 999     _memory->new_instance(new_instance);
1000     apush(append_split(new_instance));
1001     LoadIndexed* load_indexed = new LoadIndexed(array, index, length, type, state_before);
1002     load_indexed->set_vt(new_instance);
1003     append(load_indexed);

1004   } else {
1005     push(as_ValueType(type), append(new LoadIndexed(array, index, length, type, state_before)));


1006   }


1007 }
1008 
1009 
1010 void GraphBuilder::store_indexed(BasicType type) {
1011   // In case of in block code motion in range check elimination
1012   ValueStack* state_before = copy_state_indexed_access();

1013   compilation()->set_has_access_indexed(true);
1014   Value value = pop(as_ValueType(type));
1015   Value index = ipop();
1016   Value array = apop();
1017   Value length = NULL;
1018   if (CSEArrayLength ||
1019       (array->as_AccessField() && array->as_AccessField()->field()->is_constant()) ||
1020       (array->as_NewArray() && array->as_NewArray()->length() && array->as_NewArray()->length()->type()->is_constant())) {
1021     length = append(new ArrayLength(array, state_before));
1022   }
1023   ciType* array_type = array->declared_type();
1024   bool check_boolean = false;
1025   if (array_type != NULL) {
1026     if (array_type->is_loaded() &&
1027       array_type->as_array_klass()->element_type()->basic_type() == T_BOOLEAN) {
1028       assert(type == T_BYTE, "boolean store uses bastore");
1029       Value mask = append(new Constant(new IntConstant(1)));
1030       value = append(new LogicOp(Bytecodes::_iand, value, mask));
1031     }
1032   } else if (type == T_BYTE) {
1033     check_boolean = true;





1034   }
1035   StoreIndexed* result = new StoreIndexed(array, index, length, type, value, state_before, check_boolean);
1036   append(result);
1037   _memory->store_value(value);
1038 
1039   if (type == T_OBJECT && is_profiling()) {
1040     // Note that we'd collect profile data in this method if we wanted it.
1041     compilation()->set_would_profile(true);
1042 
1043     if (profile_checkcasts()) {
1044       result->set_profiled_method(method());
1045       result->set_profiled_bci(bci());
1046       result->set_should_profile(true);
1047     }
1048   }
1049 }
1050 
1051 
1052 void GraphBuilder::stack_op(Bytecodes::Code code) {
1053   switch (code) {




 965       // ret.
 966       for (ScopeData* cur_scope_data = scope_data()->parent();
 967            cur_scope_data != NULL && cur_scope_data->parsing_jsr() && cur_scope_data->scope() == scope();
 968            cur_scope_data = cur_scope_data->parent()) {
 969         if (cur_scope_data->jsr_return_address_local() == index) {
 970           BAILOUT("subroutine overwrites return address from previous subroutine");
 971         }
 972       }
 973     } else if (index == scope_data()->jsr_return_address_local()) {
 974       scope_data()->set_jsr_return_address_local(-1);
 975     }
 976   }
 977 
 978   state->store_local(index, round_fp(x));
 979 }
 980 
 981 
 982 void GraphBuilder::load_indexed(BasicType type) {
 983   // In case of in block code motion in range check elimination
 984   ValueStack* state_before = copy_state_indexed_access();
 985   ValueStack* deopt_state = copy_state_before();
 986   compilation()->set_has_access_indexed(true);
 987   Value index = ipop();
 988   Value array = apop();
 989   Value length = NULL;
 990   if (CSEArrayLength ||
 991       (array->as_AccessField() && array->as_AccessField()->field()->is_constant()) ||
 992       (array->as_NewArray() && array->as_NewArray()->length() && array->as_NewArray()->length()->type()->is_constant())) {
 993     length = append(new ArrayLength(array, state_before));
 994   }
 995 
 996   if (array->is_flattened_array()) {
 997     if (array->declared_type()->is_loaded()) {
 998       ciType* array_type = array->declared_type();
 999       ciValueKlass* elem_klass = array_type->as_value_array_klass()->element_klass()->as_value_klass();
1000       NewValueTypeInstance* new_instance = new NewValueTypeInstance(elem_klass, state_before, false);
1001       _memory->new_instance(new_instance);
1002       apush(append_split(new_instance));
1003       LoadIndexed* load_indexed = new LoadIndexed(array, index, length, type, state_before);
1004       load_indexed->set_vt(new_instance);
1005       append(load_indexed);
1006       return;
1007     } else {
1008       // Value array access may be deoptimized. Need full "before" states.
1009       state_before = deopt_state;
1010     }
1011   }
1012 
1013   push(as_ValueType(type), append(new LoadIndexed(array, index, length, type, state_before)));
1014 }
1015 
1016 
1017 void GraphBuilder::store_indexed(BasicType type) {
1018   // In case of in block code motion in range check elimination
1019   ValueStack* state_before = copy_state_indexed_access();
1020   ValueStack* deopt_state = copy_state_before();
1021   compilation()->set_has_access_indexed(true);
1022   Value value = pop(as_ValueType(type));
1023   Value index = ipop();
1024   Value array = apop();
1025   Value length = NULL;
1026   if (CSEArrayLength ||
1027       (array->as_AccessField() && array->as_AccessField()->field()->is_constant()) ||
1028       (array->as_NewArray() && array->as_NewArray()->length() && array->as_NewArray()->length()->type()->is_constant())) {
1029     length = append(new ArrayLength(array, state_before));
1030   }
1031   ciType* array_type = array->declared_type();
1032   bool check_boolean = false;
1033   if (array_type != NULL) {
1034     if (array_type->is_loaded() &&
1035       array_type->as_array_klass()->element_type()->basic_type() == T_BOOLEAN) {
1036       assert(type == T_BYTE, "boolean store uses bastore");
1037       Value mask = append(new Constant(new IntConstant(1)));
1038       value = append(new LogicOp(Bytecodes::_iand, value, mask));
1039     }
1040   } else if (type == T_BYTE) {
1041     check_boolean = true;
1042   }
1043 
1044   if (array->is_flattened_array() && !array_type->is_loaded()) {
1045     // Value array access may be deoptimized. Need full "before" states.
1046     state_before = deopt_state;
1047   }
1048   StoreIndexed* result = new StoreIndexed(array, index, length, type, value, state_before, check_boolean);
1049   append(result);
1050   _memory->store_value(value);
1051 
1052   if (type == T_OBJECT && is_profiling()) {
1053     // Note that we'd collect profile data in this method if we wanted it.
1054     compilation()->set_would_profile(true);
1055 
1056     if (profile_checkcasts()) {
1057       result->set_profiled_method(method());
1058       result->set_profiled_bci(bci());
1059       result->set_should_profile(true);
1060     }
1061   }
1062 }
1063 
1064 
1065 void GraphBuilder::stack_op(Bytecodes::Code code) {
1066   switch (code) {


< prev index next >