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

Unified Diff: src/crankshaft/hydrogen.cc

Issue 2146353002: [stubs] Properly handle length overflow in StringAddStub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Throw a proper RangeError Created 4 years, 5 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/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen.cc
diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc
index 7fce48961f3a2c8d78d23b43b7e3a08fa9e7c77e..db60d6f3523d029b45b2cbd1cf3393b62c619b44 100644
--- a/src/crankshaft/hydrogen.cc
+++ b/src/crankshaft/hydrogen.cc
@@ -2413,7 +2413,20 @@ HValue* HGraphBuilder::BuildAddStringLengths(HValue* left_length,
HValue* length = AddUncasted<HAdd>(left_length, right_length);
// Check that length <= kMaxLength <=> length < MaxLength + 1.
HValue* max_length = Add<HConstant>(String::kMaxLength + 1);
- Add<HBoundsCheck>(length, max_length);
+ if (top_info()->IsStub()) {
+ // This is a mitigation for crbug.com/627934; the real fix
+ // will be to migrate the StringAddStub to TurboFan one day.
jgruber 2017/01/31 15:13:47 FYI: We now have a TF StringAddStub. Not sure from
Benedikt Meurer 2017/01/31 17:57:20 I think we still inline this into the BinaryOpIC f
+ IfBuilder if_invalid(this);
+ if_invalid.If<HCompareNumericAndBranch>(length, max_length, Token::GT);
+ if_invalid.Then();
+ {
+ Add<HCallRuntime>(
+ Runtime::FunctionForId(Runtime::kThrowInvalidStringLength), 0);
+ }
+ if_invalid.End();
+ } else {
+ Add<HBoundsCheck>(length, max_length);
+ }
return length;
}
« no previous file with comments | « no previous file | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698