Revert of [tests] Make assertOptimized()/assertUnoptimized() great again. (patchset #6 id:130042 of https://codereview.chromium.org/2654733004/ )

Reason for revert:
Mac gc stress failures:
https://build.chromium.org/p/client.v8/builders/V8%20Mac%20GC%20Stress/builds/11195

There's also this flake, but maybe unrelated:
https://build.chromium.org/p/client.v8/builders/V8%20Win64/builds/15422

Original issue's description:
> [tests] Make assertOptimized()/assertUnoptimized() great again.
>
> The mentioned asserts did not work properly with interpreted and turbofanned functions.
>
> To fix this issue %GetOptimizationStatus() now returns a set of flags instead of a single value.
>
> This CL also adds more helper functions to mjsunit, like isNeverOptimize(), isAlwaysOptimize(),
> isOptimized(fun), etc.
>
> BUG=v8:5890
>
> Review-Url: https://codereview.chromium.org/2654733004
> Cr-Commit-Position: refs/heads/master@{#42703}
> Committed: d1ddec7857

TBR=mstarzinger@chromium.org,ishell@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:5890

Review-Url: https://codereview.chromium.org/2655223003
Cr-Commit-Position: refs/heads/master@{#42704}
This commit is contained in:
machenbach 2017-01-26 07:04:47 -08:00 committed by Commit bot
parent d1ddec7857
commit d2d99e084a
42 changed files with 210 additions and 336 deletions

View File

@ -314,19 +314,18 @@ void EnsureFeedbackMetadata(CompilationInfo* info) {
}
bool UseTurboFan(Handle<SharedFunctionInfo> shared) {
if (shared->optimization_disabled()) {
return false;
}
bool optimization_disabled = shared->optimization_disabled();
bool must_use_ignition_turbo = shared->must_use_ignition_turbo();
// Check the enabling conditions for Turbofan.
// 1. "use asm" code.
bool is_turbofanable_asm = FLAG_turbo_asm && shared->asm_function();
bool is_turbofanable_asm =
FLAG_turbo_asm && shared->asm_function() && !optimization_disabled;
// 2. Fallback for features unsupported by Crankshaft.
bool is_unsupported_by_crankshaft_but_turbofanable =
must_use_ignition_turbo && strcmp(FLAG_turbo_filter, "~~") == 0;
must_use_ignition_turbo && strcmp(FLAG_turbo_filter, "~~") == 0 &&
!optimization_disabled;
// 3. Explicitly enabled by the command-line filter.
bool passes_turbo_filter = shared->PassesFilter(FLAG_turbo_filter);

View File

@ -2429,8 +2429,7 @@ bool Shell::SetOptions(int argc, char* argv[]) {
if (strcmp(argv[i], "--stress-opt") == 0) {
options.stress_opt = true;
argv[i] = NULL;
} else if (strcmp(argv[i], "--nostress-opt") == 0 ||
strcmp(argv[i], "--no-stress-opt") == 0) {
} else if (strcmp(argv[i], "--nostress-opt") == 0) {
options.stress_opt = false;
argv[i] = NULL;
} else if (strcmp(argv[i], "--stress-deopt") == 0) {
@ -2439,8 +2438,7 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strcmp(argv[i], "--mock-arraybuffer-allocator") == 0) {
options.mock_arraybuffer_allocator = true;
argv[i] = NULL;
} else if (strcmp(argv[i], "--noalways-opt") == 0 ||
strcmp(argv[i], "--no-always-opt") == 0) {
} else if (strcmp(argv[i], "--noalways-opt") == 0) {
// No support for stressing if we can't use --always-opt.
options.stress_opt = false;
options.stress_deopt = false;

View File

@ -236,28 +236,21 @@ RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) {
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) {
HandleScope scope(isolate);
DCHECK(args.length() == 1 || args.length() == 2);
int status = 0;
if (!isolate->use_crankshaft()) {
status |= static_cast<int>(OptimizationStatus::kNeverOptimize);
}
if (FLAG_always_opt || FLAG_prepare_always_opt) {
status |= static_cast<int>(OptimizationStatus::kAlwaysOptimize);
}
if (FLAG_deopt_every_n_times) {
status |= static_cast<int>(OptimizationStatus::kMaybeDeopted);
return Smi::FromInt(4); // 4 == "never".
}
// 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 Smi::FromInt(status);
return isolate->heap()->undefined_value();
}
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
status |= static_cast<int>(OptimizationStatus::kIsFunction);
bool sync_with_compiler_thread = true;
if (args.length() == 2) {
@ -276,16 +269,22 @@ RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) {
base::OS::Sleep(base::TimeDelta::FromMilliseconds(50));
}
}
if (function->IsOptimized()) {
status |= static_cast<int>(OptimizationStatus::kOptimized);
if (function->code()->is_turbofanned()) {
status |= static_cast<int>(OptimizationStatus::kTurboFanned);
}
if (FLAG_always_opt || FLAG_prepare_always_opt) {
// With --always-opt, optimization status expectations might not
// match up, so just return a sentinel.
return Smi::FromInt(3); // 3 == "always".
}
if (FLAG_deopt_every_n_times) {
return Smi::FromInt(6); // 6 == "maybe deopted".
}
if (function->IsOptimized() && function->code()->is_turbofanned()) {
return Smi::FromInt(7); // 7 == "TurboFan compiler".
}
if (function->IsInterpreted()) {
status |= static_cast<int>(OptimizationStatus::kInterpreted);
return Smi::FromInt(8); // 8 == "Interpreted".
}
return Smi::FromInt(status);
return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes".
: Smi::FromInt(2); // 2 == "no".
}

View File

@ -1153,18 +1153,6 @@ class DeclareGlobalsNativeFlag : public BitField<bool, 1, 1> {};
STATIC_ASSERT(LANGUAGE_END == 2);
class DeclareGlobalsLanguageMode : public BitField<LanguageMode, 2, 1> {};
// A set of bits returned by Runtime_GetOptimizationStatus.
// These bits must be in sync with bits defined in test/mjsunit/mjsunit.js
enum class OptimizationStatus {
kIsFunction = 1 << 0,
kNeverOptimize = 1 << 1,
kAlwaysOptimize = 1 << 2,
kMaybeDeopted = 1 << 3,
kOptimized = 1 << 4,
kTurboFanned = 1 << 5,
kInterpreted = 1 << 6,
};
} // namespace internal
} // namespace v8

View File

@ -13,7 +13,6 @@
#include "src/compilation-cache.h"
#include "src/execution.h"
#include "src/objects.h"
#include "src/runtime/runtime.h"
#include "src/unicode-inl.h"
#include "src/utils.h"
@ -4094,7 +4093,6 @@ THREADED_TEST(NamedPropertyHandlerGetterAttributes) {
THREADED_TEST(Regress256330) {
if (!i::FLAG_crankshaft) return;
i::FLAG_allow_natives_syntax = true;
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
@ -4110,10 +4108,7 @@ THREADED_TEST(Regress256330) {
"f(o); f(o); f(o);"
"%OptimizeFunctionOnNextCall(f);"
"f(o);");
int status = v8_run_int32value(v8_compile("%GetOptimizationStatus(f)"));
int mask = static_cast<int>(i::OptimizationStatus::kIsFunction) |
static_cast<int>(i::OptimizationStatus::kOptimized);
CHECK_EQ(mask, status & mask);
ExpectBoolean("%GetOptimizationStatus(f) != 2", true);
}

View File

@ -26,15 +26,12 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --concurrent-recompilation --block-concurrent-recompilation
// Flags: --no-always-opt
if (!%IsConcurrentRecompilationSupported()) {
print("Concurrent recompilation is disabled. Skipping this test.");
quit();
}
assertFalse(isAlwaysOptimize());
Debug = debug.Debug
function foo() {

View File

@ -66,8 +66,15 @@
##############################################################################
['variant == turbofan_opt', {
# TODO(mstarzinger): Debugger cannot materialize de-materialized functions.
'debug/regress/regress-crbug-323936': [FAIL],
# TODO(jarin/mstarzinger): Investigate debugger issues with TurboFan.
'debug/debug-evaluate-closure': [FAIL],
'debug/debug-evaluate-locals': [FAIL],
'debug/debug-liveedit-double-call': [FAIL],
'debug/debug-set-variable-value': [FAIL],
'debug/es6/debug-evaluate-blockscopes': [FAIL],
}], # variant == turbofan_opt
##############################################################################

View File

@ -25,9 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --expose-gc --no-always-opt
assertFalse(isAlwaysOptimize());
// Flags: --allow-natives-syntax --expose-gc
var a = new Int32Array(1024);

View File

@ -26,10 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --expose-gc
// Flags: --no-always-opt --crankshaft
assertFalse(isNeverOptimize());
assertFalse(isAlwaysOptimize());
// Flags: --noalways-opt
// Test element kind of objects.
@ -75,7 +72,7 @@ function assertKind(expected, obj, name_opt) {
a[0] = 3.5;
b = bar0(Array);
assertKind(elements_kind.fast_double, b);
%OptimizeFunctionOnNextCall(bar0);
%OptimizeFunctionOnNextCall(bar0);
b = bar0(Array);
assertKind(elements_kind.fast_double, b);
assertOptimized(bar0);
@ -84,16 +81,18 @@ function assertKind(expected, obj, name_opt) {
assertUnoptimized(bar0)
// When it's re-optimized, we should call through the full stub
bar0(Array);
%OptimizeFunctionOnNextCall(bar0);
%OptimizeFunctionOnNextCall(bar0);
b = bar0(Array);
// This only makes sense to test if we allow crankshafting
// We also lost our ability to record kind feedback, as the site
// is megamorphic now.
assertKind(elements_kind.fast_smi_only, b);
assertOptimized(bar0);
b[0] = 3.5;
c = bar0(Array);
assertKind(elements_kind.fast_smi_only, c);
if (4 != %GetOptimizationStatus(bar0)) {
// We also lost our ability to record kind feedback, as the site
// is megamorphic now.
assertKind(elements_kind.fast_smi_only, b);
assertOptimized(bar0);
b[0] = 3.5;
c = bar0(Array);
assertKind(elements_kind.fast_smi_only, c);
}
})();
@ -142,15 +141,17 @@ function assertKind(expected, obj, name_opt) {
}
a = bar();
bar();
%OptimizeFunctionOnNextCall(bar);
%OptimizeFunctionOnNextCall(bar);
b = bar();
// This only makes sense to test if we allow crankshafting
assertOptimized(bar);
%DebugPrint(3);
b[0] = 3.5;
c = bar();
assertKind(elements_kind.fast_smi_only, c);
assertOptimized(bar);
if (4 != %GetOptimizationStatus(bar)) {
assertOptimized(bar);
%DebugPrint(3);
b[0] = 3.5;
c = bar();
assertKind(elements_kind.fast_smi_only, c);
assertOptimized(bar);
}
})();
@ -179,7 +180,7 @@ function assertKind(expected, obj, name_opt) {
function bar(len) { return new Array(len); }
bar(0);
bar(0);
%OptimizeFunctionOnNextCall(bar);
%OptimizeFunctionOnNextCall(bar);
a = bar(0);
assertOptimized(bar);
assertFalse(isHoley(a));
@ -191,8 +192,10 @@ function assertKind(expected, obj, name_opt) {
a = bar(0);
assertOptimized(bar);
// Crankshafted functions don't use mementos, so feedback still
// indicates a packed array is desired.
assertFalse(isHoley(a));
// indicates a packed array is desired. (unless --nocrankshaft is in use).
if (4 != %GetOptimizationStatus(bar)) {
assertFalse(isHoley(a));
}
})();
// Test: Make sure that crankshaft continues with feedback for large arrays.

View File

@ -25,11 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --expose-gc --ignition-osr --no-always-opt
// Flags: --crankshaft
assertFalse(isNeverOptimize());
assertFalse(isAlwaysOptimize());
// Flags: --allow-natives-syntax --expose-gc --ignition-osr
// IC and Crankshaft support for smi-only elements in dynamic array literals.
function get(foo) { return foo; } // Used to generate dynamic values.
@ -192,7 +188,9 @@ assertEquals(foo, array[2]);
(function literals_after_osr() {
var color = [0];
// Trigger OSR.
while (%GetOptimizationCount(literals_after_osr) == 0) {}
// Trigger OSR, if optimization is not disabled.
if (%GetOptimizationStatus(literals_after_osr) != 4) {
while (%GetOptimizationCount(literals_after_osr) == 0) {}
}
return [color[0]];
})();

View File

@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --no-always-opt
assertFalse(isAlwaysOptimize());
// Flags: --allow-natives-syntax
var v = 0;

View File

@ -25,15 +25,13 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --no-always-opt
// Flags: --allow-natives-syntax
// Verifies that the KeyedStoreIC correctly handles out-of-bounds stores
// to an array that grow it by a single element. Test functions are
// called twice to make sure that the IC is used, first call is handled
// by the runtime in the miss stub.
assertFalse(isAlwaysOptimize());
function array_store_1(a,b,c) {
return (a[b] = c);
}

View File

@ -43,6 +43,18 @@ function OptTracker() {
this.opt_counts_ = {};
}
/**
* The possible optimization states of a function. Must be in sync with the
* return values of Runtime_GetOptimizationStatus() in runtime.cc!
* @enum {int}
*/
OptTracker.OptimizationState = {
YES: 1,
NO: 2,
ALWAYS: 3,
NEVER: 4
};
/**
* Always call this at the beginning of your test, once for each function
* that you later want to track de/optimizations for. It is necessary because
@ -82,10 +94,12 @@ OptTracker.prototype.AssertIsOptimized = function(func, expect_optimized) {
if (this.DisableAsserts_(func)) {
return;
}
var opt_status = %GetOptimizationStatus(func);
assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0);
assertEquals(expect_optimized,
(opt_status & V8OptimizationStatus.kOptimized) !== 0);
var raw_optimized = %GetOptimizationStatus(func);
if (expect_optimized) {
assertEquals(OptTracker.OptimizationState.YES, raw_optimized);
} else {
assertEquals(OptTracker.OptimizationState.NO, raw_optimized);
}
}
/**
@ -105,8 +119,7 @@ OptTracker.prototype.GetOptCount_ = function(func) {
*/
OptTracker.prototype.GetDeoptCount_ = function(func) {
var count = this.GetOptCount_(func);
var opt_status = %GetOptimizationStatus(func);
if ((opt_status & V8OptimizationStatus.kOptimized) !== 0) {
if (%GetOptimizationStatus(func) == OptTracker.OptimizationState.YES) {
count -= 1;
}
return count;
@ -116,9 +129,15 @@ OptTracker.prototype.GetDeoptCount_ = function(func) {
* @private
*/
OptTracker.prototype.DisableAsserts_ = function(func) {
var opt_status = %GetOptimizationStatus(func);
return (opt_status & V8OptimizationStatus.kAlwaysOptimize) !== 0 ||
(opt_status & V8OptimizationStatus.kNeverOptimize) !== 0;
switch(%GetOptimizationStatus(func)) {
case OptTracker.OptimizationState.YES:
case OptTracker.OptimizationState.NO:
return false;
case OptTracker.OptimizationState.ALWAYS:
case OptTracker.OptimizationState.NEVER:
return true;
}
return true;
}
// (End of class OptTracker.)

View File

@ -27,15 +27,12 @@
// Flags: --track-fields --track-double-fields --allow-natives-syntax
// Flags: --concurrent-recompilation --block-concurrent-recompilation
// Flags: --no-always-opt
if (!%IsConcurrentRecompilationSupported()) {
print("Concurrent recompilation is disabled. Skipping this test.");
quit();
}
assertFalse(isAlwaysOptimize());
function new_object() {
var o = {};
o.a = 1;

View File

@ -27,15 +27,12 @@
// Flags: --allow-natives-syntax
// Flags: --concurrent-recompilation --block-concurrent-recompilation
// Flags: --no-always-opt
if (!%IsConcurrentRecompilationSupported()) {
print("Concurrent recompilation is disabled. Skipping this test.");
quit();
}
assertFalse(isAlwaysOptimize());
function f(foo) { return foo.bar(); }
var o = {};

View File

@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --no-always-opt
assertFalse(isAlwaysOptimize());
// Flags: --allow-natives-syntax
var s = "12345";

View File

@ -27,15 +27,12 @@
// Flags: --allow-natives-syntax --expose-gc
// Flags: --concurrent-recompilation --block-concurrent-recompilation
// Flags: --no-always-opt
if (!%IsConcurrentRecompilationSupported()) {
print("Concurrent recompilation is disabled. Skipping this test.");
quit();
}
assertFalse(isAlwaysOptimize());
function f(x) {
var xx = x * x;
var xxstr = xx.toString();

View File

@ -27,7 +27,7 @@
// Flags: --allow-natives-syntax
// Flags: --concurrent-recompilation --block-concurrent-recompilation
// Flags: --nostress-opt --no-always-opt
// Flags: --nostress-opt
// --nostress-opt is in place because this particular optimization
// (guaranteeing that the Array prototype chain has no elements) is
@ -41,8 +41,6 @@ if (!%IsConcurrentRecompilationSupported()) {
quit();
}
assertFalse(isAlwaysOptimize());
function f1(a, i) {
return a[i] + 0.5;
}

View File

@ -81,10 +81,10 @@ test(10.0, 20.0, 30.0, 40.0, 50.0, 1.5);
test(10.0, 20.0, 30.0, 40.0, 50.0, 1.5);
%OptimizeFunctionOnNextCall(test);
test(10.0, 20.0, 30.0, 40.0, 50.0, 1.5);
assertOptimized(test);
assertTrue(2 != %GetOptimizationStatus(test));
// By deleting the field we are forcing the code to deopt when the field is
// read on next execution.
delete deopt_trigger;
test(10.0, 20.0, 30.0, 40.0, 50.0, 1.5);
assertUnoptimized(test);
assertTrue(1 != %GetOptimizationStatus(test));

View File

@ -2,18 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --noverify-heap --noenable-slow-asserts
// Flags: --no-always-opt --crankshaft
// Flags: --allow-natives-syntax --noverify-heap --noenable-slow-asserts
// --noverify-heap and --noenable-slow-asserts are set because the test is too
// slow with it on.
// --noverify-heap and --noenable-slow-asserts are set because the test is too
// slow with it on.
assertFalse(isNeverOptimize());
assertFalse(isAlwaysOptimize());
// Ensure that keyed stores work, and optimized functions learn if the
// store required change to dictionary mode. Verify that stores that grow
// the array into large object space don't cause a deopt.
// Ensure that keyed stores work, and optimized functions learn if the
// store required change to dictionary mode. Verify that stores that grow
// the array into large object space don't cause a deopt.
(function() {
var a = [];
@ -64,24 +60,27 @@ assertFalse(isAlwaysOptimize());
%OptimizeFunctionOnNextCall(foo2);
foo2(a, 40);
assertOptimized(foo2);
assertTrue(%HasFastSmiElements(a));
// This test is way too slow without crankshaft.
if (4 != %GetOptimizationStatus(foo2)) {
assertOptimized(foo2);
assertTrue(%HasFastSmiElements(a));
// Grow a large array into large object space through the keyed store
// without deoptimizing. Grow by 10s. If we set elements too sparsely, the
// array will convert to dictionary mode.
a = new Array(99999);
assertTrue(%HasFastSmiElements(a));
for (var i = 0; i < 263000; i += 10) {
foo2(a, i);
// Grow a large array into large object space through the keyed store
// without deoptimizing. Grow by 10s. If we set elements too sparsely, the
// array will convert to dictionary mode.
a = new Array(99999);
assertTrue(%HasFastSmiElements(a));
for (var i = 0; i < 263000; i += 10) {
foo2(a, i);
}
// Verify that we are over 1 page in size, and foo2 remains optimized.
// This means we've smoothly transitioned to allocating in large object
// space.
assertTrue(%HasFastSmiElements(a));
assertTrue(a.length * 4 > (1024 * 1024));
assertOptimized(foo2);
}
// Verify that we are over 1 page in size, and foo2 remains optimized.
// This means we've smoothly transitioned to allocating in large object
// space.
assertTrue(%HasFastSmiElements(a));
assertTrue(a.length * 4 > (1024 * 1024));
assertOptimized(foo2);
%ClearFunctionTypeFeedback(foo2);
})();

View File

@ -6,6 +6,21 @@
"use strict";
const kDeoptimized = 2;
const kTurbofanned = 7;
const kInterpreted = 8;
function GetOptimizationStatus(fn) {
let status = %GetOptimizationStatus(fn);
switch (status) {
case kInterpreted: // Treat interpreted frames as unoptimized
status = kDeoptimized;
break;
}
return status;
}
let global = this;
let tests = {
FastElementsKind() {
@ -103,27 +118,15 @@ let tests = {
// TODO(bmeurer): FAST_HOLEY_DOUBLE_ELEMENTS maps generally deopt when
// a hole is encountered. Test should be fixed once that is corrected.
let expect_deopt = /HOLEY_DOUBLE/.test(key);
let status = /HOLEY_DOUBLE/.test(key) ? kDeoptimized : kTurbofanned;
if (expect_deopt) {
assertUnoptimized(fn, '', key);
} else {
assertOptimized(fn, '', key);
}
assertEquals(status, GetOptimizationStatus(fn), key);
assertEquals(expected, fn(array), key);
if (expect_deopt) {
assertUnoptimized(fn, '', key);
} else {
assertOptimized(fn, '', key);
}
assertEquals(status, GetOptimizationStatus(fn), key);
// Check no deopt when another array with the same map is used
// Check no deopt when another arra with the same map is used
assertTrue(%HaveSameMap(array, array2), key);
if (expect_deopt) {
assertUnoptimized(fn, '', key);
} else {
assertOptimized(fn, '', key);
}
assertEquals(status, GetOptimizationStatus(fn), key);
assertEquals(expected2, fn(array2), key);
// CheckMaps bailout
@ -131,7 +134,7 @@ let tests = {
[1, 2, 3], 2, { enumerable: false, configurable: false,
get() { return 7; } });
fn(newArray);
assertUnoptimized(fn, '', key);
assertEquals(kDeoptimized, GetOptimizationStatus(fn), key);
}
},
@ -219,12 +222,12 @@ let tests = {
%OptimizeFunctionOnNextCall(sum);
assertEquals(expected, sum(array), key);
assertOptimized(sum, '', key);
assertEquals(kTurbofanned, GetOptimizationStatus(sum), key);
// Not deoptimized when called on typed array of same type / map
assertTrue(%HaveSameMap(array, array2));
assertEquals(expected2, sum(array2), key);
assertOptimized(sum, '', key);
assertEquals(kTurbofanned, GetOptimizationStatus(sum), key);
// Throw when detached
let clone = new array.constructor(array);

View File

@ -478,5 +478,5 @@ for (var i=0; i<10; i++) {
f(12);
g(12);
assertOptimized(f);
assertOptimized(g);
assertTrue(%GetOptimizationStatus(f) != 2);
assertTrue(%GetOptimizationStatus(g) != 2);

View File

@ -480,5 +480,5 @@ for (var i=0; i<10; i++) {
f(12);
g(12);
assertOptimized(f);
assertOptimized(g);
assertTrue(%GetOptimizationStatus(f) != 2);
assertTrue(%GetOptimizationStatus(g) != 2);

View File

@ -40,7 +40,7 @@ function f1() {
for (var j = 0; j < 5; ++j) f1();
%OptimizeFunctionOnNextCall(f1);
f1();
assertOptimized(f1);
assertTrue(%GetOptimizationStatus(f1) != 2);
// Dynamic lookup in and through block contexts.
function f2(one) {

View File

@ -42,7 +42,7 @@ function f1() {
for (var j = 0; j < 5; ++j) f1();
%OptimizeFunctionOnNextCall(f1);
f1();
assertOptimized(f1);
assertTrue(%GetOptimizationStatus(f1) != 2);
// Dynamic lookup in and through block contexts.
function f2(one) {

View File

@ -3,9 +3,6 @@
// found in the LICENSE file.
// Flags: --allow-natives-syntax --nostress-opt --track-field-types
// Flags: --no-always-opt
assertFalse(isAlwaysOptimize());
(function() {
var o = { text: "Hello World!" };

View File

@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-do-expressions --allow-natives-syntax --no-always-opt
assertFalse(isAlwaysOptimize());
// Flags: --harmony-do-expressions --allow-natives-syntax
function returnValue(v) { return v; }
function MyError() {}

View File

@ -3,15 +3,13 @@
// found in the LICENSE file.
// Flags: --allow-natives-syntax
// Flags: --nostress-opt --no-always-opt
// Flags: --nostress-opt
// --nostress-opt is specified because the test corrupts the "pristine"
// array prototype chain by storing an element, and this is tracked
// per-isolate. A subsequent stress run would send the load generic,
// and no more deoptimizations of foo would occur.
assertFalse(isAlwaysOptimize());
function foo(a, i) { return a[i]; }
var a = ['one', , 'three'];

View File

@ -25,10 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --no-always-opt
assertFalse(isAlwaysOptimize());
// Flags: --allow-natives-syntax
var s = Symbol("foo");
var o = {

View File

@ -120,38 +120,6 @@ var assertContains;
// Assert that a string matches a given regex.
var assertMatches;
// These bits must be in sync with bits defined in Runtime_GetOptimizationStatus
var V8OptimizationStatus = {
kIsFunction: 1 << 0,
kNeverOptimize: 1 << 1,
kAlwaysOptimize: 1 << 2,
kMaybeDeopted: 1 << 3,
kOptimized: 1 << 4,
kTurboFanned: 1 << 5,
kInterpreted: 1 << 6
};
// Returns true if --no-crankshaft mode is on.
var isNeverOptimize;
// Returns true if --always-opt mode is on.
var isAlwaysOptimize;
// Returns true if given function in interpreted.
var isInterpreted;
// Returns true if given function is compiled by a base-line compiler.
var isBaselined;
// Returns true if given function is optimized.
var isOptimized;
// Returns true if given function is compiled by Crankshaft.
var isCrankshafted;
// Returns true if given function is compiled by TurboFan.
var isTurboFanned;
(function () { // Scope for utility functions.
@ -494,72 +462,12 @@ var isTurboFanned;
assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) {
if (sync_opt === undefined) sync_opt = "";
var opt_status = OptimizationStatus(fun, sync_opt);
assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, name_opt);
assertFalse((opt_status & V8OptimizationStatus.kOptimized) !== 0, name_opt);
assertTrue(OptimizationStatus(fun, sync_opt) !== 1, name_opt);
}
assertOptimized = function assertOptimized(fun, sync_opt, name_opt) {
if (sync_opt === undefined) sync_opt = "";
var opt_status = OptimizationStatus(fun, sync_opt);
assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, name_opt);
if ((opt_status & V8OptimizationStatus.kNeverOptimize) !== 0) {
// TODO(ishell): every test that calls %OptimizeFunctionOnNextCall()
// does not make sense when --no-crankshaft option is provided.
return;
}
assertTrue((opt_status & V8OptimizationStatus.kOptimized) !== 0, name_opt);
}
isNeverOptimize = function isNeverOptimize() {
var opt_status = OptimizationStatus(undefined, "");
return (opt_status & V8OptimizationStatus.kNeverOptimize) !== 0;
}
isAlwaysOptimize = function isAlwaysOptimize() {
var opt_status = OptimizationStatus(undefined, "");
return (opt_status & V8OptimizationStatus.kAlwaysOptimize) !== 0;
}
isInterpreted = function isInterpreted(fun) {
var opt_status = OptimizationStatus(fun, "");
assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
"not a function");
return (opt_status & V8OptimizationStatus.kOptimized) === 0 &&
(opt_status & V8OptimizationStatus.kInterpreted) !== 0;
}
// NOTE: This predicate also returns true for functions that have never
// been compiled (i.e. that have LazyCompile stub as a code).
isBaselined = function isBaselined(fun) {
var opt_status = OptimizationStatus(fun, "");
assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
"not a function");
return (opt_status & V8OptimizationStatus.kOptimized) === 0 &&
(opt_status & V8OptimizationStatus.kInterpreted) === 0;
}
isOptimized = function isOptimized(fun) {
var opt_status = OptimizationStatus(fun, "");
assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
"not a function");
return (opt_status & V8OptimizationStatus.kOptimized) !== 0;
}
isCrankshafted = function isCrankshafted(fun) {
var opt_status = OptimizationStatus(fun, "");
assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
"not a function");
return (opt_status & V8OptimizationStatus.kOptimized) !== 0 &&
(opt_status & V8OptimizationStatus.kTurboFanned) === 0;
}
isTurboFanned = function isTurboFanned(fun) {
var opt_status = OptimizationStatus(fun, "");
assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
"not a function");
return (opt_status & V8OptimizationStatus.kOptimized) !== 0 &&
(opt_status & V8OptimizationStatus.kTurboFanned) !== 0;
assertTrue(OptimizationStatus(fun, sync_opt) !== 2, name_opt);
}
})();

View File

@ -30,30 +30,34 @@
function o1() {
}
o1(); o1();
%OptimizeFunctionOnNextCall(o1);
o1();
if (%GetOptimizationStatus(o1) != 4) {
// 4 == optimization disabled.
o1(); o1();
%OptimizeFunctionOnNextCall(o1);
o1();
// Check that the given function was optimized.
assertOptimized(o1);
// Check that the given function was optimized.
assertOptimized(o1);
// Test the %NeverOptimizeFunction runtime call.
%NeverOptimizeFunction(u1);
function u1() {
// Test the %NeverOptimizeFunction runtime call.
%NeverOptimizeFunction(u1);
function u1() {
}
function u2() {
u1();
}
u1(); u1();
u2(); u2();
%OptimizeFunctionOnNextCall(u1);
%OptimizeFunctionOnNextCall(u2);
u1(); u1();
u2(); u2();
// 2 => not optimized.
assertUnoptimized(u1);
assertOptimized(u2);
}
function u2() {
u1();
}
u1(); u1();
u2(); u2();
%OptimizeFunctionOnNextCall(u1);
%OptimizeFunctionOnNextCall(u2);
u1(); u1();
u2(); u2();
assertUnoptimized(u1);
assertOptimized(u2);

View File

@ -25,9 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --use-osr --allow-natives-syntax --ignition-osr --crankshaft
assertFalse(isNeverOptimize());
// Flags: --use-osr --allow-natives-syntax --ignition-osr
function f() {
do {
@ -38,7 +36,7 @@ function f() {
}
f();
assertTrue(%GetOptimizationCount(f) > 0);
assertTrue(%GetOptimizationCount(f) > 0 || %GetOptimizationStatus(f) == 4);
function g() {
for (var i = 0; i < 1; i++) { }
@ -69,4 +67,4 @@ function g() {
}
g();
assertTrue(%GetOptimizationCount(g) > 0);
assertTrue(%GetOptimizationCount(g) > 0 || %GetOptimizationStatus(g) == 4);

View File

@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --no-always-opt
assertFalse(isAlwaysOptimize());
// Flags: --allow-natives-syntax
function getobj() {
return { bar : function() { return 0}};

View File

@ -25,9 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --no-always-opt
assertFalse(isAlwaysOptimize());
// Flags: --allow-natives-syntax
var calls = 0;

View File

@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --no-always-opt
assertFalse(isAlwaysOptimize());
// Flags: --allow-natives-syntax
function literals_sharing_test(warmup, optimize) {
function closure() {
@ -41,4 +39,10 @@ function test() {
literals_sharing_test(warmup, true);
}
test();
function stress_opt_test() {}
stress_opt_test();
if (%GetOptimizationStatus(stress_opt_test) == 2) {
// This test is not suitable for --always-opt mode.
test();
}

View File

@ -4,9 +4,7 @@
// New space must be at max capacity to trigger pretenuring decision.
// Flags: --allow-natives-syntax --verify-heap --max-semi-space-size=1
// Flags: --expose-gc --no-always-opt
assertFalse(isAlwaysOptimize());
// Flags: --expose-gc
var global = []; // Used to keep some objects alive.

View File

@ -79,8 +79,4 @@ assertOptimized(inferrable_store);
// seeing a property name key. It should have inferred a receiver map and
// emitted an elements store, however.
inferrable_store("deopt");
// TurboFan is not sophisticated enough to use key type provided by ICs.
if (!isTurboFanned(inferrable_store)) {
assertUnoptimized(inferrable_store);
}
assertUnoptimized(inferrable_store);

View File

@ -28,15 +28,12 @@
// Flags: --fold-constants --nodead-code-elimination
// Flags: --expose-gc --allow-natives-syntax
// Flags: --concurrent-recompilation --block-concurrent-recompilation
// Flags: --no-always-opt
if (!%IsConcurrentRecompilationSupported()) {
print("Concurrent recompilation is disabled. Skipping this test.");
quit();
}
assertFalse(isAlwaysOptimize());
function test(fun) {
fun();
%BaselineFunctionOnNextCall(fun);

View File

@ -9,7 +9,6 @@ function load(o) { return o.x; }
for (var x = 0; x < 1000; ++x) {
load({x});
load({x});
%OptimizeFunctionOnNextCall(load);
try { load(); } catch (e) { }
}
@ -21,7 +20,6 @@ function store(o) { o.x = -1; }
for (var x = 0; x < 1000; ++x) {
store({x});
store({x});
%OptimizeFunctionOnNextCall(store);
try { store(); } catch (e) { }
}

View File

@ -13,20 +13,20 @@
}
sum += f(i);
if (isAlwaysOptimize() || isNeverOptimize()) {
if (%GetOptimizationStatus(f) == 3 || %GetOptimizationStatus(f) == 4) {
// If we are always or never optimizing f, just exit, this test is useless.
return;
}
if (i == 1) {
// f must be baseline code.
assertTrue(isBaselined(f));
assertEquals(2, %GetOptimizationStatus(f));
// Run twice (i = 0, 1), then tier-up.
%OptimizeFunctionOnNextCall(f);
} else if (i == 2) {
// Tier-up at i = 2 should go up to crankshaft.
assertTrue(isCrankshafted(f));
assertEquals(1, %GetOptimizationStatus(f));
}
}
})()

View File

@ -13,30 +13,29 @@
}
sum += f(i);
if (isAlwaysOptimize() || isNeverOptimize()) {
if (%GetOptimizationStatus(f) == 3 || %GetOptimizationStatus(f) == 4) {
// If we are always or never optimizing f, just exit, this test is useless.
return;
}
if (i == 1) {
// f must be interpreted code.
assertTrue(isInterpreted(f));
assertEquals(8, %GetOptimizationStatus(f));
// Allow it to run twice (i = 0, 1), then tier-up to baseline.
%BaselineFunctionOnNextCall(f);
} else if (i == 2) {
// Tier-up at i = 2 should only go up to baseline.
assertTrue(isBaselined(f));
assertEquals(2, %GetOptimizationStatus(f));
} else if (i == 3) {
// Now f must be baseline code.
assertTrue(isBaselined(f));
assertEquals(2, %GetOptimizationStatus(f));
// Run two more times (i = 2, 3), then tier-up to optimized.
%OptimizeFunctionOnNextCall(f);
} else if (i == 4) {
// Tier-up at i = 4 should now go up to crankshaft.
assertTrue(isCrankshafted(f));
assertEquals(1, %GetOptimizationStatus(f));
}
}
})()

View File

@ -13,20 +13,20 @@
}
sum += f(i);
if (isAlwaysOptimize() || isNeverOptimize()) {
if (%GetOptimizationStatus(f) == 3 || %GetOptimizationStatus(f) == 4) {
// If we are always or never optimizing f, just exit, this test is useless.
return;
}
if (i == 1) {
// f must be interpreted code.
assertTrue(isInterpreted(f));
assertEquals(8, %GetOptimizationStatus(f));
// Run twice (i = 0, 1), then tier-up.
%OptimizeFunctionOnNextCall(f);
} else if (i == 2) {
// Tier-up at i = 2 should go up to turbofan.
assertTrue(isTurboFanned(f));
assertEquals(7, %GetOptimizationStatus(f));
}
}
})()