[tests] Make %NeverOptimizeFunction ClusterFuzz safe
It expected its argument to be a JSFunction, but fuzzer tests can pass anything. Non-JSFunction arguments should just silently be ignored, just like similar CF-whitelisted runtime functions do. Bug: chromium:754177 Change-Id: I41b29528bbe72f24b3d84f021b22602160769d26 Reviewed-on: https://chromium-review.googlesource.com/610706 Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#47316}
This commit is contained in:
parent
00f21d3d48
commit
89e5792d60
@ -314,7 +314,13 @@ RUNTIME_FUNCTION(Runtime_OptimizeOsr) {
|
||||
RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK_EQ(1, args.length());
|
||||
CONVERT_ARG_CHECKED(JSFunction, function, 0);
|
||||
// This function is used by fuzzers to get coverage for optimizations
|
||||
// in compiler. Ignore calls on non-function objects to avoid runtime errors.
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0);
|
||||
if (!function_object->IsJSFunction()) {
|
||||
return isolate->heap()->undefined_value();
|
||||
}
|
||||
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
|
||||
function->shared()->DisableOptimization(kOptimizationDisabledForTest);
|
||||
return isolate->heap()->undefined_value();
|
||||
}
|
||||
|
12
test/mjsunit/regress/regress-crbug-754177.js
Normal file
12
test/mjsunit/regress/regress-crbug-754177.js
Normal file
@ -0,0 +1,12 @@
|
||||
// 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
|
||||
|
||||
// Do not crash on non-JSFunction input.
|
||||
%NeverOptimizeFunction(undefined);
|
||||
%NeverOptimizeFunction(true);
|
||||
%NeverOptimizeFunction(1);
|
||||
%NeverOptimizeFunction({});
|
||||
assertThrows("%NeverOptimizeFunction()", SyntaxError);
|
Loading…
Reference in New Issue
Block a user