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

Side by Side Diff: src/objects.cc

Issue 16051002: Fix Object.freeze for objects with mixed accessors and data properties (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
« no previous file with comments | « no previous file | test/mjsunit/object-freeze.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 // 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 6726 matching lines...) Expand 10 before | Expand all | Expand 10 after
6737 6737
6738 DescriptorArray* descriptors; 6738 DescriptorArray* descriptors;
6739 MaybeObject* maybe_descriptors = Allocate(size); 6739 MaybeObject* maybe_descriptors = Allocate(size);
6740 if (!maybe_descriptors->To(&descriptors)) return maybe_descriptors; 6740 if (!maybe_descriptors->To(&descriptors)) return maybe_descriptors;
6741 DescriptorArray::WhitenessWitness witness(descriptors); 6741 DescriptorArray::WhitenessWitness witness(descriptors);
6742 6742
6743 if (attributes != NONE) { 6743 if (attributes != NONE) {
6744 for (int i = 0; i < size; ++i) { 6744 for (int i = 0; i < size; ++i) {
6745 Object* value = GetValue(i); 6745 Object* value = GetValue(i);
6746 PropertyDetails details = GetDetails(i); 6746 PropertyDetails details = GetDetails(i);
6747 int mask = DONT_DELETE | DONT_ENUM;
Toon Verwaest 2013/05/25 10:52:59 This is very confusing to me. Don't we just want t
6747 // READ_ONLY is an invalid attribute for JS setters/getters. 6748 // READ_ONLY is an invalid attribute for JS setters/getters.
6748 if (details.type() == CALLBACKS && value->IsAccessorPair()) { 6749 if (details.type() != CALLBACKS || !value->IsAccessorPair()) {
6749 attributes = static_cast<PropertyAttributes>(attributes & ~READ_ONLY); 6750 mask |= READ_ONLY;
6750 } 6751 }
6751 Descriptor desc(GetKey(i), value, details.CopyAddAttributes(attributes)); 6752 details = details.CopyAddAttributes(
6753 static_cast<PropertyAttributes>(attributes & mask));
6754 Descriptor desc(GetKey(i), value, details);
6752 descriptors->Set(i, &desc, witness); 6755 descriptors->Set(i, &desc, witness);
6753 } 6756 }
6754 } else { 6757 } else {
6755 for (int i = 0; i < size; ++i) { 6758 for (int i = 0; i < size; ++i) {
6756 descriptors->CopyFrom(i, this, i, witness); 6759 descriptors->CopyFrom(i, this, i, witness);
6757 } 6760 }
6758 } 6761 }
6759 6762
6760 if (number_of_descriptors() != enumeration_index) descriptors->Sort(); 6763 if (number_of_descriptors() != enumeration_index) descriptors->Sort();
6761 6764
(...skipping 8871 matching lines...) Expand 10 before | Expand all | Expand 10 after
15633 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 15636 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
15634 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 15637 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
15635 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 15638 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
15636 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 15639 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
15637 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 15640 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
15638 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 15641 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
15639 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 15642 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
15640 } 15643 }
15641 15644
15642 } } // namespace v8::internal 15645 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/object-freeze.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698