forked from crosswalk-project/v8-crosswalk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[regexp] Properly handle HeapNumbers in AdvanceStringIndex
This fixes behavior for HeapNumber {index} arguments passed to AdvanceStringIndex. Previously, we'd blindly treat {index} as a Smi. Passing a HeapNumber instead would result in a Smi addition on the tagged HeapNumber pointer. Backmerge of commit ed5496f. BUG=chromium:709015 NOPRESUBMIT=true NOTRY=true Review-Url: https://codereview.chromium.org/2808033002 Cr-Commit-Position: refs/branch-heads/5.8@{crosswalk-project#55} Cr-Branched-From: eda659c-refs/heads/5.8.283@{crosswalk-project#1} Cr-Branched-From: 4310cd0-refs/heads/master@{#43429}
- Loading branch information
Showing
3 changed files
with
55 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// 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. | ||
|
||
// Flags: --allow-natives-syntax | ||
|
||
function testAdvanceStringIndex(lastIndex, expectedLastIndex) { | ||
let exec_count = 0; | ||
let last_last_index = -1; | ||
|
||
let fake_re = { | ||
exec: () => { return (exec_count++ == 0) ? [""] : null }, | ||
get lastIndex() { return lastIndex; }, | ||
set lastIndex(value) { last_last_index = value }, | ||
get global() { return true; }, | ||
get flags() { return "g"; } | ||
}; | ||
|
||
assertEquals([""], RegExp.prototype[Symbol.match].call(fake_re, "abc")); | ||
assertEquals(expectedLastIndex, last_last_index); | ||
} | ||
|
||
testAdvanceStringIndex(new Number(42), 43); // Value wrapper. | ||
testAdvanceStringIndex(%AllocateHeapNumber(), 1); // HeapNumber. | ||
testAdvanceStringIndex(4294967295, 4294967296); // HeapNumber. |