v8/test/mjsunit/es6/large-classes-properties.js
Mythri A 2999cea522 Reland "[ic] Don't transition to premonomorphic state"
This is a reland of 159df2488c

Original change's description:
> [ic] Don't transition to premonomorphic state
> 
> We used to use premonomorphic state to delay initializing the ICs.
> This optimization was to avoid the cost of setting up handlers if the
> code executed only once. With lazy feedback allocation we no longer
> need this.
> 
> This cl also renames LoadIC_Uninitialized to LoadIC_Nofeedback and
> StoreIC_Uninitialized to StoreIC_Nofeedback since we now miss to
> runtime in the uninitialized state and use the builtin when there
> is no feedback.
> 
> 
> Change-Id: I1633e61ea74664da51348e362c34c47a017a264a
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1683525
> Commit-Queue: Mythri Alle <mythria@chromium.org>
> Reviewed-by: Toon Verwaest <verwaest@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#63020}

Change-Id: Ica7eb65649615c2f8410d5b815a98b55cb1cfc4d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1731000
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63082}
2019-08-05 15:51:47 +00:00

40 lines
1.2 KiB
JavaScript

// Copyright 2019 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 testLargeClassesProperties(){
// This is to test for dictionary mode when there more than
// kMaxNumberOfDescriptors (1024) properties.
const kLimit = 1030;
let evalString = "function f(i) { " +
"let clazz = class { " +
" constructor(i) { this.value = i;";
for (let i = 0; i < kLimit ; i++) {
evalString += "this.property"+i +" = "+i+"; "
}
evalString += "}};" +
" return (new clazz(i)); }; f;";
let fn = eval(evalString);
%PrepareFunctionForOptimization(fn);
assertEquals(fn(1).value, 1);
assertEquals(fn(2).value, 2);
assertEquals(fn(3).value, 3);
%OptimizeFunctionOnNextCall(fn);
assertEquals(fn(4).value, 4);
let instance = fn(1);
assertEquals(Object.getOwnPropertyNames(instance).length, kLimit+1);
// Get and set all properties.
for (let i = 0; i < kLimit; i++) {
const key = "property" + i;
assertEquals(instance[key], i);
const value = "value"+i;
instance[key] = value;
assertEquals(instance[key], value);
}
})();