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

Side by Side Diff: src/interface.cc

Issue 10534006: Remove TLS access for current Zone. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review. Created 8 years, 6 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/interface.h ('k') | src/isolate.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 23 matching lines...) Expand all
34 34
35 static bool Match(void* key1, void* key2) { 35 static bool Match(void* key1, void* key2) {
36 String* name1 = *static_cast<String**>(key1); 36 String* name1 = *static_cast<String**>(key1);
37 String* name2 = *static_cast<String**>(key2); 37 String* name2 = *static_cast<String**>(key2);
38 ASSERT(name1->IsSymbol()); 38 ASSERT(name1->IsSymbol());
39 ASSERT(name2->IsSymbol()); 39 ASSERT(name2->IsSymbol());
40 return name1 == name2; 40 return name1 == name2;
41 } 41 }
42 42
43 43
44 Interface* Interface::Lookup(Handle<String> name) { 44 Interface* Interface::Lookup(Handle<String> name, Zone* zone) {
45 ASSERT(IsModule()); 45 ASSERT(IsModule());
46 ZoneHashMap* map = Chase()->exports_; 46 ZoneHashMap* map = Chase()->exports_;
47 if (map == NULL) return NULL; 47 if (map == NULL) return NULL;
48 ZoneHashMap::Entry* p = map->Lookup(name.location(), name->Hash(), false); 48 ZoneAllocationPolicy allocator(zone);
49 ZoneHashMap::Entry* p = map->Lookup(name.location(), name->Hash(), false,
50 allocator);
49 if (p == NULL) return NULL; 51 if (p == NULL) return NULL;
50 ASSERT(*static_cast<String**>(p->key) == *name); 52 ASSERT(*static_cast<String**>(p->key) == *name);
51 ASSERT(p->value != NULL); 53 ASSERT(p->value != NULL);
52 return static_cast<Interface*>(p->value); 54 return static_cast<Interface*>(p->value);
53 } 55 }
54 56
55 57
56 #ifdef DEBUG 58 #ifdef DEBUG
57 // Current nesting depth for debug output. 59 // Current nesting depth for debug output.
58 class Nesting { 60 class Nesting {
59 public: 61 public:
60 Nesting() { current_ += 2; } 62 Nesting() { current_ += 2; }
61 ~Nesting() { current_ -= 2; } 63 ~Nesting() { current_ -= 2; }
62 static int current() { return current_; } 64 static int current() { return current_; }
63 private: 65 private:
64 static int current_; 66 static int current_;
65 }; 67 };
66 68
67 int Nesting::current_ = 0; 69 int Nesting::current_ = 0;
68 #endif 70 #endif
69 71
70 72
71 void Interface::DoAdd( 73 void Interface::DoAdd(
72 void* name, uint32_t hash, Interface* interface, bool* ok) { 74 void* name, uint32_t hash, Interface* interface, Zone* zone, bool* ok) {
73 MakeModule(ok); 75 MakeModule(ok);
74 if (!*ok) return; 76 if (!*ok) return;
75 77
76 #ifdef DEBUG 78 #ifdef DEBUG
77 if (FLAG_print_interface_details) { 79 if (FLAG_print_interface_details) {
78 PrintF("%*s# Adding...\n", Nesting::current(), ""); 80 PrintF("%*s# Adding...\n", Nesting::current(), "");
79 PrintF("%*sthis = ", Nesting::current(), ""); 81 PrintF("%*sthis = ", Nesting::current(), "");
80 this->Print(Nesting::current()); 82 this->Print(Nesting::current());
81 PrintF("%*s%s : ", Nesting::current(), "", 83 PrintF("%*s%s : ", Nesting::current(), "",
82 (*static_cast<String**>(name))->ToAsciiArray()); 84 (*static_cast<String**>(name))->ToAsciiArray());
83 interface->Print(Nesting::current()); 85 interface->Print(Nesting::current());
84 } 86 }
85 #endif 87 #endif
86 88
87 ZoneHashMap** map = &Chase()->exports_; 89 ZoneHashMap** map = &Chase()->exports_;
88 if (*map == NULL) *map = new ZoneHashMap(Match, 8); 90 ZoneAllocationPolicy allocator(zone);
89 91
90 ZoneHashMap::Entry* p = (*map)->Lookup(name, hash, !IsFrozen()); 92 if (*map == NULL)
93 *map = new ZoneHashMap(Match, ZoneHashMap::kDefaultHashMapCapacity,
94 allocator);
95
96 ZoneHashMap::Entry* p = (*map)->Lookup(name, hash, !IsFrozen(), allocator);
91 if (p == NULL) { 97 if (p == NULL) {
92 // This didn't have name but was frozen already, that's an error. 98 // This didn't have name but was frozen already, that's an error.
93 *ok = false; 99 *ok = false;
94 } else if (p->value == NULL) { 100 } else if (p->value == NULL) {
95 p->value = interface; 101 p->value = interface;
96 } else { 102 } else {
97 #ifdef DEBUG 103 #ifdef DEBUG
98 Nesting nested; 104 Nesting nested;
99 #endif 105 #endif
100 static_cast<Interface*>(p->value)->Unify(interface, ok); 106 static_cast<Interface*>(p->value)->Unify(interface, zone, ok);
101 } 107 }
102 108
103 #ifdef DEBUG 109 #ifdef DEBUG
104 if (FLAG_print_interface_details) { 110 if (FLAG_print_interface_details) {
105 PrintF("%*sthis' = ", Nesting::current(), ""); 111 PrintF("%*sthis' = ", Nesting::current(), "");
106 this->Print(Nesting::current()); 112 this->Print(Nesting::current());
107 PrintF("%*s# Added.\n", Nesting::current(), ""); 113 PrintF("%*s# Added.\n", Nesting::current(), "");
108 } 114 }
109 #endif 115 #endif
110 } 116 }
111 117
112 118
113 void Interface::Unify(Interface* that, bool* ok) { 119 void Interface::Unify(Interface* that, Zone* zone, bool* ok) {
114 if (this->forward_) return this->Chase()->Unify(that, ok); 120 if (this->forward_) return this->Chase()->Unify(that, zone, ok);
115 if (that->forward_) return this->Unify(that->Chase(), ok); 121 if (that->forward_) return this->Unify(that->Chase(), zone, ok);
116 ASSERT(this->forward_ == NULL); 122 ASSERT(this->forward_ == NULL);
117 ASSERT(that->forward_ == NULL); 123 ASSERT(that->forward_ == NULL);
118 124
119 *ok = true; 125 *ok = true;
120 if (this == that) return; 126 if (this == that) return;
121 if (this->IsValue()) return that->MakeValue(ok); 127 if (this->IsValue()) return that->MakeValue(ok);
122 if (that->IsValue()) return this->MakeValue(ok); 128 if (that->IsValue()) return this->MakeValue(ok);
123 129
124 #ifdef DEBUG 130 #ifdef DEBUG
125 if (FLAG_print_interface_details) { 131 if (FLAG_print_interface_details) {
126 PrintF("%*s# Unifying...\n", Nesting::current(), ""); 132 PrintF("%*s# Unifying...\n", Nesting::current(), "");
127 PrintF("%*sthis = ", Nesting::current(), ""); 133 PrintF("%*sthis = ", Nesting::current(), "");
128 this->Print(Nesting::current()); 134 this->Print(Nesting::current());
129 PrintF("%*sthat = ", Nesting::current(), ""); 135 PrintF("%*sthat = ", Nesting::current(), "");
130 that->Print(Nesting::current()); 136 that->Print(Nesting::current());
131 } 137 }
132 #endif 138 #endif
133 139
134 // Merge the smaller interface into the larger, for performance. 140 // Merge the smaller interface into the larger, for performance.
135 if (this->exports_ != NULL && (that->exports_ == NULL || 141 if (this->exports_ != NULL && (that->exports_ == NULL ||
136 this->exports_->occupancy() >= that->exports_->occupancy())) { 142 this->exports_->occupancy() >= that->exports_->occupancy())) {
137 this->DoUnify(that, ok); 143 this->DoUnify(that, ok, zone);
138 } else { 144 } else {
139 that->DoUnify(this, ok); 145 that->DoUnify(this, ok, zone);
140 } 146 }
141 147
142 #ifdef DEBUG 148 #ifdef DEBUG
143 if (FLAG_print_interface_details) { 149 if (FLAG_print_interface_details) {
144 PrintF("%*sthis' = ", Nesting::current(), ""); 150 PrintF("%*sthis' = ", Nesting::current(), "");
145 this->Print(Nesting::current()); 151 this->Print(Nesting::current());
146 PrintF("%*sthat' = ", Nesting::current(), ""); 152 PrintF("%*sthat' = ", Nesting::current(), "");
147 that->Print(Nesting::current()); 153 that->Print(Nesting::current());
148 PrintF("%*s# Unified.\n", Nesting::current(), ""); 154 PrintF("%*s# Unified.\n", Nesting::current(), "");
149 } 155 }
150 #endif 156 #endif
151 } 157 }
152 158
153 159
154 void Interface::DoUnify(Interface* that, bool* ok) { 160 void Interface::DoUnify(Interface* that, bool* ok, Zone* zone) {
155 ASSERT(this->forward_ == NULL); 161 ASSERT(this->forward_ == NULL);
156 ASSERT(that->forward_ == NULL); 162 ASSERT(that->forward_ == NULL);
157 ASSERT(!this->IsValue()); 163 ASSERT(!this->IsValue());
158 ASSERT(!that->IsValue()); 164 ASSERT(!that->IsValue());
159 ASSERT(*ok); 165 ASSERT(*ok);
160 166
161 #ifdef DEBUG 167 #ifdef DEBUG
162 Nesting nested; 168 Nesting nested;
163 #endif 169 #endif
164 170
165 // Try to merge all members from that into this. 171 // Try to merge all members from that into this.
166 ZoneHashMap* map = that->exports_; 172 ZoneHashMap* map = that->exports_;
167 if (map != NULL) { 173 if (map != NULL) {
168 for (ZoneHashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) { 174 for (ZoneHashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) {
169 this->DoAdd(p->key, p->hash, static_cast<Interface*>(p->value), ok); 175 this->DoAdd(p->key, p->hash, static_cast<Interface*>(p->value), zone, ok);
170 if (!*ok) return; 176 if (!*ok) return;
171 } 177 }
172 } 178 }
173 179
174 // If the new interface is larger than that's, then there were members in 180 // If the new interface is larger than that's, then there were members in
175 // 'this' which 'that' didn't have. If 'that' was frozen that is an error. 181 // 'this' which 'that' didn't have. If 'that' was frozen that is an error.
176 int this_size = this->exports_ == NULL ? 0 : this->exports_->occupancy(); 182 int this_size = this->exports_ == NULL ? 0 : this->exports_->occupancy();
177 int that_size = map == NULL ? 0 : map->occupancy(); 183 int that_size = map == NULL ? 0 : map->occupancy();
178 if (that->IsFrozen() && this_size > that_size) { 184 if (that->IsFrozen() && this_size > that_size) {
179 *ok = false; 185 *ok = false;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 PrintF("%*s%s : ", n0 + 2, "", name->ToAsciiArray()); 232 PrintF("%*s%s : ", n0 + 2, "", name->ToAsciiArray());
227 interface->Print(n0 + 2); 233 interface->Print(n0 + 2);
228 } 234 }
229 PrintF("%*s}\n", n0, ""); 235 PrintF("%*s}\n", n0, "");
230 } 236 }
231 } 237 }
232 } 238 }
233 #endif 239 #endif
234 240
235 } } // namespace v8::internal 241 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/interface.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698