OLD | NEW |
---|---|
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 if (probe->IsCode()) return Handle<Code>::cast(probe); | 110 if (probe->IsCode()) return Handle<Code>::cast(probe); |
111 return Handle<Code>::null(); | 111 return Handle<Code>::null(); |
112 } | 112 } |
113 | 113 |
114 | 114 |
115 Handle<Code> StubCache::FindHandler(Handle<Name> name, | 115 Handle<Code> StubCache::FindHandler(Handle<Name> name, |
116 Handle<Map> stub_holder, | 116 Handle<Map> stub_holder, |
117 Code::Kind kind, | 117 Code::Kind kind, |
118 InlineCacheHolderFlag cache_holder, | 118 InlineCacheHolderFlag cache_holder, |
119 StrictModeFlag strict_mode) { | 119 StrictModeFlag strict_mode) { |
120 Code::ExtraICState extra_ic_state = Code::kNoExtraICState; | 120 Code::ExtraICState extra_ic_state = IC::kNoExtraICState; |
121 if (kind == Code::STORE_IC || kind == Code::KEYED_STORE_IC) { | 121 if (kind == Code::STORE_IC) { |
122 extra_ic_state = Code::ComputeExtraICState( | 122 extra_ic_state = StoreIC::ComputeExtraICState(strict_mode); |
123 STANDARD_STORE, strict_mode); | 123 } else if (kind == Code::KEYED_STORE_IC) { |
124 extra_ic_state = KeyedStoreIC::ComputeExtraICState(strict_mode, | |
125 STANDARD_STORE); | |
124 } | 126 } |
125 Code::Flags flags = Code::ComputeMonomorphicFlags( | 127 Code::Flags flags = Code::ComputeMonomorphicFlags( |
126 Code::HANDLER, extra_ic_state, cache_holder, Code::NORMAL, kind); | 128 Code::HANDLER, extra_ic_state, cache_holder, Code::NORMAL, kind); |
127 | 129 |
128 Handle<Object> probe(stub_holder->FindInCodeCache(*name, flags), isolate_); | 130 Handle<Object> probe(stub_holder->FindInCodeCache(*name, flags), isolate_); |
129 if (probe->IsCode()) return Handle<Code>::cast(probe); | 131 if (probe->IsCode()) return Handle<Code>::cast(probe); |
130 return Handle<Code>::null(); | 132 return Handle<Code>::null(); |
131 } | 133 } |
132 | 134 |
133 | 135 |
134 Handle<Code> StubCache::ComputeMonomorphicIC(Handle<Name> name, | 136 Handle<Code> StubCache::ComputeMonomorphicIC( |
135 Handle<Type> type, | 137 Handle<Name> name, |
136 Handle<Code> handler, | 138 Handle<Type> type, |
137 StrictModeFlag strict_mode) { | 139 Handle<Code> handler, |
140 Code::ExtraICState extra_ic_state) { | |
138 Code::Kind kind = handler->handler_kind(); | 141 Code::Kind kind = handler->handler_kind(); |
139 InlineCacheHolderFlag flag = IC::GetCodeCacheFlag(*type); | 142 InlineCacheHolderFlag flag = IC::GetCodeCacheFlag(*type); |
140 | 143 |
141 Handle<Map> stub_holder; | 144 Handle<Map> stub_holder; |
142 Handle<Code> ic; | 145 Handle<Code> ic; |
143 // There are multiple string maps that all use the same prototype. That | 146 // There are multiple string maps that all use the same prototype. That |
144 // prototype cannot hold multiple handlers, one for each of the string maps, | 147 // prototype cannot hold multiple handlers, one for each of the string maps, |
145 // for a single name. Hence, turn off caching of the IC. | 148 // for a single name. Hence, turn off caching of the IC. |
146 bool can_be_cached = !type->Is(Type::String()); | 149 bool can_be_cached = !type->Is(Type::String()); |
147 if (can_be_cached) { | 150 if (can_be_cached) { |
148 stub_holder = IC::GetCodeCacheHolder(flag, *type, isolate()); | 151 stub_holder = IC::GetCodeCacheHolder(flag, *type, isolate()); |
149 ic = FindIC(name, stub_holder, kind, strict_mode, flag); | 152 ic = FindIC(name, stub_holder, kind, extra_ic_state, flag); |
150 if (!ic.is_null()) return ic; | 153 if (!ic.is_null()) return ic; |
151 } | 154 } |
152 | 155 |
153 if (kind == Code::LOAD_IC) { | 156 if (kind == Code::LOAD_IC) { |
154 LoadStubCompiler ic_compiler(isolate(), flag); | 157 LoadStubCompiler ic_compiler(isolate(), flag); |
155 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); | 158 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); |
156 } else if (kind == Code::KEYED_LOAD_IC) { | 159 } else if (kind == Code::KEYED_LOAD_IC) { |
157 KeyedLoadStubCompiler ic_compiler(isolate(), flag); | 160 KeyedLoadStubCompiler ic_compiler(isolate(), flag); |
158 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); | 161 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); |
159 } else if (kind == Code::STORE_IC) { | 162 } else if (kind == Code::STORE_IC) { |
163 StrictModeFlag strict_mode = StoreIC::GetStrictMode(extra_ic_state); | |
160 StoreStubCompiler ic_compiler(isolate(), strict_mode); | 164 StoreStubCompiler ic_compiler(isolate(), strict_mode); |
161 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); | 165 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); |
162 } else { | 166 } else { |
163 ASSERT(kind == Code::KEYED_STORE_IC); | 167 ASSERT(kind == Code::KEYED_STORE_IC); |
168 StrictModeFlag strict_mode = StoreIC::GetStrictMode(extra_ic_state); | |
164 KeyedStoreStubCompiler ic_compiler(isolate(), strict_mode, STANDARD_STORE); | 169 KeyedStoreStubCompiler ic_compiler(isolate(), strict_mode, STANDARD_STORE); |
165 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); | 170 ic = ic_compiler.CompileMonomorphicIC(type, handler, name); |
166 } | 171 } |
167 | 172 |
168 if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic); | 173 if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic); |
169 return ic; | 174 return ic; |
170 } | 175 } |
171 | 176 |
172 | 177 |
173 Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name, | 178 Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 Map::UpdateCodeCache(receiver_map, name, code); | 223 Map::UpdateCodeCache(receiver_map, name, code); |
219 return code; | 224 return code; |
220 } | 225 } |
221 | 226 |
222 | 227 |
223 Handle<Code> StubCache::ComputeKeyedStoreElement( | 228 Handle<Code> StubCache::ComputeKeyedStoreElement( |
224 Handle<Map> receiver_map, | 229 Handle<Map> receiver_map, |
225 StrictModeFlag strict_mode, | 230 StrictModeFlag strict_mode, |
226 KeyedAccessStoreMode store_mode) { | 231 KeyedAccessStoreMode store_mode) { |
227 Code::ExtraICState extra_state = | 232 Code::ExtraICState extra_state = |
228 Code::ComputeExtraICState(store_mode, strict_mode); | 233 KeyedStoreIC::ComputeExtraICState(strict_mode, store_mode); |
229 Code::Flags flags = Code::ComputeMonomorphicFlags( | 234 Code::Flags flags = Code::ComputeMonomorphicFlags( |
230 Code::KEYED_STORE_IC, extra_state); | 235 Code::KEYED_STORE_IC, extra_state); |
231 | 236 |
232 ASSERT(store_mode == STANDARD_STORE || | 237 ASSERT(store_mode == STANDARD_STORE || |
233 store_mode == STORE_AND_GROW_NO_TRANSITION || | 238 store_mode == STORE_AND_GROW_NO_TRANSITION || |
234 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || | 239 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || |
235 store_mode == STORE_NO_TRANSITION_HANDLE_COW); | 240 store_mode == STORE_NO_TRANSITION_HANDLE_COW); |
236 | 241 |
237 Handle<String> name = | 242 Handle<String> name = |
238 isolate()->factory()->KeyedStoreElementMonomorphic_string(); | 243 isolate()->factory()->KeyedStoreElementMonomorphic_string(); |
239 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_); | 244 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_); |
240 if (probe->IsCode()) return Handle<Code>::cast(probe); | 245 if (probe->IsCode()) return Handle<Code>::cast(probe); |
241 | 246 |
242 KeyedStoreStubCompiler compiler(isolate(), strict_mode, store_mode); | 247 KeyedStoreStubCompiler compiler(isolate(), strict_mode, store_mode); |
243 Handle<Code> code = compiler.CompileStoreElement(receiver_map); | 248 Handle<Code> code = compiler.CompileStoreElement(receiver_map); |
244 | 249 |
245 Map::UpdateCodeCache(receiver_map, name, code); | 250 Map::UpdateCodeCache(receiver_map, name, code); |
246 ASSERT(Code::GetKeyedAccessStoreMode(code->extra_ic_state()) == store_mode); | 251 ASSERT(KeyedStoreIC::GetKeyedAccessStoreMode(code->extra_ic_state()) |
252 == store_mode); | |
247 return code; | 253 return code; |
248 } | 254 } |
249 | 255 |
250 | 256 |
251 #define CALL_LOGGER_TAG(kind, type) \ | 257 #define CALL_LOGGER_TAG(kind, type) \ |
252 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) | 258 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) |
253 | 259 |
254 Handle<Code> StubCache::ComputeCallConstant(int argc, | 260 Handle<Code> StubCache::ComputeCallConstant(int argc, |
255 Code::Kind kind, | 261 Code::Kind kind, |
256 Code::ExtraICState extra_state, | 262 Code::ExtraICState extra_state, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
417 code); | 423 code); |
418 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); | 424 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); |
419 } | 425 } |
420 | 426 |
421 | 427 |
422 Code* StubCache::FindCallInitialize(int argc, | 428 Code* StubCache::FindCallInitialize(int argc, |
423 RelocInfo::Mode mode, | 429 RelocInfo::Mode mode, |
424 Code::Kind kind) { | 430 Code::Kind kind) { |
425 Code::ExtraICState extra_state = | 431 Code::ExtraICState extra_state = |
426 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | | 432 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | |
427 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT); | 433 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT |
434 ? CONTEXTUAL : NOT_CONTEXTUAL); | |
428 Code::Flags flags = | 435 Code::Flags flags = |
429 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); | 436 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); |
430 UnseededNumberDictionary* dictionary = | 437 UnseededNumberDictionary* dictionary = |
431 isolate()->heap()->non_monomorphic_cache(); | 438 isolate()->heap()->non_monomorphic_cache(); |
432 int entry = dictionary->FindEntry(isolate(), flags); | 439 int entry = dictionary->FindEntry(isolate(), flags); |
433 ASSERT(entry != -1); | 440 ASSERT(entry != -1); |
434 Object* code = dictionary->ValueAt(entry); | 441 Object* code = dictionary->ValueAt(entry); |
435 // This might be called during the marking phase of the collector | 442 // This might be called during the marking phase of the collector |
436 // hence the unchecked cast. | 443 // hence the unchecked cast. |
437 return reinterpret_cast<Code*>(code); | 444 return reinterpret_cast<Code*>(code); |
438 } | 445 } |
439 | 446 |
440 | 447 |
441 Handle<Code> StubCache::ComputeCallInitialize(int argc, | 448 Handle<Code> StubCache::ComputeCallInitialize(int argc, |
442 RelocInfo::Mode mode, | 449 RelocInfo::Mode mode, |
443 Code::Kind kind) { | 450 Code::Kind kind) { |
444 Code::ExtraICState extra_state = | 451 Code::ExtraICState extra_state = |
445 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | | 452 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | |
446 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT); | 453 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT |
454 ? CONTEXTUAL : NOT_CONTEXTUAL); | |
Toon Verwaest
2013/11/28 09:58:47
nit: indent by 4 extra spaces
mvstanton
2013/11/28 11:23:11
Fixed in both places.
| |
447 Code::Flags flags = | 455 Code::Flags flags = |
448 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); | 456 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, Code::NORMAL, argc); |
449 Handle<UnseededNumberDictionary> cache = | 457 Handle<UnseededNumberDictionary> cache = |
450 isolate_->factory()->non_monomorphic_cache(); | 458 isolate_->factory()->non_monomorphic_cache(); |
451 int entry = cache->FindEntry(isolate_, flags); | 459 int entry = cache->FindEntry(isolate_, flags); |
452 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); | 460 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
453 | 461 |
454 StubCompiler compiler(isolate_); | 462 StubCompiler compiler(isolate_); |
455 Handle<Code> code = compiler.CompileCallInitialize(flags); | 463 Handle<Code> code = compiler.CompileCallInitialize(flags); |
456 FillCache(isolate_, code); | 464 FillCache(isolate_, code); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
500 StubCompiler compiler(isolate_); | 508 StubCompiler compiler(isolate_); |
501 Handle<Code> code = compiler.CompileCallNormal(flags); | 509 Handle<Code> code = compiler.CompileCallNormal(flags); |
502 FillCache(isolate_, code); | 510 FillCache(isolate_, code); |
503 return code; | 511 return code; |
504 } | 512 } |
505 | 513 |
506 | 514 |
507 Handle<Code> StubCache::ComputeCallArguments(int argc) { | 515 Handle<Code> StubCache::ComputeCallArguments(int argc) { |
508 Code::Flags flags = | 516 Code::Flags flags = |
509 Code::ComputeFlags(Code::KEYED_CALL_IC, MEGAMORPHIC, | 517 Code::ComputeFlags(Code::KEYED_CALL_IC, MEGAMORPHIC, |
510 Code::kNoExtraICState, Code::NORMAL, argc); | 518 IC::kNoExtraICState, Code::NORMAL, argc); |
511 Handle<UnseededNumberDictionary> cache = | 519 Handle<UnseededNumberDictionary> cache = |
512 isolate_->factory()->non_monomorphic_cache(); | 520 isolate_->factory()->non_monomorphic_cache(); |
513 int entry = cache->FindEntry(isolate_, flags); | 521 int entry = cache->FindEntry(isolate_, flags); |
514 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); | 522 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
515 | 523 |
516 StubCompiler compiler(isolate_); | 524 StubCompiler compiler(isolate_); |
517 Handle<Code> code = compiler.CompileCallArguments(flags); | 525 Handle<Code> code = compiler.CompileCallArguments(flags); |
518 FillCache(isolate_, code); | 526 FillCache(isolate_, code); |
519 return code; | 527 return code; |
520 } | 528 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 Handle<Code> StubCache::ComputeStoreElementPolymorphic( | 638 Handle<Code> StubCache::ComputeStoreElementPolymorphic( |
631 MapHandleList* receiver_maps, | 639 MapHandleList* receiver_maps, |
632 KeyedAccessStoreMode store_mode, | 640 KeyedAccessStoreMode store_mode, |
633 StrictModeFlag strict_mode) { | 641 StrictModeFlag strict_mode) { |
634 ASSERT(store_mode == STANDARD_STORE || | 642 ASSERT(store_mode == STANDARD_STORE || |
635 store_mode == STORE_AND_GROW_NO_TRANSITION || | 643 store_mode == STORE_AND_GROW_NO_TRANSITION || |
636 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || | 644 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || |
637 store_mode == STORE_NO_TRANSITION_HANDLE_COW); | 645 store_mode == STORE_NO_TRANSITION_HANDLE_COW); |
638 Handle<PolymorphicCodeCache> cache = | 646 Handle<PolymorphicCodeCache> cache = |
639 isolate_->factory()->polymorphic_code_cache(); | 647 isolate_->factory()->polymorphic_code_cache(); |
640 Code::ExtraICState extra_state = Code::ComputeExtraICState(store_mode, | 648 Code::ExtraICState extra_state = KeyedStoreIC::ComputeExtraICState( |
641 strict_mode); | 649 strict_mode, store_mode); |
642 Code::Flags flags = | 650 Code::Flags flags = |
643 Code::ComputeFlags(Code::KEYED_STORE_IC, POLYMORPHIC, extra_state); | 651 Code::ComputeFlags(Code::KEYED_STORE_IC, POLYMORPHIC, extra_state); |
644 Handle<Object> probe = cache->Lookup(receiver_maps, flags); | 652 Handle<Object> probe = cache->Lookup(receiver_maps, flags); |
645 if (probe->IsCode()) return Handle<Code>::cast(probe); | 653 if (probe->IsCode()) return Handle<Code>::cast(probe); |
646 | 654 |
647 KeyedStoreStubCompiler compiler(isolate_, strict_mode, store_mode); | 655 KeyedStoreStubCompiler compiler(isolate_, strict_mode, store_mode); |
648 Handle<Code> code = compiler.CompileStoreElementPolymorphic(receiver_maps); | 656 Handle<Code> code = compiler.CompileStoreElementPolymorphic(receiver_maps); |
649 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); | 657 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); |
650 return code; | 658 return code; |
651 } | 659 } |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1068 } | 1076 } |
1069 | 1077 |
1070 | 1078 |
1071 Handle<Code> StubCompiler::CompileCallDebugPrepareStepIn(Code::Flags flags) { | 1079 Handle<Code> StubCompiler::CompileCallDebugPrepareStepIn(Code::Flags flags) { |
1072 // Use the same code for the the step in preparations as we do for the | 1080 // Use the same code for the the step in preparations as we do for the |
1073 // miss case. | 1081 // miss case. |
1074 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1082 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
1075 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1083 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
1076 if (kind == Code::CALL_IC) { | 1084 if (kind == Code::CALL_IC) { |
1077 // For the debugger extra ic state is irrelevant. | 1085 // For the debugger extra ic state is irrelevant. |
1078 CallIC::GenerateMiss(masm(), argc, Code::kNoExtraICState); | 1086 CallIC::GenerateMiss(masm(), argc, IC::kNoExtraICState); |
1079 } else { | 1087 } else { |
1080 KeyedCallIC::GenerateMiss(masm(), argc); | 1088 KeyedCallIC::GenerateMiss(masm(), argc); |
1081 } | 1089 } |
1082 Handle<Code> code = GetCodeWithFlags(flags, "CompileCallDebugPrepareStepIn"); | 1090 Handle<Code> code = GetCodeWithFlags(flags, "CompileCallDebugPrepareStepIn"); |
1083 PROFILE(isolate(), | 1091 PROFILE(isolate(), |
1084 CodeCreateEvent( | 1092 CodeCreateEvent( |
1085 CALL_LOGGER_TAG(kind, CALL_DEBUG_PREPARE_STEP_IN_TAG), | 1093 CALL_LOGGER_TAG(kind, CALL_DEBUG_PREPARE_STEP_IN_TAG), |
1086 *code, | 1094 *code, |
1087 code->arguments_count())); | 1095 code->arguments_count())); |
1088 return code; | 1096 return code; |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1833 Handle<FunctionTemplateInfo>( | 1841 Handle<FunctionTemplateInfo>( |
1834 FunctionTemplateInfo::cast(signature->receiver())); | 1842 FunctionTemplateInfo::cast(signature->receiver())); |
1835 } | 1843 } |
1836 } | 1844 } |
1837 | 1845 |
1838 is_simple_api_call_ = true; | 1846 is_simple_api_call_ = true; |
1839 } | 1847 } |
1840 | 1848 |
1841 | 1849 |
1842 } } // namespace v8::internal | 1850 } } // namespace v8::internal |
OLD | NEW |