61ce45c9e2
With bytecode flushing and lazy feedback allocation, we need to call %PrepareForOptimization before we call %OptimizeFunctionOnNextCall, ideally after declaring the function. Bug: v8:8801, v8:8394, v8:9183 Change-Id: I6bf119e726426df8527d97546b6ce806112c894d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1643167 Auto-Submit: Mathias Bynens <mathias@chromium.org> Reviewed-by: Mythri Alle <mythria@chromium.org> Commit-Queue: Mathias Bynens <mathias@chromium.org> Cr-Commit-Position: refs/heads/master@{#61988}
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
// Copyright 2014 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 push_wrapper(array, value) {
|
|
array.push(value);
|
|
}
|
|
%PrepareFunctionForOptimization(push_wrapper);
|
|
|
|
function pop_wrapper(array) {
|
|
return array.pop();
|
|
}
|
|
%PrepareFunctionForOptimization(pop_wrapper);
|
|
|
|
// Test the frzon arrays throw an exception if you try to push to them, both in
|
|
// optimized and non-optimized code.
|
|
var array = [2, 2];
|
|
Object.freeze(array);
|
|
|
|
try { push_wrapper(array, 1); } catch (e) {}
|
|
assertEquals(2, array.length);
|
|
try { push_wrapper(array, 1); } catch (e) {}
|
|
assertEquals(2, array.length);
|
|
%OptimizeFunctionOnNextCall(push_wrapper);
|
|
try { push_wrapper(array, 1); } catch (e) {}
|
|
assertEquals(2, array.length);
|
|
try { push_wrapper(array, 1); } catch (e) {}
|
|
assertEquals(2, array.length);
|
|
|
|
try { pop_wrapper(array); } catch (e) {}
|
|
assertEquals(2, array.length);
|
|
try { pop_wrapper(array); } catch (e) {}
|
|
assertEquals(2, array.length);
|
|
%OptimizeFunctionOnNextCall(pop_wrapper);
|
|
try { pop_wrapper(array); } catch (e) {}
|
|
assertEquals(2, array.length);
|
|
try { pop_wrapper(array); } catch (e) {}
|
|
assertEquals(2, array.length);
|