Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Unified Diff: src/deoptimizer.cc

Issue 344513004: Fix a potential overflow in SortedListBSearch (Closed) Base URL: https://github.com/v8/v8.git@master
Patch Set: optimize Deoptimizer::GetOutputInfo Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/full-codegen.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/deoptimizer.cc
diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc
index 2b39ff6965e89a1290c03d1af0ea33c20c2c963a..27ec5f0fc286a4b6d602da6b9e5c97c2225b1e6e 100644
--- a/src/deoptimizer.cc
+++ b/src/deoptimizer.cc
@@ -690,14 +690,17 @@ int Deoptimizer::GetDeoptimizationId(Isolate* isolate,
int Deoptimizer::GetOutputInfo(DeoptimizationOutputData* data,
BailoutId id,
SharedFunctionInfo* shared) {
- // TODO(kasperl): For now, we do a simple linear search for the PC
- // offset associated with the given node id. This should probably be
- // changed to a binary search.
int length = data->DeoptPoints();
- for (int i = 0; i < length; i++) {
- if (data->AstId(i) == id) {
- return data->PcAndState(i)->value();
- }
+ int low = 0, high = length - 1, mid;
+ while (low <= high) {
+ mid = low + (high - low) / 2;
+ if (id == data->AstId(mid)) {
+ return data->PcAndState(mid)->value();
+ } else if (id < data->AstId(mid)) {
+ high = mid - 1;
+ } else {
+ low = mid + 1;
+ }
}
PrintF(stderr, "[couldn't find pc offset for node=%d]\n", id.ToInt());
PrintF(stderr, "[method: %s]\n", shared->DebugName()->ToCString().get());
« no previous file with comments | « no previous file | src/full-codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698