Commit 4e2376b1 authored by Erik Luo's avatar Erik Luo Committed by Commit Bot

[debug] whitelist Function, BigInt methods as side-effect-free

This whitelists Function-related builtins used by Blink callbacks at
the DOM wrapping stage, and other BigInt methods.

Bug: chromium:810176
Change-Id: If036114cd7f133f2c30247dff836698c2eb16a51
Reviewed-on: https://chromium-review.googlesource.com/1004000Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Erik Luo <luoe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52530}
parent 20a427f6
......@@ -55,6 +55,7 @@ class JavaScriptFrame;
V(BoundFunctionName) \
V(FunctionName) \
V(FunctionLength) \
V(FunctionPrototype) \
V(StringLength)
#define ACCESSOR_SETTER_LIST(V) \
......
......@@ -762,6 +762,12 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) {
case Builtins::kNumberPrototypeToPrecision:
case Builtins::kNumberPrototypeToString:
case Builtins::kNumberPrototypeValueOf:
// BigInt builtins.
case Builtins::kBigIntConstructor:
case Builtins::kBigIntAsIntN:
case Builtins::kBigIntAsUintN:
case Builtins::kBigIntPrototypeToString:
case Builtins::kBigIntPrototypeValueOf:
// Set builtins.
case Builtins::kSetConstructor:
case Builtins::kSetPrototypeEntries:
......@@ -833,6 +839,12 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) {
case Builtins::kGlobalUnescape:
case Builtins::kGlobalIsFinite:
case Builtins::kGlobalIsNaN:
// Function builtins.
case Builtins::kFunctionPrototypeToString:
case Builtins::kFunctionPrototypeBind:
case Builtins::kFastFunctionPrototypeBind:
case Builtins::kFunctionPrototypeCall:
case Builtins::kFunctionPrototypeApply:
// Error builtins.
case Builtins::kErrorConstructor:
case Builtins::kMakeError:
......
......@@ -11,6 +11,7 @@ var set = new Set([1, 2]);
var weak_key = [];
var weak_map = new WeakMap().set(weak_key, "a").set({}, "b");
var weak_set = new WeakSet([weak_key, {}]);
var add = function (a, b) { return a + b; };
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
......@@ -24,6 +25,13 @@ function listener(event, exec_state, event_data, data) {
EvalError);
}
// Test Function-related functions.
success("func", `(function func(){}).prototype.constructor.name`);
success("[object Object]", `(function func(){}).prototype.toString()`);
success(12, `add.bind(null, 10)(2)`);
success(3, `add.call(null, 1, 2)`);
success(3, `add.apply(null, [1, 2])`);
// Test Date.prototype functions.
success(undefined, `Date()`);
success(undefined, `new Date()`);
......@@ -108,6 +116,12 @@ function listener(event, exec_state, event_data, data) {
fail(`weak_set.add([])`);
fail(`weak_set.delete("a")`);
// Test BigInt functions.
success(10n, `BigInt('10')`);
success(10n, `BigInt.asIntN(10, 10n)`);
success(10n, `BigInt.asUintN(10, 10n)`);
success("10", `10n.toString()`);
success(10n, `10n.valueOf()`);
} catch (e) {
exception = e;
print(e, e.stack);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment