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

Side by Side Diff: src/objects.cc

Issue 424093002: Fix Object.freeze with field type tracking. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/regress/regress-update-field-type-attributes.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 2425 matching lines...) Expand 10 before | Expand all | Expand 10 after
2436 Object* back = result->GetBackPointer(); 2436 Object* back = result->GetBackPointer();
2437 if (back->IsUndefined()) break; 2437 if (back->IsUndefined()) break;
2438 Map* parent = Map::cast(back); 2438 Map* parent = Map::cast(back);
2439 if (parent->NumberOfOwnDescriptors() <= descriptor) break; 2439 if (parent->NumberOfOwnDescriptors() <= descriptor) break;
2440 result = parent; 2440 result = parent;
2441 } 2441 }
2442 return result; 2442 return result;
2443 } 2443 }
2444 2444
2445 2445
2446 void Map::UpdateDescriptor(int descriptor_number, Descriptor* desc) { 2446 void Map::UpdateFieldType(int descriptor, Handle<Name> name,
2447 Handle<HeapType> new_type) {
2447 DisallowHeapAllocation no_allocation; 2448 DisallowHeapAllocation no_allocation;
2449 PropertyDetails details = instance_descriptors()->GetDetails(descriptor);
2450 if (!details.type() == FIELD) return;
2448 if (HasTransitionArray()) { 2451 if (HasTransitionArray()) {
2449 TransitionArray* transitions = this->transitions(); 2452 TransitionArray* transitions = this->transitions();
2450 for (int i = 0; i < transitions->number_of_transitions(); ++i) { 2453 for (int i = 0; i < transitions->number_of_transitions(); ++i) {
2451 transitions->GetTarget(i)->UpdateDescriptor(descriptor_number, desc); 2454 transitions->GetTarget(i)->UpdateFieldType(descriptor, name, new_type);
2452 } 2455 }
2453 } 2456 }
2454 instance_descriptors()->Replace(descriptor_number, desc);; 2457 // Skip if already updated the shared descriptor.
2458 if (instance_descriptors()->GetFieldType(descriptor) == *new_type) return;
2459 FieldDescriptor d(name, instance_descriptors()->GetFieldIndex(descriptor),
2460 new_type, details.attributes(), details.representation());
2461 instance_descriptors()->Replace(descriptor, &d);
2462 ;
2455 } 2463 }
2456 2464
2457 2465
2458 // static 2466 // static
2459 Handle<HeapType> Map::GeneralizeFieldType(Handle<HeapType> type1, 2467 Handle<HeapType> Map::GeneralizeFieldType(Handle<HeapType> type1,
2460 Handle<HeapType> type2, 2468 Handle<HeapType> type2,
2461 Isolate* isolate) { 2469 Isolate* isolate) {
2462 static const int kMaxClassesPerFieldType = 5; 2470 static const int kMaxClassesPerFieldType = 5;
2463 if (type1->NowIs(type2)) return type2; 2471 if (type1->NowIs(type2)) return type2;
2464 if (type2->NowIs(type1)) return type1; 2472 if (type2->NowIs(type1)) return type1;
(...skipping 30 matching lines...) Expand all
2495 Handle<Map> field_owner(map->FindFieldOwner(modify_index), isolate); 2503 Handle<Map> field_owner(map->FindFieldOwner(modify_index), isolate);
2496 Handle<DescriptorArray> descriptors( 2504 Handle<DescriptorArray> descriptors(
2497 field_owner->instance_descriptors(), isolate); 2505 field_owner->instance_descriptors(), isolate);
2498 ASSERT_EQ(*old_field_type, descriptors->GetFieldType(modify_index)); 2506 ASSERT_EQ(*old_field_type, descriptors->GetFieldType(modify_index));
2499 2507
2500 // Determine the generalized new field type. 2508 // Determine the generalized new field type.
2501 new_field_type = Map::GeneralizeFieldType( 2509 new_field_type = Map::GeneralizeFieldType(
2502 old_field_type, new_field_type, isolate); 2510 old_field_type, new_field_type, isolate);
2503 2511
2504 PropertyDetails details = descriptors->GetDetails(modify_index); 2512 PropertyDetails details = descriptors->GetDetails(modify_index);
2505 FieldDescriptor d(handle(descriptors->GetKey(modify_index), isolate), 2513 Handle<Name> name(descriptors->GetKey(modify_index));
2506 descriptors->GetFieldIndex(modify_index), 2514 field_owner->UpdateFieldType(modify_index, name, new_field_type);
2507 new_field_type,
2508 details.attributes(),
2509 details.representation());
2510 field_owner->UpdateDescriptor(modify_index, &d);
2511 field_owner->dependent_code()->DeoptimizeDependentCodeGroup( 2515 field_owner->dependent_code()->DeoptimizeDependentCodeGroup(
2512 isolate, DependentCode::kFieldTypeGroup); 2516 isolate, DependentCode::kFieldTypeGroup);
2513 2517
2514 if (FLAG_trace_generalization) { 2518 if (FLAG_trace_generalization) {
2515 map->PrintGeneralization( 2519 map->PrintGeneralization(
2516 stdout, "field type generalization", 2520 stdout, "field type generalization",
2517 modify_index, map->NumberOfOwnDescriptors(), 2521 modify_index, map->NumberOfOwnDescriptors(),
2518 map->NumberOfOwnDescriptors(), false, 2522 map->NumberOfOwnDescriptors(), false,
2519 details.representation(), details.representation(), 2523 details.representation(), details.representation(),
2520 *old_field_type, *new_field_type); 2524 *old_field_type, *new_field_type);
(...skipping 14461 matching lines...) Expand 10 before | Expand all | Expand 10 after
16982 #define ERROR_MESSAGES_TEXTS(C, T) T, 16986 #define ERROR_MESSAGES_TEXTS(C, T) T,
16983 static const char* error_messages_[] = { 16987 static const char* error_messages_[] = {
16984 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16988 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16985 }; 16989 };
16986 #undef ERROR_MESSAGES_TEXTS 16990 #undef ERROR_MESSAGES_TEXTS
16987 return error_messages_[reason]; 16991 return error_messages_[reason];
16988 } 16992 }
16989 16993
16990 16994
16991 } } // namespace v8::internal 16995 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/regress/regress-update-field-type-attributes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698