[crankshaft] Properly handle OOB string accesses.
BUG=chromium:665793 Review-Url: https://codereview.chromium.org/2589823003 Cr-Commit-Position: refs/heads/master@{#41842}
This commit is contained in:
parent
119db080c5
commit
576a46f520
@ -7508,6 +7508,12 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr,
|
|||||||
HValue* string = Pop();
|
HValue* string = Pop();
|
||||||
HInstruction* char_code = BuildStringCharCodeAt(string, index);
|
HInstruction* char_code = BuildStringCharCodeAt(string, index);
|
||||||
AddInstruction(char_code);
|
AddInstruction(char_code);
|
||||||
|
if (char_code->IsConstant()) {
|
||||||
|
HConstant* c_code = HConstant::cast(char_code);
|
||||||
|
if (c_code->HasNumberValue() && std::isnan(c_code->DoubleValue())) {
|
||||||
|
Add<HDeoptimize>(DeoptimizeReason::kOutOfBounds, Deoptimizer::EAGER);
|
||||||
|
}
|
||||||
|
}
|
||||||
instr = NewUncasted<HStringCharFromCode>(char_code);
|
instr = NewUncasted<HStringCharFromCode>(char_code);
|
||||||
|
|
||||||
} else if (expr->key()->IsPropertyName()) {
|
} else if (expr->key()->IsPropertyName()) {
|
||||||
|
12
test/mjsunit/regress/regress-crbug-665793.js
Normal file
12
test/mjsunit/regress/regress-crbug-665793.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright 2016 the V8 project authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// Flags: --allow-natives-syntax
|
||||||
|
|
||||||
|
function foo() {
|
||||||
|
return 'x'[1];
|
||||||
|
}
|
||||||
|
assertEquals(undefined, foo());
|
||||||
|
%OptimizeFunctionOnNextCall(foo);
|
||||||
|
assertEquals(undefined, foo());
|
Loading…
Reference in New Issue
Block a user