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

Side by Side Diff: src/stub-cache.h

Issue 2493001: - Continue removing [static] qualifier from StubCache. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 10 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/isolate.h ('k') | src/x64/ic-x64.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 Object* ComputeCallGlobal(int argc, 167 Object* ComputeCallGlobal(int argc,
168 InLoopFlag in_loop, 168 InLoopFlag in_loop,
169 String* name, 169 String* name,
170 JSObject* receiver, 170 JSObject* receiver,
171 GlobalObject* holder, 171 GlobalObject* holder,
172 JSGlobalPropertyCell* cell, 172 JSGlobalPropertyCell* cell,
173 JSFunction* function); 173 JSFunction* function);
174 174
175 // --- 175 // ---
176 176
177 static Object* ComputeCallInitialize(int argc, InLoopFlag in_loop); 177 Object* ComputeCallInitialize(int argc, InLoopFlag in_loop);
178 static Object* ComputeCallPreMonomorphic(int argc, InLoopFlag in_loop); 178 Object* ComputeCallPreMonomorphic(int argc, InLoopFlag in_loop);
179 Object* ComputeCallNormal(int argc, InLoopFlag in_loop); 179 Object* ComputeCallNormal(int argc, InLoopFlag in_loop);
180 Object* ComputeCallMegamorphic(int argc, InLoopFlag in_loop); 180 Object* ComputeCallMegamorphic(int argc, InLoopFlag in_loop);
181 Object* ComputeCallMiss(int argc); 181 Object* ComputeCallMiss(int argc);
182 182
183 // Finds the Code object stored in the Heap::non_monomorphic_cache(). 183 // Finds the Code object stored in the Heap::non_monomorphic_cache().
184 Code* FindCallInitialize(int argc, InLoopFlag in_loop); 184 Code* FindCallInitialize(int argc, InLoopFlag in_loop);
185 185
186 #ifdef ENABLE_DEBUGGER_SUPPORT 186 #ifdef ENABLE_DEBUGGER_SUPPORT
187 Object* ComputeCallDebugBreak(int argc); 187 Object* ComputeCallDebugBreak(int argc);
188 Object* ComputeCallDebugPrepareStepIn(int argc); 188 Object* ComputeCallDebugPrepareStepIn(int argc);
189 #endif 189 #endif
190 190
191 static Object* ComputeLazyCompile(int argc); 191 Object* ComputeLazyCompile(int argc);
192 192
193 193
194 // Update cache for entry hash(name, map). 194 // Update cache for entry hash(name, map).
195 static Code* Set(String* name, Map* map, Code* code); 195 Code* Set(String* name, Map* map, Code* code);
196 196
197 // Clear the lookup table (@ mark compact collection). 197 // Clear the lookup table (@ mark compact collection).
198 void Clear(); 198 void Clear();
199 199
200 // Functions for generating stubs at startup. 200 // Functions for generating stubs at startup.
201 static void GenerateMiss(MacroAssembler* masm); 201 void GenerateMiss(MacroAssembler* masm);
202 202
203 // Generate code for probing the stub cache table. 203 // Generate code for probing the stub cache table.
204 // If extra != no_reg it might be used as am extra scratch register. 204 // If extra != no_reg it might be used as am extra scratch register.
205 static void GenerateProbe(MacroAssembler* masm, 205 void GenerateProbe(MacroAssembler* masm,
206 Code::Flags flags, 206 Code::Flags flags,
207 Register receiver, 207 Register receiver,
208 Register name, 208 Register name,
209 Register scratch, 209 Register scratch,
210 Register extra); 210 Register extra);
211 211
212 enum Table { 212 enum Table {
213 kPrimary, 213 kPrimary,
214 kSecondary 214 kSecondary
215 }; 215 };
216 216
217 private: 217 private:
218 StubCache(); 218 StubCache();
219 219
220 friend class Isolate; 220 friend class Isolate;
221 friend class SCTableReference; 221 friend class SCTableReference;
222 static const int kPrimaryTableSize = 2048; 222 static const int kPrimaryTableSize = 2048;
223 static const int kSecondaryTableSize = 512; 223 static const int kSecondaryTableSize = 512;
224 static Entry primary_[]; 224 static Entry primary_[];
225 static Entry secondary_[]; 225 static Entry secondary_[];
226 226
227 // Computes the hashed offsets for primary and secondary caches. 227 // Computes the hashed offsets for primary and secondary caches.
228 static int PrimaryOffset(String* name, Code::Flags flags, Map* map) { 228 RLYSTC int PrimaryOffset(String* name, Code::Flags flags, Map* map) {
229 // This works well because the heap object tag size and the hash 229 // This works well because the heap object tag size and the hash
230 // shift are equal. Shifting down the length field to get the 230 // shift are equal. Shifting down the length field to get the
231 // hash code would effectively throw away two bits of the hash 231 // hash code would effectively throw away two bits of the hash
232 // code. 232 // code.
233 ASSERT(kHeapObjectTagSize == String::kHashShift); 233 ASSERT(kHeapObjectTagSize == String::kHashShift);
234 // Compute the hash of the name (use entire hash field). 234 // Compute the hash of the name (use entire hash field).
235 ASSERT(name->HasHashCode()); 235 ASSERT(name->HasHashCode());
236 uint32_t field = name->hash_field(); 236 uint32_t field = name->hash_field();
237 // Using only the low bits in 64-bit mode is unlikely to increase the 237 // Using only the low bits in 64-bit mode is unlikely to increase the
238 // risk of collision even if the heap is spread over an area larger than 238 // risk of collision even if the heap is spread over an area larger than
239 // 4Gb (and not at all if it isn't). 239 // 4Gb (and not at all if it isn't).
240 uint32_t map_low32bits = 240 uint32_t map_low32bits =
241 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map)); 241 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map));
242 // We always set the in_loop bit to zero when generating the lookup code 242 // We always set the in_loop bit to zero when generating the lookup code
243 // so do it here too so the hash codes match. 243 // so do it here too so the hash codes match.
244 uint32_t iflags = 244 uint32_t iflags =
245 (static_cast<uint32_t>(flags) & ~Code::kFlagsNotUsedInLookup); 245 (static_cast<uint32_t>(flags) & ~Code::kFlagsNotUsedInLookup);
246 // Base the offset on a simple combination of name, flags, and map. 246 // Base the offset on a simple combination of name, flags, and map.
247 uint32_t key = (map_low32bits + field) ^ iflags; 247 uint32_t key = (map_low32bits + field) ^ iflags;
248 return key & ((kPrimaryTableSize - 1) << kHeapObjectTagSize); 248 return key & ((kPrimaryTableSize - 1) << kHeapObjectTagSize);
249 } 249 }
250 250
251 static int SecondaryOffset(String* name, Code::Flags flags, int seed) { 251 RLYSTC int SecondaryOffset(String* name, Code::Flags flags, int seed) {
252 // Use the seed from the primary cache in the secondary cache. 252 // Use the seed from the primary cache in the secondary cache.
253 uint32_t string_low32bits = 253 uint32_t string_low32bits =
254 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name)); 254 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name));
255 // We always set the in_loop bit to zero when generating the lookup code 255 // We always set the in_loop bit to zero when generating the lookup code
256 // so do it here too so the hash codes match. 256 // so do it here too so the hash codes match.
257 uint32_t iflags = 257 uint32_t iflags =
258 (static_cast<uint32_t>(flags) & ~Code::kFlagsICInLoopMask); 258 (static_cast<uint32_t>(flags) & ~Code::kFlagsICInLoopMask);
259 uint32_t key = seed - string_low32bits + iflags; 259 uint32_t key = seed - string_low32bits + iflags;
260 return key & ((kSecondaryTableSize - 1) << kHeapObjectTagSize); 260 return key & ((kSecondaryTableSize - 1) << kHeapObjectTagSize);
261 } 261 }
262 262
263 // Compute the entry for a given offset in exactly the same way as 263 // Compute the entry for a given offset in exactly the same way as
264 // we do in generated code. We generate an hash code that already 264 // we do in generated code. We generate an hash code that already
265 // ends in String::kHashShift 0s. Then we shift it so it is a multiple 265 // ends in String::kHashShift 0s. Then we shift it so it is a multiple
266 // of sizeof(Entry). This makes it easier to avoid making mistakes 266 // of sizeof(Entry). This makes it easier to avoid making mistakes
267 // in the hashed offset computations. 267 // in the hashed offset computations.
268 static Entry* entry(Entry* table, int offset) { 268 RLYSTC Entry* entry(Entry* table, int offset) {
269 const int shift_amount = kPointerSizeLog2 + 1 - String::kHashShift; 269 const int shift_amount = kPointerSizeLog2 + 1 - String::kHashShift;
270 return reinterpret_cast<Entry*>( 270 return reinterpret_cast<Entry*>(
271 reinterpret_cast<Address>(table) + (offset << shift_amount)); 271 reinterpret_cast<Address>(table) + (offset << shift_amount));
272 } 272 }
273 273
274 DISALLOW_COPY_AND_ASSIGN(StubCache); 274 DISALLOW_COPY_AND_ASSIGN(StubCache);
275 }; 275 };
276 276
277 277
278 class SCTableReference { 278 class SCTableReference {
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 697
698 JSFunction* constant_function_; 698 JSFunction* constant_function_;
699 bool is_simple_api_call_; 699 bool is_simple_api_call_;
700 FunctionTemplateInfo* expected_receiver_type_; 700 FunctionTemplateInfo* expected_receiver_type_;
701 CallHandlerInfo* api_call_info_; 701 CallHandlerInfo* api_call_info_;
702 }; 702 };
703 703
704 } } // namespace v8::internal 704 } } // namespace v8::internal
705 705
706 #endif // V8_STUB_CACHE_H_ 706 #endif // V8_STUB_CACHE_H_
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/x64/ic-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698