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

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

Issue 2862032: [Isolates] Move more statics (part IV) (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 10 years, 5 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/string-stream.cc ('k') | src/stub-cache.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 24 matching lines...) Expand all
35 35
36 36
37 // The stub cache is used for megamorphic calls and property accesses. 37 // The stub cache is used for megamorphic calls and property accesses.
38 // It maps (map, name, type)->Code* 38 // It maps (map, name, type)->Code*
39 39
40 // The design of the table uses the inline cache stubs used for 40 // The design of the table uses the inline cache stubs used for
41 // mono-morphic calls. The beauty of this, we do not have to 41 // mono-morphic calls. The beauty of this, we do not have to
42 // invalidate the cache whenever a prototype map is changed. The stub 42 // invalidate the cache whenever a prototype map is changed. The stub
43 // validates the map chain as in the mono-morphic case. 43 // validates the map chain as in the mono-morphic case.
44 44
45 class SCTableReference; 45 class StubCache;
46
47 class SCTableReference {
48 public:
49 Address address() const { return address_; }
50
51 private:
52 explicit SCTableReference(Address address) : address_(address) {}
53
54 Address address_;
55
56 friend class StubCache;
57 };
58
46 59
47 class StubCache { 60 class StubCache {
48 public: 61 public:
49 struct Entry { 62 struct Entry {
50 String* key; 63 String* key;
51 Code* value; 64 Code* value;
52 }; 65 };
53 66
54
55 void Initialize(bool create_heap_objects); 67 void Initialize(bool create_heap_objects);
56 68
57 // Computes the right stub matching. Inserts the result in the 69 // Computes the right stub matching. Inserts the result in the
58 // cache before returning. This might compile a stub if needed. 70 // cache before returning. This might compile a stub if needed.
59 Object* ComputeLoadNonexistent(String* name, JSObject* receiver); 71 Object* ComputeLoadNonexistent(String* name, JSObject* receiver);
60 72
61 Object* ComputeLoadField(String* name, 73 Object* ComputeLoadField(String* name,
62 JSObject* receiver, 74 JSObject* receiver,
63 JSObject* holder, 75 JSObject* holder,
64 int field_index); 76 int field_index);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 Register receiver, 236 Register receiver,
225 Register name, 237 Register name,
226 Register scratch, 238 Register scratch,
227 Register extra); 239 Register extra);
228 240
229 enum Table { 241 enum Table {
230 kPrimary, 242 kPrimary,
231 kSecondary 243 kSecondary
232 }; 244 };
233 245
246
247 SCTableReference key_reference(StubCache::Table table) {
248 return SCTableReference(
249 reinterpret_cast<Address>(&first_entry(table)->key));
250 }
251
252
253 SCTableReference value_reference(StubCache::Table table) {
254 return SCTableReference(
255 reinterpret_cast<Address>(&first_entry(table)->value));
256 }
257
258
259 StubCache::Entry* first_entry(StubCache::Table table) {
260 switch (table) {
261 case StubCache::kPrimary: return StubCache::primary_;
262 case StubCache::kSecondary: return StubCache::secondary_;
263 }
264 UNREACHABLE();
265 return NULL;
266 }
267
268
234 private: 269 private:
235 StubCache(); 270 StubCache();
236 271
237 friend class Isolate; 272 friend class Isolate;
238 friend class SCTableReference; 273 friend class SCTableReference;
239 static const int kPrimaryTableSize = 2048; 274 static const int kPrimaryTableSize = 2048;
240 static const int kSecondaryTableSize = 512; 275 static const int kSecondaryTableSize = 512;
241 static Entry primary_[]; 276 Entry primary_[kPrimaryTableSize];
242 static Entry secondary_[]; 277 Entry secondary_[kSecondaryTableSize];
243 278
244 // Computes the hashed offsets for primary and secondary caches. 279 // Computes the hashed offsets for primary and secondary caches.
245 RLYSTC int PrimaryOffset(String* name, Code::Flags flags, Map* map) { 280 RLYSTC int PrimaryOffset(String* name, Code::Flags flags, Map* map) {
246 // This works well because the heap object tag size and the hash 281 // This works well because the heap object tag size and the hash
247 // shift are equal. Shifting down the length field to get the 282 // shift are equal. Shifting down the length field to get the
248 // hash code would effectively throw away two bits of the hash 283 // hash code would effectively throw away two bits of the hash
249 // code. 284 // code.
250 ASSERT(kHeapObjectTagSize == String::kHashShift); 285 ASSERT(kHeapObjectTagSize == String::kHashShift);
251 // Compute the hash of the name (use entire hash field). 286 // Compute the hash of the name (use entire hash field).
252 ASSERT(name->HasHashCode()); 287 ASSERT(name->HasHashCode());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 RLYSTC Entry* entry(Entry* table, int offset) { 320 RLYSTC Entry* entry(Entry* table, int offset) {
286 const int shift_amount = kPointerSizeLog2 + 1 - String::kHashShift; 321 const int shift_amount = kPointerSizeLog2 + 1 - String::kHashShift;
287 return reinterpret_cast<Entry*>( 322 return reinterpret_cast<Entry*>(
288 reinterpret_cast<Address>(table) + (offset << shift_amount)); 323 reinterpret_cast<Address>(table) + (offset << shift_amount));
289 } 324 }
290 325
291 DISALLOW_COPY_AND_ASSIGN(StubCache); 326 DISALLOW_COPY_AND_ASSIGN(StubCache);
292 }; 327 };
293 328
294 329
295 class SCTableReference {
296 public:
297 static SCTableReference keyReference(StubCache::Table table) {
298 return SCTableReference(
299 reinterpret_cast<Address>(&first_entry(table)->key));
300 }
301
302
303 static SCTableReference valueReference(StubCache::Table table) {
304 return SCTableReference(
305 reinterpret_cast<Address>(&first_entry(table)->value));
306 }
307
308 Address address() const { return address_; }
309
310 private:
311 explicit SCTableReference(Address address) : address_(address) {}
312
313 static StubCache::Entry* first_entry(StubCache::Table table) {
314 switch (table) {
315 case StubCache::kPrimary: return StubCache::primary_;
316 case StubCache::kSecondary: return StubCache::secondary_;
317 }
318 UNREACHABLE();
319 return NULL;
320 }
321
322 Address address_;
323 };
324
325 // ------------------------------------------------------------------------ 330 // ------------------------------------------------------------------------
326 331
327 332
328 // Support functions for IC stubs for callbacks. 333 // Support functions for IC stubs for callbacks.
329 Object* LoadCallbackProperty(Arguments args); 334 Object* LoadCallbackProperty(Arguments args);
330 Object* StoreCallbackProperty(Arguments args); 335 Object* StoreCallbackProperty(Arguments args);
331 336
332 337
333 // Support functions for IC stubs for interceptors. 338 // Support functions for IC stubs for interceptors.
334 Object* LoadPropertyWithInterceptorOnly(Arguments args); 339 Object* LoadPropertyWithInterceptorOnly(Arguments args);
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 733
729 JSFunction* constant_function_; 734 JSFunction* constant_function_;
730 bool is_simple_api_call_; 735 bool is_simple_api_call_;
731 FunctionTemplateInfo* expected_receiver_type_; 736 FunctionTemplateInfo* expected_receiver_type_;
732 CallHandlerInfo* api_call_info_; 737 CallHandlerInfo* api_call_info_;
733 }; 738 };
734 739
735 } } // namespace v8::internal 740 } } // namespace v8::internal
736 741
737 #endif // V8_STUB_CACHE_H_ 742 #endif // V8_STUB_CACHE_H_
OLDNEW
« no previous file with comments | « src/string-stream.cc ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698