Mercurial > hg > truffle
comparison src/cpu/x86/vm/c1_CodeStubs_x86.cpp @ 8860:46f6f063b272
7153771: array bound check elimination for c1
Summary: when possible optimize out array bound checks, inserting predicates when needed.
Reviewed-by: never, kvn, twisti
Contributed-by: thomaswue <thomas.wuerthinger@oracle.com>
author | roland |
---|---|
date | Thu, 21 Mar 2013 09:27:54 +0100 |
parents | db9981fd3124 |
children | f98f5d48f511 |
comparison
equal
deleted
inserted
replaced
8780:98f3af397705 | 8860:46f6f063b272 |
---|---|
99 } | 99 } |
100 | 100 |
101 | 101 |
102 void RangeCheckStub::emit_code(LIR_Assembler* ce) { | 102 void RangeCheckStub::emit_code(LIR_Assembler* ce) { |
103 __ bind(_entry); | 103 __ bind(_entry); |
104 if (_info->deoptimize_on_exception()) { | |
105 address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); | |
106 __ call(RuntimeAddress(a)); | |
107 ce->add_call_info_here(_info); | |
108 ce->verify_oop_map(_info); | |
109 debug_only(__ should_not_reach_here()); | |
110 return; | |
111 } | |
112 | |
104 // pass the array index on stack because all registers must be preserved | 113 // pass the array index on stack because all registers must be preserved |
105 if (_index->is_cpu_register()) { | 114 if (_index->is_cpu_register()) { |
106 ce->store_parameter(_index->as_register(), 0); | 115 ce->store_parameter(_index->as_register(), 0); |
107 } else { | 116 } else { |
108 ce->store_parameter(_index->as_jint(), 0); | 117 ce->store_parameter(_index->as_jint(), 0); |
113 } else { | 122 } else { |
114 stub_id = Runtime1::throw_range_check_failed_id; | 123 stub_id = Runtime1::throw_range_check_failed_id; |
115 } | 124 } |
116 __ call(RuntimeAddress(Runtime1::entry_for(stub_id))); | 125 __ call(RuntimeAddress(Runtime1::entry_for(stub_id))); |
117 ce->add_call_info_here(_info); | 126 ce->add_call_info_here(_info); |
127 ce->verify_oop_map(_info); | |
118 debug_only(__ should_not_reach_here()); | 128 debug_only(__ should_not_reach_here()); |
119 } | 129 } |
120 | 130 |
131 PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) { | |
132 _info = new CodeEmitInfo(info); | |
133 } | |
134 | |
135 void PredicateFailedStub::emit_code(LIR_Assembler* ce) { | |
136 __ bind(_entry); | |
137 address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); | |
138 __ call(RuntimeAddress(a)); | |
139 ce->add_call_info_here(_info); | |
140 ce->verify_oop_map(_info); | |
141 debug_only(__ should_not_reach_here()); | |
142 } | |
121 | 143 |
122 void DivByZeroStub::emit_code(LIR_Assembler* ce) { | 144 void DivByZeroStub::emit_code(LIR_Assembler* ce) { |
123 if (_offset != -1) { | 145 if (_offset != -1) { |
124 ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); | 146 ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); |
125 } | 147 } |
412 DEBUG_ONLY(__ should_not_reach_here()); | 434 DEBUG_ONLY(__ should_not_reach_here()); |
413 } | 435 } |
414 | 436 |
415 | 437 |
416 void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { | 438 void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { |
439 address a; | |
440 if (_info->deoptimize_on_exception()) { | |
441 // Deoptimize, do not throw the exception, because it is probably wrong to do it here. | |
442 a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); | |
443 } else { | |
444 a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id); | |
445 } | |
446 | |
417 ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); | 447 ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); |
418 __ bind(_entry); | 448 __ bind(_entry); |
419 __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id))); | 449 __ call(RuntimeAddress(a)); |
420 ce->add_call_info_here(_info); | 450 ce->add_call_info_here(_info); |
451 ce->verify_oop_map(_info); | |
421 debug_only(__ should_not_reach_here()); | 452 debug_only(__ should_not_reach_here()); |
422 } | 453 } |
423 | 454 |
424 | 455 |
425 void SimpleExceptionStub::emit_code(LIR_Assembler* ce) { | 456 void SimpleExceptionStub::emit_code(LIR_Assembler* ce) { |