From f21ea065b3affe572cfeee9e2d03b0548b0d02dd Mon Sep 17 00:00:00 2001 From: verwaest Date: Mon, 4 May 2015 08:02:24 -0700 Subject: [PATCH] Fix smi scanning BUG=chromium:483176 LOG=n Review URL: https://codereview.chromium.org/1114073003 Cr-Commit-Position: refs/heads/master@{#28202} --- src/scanner.cc | 2 +- src/scanner.h | 6 ++---- test/mjsunit/regress/regress-smi-scanning.js | 7 +++++++ 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 test/mjsunit/regress/regress-smi-scanning.js diff --git a/src/scanner.cc b/src/scanner.cc index 1dae1e4..aa5ae4a 100644 --- a/src/scanner.cc +++ b/src/scanner.cc @@ -1006,7 +1006,7 @@ Token::Value Scanner::ScanNumber(bool seen_period) { if (next_.literal_chars->one_byte_literal().length() <= 10 && value <= Smi::kMaxValue && c0_ != '.' && c0_ != 'e' && c0_ != 'E') { - smi_value_ = static_cast(value); + next_.smi_value_ = static_cast(value); literal.Complete(); HandleLeadSurrogate(); diff --git a/src/scanner.h b/src/scanner.h index 5162fbe..ef5f01b 100644 --- a/src/scanner.h +++ b/src/scanner.h @@ -436,7 +436,7 @@ class Scanner { void clear_octal_position() { octal_pos_ = Location::invalid(); } // Returns the value of the last smi that was scanned. - int smi_value() const { return smi_value_; } + int smi_value() const { return current_.smi_value_; } // Seek forward to the given position. This operation does not // work in general, for instance when there are pushed back @@ -491,6 +491,7 @@ class Scanner { Location location; LiteralBuffer* literal_chars; LiteralBuffer* raw_literal_chars; + int smi_value_; }; static const int kCharacterLookaheadBufferSize = 1; @@ -718,9 +719,6 @@ class Scanner { // Start position of the octal literal last scanned. Location octal_pos_; - // Value of the last smi that was scanned. - int smi_value_; - // One Unicode character look-ahead; c0_ < 0 at the end of the input. uc32 c0_; diff --git a/test/mjsunit/regress/regress-smi-scanning.js b/test/mjsunit/regress/regress-smi-scanning.js new file mode 100644 index 0000000..56cf9f9 --- /dev/null +++ b/test/mjsunit/regress/regress-smi-scanning.js @@ -0,0 +1,7 @@ +// Copyright 2015 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. + +x = 2 +3; +assertEquals(2, x); -- 2.7.4