Commit 210be521 authored by verwaest's avatar verwaest Committed by Commit bot

Let AddDictionaryElement / AddFastElement purely add, move transition heuristics to AddDataElement

BUG=v8:4137
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#29287}
parent f283021f
This diff is collapsed.
...@@ -1899,9 +1899,6 @@ class JSObject: public JSReceiver { ...@@ -1899,9 +1899,6 @@ class JSObject: public JSReceiver {
static void SetNormalizedProperty(Handle<JSObject> object, Handle<Name> name, static void SetNormalizedProperty(Handle<JSObject> object, Handle<Name> name,
Handle<Object> value, Handle<Object> value,
PropertyDetails details); PropertyDetails details);
static void AddDictionaryElement(Handle<JSObject> object, uint32_t index,
Handle<Object> value,
PropertyAttributes attributes);
static void SetDictionaryElement(Handle<JSObject> object, uint32_t index, static void SetDictionaryElement(Handle<JSObject> object, uint32_t index,
Handle<Object> value, Handle<Object> value,
PropertyAttributes attributes); PropertyAttributes attributes);
...@@ -2011,12 +2008,6 @@ class JSObject: public JSReceiver { ...@@ -2011,12 +2008,6 @@ class JSObject: public JSReceiver {
// an access at key? // an access at key?
bool WouldConvertToSlowElements(uint32_t index); bool WouldConvertToSlowElements(uint32_t index);
inline bool WouldConvertToSlowElements(Handle<Object> key); inline bool WouldConvertToSlowElements(Handle<Object> key);
// Do we want to keep fast elements when adding an element at |index|?
// Returns |new_capacity| indicating to which capacity the object should be
// increased.
bool ShouldConvertToSlowElements(uint32_t capacity, uint32_t index,
uint32_t* new_capacity);
ElementsKind BestFittingFastElementsKind();
// Computes the new capacity when expanding the elements of a JSObject. // Computes the new capacity when expanding the elements of a JSObject.
static uint32_t NewElementsCapacity(uint32_t old_capacity) { static uint32_t NewElementsCapacity(uint32_t old_capacity) {
...@@ -2285,6 +2276,9 @@ class JSObject: public JSReceiver { ...@@ -2285,6 +2276,9 @@ class JSObject: public JSReceiver {
Handle<JSObject> object, const char* type, Handle<Name> name, Handle<JSObject> object, const char* type, Handle<Name> name,
Handle<Object> old_value); Handle<Object> old_value);
// Gets the current elements capacity and the number of used elements.
void GetElementsCapacityAndUsage(int* capacity, int* used);
private: private:
friend class DictionaryElementsAccessor; friend class DictionaryElementsAccessor;
friend class JSReceiver; friend class JSReceiver;
...@@ -2319,12 +2313,6 @@ class JSObject: public JSReceiver { ...@@ -2319,12 +2313,6 @@ class JSObject: public JSReceiver {
ElementsKind kind, ElementsKind kind,
Object* object); Object* object);
// Returns true if most of the elements backing storage is used.
bool HasDenseElements();
// Gets the current elements capacity and the number of used elements.
void GetElementsCapacityAndUsage(int* capacity, int* used);
static bool CanSetCallback(Handle<JSObject> object, Handle<Name> name); static bool CanSetCallback(Handle<JSObject> object, Handle<Name> name);
static void SetElementCallback(Handle<JSObject> object, static void SetElementCallback(Handle<JSObject> object,
uint32_t index, uint32_t index,
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax
function argc0() { function argc0() {
return arguments.length; return arguments.length;
} }
...@@ -188,3 +190,17 @@ function arg_set(x) { return (arguments[x] = 117); } ...@@ -188,3 +190,17 @@ function arg_set(x) { return (arguments[x] = 117); }
assertEquals(undefined, arg_get(0xFFFFFFFF)); assertEquals(undefined, arg_get(0xFFFFFFFF));
assertEquals(true, arg_del(0xFFFFFFFF)); assertEquals(true, arg_del(0xFFFFFFFF));
assertEquals(117, arg_set(0xFFFFFFFF)); assertEquals(117, arg_set(0xFFFFFFFF));
(function() {
function f(a) { return arguments; }
var a = f(1,2,3);
// Turn arguments into slow.
assertTrue(%HasSloppyArgumentsElements(a));
a[10000] = 1;
assertTrue(%HasSloppyArgumentsElements(a));
// Make it fast again by adding values.
for (var i = 0; i < 1000; i++) {
a[i] = 1.5;
}
assertTrue(%HasSloppyArgumentsElements(a));
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment