Commit ca23cdd8 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Simplify HandlerTable::LookupRange search.

This simplifies the lookup mechanism used for range-based exception
handler tables. Those tables are well nested and we can assume that
results get increasingly narrow the later they appear in the table.

R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/1639743002

Cr-Commit-Position: refs/heads/master@{#33507}
parent 51879692
......@@ -10951,10 +10951,11 @@ Handle<LiteralsArray> LiteralsArray::New(Isolate* isolate,
int HandlerTable::LookupRange(int pc_offset, int* stack_depth_out,
CatchPrediction* prediction_out) {
int innermost_handler = -1, innermost_start = -1;
int innermost_handler = -1;
#ifdef DEBUG
// Assuming that ranges are well nested, we don't need to track the innermost
// end offset. This is just to verify that the table is actually well nested.
// offsets. This is just to verify that the table is actually well nested.
int innermost_start = std::numeric_limits<int>::min();
int innermost_end = std::numeric_limits<int>::max();
#endif
for (int i = 0; i < length(); i += kRangeEntrySize) {
......@@ -10965,11 +10966,11 @@ int HandlerTable::LookupRange(int pc_offset, int* stack_depth_out,
CatchPrediction prediction = HandlerPredictionField::decode(handler_field);
int stack_depth = Smi::cast(get(i + kRangeDepthIndex))->value();
if (pc_offset > start_offset && pc_offset <= end_offset) {
if (start_offset < innermost_start) continue;
DCHECK_GE(start_offset, innermost_start);
DCHECK_LT(end_offset, innermost_end);
innermost_handler = handler_offset;
innermost_start = start_offset;
#ifdef DEBUG
innermost_start = start_offset;
innermost_end = end_offset;
#endif
*stack_depth_out = stack_depth;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment