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

Side by Side Diff: src/property.cc

Issue 2591233002: [runtime] Add PropertyConstness bit to PropertyDetails. (Closed)
Patch Set: Addressed comments, used better name: IsGeneralizableTo Created 3 years, 11 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
« no previous file with comments | « src/property.h ('k') | src/property-details.h » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/property.h" 5 #include "src/property.h"
6 6
7 #include "src/field-type.h" 7 #include "src/field-type.h"
8 #include "src/handles-inl.h" 8 #include "src/handles-inl.h"
9 #include "src/objects-inl.h" 9 #include "src/objects-inl.h"
10 #include "src/ostreams.h" 10 #include "src/ostreams.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 std::ostream& operator<<(std::ostream& os, 15 std::ostream& operator<<(std::ostream& os,
16 const PropertyAttributes& attributes) { 16 const PropertyAttributes& attributes) {
17 os << "["; 17 os << "[";
18 os << (((attributes & READ_ONLY) == 0) ? "W" : "_"); // writable 18 os << (((attributes & READ_ONLY) == 0) ? "W" : "_"); // writable
19 os << (((attributes & DONT_ENUM) == 0) ? "E" : "_"); // enumerable 19 os << (((attributes & DONT_ENUM) == 0) ? "E" : "_"); // enumerable
20 os << (((attributes & DONT_DELETE) == 0) ? "C" : "_"); // configurable 20 os << (((attributes & DONT_DELETE) == 0) ? "C" : "_"); // configurable
21 os << "]"; 21 os << "]";
22 return os; 22 return os;
23 } 23 }
24 24
25 Descriptor Descriptor::DataField(Handle<Name> key, int field_index, 25 Descriptor Descriptor::DataField(Handle<Name> key, int field_index,
26 PropertyAttributes attributes, 26 PropertyAttributes attributes,
27 Representation representation) { 27 Representation representation) {
28 return DataField(key, field_index, FieldType::Any(key->GetIsolate()), 28 return DataField(key, field_index, attributes, kMutable, representation,
29 attributes, representation); 29 FieldType::Any(key->GetIsolate()));
30 }
31
32 Descriptor Descriptor::DataField(Handle<Name> key, int field_index,
33 PropertyAttributes attributes,
34 PropertyConstness constness,
35 Representation representation,
36 Handle<Object> wrapped_field_type) {
37 DCHECK(wrapped_field_type->IsSmi() || wrapped_field_type->IsWeakCell());
38 PropertyDetails details(kData, attributes, kField, constness, representation,
39 field_index);
40 return Descriptor(key, wrapped_field_type, details);
30 } 41 }
31 42
32 // Outputs PropertyDetails as a dictionary details. 43 // Outputs PropertyDetails as a dictionary details.
33 void PropertyDetails::PrintAsSlowTo(std::ostream& os) { 44 void PropertyDetails::PrintAsSlowTo(std::ostream& os) {
34 os << "("; 45 os << "(";
46 if (constness() == kConst) os << "const ";
35 os << (kind() == kData ? "data" : "accessor"); 47 os << (kind() == kData ? "data" : "accessor");
36 os << ", dictionary_index: " << dictionary_index(); 48 os << ", dictionary_index: " << dictionary_index();
37 os << ", attrs: " << attributes() << ")"; 49 os << ", attrs: " << attributes() << ")";
38 } 50 }
39 51
40 // Outputs PropertyDetails as a descriptor array details. 52 // Outputs PropertyDetails as a descriptor array details.
41 void PropertyDetails::PrintAsFastTo(std::ostream& os, PrintMode mode) { 53 void PropertyDetails::PrintAsFastTo(std::ostream& os, PrintMode mode) {
42 os << "("; 54 os << "(";
55 if (constness() == kConst) os << "const ";
43 os << (kind() == kData ? "data" : "accessor"); 56 os << (kind() == kData ? "data" : "accessor");
44 if (location() == kField) { 57 if (location() == kField) {
45 os << " field"; 58 os << " field";
46 if (mode & kPrintFieldIndex) { 59 if (mode & kPrintFieldIndex) {
47 os << " " << field_index(); 60 os << " " << field_index();
48 } 61 }
49 if (mode & kPrintRepresentation) { 62 if (mode & kPrintRepresentation) {
50 os << ":" << representation().Mnemonic(); 63 os << ":" << representation().Mnemonic();
51 } 64 }
52 } else { 65 } else {
(...skipping 15 matching lines...) Expand all
68 PrintAsSlowTo(os); 81 PrintAsSlowTo(os);
69 } else { 82 } else {
70 PrintAsFastTo(os, PrintMode::kPrintFull); 83 PrintAsFastTo(os, PrintMode::kPrintFull);
71 } 84 }
72 os << "\n" << std::flush; 85 os << "\n" << std::flush;
73 } 86 }
74 #endif 87 #endif
75 88
76 } // namespace internal 89 } // namespace internal
77 } // namespace v8 90 } // namespace v8
OLDNEW
« no previous file with comments | « src/property.h ('k') | src/property-details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698