Commit 2fba1902 authored by ishell@chromium.org's avatar ishell@chromium.org

One of the fast cases in JSObject::MigrateFastToFast() should not be taken if...

One of the fast cases in JSObject::MigrateFastToFast() should not be taken if the number of fields did not change.

BUG=chromium:390918
LOG=N
R=verwaest@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22174 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a1dd1a26
......@@ -2062,14 +2062,13 @@ static void RightTrimFixedArray(Heap* heap, FixedArray* elms, int to_trim) {
}
bool Map::InstancesNeedRewriting(Map* target,
int target_number_of_fields,
int target_inobject,
int target_unused) {
bool Map::InstancesNeedRewriting(Map* target, int target_number_of_fields,
int target_inobject, int target_unused,
int* old_number_of_fields) {
// If fields were added (or removed), rewrite the instance.
int number_of_fields = NumberOfFields();
ASSERT(target_number_of_fields >= number_of_fields);
if (target_number_of_fields != number_of_fields) return true;
*old_number_of_fields = NumberOfFields();
ASSERT(target_number_of_fields >= *old_number_of_fields);
if (target_number_of_fields != *old_number_of_fields) return true;
// If smi descriptors were replaced by double descriptors, rewrite.
DescriptorArray* old_desc = instance_descriptors();
......@@ -2147,14 +2146,15 @@ void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map) {
void JSObject::MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map) {
Isolate* isolate = object->GetIsolate();
Handle<Map> old_map(object->map());
int old_number_of_fields;
int number_of_fields = new_map->NumberOfFields();
int inobject = new_map->inobject_properties();
int unused = new_map->unused_property_fields();
// Nothing to do if no functions were converted to fields and no smis were
// converted to doubles.
if (!old_map->InstancesNeedRewriting(
*new_map, number_of_fields, inobject, unused)) {
if (!old_map->InstancesNeedRewriting(*new_map, number_of_fields, inobject,
unused, &old_number_of_fields)) {
object->synchronized_set_map(*new_map);
return;
}
......@@ -2163,7 +2163,9 @@ void JSObject::MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map) {
int external = total_size - inobject;
if ((old_map->unused_property_fields() == 0) &&
(number_of_fields != old_number_of_fields) &&
(new_map->GetBackPointer() == *old_map)) {
ASSERT(number_of_fields == old_number_of_fields + 1);
// This migration is a transition from a map that has run out out property
// space. Therefore it could be done by extending the backing store.
Handle<FixedArray> old_storage = handle(object->properties(), isolate);
......
......@@ -6285,10 +6285,9 @@ class Map: public HeapObject {
int NumberOfFields();
// TODO(ishell): candidate with JSObject::MigrateToMap().
bool InstancesNeedRewriting(Map* target,
int target_number_of_fields,
int target_inobject,
int target_unused);
bool InstancesNeedRewriting(Map* target, int target_number_of_fields,
int target_inobject, int target_unused,
int* old_number_of_fields);
// TODO(ishell): moveit!
static Handle<Map> GeneralizeAllFieldRepresentations(Handle<Map> map);
MUST_USE_RESULT static Handle<HeapType> GeneralizeFieldType(
......
// 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 f(scale) {
var arr = {a: 1.1};
for (var i = 0; i < 2; i++) {
arr[2 * scale] = 0;
}
}
f({});
f({});
%OptimizeFunctionOnNextCall(f);
f(1004);
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