Browse Source

deps: backport dd310b4341 from upstream V8

Original commit message:

    [crankshaft] Fix string addition to check for max length of cons string.

    BUG=chromium:678917

    Review-Url: https://codereview.chromium.org/2653623002
    Cr-Commit-Position: refs/heads/master@{#42621}

PR-URL: https://github.com/nodejs/node/pull/12696
Fixes: https://github.com/nodejs/node/issues/12573
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
v7.x-staging
Yang Guo 8 years ago
committed by Michaël Zasso
parent
commit
50e60e979c
  1. 2
      deps/v8/include/v8-version.h
  2. 3
      deps/v8/src/crankshaft/hydrogen.cc
  3. 24
      deps/v8/test/mjsunit/regress/regress-678917.js

2
deps/v8/include/v8-version.h

@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 5
#define V8_MINOR_VERSION 5
#define V8_BUILD_NUMBER 372
#define V8_PATCH_LEVEL 44
#define V8_PATCH_LEVEL 45
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)

3
deps/v8/src/crankshaft/hydrogen.cc

@ -2541,6 +2541,9 @@ HValue* HGraphBuilder::BuildUncheckedStringAdd(
IfBuilder if_createcons(this);
if_createcons.If<HCompareNumericAndBranch>(
length, Add<HConstant>(ConsString::kMinLength), Token::GTE);
if_createcons.And();
if_createcons.If<HCompareNumericAndBranch>(
length, Add<HConstant>(ConsString::kMaxLength), Token::LTE);
if_createcons.Then();
{
// Create a cons string.

24
deps/v8/test/mjsunit/regress/regress-678917.js

@ -0,0 +1,24 @@
// Copyright 2017 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.
s1 = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
s1 += s1;
s1 += s1;
s1 += s1;
s1 += s1;
s0 = 'a';
function g() {
for (var j = 0; j < 1000000; j++) {
s0 += s1;
}
}
try {
g();
} catch (e) {
}
assertEquals('x', s0[10]);
Loading…
Cancel
Save