| OLD | NEW |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 class SCTableReference; | 45 class SCTableReference; |
| 46 | 46 |
| 47 class StubCache { | 47 class StubCache { |
| 48 public: | 48 public: |
| 49 struct Entry { | 49 struct Entry { |
| 50 String* key; | 50 String* key; |
| 51 Code* value; | 51 Code* value; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 | 54 |
| 55 static void Initialize(bool create_heap_objects); | 55 void Initialize(bool create_heap_objects); |
| 56 | 56 |
| 57 // Computes the right stub matching. Inserts the result in the | 57 // Computes the right stub matching. Inserts the result in the |
| 58 // cache before returning. This might compile a stub if needed. | 58 // cache before returning. This might compile a stub if needed. |
| 59 static Object* ComputeLoadNonexistent(String* name, JSObject* receiver); | 59 Object* ComputeLoadNonexistent(String* name, JSObject* receiver); |
| 60 | 60 |
| 61 static Object* ComputeLoadField(String* name, | 61 Object* ComputeLoadField(String* name, |
| 62 JSObject* receiver, | 62 JSObject* receiver, |
| 63 JSObject* holder, | 63 JSObject* holder, |
| 64 int field_index); | 64 int field_index); |
| 65 | 65 |
| 66 static Object* ComputeLoadCallback(String* name, | 66 Object* ComputeLoadCallback(String* name, |
| 67 JSObject* receiver, | 67 JSObject* receiver, |
| 68 JSObject* holder, | 68 JSObject* holder, |
| 69 AccessorInfo* callback); | 69 AccessorInfo* callback); |
| 70 | 70 |
| 71 static Object* ComputeLoadConstant(String* name, | 71 Object* ComputeLoadConstant(String* name, |
| 72 JSObject* receiver, | 72 JSObject* receiver, |
| 73 JSObject* holder, | 73 JSObject* holder, |
| 74 Object* value); | 74 Object* value); |
| 75 | 75 |
| 76 static Object* ComputeLoadInterceptor(String* name, | 76 Object* ComputeLoadInterceptor(String* name, |
| 77 JSObject* receiver, | 77 JSObject* receiver, |
| 78 JSObject* holder); | 78 JSObject* holder); |
| 79 | 79 |
| 80 static Object* ComputeLoadNormal(String* name, JSObject* receiver); | 80 Object* ComputeLoadNormal(String* name, JSObject* receiver); |
| 81 | 81 |
| 82 | 82 |
| 83 static Object* ComputeLoadGlobal(String* name, | 83 Object* ComputeLoadGlobal(String* name, |
| 84 JSObject* receiver, | 84 JSObject* receiver, |
| 85 GlobalObject* holder, | 85 GlobalObject* holder, |
| 86 JSGlobalPropertyCell* cell, | 86 JSGlobalPropertyCell* cell, |
| 87 bool is_dont_delete); | 87 bool is_dont_delete); |
| 88 | 88 |
| 89 | 89 |
| 90 // --- | 90 // --- |
| 91 | 91 |
| 92 static Object* ComputeKeyedLoadField(String* name, | 92 Object* ComputeKeyedLoadField(String* name, |
| 93 JSObject* receiver, | 93 JSObject* receiver, |
| 94 JSObject* holder, | 94 JSObject* holder, |
| 95 int field_index); | 95 int field_index); |
| 96 | 96 |
| 97 static Object* ComputeKeyedLoadCallback(String* name, | 97 Object* ComputeKeyedLoadCallback(String* name, |
| 98 JSObject* receiver, | 98 JSObject* receiver, |
| 99 JSObject* holder, | 99 JSObject* holder, |
| 100 AccessorInfo* callback); | 100 AccessorInfo* callback); |
| 101 | 101 |
| 102 static Object* ComputeKeyedLoadConstant(String* name, JSObject* receiver, | 102 Object* ComputeKeyedLoadConstant(String* name, JSObject* receiver, |
| 103 JSObject* holder, Object* value); | 103 JSObject* holder, Object* value); |
| 104 | 104 |
| 105 static Object* ComputeKeyedLoadInterceptor(String* name, | 105 Object* ComputeKeyedLoadInterceptor(String* name, |
| 106 JSObject* receiver, | 106 JSObject* receiver, |
| 107 JSObject* holder); | 107 JSObject* holder); |
| 108 | 108 |
| 109 static Object* ComputeKeyedLoadArrayLength(String* name, JSArray* receiver); | 109 Object* ComputeKeyedLoadArrayLength(String* name, JSArray* receiver); |
| 110 | 110 |
| 111 static Object* ComputeKeyedLoadStringLength(String* name, | 111 Object* ComputeKeyedLoadStringLength(String* name, |
| 112 String* receiver); | 112 String* receiver); |
| 113 | 113 |
| 114 static Object* ComputeKeyedLoadFunctionPrototype(String* name, | 114 Object* ComputeKeyedLoadFunctionPrototype(String* name, |
| 115 JSFunction* receiver); | 115 JSFunction* receiver); |
| 116 | 116 |
| 117 // --- | 117 // --- |
| 118 | 118 |
| 119 static Object* ComputeStoreField(String* name, | 119 Object* ComputeStoreField(String* name, |
| 120 JSObject* receiver, | 120 JSObject* receiver, |
| 121 int field_index, | 121 int field_index, |
| 122 Map* transition = NULL); | 122 Map* transition = NULL); |
| 123 | 123 |
| 124 static Object* ComputeStoreGlobal(String* name, | 124 Object* ComputeStoreGlobal(String* name, |
| 125 GlobalObject* receiver, | 125 GlobalObject* receiver, |
| 126 JSGlobalPropertyCell* cell); | 126 JSGlobalPropertyCell* cell); |
| 127 | 127 |
| 128 static Object* ComputeStoreCallback(String* name, | 128 Object* ComputeStoreCallback(String* name, |
| 129 JSObject* receiver, | 129 JSObject* receiver, |
| 130 AccessorInfo* callback); | 130 AccessorInfo* callback); |
| 131 | 131 |
| 132 static Object* ComputeStoreInterceptor(String* name, JSObject* receiver); | 132 Object* ComputeStoreInterceptor(String* name, JSObject* receiver); |
| 133 | 133 |
| 134 // --- | 134 // --- |
| 135 | 135 |
| 136 static Object* ComputeKeyedStoreField(String* name, | 136 Object* ComputeKeyedStoreField(String* name, |
| 137 JSObject* receiver, | 137 JSObject* receiver, |
| 138 int field_index, | 138 int field_index, |
| 139 Map* transition = NULL); | 139 Map* transition = NULL); |
| 140 | 140 |
| 141 // --- | 141 // --- |
| 142 | 142 |
| 143 static Object* ComputeCallField(int argc, | 143 Object* ComputeCallField(int argc, |
| 144 InLoopFlag in_loop, | 144 InLoopFlag in_loop, |
| 145 String* name, | 145 String* name, |
| 146 Object* object, | 146 Object* object, |
| 147 JSObject* holder, | 147 JSObject* holder, |
| 148 int index); | 148 int index); |
| 149 | 149 |
| 150 static Object* ComputeCallConstant(int argc, | 150 Object* ComputeCallConstant(int argc, |
| 151 InLoopFlag in_loop, | 151 InLoopFlag in_loop, |
| 152 String* name, | 152 String* name, |
| 153 Object* object, | 153 Object* object, |
| 154 JSObject* holder, | 154 JSObject* holder, |
| 155 JSFunction* function); | 155 JSFunction* function); |
| 156 | 156 |
| 157 static Object* ComputeCallNormal(int argc, | 157 Object* ComputeCallNormal(int argc, |
| 158 InLoopFlag in_loop, | 158 InLoopFlag in_loop, |
| 159 String* name, | 159 String* name, |
| 160 JSObject* receiver); | 160 JSObject* receiver); |
| 161 | 161 |
| 162 static Object* ComputeCallInterceptor(int argc, | 162 Object* ComputeCallInterceptor(int argc, |
| 163 String* name, | 163 String* name, |
| 164 Object* object, | 164 Object* object, |
| 165 JSObject* holder); | 165 JSObject* holder); |
| 166 | 166 |
| 167 static 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 static Object* ComputeCallInitialize(int argc, InLoopFlag in_loop); |
| 178 static Object* ComputeCallPreMonomorphic(int argc, InLoopFlag in_loop); | 178 static Object* ComputeCallPreMonomorphic(int argc, InLoopFlag in_loop); |
| 179 static Object* ComputeCallNormal(int argc, InLoopFlag in_loop); | 179 static Object* ComputeCallNormal(int argc, InLoopFlag in_loop); |
| 180 static Object* ComputeCallMegamorphic(int argc, InLoopFlag in_loop); | 180 static Object* ComputeCallMegamorphic(int argc, InLoopFlag in_loop); |
| 181 static Object* ComputeCallMiss(int argc); | 181 static 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(). |
| (...skipping 25 matching lines...) Expand all Loading... |
| 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 static 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 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 static 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 |
| 274 DISALLOW_COPY_AND_ASSIGN(StubCache); |
| 273 }; | 275 }; |
| 274 | 276 |
| 275 | 277 |
| 276 class SCTableReference { | 278 class SCTableReference { |
| 277 public: | 279 public: |
| 278 static SCTableReference keyReference(StubCache::Table table) { | 280 static SCTableReference keyReference(StubCache::Table table) { |
| 279 return SCTableReference( | 281 return SCTableReference( |
| 280 reinterpret_cast<Address>(&first_entry(table)->key)); | 282 reinterpret_cast<Address>(&first_entry(table)->key)); |
| 281 } | 283 } |
| 282 | 284 |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 | 697 |
| 696 JSFunction* constant_function_; | 698 JSFunction* constant_function_; |
| 697 bool is_simple_api_call_; | 699 bool is_simple_api_call_; |
| 698 FunctionTemplateInfo* expected_receiver_type_; | 700 FunctionTemplateInfo* expected_receiver_type_; |
| 699 CallHandlerInfo* api_call_info_; | 701 CallHandlerInfo* api_call_info_; |
| 700 }; | 702 }; |
| 701 | 703 |
| 702 } } // namespace v8::internal | 704 } } // namespace v8::internal |
| 703 | 705 |
| 704 #endif // V8_STUB_CACHE_H_ | 706 #endif // V8_STUB_CACHE_H_ |
| OLD | NEW |