Remove flag track-allocation-sites.

The flag has been on in the build for ~9 months, and we aren't likely to turn it off. The only customer of the flag is a set of tests that want to verify transitioning behavior in isolation. This CL removes the flag and updates those tests to get what they want without the flag.

R=verwaest@chromium.org

Review URL: https://codereview.chromium.org/104923010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18385 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mvstanton@chromium.org 2013-12-20 11:46:31 +00:00
parent e595dc0368
commit e654c88fab
22 changed files with 159 additions and 118 deletions

View File

@ -1907,8 +1907,7 @@ class ArrayConstructorStubBase : public HydrogenCodeStub {
// It only makes sense to override local allocation site behavior
// if there is a difference between the global allocation site policy
// for an ElementsKind and the desired usage of the stub.
ASSERT(!(FLAG_track_allocation_sites &&
override_mode == DISABLE_ALLOCATION_SITES) ||
ASSERT(override_mode != DISABLE_ALLOCATION_SITES ||
AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE);
bit_field_ = ElementsKindBits::encode(kind) |
AllocationSiteOverrideModeBits::encode(override_mode) |

View File

@ -309,8 +309,6 @@ DEFINE_bool(dead_code_elimination, true, "use dead code elimination")
DEFINE_bool(fold_constants, true, "use constant folding")
DEFINE_bool(trace_dead_code_elimination, false, "trace dead code elimination")
DEFINE_bool(unreachable_code_elimination, true, "eliminate unreachable code")
DEFINE_bool(track_allocation_sites, true,
"Use allocation site info to reduce transitions")
DEFINE_bool(trace_osr, false, "trace on-stack replacement")
DEFINE_int(stress_runs, 0, "number of stress runs")
DEFINE_bool(optimize_closures, true, "optimize closures")

View File

@ -5457,18 +5457,13 @@ static void CreateArrayDispatchOneArgument(MacroAssembler* masm,
template<class T>
static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) {
ElementsKind initial_kind = GetInitialFastElementsKind();
ElementsKind initial_holey_kind = GetHoleyElementsKind(initial_kind);
int to_index = GetSequenceIndexFromFastElementsKind(
TERMINAL_FAST_ELEMENTS_KIND);
for (int i = 0; i <= to_index; ++i) {
ElementsKind kind = GetFastElementsKindFromSequenceIndex(i);
T stub(kind);
stub.GetCode(isolate);
if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE ||
(!FLAG_track_allocation_sites &&
(kind == initial_kind || kind == initial_holey_kind))) {
if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) {
T stub1(kind, CONTEXT_CHECK_REQUIRED, DISABLE_ALLOCATION_SITES);
stub1.GetCode(isolate);
}

View File

@ -1716,8 +1716,7 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
Handle<FixedArrayBase> constant_elements_values(
FixedArrayBase::cast(constant_elements->get(1)));
AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites
? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE;
AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE;
if (has_constant_fast_elements && !FLAG_allocation_site_pretenuring) {
// If the only customer of allocation sites is transitioning, then
// we can turn it off if we don't have anywhere else to transition to.

View File

@ -1326,8 +1326,7 @@ void AllocationSite::MarkZombie() {
// elements kind is the initial elements kind.
AllocationSiteMode AllocationSite::GetMode(
ElementsKind boilerplate_elements_kind) {
if (FLAG_track_allocation_sites &&
IsFastSmiElementsKind(boilerplate_elements_kind)) {
if (IsFastSmiElementsKind(boilerplate_elements_kind)) {
return TRACK_ALLOCATION_SITE;
}
@ -1337,8 +1336,7 @@ AllocationSiteMode AllocationSite::GetMode(
AllocationSiteMode AllocationSite::GetMode(ElementsKind from,
ElementsKind to) {
if (FLAG_track_allocation_sites &&
IsFastSmiElementsKind(from) &&
if (IsFastSmiElementsKind(from) &&
IsMoreGeneralElementsKindTransition(from, to)) {
return TRACK_ALLOCATION_SITE;
}

View File

@ -9191,26 +9191,24 @@ AllocationMemento* AllocationMemento::FindForHeapObject(HeapObject* object,
// checking the object immediately after the current object (if there is one)
// to see if it's an AllocationMemento.
ASSERT(object->GetHeap()->InNewSpace(object));
if (FLAG_track_allocation_sites) {
Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) +
object->Size();
Address top;
if (in_GC) {
top = object->GetHeap()->new_space()->FromSpacePageHigh();
} else {
top = object->GetHeap()->NewSpaceTop();
}
if ((ptr_end + AllocationMemento::kSize) <= top) {
// There is room in newspace for allocation info. Do we have some?
Map** possible_allocation_memento_map =
reinterpret_cast<Map**>(ptr_end);
if (*possible_allocation_memento_map ==
object->GetHeap()->allocation_memento_map()) {
AllocationMemento* memento = AllocationMemento::cast(
reinterpret_cast<Object*>(ptr_end + kHeapObjectTag));
if (memento->IsValid()) {
return memento;
}
Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) +
object->Size();
Address top;
if (in_GC) {
top = object->GetHeap()->new_space()->FromSpacePageHigh();
} else {
top = object->GetHeap()->NewSpaceTop();
}
if ((ptr_end + AllocationMemento::kSize) <= top) {
// There is room in newspace for allocation info. Do we have some?
Map** possible_allocation_memento_map =
reinterpret_cast<Map**>(ptr_end);
if (*possible_allocation_memento_map ==
object->GetHeap()->allocation_memento_map()) {
AllocationMemento* memento = AllocationMemento::cast(
reinterpret_cast<Object*>(ptr_end + kHeapObjectTag));
if (memento->IsValid()) {
return memento;
}
}
}
@ -12895,7 +12893,7 @@ void JSObject::UpdateAllocationSite(Handle<JSObject> object,
MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) {
if (!FLAG_track_allocation_sites || !IsJSArray()) {
if (!IsJSArray()) {
return this;
}

View File

@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
// Flags: --track-allocation-sites --noalways-opt
// Flags: --noalways-opt
// Test element kind of objects.
// Since --smi-only-arrays affects builtins, its default setting at compile

View File

@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
// Flags: --track-allocation-sites --noalways-opt
// Flags: --noalways-opt
// Test element kind of objects.
// Since --smi-only-arrays affects builtins, its default setting at compile

View File

@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
// Flags: --track-allocation-sites --noalways-opt
// Flags: --noalways-opt
// Test element kind of objects.
// Since --smi-only-arrays affects builtins, its default setting at compile

View File

@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
// Flags: --track-allocation-sites --noalways-opt
// Flags: --noalways-opt
// Test element kind of objects.
// Since --smi-only-arrays affects builtins, its default setting at compile

View File

@ -26,7 +26,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays
// Flags: --notrack-allocation-sites
// Test element kind of objects.
// Since --smi-only-arrays affects builtins, its default setting at compile time

View File

@ -26,12 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
// Flags: --notrack_allocation_sites
// Limit the number of stress runs to reduce polymorphism it defeats some of the
// assumptions made about how elements transitions work because transition stubs
// end up going generic.
// Flags: --stress-runs=2
// Flags: --nostress-opt
// Test element kind of objects.
// Since --smi-only-arrays affects builtins, its default setting at compile
@ -123,56 +118,75 @@ if (support_smi_only_arrays) {
}
// Make sure the element kind transitions from smi when a non-smi is stored.
var you = new Array();
assertKind(elements_kind.fast_smi_only, you);
for (var i = 0; i < 1337; i++) {
var val = i;
if (i == 1336) {
assertKind(elements_kind.fast_smi_only, you);
val = new Object();
function test_wrapper() {
var you = new Array();
assertKind(elements_kind.fast_smi_only, you);
for (var i = 0; i < 1337; i++) {
var val = i;
if (i == 1336) {
assertKind(elements_kind.fast_smi_only, you);
val = new Object();
}
you[i] = val;
}
you[i] = val;
assertKind(elements_kind.fast, you);
assertKind(elements_kind.dictionary, new Array(0xDECAF));
var fast_double_array = new Array(0xDECAF);
for (var i = 0; i < 0xDECAF; i++) fast_double_array[i] = i / 2;
assertKind(elements_kind.fast_double, fast_double_array);
assertKind(elements_kind.external_byte, new Int8Array(9001));
assertKind(elements_kind.external_unsigned_byte, new Uint8Array(007));
assertKind(elements_kind.external_short, new Int16Array(666));
assertKind(elements_kind.external_unsigned_short, new Uint16Array(42));
assertKind(elements_kind.external_int, new Int32Array(0xF));
assertKind(elements_kind.external_unsigned_int, new Uint32Array(23));
assertKind(elements_kind.external_float, new Float32Array(7));
assertKind(elements_kind.external_double, new Float64Array(0));
assertKind(elements_kind.external_pixel, new Uint8ClampedArray(512));
// Crankshaft support for smi-only array elements.
function monomorphic(array) {
assertKind(elements_kind.fast_smi_only, array);
for (var i = 0; i < 3; i++) {
array[i] = i + 10;
}
assertKind(elements_kind.fast_smi_only, array);
for (var i = 0; i < 3; i++) {
var a = array[i];
assertEquals(i + 10, a);
}
}
var smi_only = new Array(1, 2, 3);
assertKind(elements_kind.fast_smi_only, smi_only);
for (var i = 0; i < 3; i++) monomorphic(smi_only);
%OptimizeFunctionOnNextCall(monomorphic);
monomorphic(smi_only);
}
assertKind(elements_kind.fast, you);
assertKind(elements_kind.dictionary, new Array(0xDECAF));
var fast_double_array = new Array(0xDECAF);
for (var i = 0; i < 0xDECAF; i++) fast_double_array[i] = i / 2;
assertKind(elements_kind.fast_double, fast_double_array);
assertKind(elements_kind.external_byte, new Int8Array(9001));
assertKind(elements_kind.external_unsigned_byte, new Uint8Array(007));
assertKind(elements_kind.external_short, new Int16Array(666));
assertKind(elements_kind.external_unsigned_short, new Uint16Array(42));
assertKind(elements_kind.external_int, new Int32Array(0xF));
assertKind(elements_kind.external_unsigned_int, new Uint32Array(23));
assertKind(elements_kind.external_float, new Float32Array(7));
assertKind(elements_kind.external_double, new Float64Array(0));
assertKind(elements_kind.external_pixel, new Uint8ClampedArray(512));
// Crankshaft support for smi-only array elements.
function monomorphic(array) {
assertKind(elements_kind.fast_smi_only, array);
for (var i = 0; i < 3; i++) {
array[i] = i + 10;
}
assertKind(elements_kind.fast_smi_only, array);
for (var i = 0; i < 3; i++) {
var a = array[i];
assertEquals(i + 10, a);
}
}
var smi_only = new Array(1, 2, 3);
assertKind(elements_kind.fast_smi_only, smi_only);
for (var i = 0; i < 3; i++) monomorphic(smi_only);
%OptimizeFunctionOnNextCall(monomorphic);
monomorphic(smi_only);
// The test is called in a wrapper function to eliminate the transition learning
// feedback of AllocationSites.
test_wrapper();
%ClearFunctionTypeFeedback(test_wrapper);
if (support_smi_only_arrays) {
%NeverOptimizeFunction(construct_smis);
// This code exists to eliminate the learning influence of AllocationSites
// on the following tests.
var __sequence = 0;
function make_array_string() {
this.__sequence = this.__sequence + 1;
return "/* " + this.__sequence + " */ [0, 0, 0];"
}
function make_array() {
return eval(make_array_string());
}
function construct_smis() {
var a = [0, 0, 0];
var a = make_array();
a[0] = 0; // Send the COW array map to the steak house.
assertKind(elements_kind.fast_smi_only, a);
return a;

View File

@ -25,8 +25,6 @@
// (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: --notrack-allocation-sites
function foo(a, v) {
a[0] = v;
return a;

View File

@ -25,10 +25,8 @@
// (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 --smi-only-arrays --notrack-allocation-sites
// No tracking of allocation sites because it interfers with the semantics
// the test is trying to ensure.
// Flags: --allow-natives-syntax --smi-only-arrays
// Flags: --nostress-opt
// Ensure that ElementsKind transitions in various situations are hoisted (or
// not hoisted) correctly, don't change the semantics programs and don't trigger
@ -42,7 +40,7 @@ if (support_smi_only_arrays) {
print("Tests do NOT include smi-only arrays.");
}
if (support_smi_only_arrays) {
function test_wrapper() {
// Make sure that a simple elements array transitions inside a loop before
// stores to an array gets hoisted in a way that doesn't generate a deopt in
// simple cases.}
@ -239,3 +237,10 @@ if (support_smi_only_arrays) {
assertOptimized(testStraightLineDupeElinination);
%ClearFunctionTypeFeedback(testStraightLineDupeElinination);
}
if (support_smi_only_arrays) {
// The test is called in a test wrapper that has type feedback cleared to
// prevent the influence of allocation-sites, which learn from transitions.
test_wrapper();
%ClearFunctionTypeFeedback(test_wrapper);
}

View File

@ -25,7 +25,8 @@
// (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 --smi-only-arrays --notrack-allocation-sites
// Flags: --allow-natives-syntax --smi-only-arrays
// Flags: --nostress-opt
support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8));
@ -36,14 +37,26 @@ if (support_smi_only_arrays) {
}
if (support_smi_only_arrays) {
// This code exists to eliminate the learning influence of AllocationSites
// on the following tests.
var __sequence = 0;
function make_array_string(length) {
this.__sequence = this.__sequence + 1;
return "/* " + this.__sequence + " */ new Array(" + length + ");";
}
function make_array(length) {
return eval(make_array_string(length));
}
function test(test_double, test_object, set, length) {
// We apply the same operations to two identical arrays. The first array
// triggers an IC miss, upon which the conversion stub is generated, but the
// actual conversion is done in runtime. The second array, arriving at
// the previously patched IC, is then converted using the conversion stub.
var array_1 = new Array(length);
var array_2 = new Array(length);
var array_1 = make_array(length);
var array_2 = make_array(length);
// false, true, nice setter function, 20
assertTrue(%HasFastSmiElements(array_1));
assertTrue(%HasFastSmiElements(array_2));
for (var i = 0; i < length; i++) {
@ -86,15 +99,20 @@ if (support_smi_only_arrays) {
assertEquals(length, array_2.length);
}
test(false, false, function(a,i,v){ a[i] = v; }, 20);
test(true, false, function(a,i,v){ a[i] = v; }, 20);
test(false, true, function(a,i,v){ a[i] = v; }, 20);
test(true, true, function(a,i,v){ a[i] = v; }, 20);
function run_test(test_double, test_object, set, length) {
test(test_double, test_object, set, length);
%ClearFunctionTypeFeedback(test);
}
test(false, false, function(a,i,v){ a[i] = v; }, 10000);
test(true, false, function(a,i,v){ a[i] = v; }, 10000);
test(false, true, function(a,i,v){ a[i] = v; }, 10000);
test(true, true, function(a,i,v){ a[i] = v; }, 10000);
run_test(false, false, function(a,i,v){ a[i] = v; }, 20);
run_test(true, false, function(a,i,v){ a[i] = v; }, 20);
run_test(false, true, function(a,i,v){ a[i] = v; }, 20);
run_test(true, true, function(a,i,v){ a[i] = v; }, 20);
run_test(false, false, function(a,i,v){ a[i] = v; }, 10000);
run_test(true, false, function(a,i,v){ a[i] = v; }, 10000);
run_test(false, true, function(a,i,v){ a[i] = v; }, 10000);
run_test(true, true, function(a,i,v){ a[i] = v; }, 10000);
// Check COW arrays
function get_cow() { return [1, 2, 3]; }

View File

@ -26,7 +26,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
// Flags: --notrack_allocation_sites
// Limit the number of stress runs to reduce polymorphism it defeats some of the
// assumptions made about how elements transitions work because transition stubs
@ -114,8 +113,20 @@ function assertKind(expected, obj, name_opt) {
}
%NeverOptimizeFunction(construct_smis);
// This code exists to eliminate the learning influence of AllocationSites
// on the following tests.
var __sequence = 0;
function make_array_string() {
this.__sequence = this.__sequence + 1;
return "/* " + this.__sequence + " */ [0, 0, 0];"
}
function make_array() {
return eval(make_array_string());
}
function construct_smis() {
var a = [0, 0, 0];
var a = make_array();
a[0] = 0; // Send the COW array map to the steak house.
assertKind(elements_kind.fast_smi_only, a);
return a;

View File

@ -26,7 +26,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
// Flags: --notrack_allocation_sites
// Limit the number of stress runs to reduce polymorphism it defeats some of the
// assumptions made about how elements transitions work because transition stubs
@ -120,8 +119,19 @@ function assertKind(expected, obj, name_opt) {
for (var i = 0; i < 1000000; i++) { }
if (support_smi_only_arrays) {
// This code exists to eliminate the learning influence of AllocationSites
// on the following tests.
var __sequence = 0;
function make_array_string() {
this.__sequence = this.__sequence + 1;
return "/* " + this.__sequence + " */ [0, 0, 0];"
}
function make_array() {
return eval(make_array_string());
}
function construct_smis() {
var a = [0, 0, 0];
var a = make_array();
a[0] = 0; // Send the COW array map to the steak house.
assertKind(elements_kind.fast_smi_only, a);
return a;

View File

@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
// Flags: --track-allocation-sites --noalways-opt
// Flags: --noalways-opt
// Flags: --stress-runs=8 --send-idle-notification --gc-global

View File

@ -24,7 +24,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (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 --notrack-allocation-sites
// Flags: --allow-natives-syntax
// Test adding undefined from hole in double-holey to string.
var a = [1.5, , 1.8];

View File

@ -26,7 +26,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays
// Flags: --track-allocation-sites
function foo(arg) {
var a = arg();

View File

@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
// Flags: --track-allocation-sites --noalways-opt
// Flags: --noalways-opt
// Test element kind of objects.
// Since --smi-only-arrays affects builtins, its default setting at compile

View File

@ -25,7 +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 --track-allocation-sites
// Flags: --allow-natives-syntax
// Allocation site for empty double arrays.
function foo() {