Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: src/objects.cc

Issue 14629005: Adding fast path for generalizing maps. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2442 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 return CopyGeneralizeAllRepresentations(); 2453 return CopyGeneralizeAllRepresentations();
2454 } 2454 }
2455 2455
2456 int verbatim = root_map->NumberOfOwnDescriptors(); 2456 int verbatim = root_map->NumberOfOwnDescriptors();
2457 2457
2458 Map* updated = root_map->FindUpdatedMap( 2458 Map* updated = root_map->FindUpdatedMap(
2459 verbatim, descriptors, old_descriptors); 2459 verbatim, descriptors, old_descriptors);
2460 // Check the state of the root map. 2460 // Check the state of the root map.
2461 DescriptorArray* updated_descriptors = updated->instance_descriptors(); 2461 DescriptorArray* updated_descriptors = updated->instance_descriptors();
2462 2462
2463 int valid = updated->NumberOfOwnDescriptors();
2464 if (updated_descriptors->IsMoreGeneralThan(
2465 verbatim, valid, descriptors, old_descriptors)) {
2466 Representation updated_representation =
2467 updated_descriptors->GetDetails(modify_index).representation();
2468 if (new_representation.fits(updated_representation)) return updated;
2469 }
2470
2463 DescriptorArray* new_descriptors; 2471 DescriptorArray* new_descriptors;
2464 MaybeObject* maybe_descriptors = updated_descriptors->Merge( 2472 MaybeObject* maybe_descriptors = updated_descriptors->Merge(
2465 verbatim, 2473 verbatim, valid, descriptors, old_descriptors);
2466 updated->NumberOfOwnDescriptors(),
2467 descriptors,
2468 old_descriptors);
2469 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; 2474 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;
2470 2475
2471 old_reprepresentation = 2476 old_reprepresentation =
2472 new_descriptors->GetDetails(modify_index).representation(); 2477 new_descriptors->GetDetails(modify_index).representation();
2473 new_representation = new_representation.generalize(old_reprepresentation); 2478 new_representation = new_representation.generalize(old_reprepresentation);
2474 new_descriptors->SetRepresentation(modify_index, new_representation); 2479 new_descriptors->SetRepresentation(modify_index, new_representation);
2475 2480
2476 Map* split_map = root_map->FindLastMatchMap( 2481 Map* split_map = root_map->FindLastMatchMap(
2477 verbatim, descriptors, new_descriptors); 2482 verbatim, descriptors, new_descriptors);
2478 2483
2479 int split_descriptors = split_map->NumberOfOwnDescriptors(); 2484 int split_descriptors = split_map->NumberOfOwnDescriptors();
2480 // Check whether |split_map| matches what we were looking for. If so, return 2485 // This is shadowed by |updated_descriptors| being more general than
2481 // it. 2486 // |old_descriptors|.
2482 if (descriptors == split_descriptors) return split_map; 2487 ASSERT(descriptors != split_descriptors);
2483 2488
2484 int descriptor = split_descriptors; 2489 int descriptor = split_descriptors;
2485 split_map->DeprecateTarget( 2490 split_map->DeprecateTarget(
2486 old_descriptors->GetKey(descriptor), new_descriptors); 2491 old_descriptors->GetKey(descriptor), new_descriptors);
2487 2492
2488 Map* new_map = split_map; 2493 Map* new_map = split_map;
2489 // Add missing transitions. 2494 // Add missing transitions.
2490 for (; descriptor < descriptors; descriptor++) { 2495 for (; descriptor < descriptors; descriptor++) {
2491 MaybeObject* maybe_map = new_map->CopyInstallDescriptors( 2496 MaybeObject* maybe_map = new_map->CopyInstallDescriptors(
2492 descriptor, new_descriptors); 2497 descriptor, new_descriptors);
(...skipping 4843 matching lines...) Expand 10 before | Expand all | Expand 10 after
7336 } else { 7341 } else {
7337 result->CopyFrom(descriptor, other, descriptor, witness); 7342 result->CopyFrom(descriptor, other, descriptor, witness);
7338 } 7343 }
7339 } 7344 }
7340 7345
7341 result->Sort(); 7346 result->Sort();
7342 return result; 7347 return result;
7343 } 7348 }
7344 7349
7345 7350
7351 // Checks whether a merge of |this| and |other| would return a copy of |this|.
7352 bool DescriptorArray::IsMoreGeneralThan(int verbatim,
7353 int valid,
7354 int new_size,
7355 DescriptorArray* other) {
7356 ASSERT(verbatim <= valid);
7357 ASSERT(valid <= new_size);
7358 if (valid != new_size) return false;
7359
7360 for (int descriptor = verbatim; descriptor < valid; descriptor++) {
7361 PropertyDetails details = GetDetails(descriptor);
7362 PropertyDetails other_details = other->GetDetails(descriptor);
7363 if (details.type() != other_details.type()) {
7364 if (details.type() != FIELD ||
7365 other_details.type() != CONSTANT_FUNCTION) {
danno 2013/05/02 14:26:41 What about when other_details is a FIELD and detai
Toon Verwaest 2013/05/02 15:15:57 In that case |this| is not a valid updated version
7366 return false;
7367 }
7368 } else if (details.type() == CONSTANT_FUNCTION) {
7369 if (GetValue(descriptor) != other->GetValue(descriptor)) {
7370 return false;
7371 }
7372 } else if (!other_details.representation().fits(details.representation())) {
danno 2013/05/02 14:26:41 So, merge doesn't seem to be commutative? Shouldn'
7373 return false;
7374 }
7375 }
7376
7377 return true;
7378 }
7379
7380
7346 // We need the whiteness witness since sort will reshuffle the entries in the 7381 // We need the whiteness witness since sort will reshuffle the entries in the
7347 // descriptor array. If the descriptor array were to be black, the shuffling 7382 // descriptor array. If the descriptor array were to be black, the shuffling
7348 // would move a slot that was already recorded as pointing into an evacuation 7383 // would move a slot that was already recorded as pointing into an evacuation
7349 // candidate. This would result in missing updates upon evacuation. 7384 // candidate. This would result in missing updates upon evacuation.
7350 void DescriptorArray::Sort() { 7385 void DescriptorArray::Sort() {
7351 // In-place heap sort. 7386 // In-place heap sort.
7352 int len = number_of_descriptors(); 7387 int len = number_of_descriptors();
7353 // Reset sorting since the descriptor array might contain invalid pointers. 7388 // Reset sorting since the descriptor array might contain invalid pointers.
7354 for (int i = 0; i < len; ++i) SetSortedKey(i, i); 7389 for (int i = 0; i < len; ++i) SetSortedKey(i, i);
7355 // Bottom-up max-heap construction. 7390 // Bottom-up max-heap construction.
(...skipping 7734 matching lines...) Expand 10 before | Expand all | Expand 10 after
15090 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 15125 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
15091 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 15126 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
15092 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 15127 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
15093 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 15128 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
15094 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 15129 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
15095 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 15130 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
15096 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 15131 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
15097 } 15132 }
15098 15133
15099 } } // namespace v8::internal 15134 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/property-details.h » ('j') | src/property-details.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698