OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 JSObject::GetElementWithInterceptor(receiver, receiver, index)); | 600 JSObject::GetElementWithInterceptor(receiver, receiver, index)); |
601 return *result; | 601 return *result; |
602 } | 602 } |
603 | 603 |
604 | 604 |
605 Handle<Code> StubCompiler::CompileLoadInitialize(Code::Flags flags) { | 605 Handle<Code> StubCompiler::CompileLoadInitialize(Code::Flags flags) { |
606 LoadIC::GenerateInitialize(masm()); | 606 LoadIC::GenerateInitialize(masm()); |
607 Handle<Code> code = GetCodeWithFlags(flags, "CompileLoadInitialize"); | 607 Handle<Code> code = GetCodeWithFlags(flags, "CompileLoadInitialize"); |
608 PROFILE(isolate(), | 608 PROFILE(isolate(), |
609 CodeCreateEvent(Logger::LOAD_INITIALIZE_TAG, *code, 0)); | 609 CodeCreateEvent(Logger::LOAD_INITIALIZE_TAG, *code, 0)); |
610 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *code)); | |
611 return code; | 610 return code; |
612 } | 611 } |
613 | 612 |
614 | 613 |
615 Handle<Code> StubCompiler::CompileLoadPreMonomorphic(Code::Flags flags) { | 614 Handle<Code> StubCompiler::CompileLoadPreMonomorphic(Code::Flags flags) { |
616 LoadIC::GeneratePreMonomorphic(masm()); | 615 LoadIC::GeneratePreMonomorphic(masm()); |
617 Handle<Code> code = GetCodeWithFlags(flags, "CompileLoadPreMonomorphic"); | 616 Handle<Code> code = GetCodeWithFlags(flags, "CompileLoadPreMonomorphic"); |
618 PROFILE(isolate(), | 617 PROFILE(isolate(), |
619 CodeCreateEvent(Logger::LOAD_PREMONOMORPHIC_TAG, *code, 0)); | 618 CodeCreateEvent(Logger::LOAD_PREMONOMORPHIC_TAG, *code, 0)); |
620 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *code)); | |
621 return code; | 619 return code; |
622 } | 620 } |
623 | 621 |
624 | 622 |
625 Handle<Code> StubCompiler::CompileLoadMegamorphic(Code::Flags flags) { | 623 Handle<Code> StubCompiler::CompileLoadMegamorphic(Code::Flags flags) { |
626 LoadIC::GenerateMegamorphic(masm()); | 624 LoadIC::GenerateMegamorphic(masm()); |
627 Handle<Code> code = GetCodeWithFlags(flags, "CompileLoadMegamorphic"); | 625 Handle<Code> code = GetCodeWithFlags(flags, "CompileLoadMegamorphic"); |
628 PROFILE(isolate(), | 626 PROFILE(isolate(), |
629 CodeCreateEvent(Logger::LOAD_MEGAMORPHIC_TAG, *code, 0)); | 627 CodeCreateEvent(Logger::LOAD_MEGAMORPHIC_TAG, *code, 0)); |
630 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *code)); | |
631 return code; | 628 return code; |
632 } | 629 } |
633 | 630 |
634 | 631 |
635 Handle<Code> StubCompiler::CompileStoreInitialize(Code::Flags flags) { | 632 Handle<Code> StubCompiler::CompileStoreInitialize(Code::Flags flags) { |
636 StoreIC::GenerateInitialize(masm()); | 633 StoreIC::GenerateInitialize(masm()); |
637 Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreInitialize"); | 634 Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreInitialize"); |
638 PROFILE(isolate(), | 635 PROFILE(isolate(), |
639 CodeCreateEvent(Logger::STORE_INITIALIZE_TAG, *code, 0)); | 636 CodeCreateEvent(Logger::STORE_INITIALIZE_TAG, *code, 0)); |
640 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *code)); | |
641 return code; | 637 return code; |
642 } | 638 } |
643 | 639 |
644 | 640 |
645 Handle<Code> StubCompiler::CompileStorePreMonomorphic(Code::Flags flags) { | 641 Handle<Code> StubCompiler::CompileStorePreMonomorphic(Code::Flags flags) { |
646 StoreIC::GeneratePreMonomorphic(masm()); | 642 StoreIC::GeneratePreMonomorphic(masm()); |
647 Handle<Code> code = GetCodeWithFlags(flags, "CompileStorePreMonomorphic"); | 643 Handle<Code> code = GetCodeWithFlags(flags, "CompileStorePreMonomorphic"); |
648 PROFILE(isolate(), | 644 PROFILE(isolate(), |
649 CodeCreateEvent(Logger::STORE_PREMONOMORPHIC_TAG, *code, 0)); | 645 CodeCreateEvent(Logger::STORE_PREMONOMORPHIC_TAG, *code, 0)); |
650 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *code)); | |
651 return code; | 646 return code; |
652 } | 647 } |
653 | 648 |
654 | 649 |
655 Handle<Code> StubCompiler::CompileStoreGeneric(Code::Flags flags) { | 650 Handle<Code> StubCompiler::CompileStoreGeneric(Code::Flags flags) { |
656 ExtraICState extra_state = Code::ExtractExtraICStateFromFlags(flags); | 651 ExtraICState extra_state = Code::ExtractExtraICStateFromFlags(flags); |
657 StrictMode strict_mode = StoreIC::GetStrictMode(extra_state); | 652 StrictMode strict_mode = StoreIC::GetStrictMode(extra_state); |
658 StoreIC::GenerateRuntimeSetProperty(masm(), strict_mode); | 653 StoreIC::GenerateRuntimeSetProperty(masm(), strict_mode); |
659 Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreGeneric"); | 654 Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreGeneric"); |
660 PROFILE(isolate(), | 655 PROFILE(isolate(), |
661 CodeCreateEvent(Logger::STORE_GENERIC_TAG, *code, 0)); | 656 CodeCreateEvent(Logger::STORE_GENERIC_TAG, *code, 0)); |
662 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *code)); | |
663 return code; | 657 return code; |
664 } | 658 } |
665 | 659 |
666 | 660 |
667 Handle<Code> StubCompiler::CompileStoreMegamorphic(Code::Flags flags) { | 661 Handle<Code> StubCompiler::CompileStoreMegamorphic(Code::Flags flags) { |
668 StoreIC::GenerateMegamorphic(masm()); | 662 StoreIC::GenerateMegamorphic(masm()); |
669 Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreMegamorphic"); | 663 Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreMegamorphic"); |
670 PROFILE(isolate(), | 664 PROFILE(isolate(), |
671 CodeCreateEvent(Logger::STORE_MEGAMORPHIC_TAG, *code, 0)); | 665 CodeCreateEvent(Logger::STORE_MEGAMORPHIC_TAG, *code, 0)); |
672 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *code)); | |
673 return code; | 666 return code; |
674 } | 667 } |
675 | 668 |
676 | 669 |
677 #undef CALL_LOGGER_TAG | 670 #undef CALL_LOGGER_TAG |
678 | 671 |
679 | 672 |
680 Handle<Code> StubCompiler::GetCodeWithFlags(Code::Flags flags, | 673 Handle<Code> StubCompiler::GetCodeWithFlags(Code::Flags flags, |
681 const char* name) { | 674 const char* name) { |
682 // Create code object in the heap. | 675 // Create code object in the heap. |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 | 1152 |
1160 #undef __ | 1153 #undef __ |
1161 | 1154 |
1162 | 1155 |
1163 void StubCompiler::TailCallBuiltin(MacroAssembler* masm, Builtins::Name name) { | 1156 void StubCompiler::TailCallBuiltin(MacroAssembler* masm, Builtins::Name name) { |
1164 Handle<Code> code(masm->isolate()->builtins()->builtin(name)); | 1157 Handle<Code> code(masm->isolate()->builtins()->builtin(name)); |
1165 GenerateTailCall(masm, code); | 1158 GenerateTailCall(masm, code); |
1166 } | 1159 } |
1167 | 1160 |
1168 | 1161 |
1169 void BaseLoadStoreStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) { | |
1170 #ifdef ENABLE_GDB_JIT_INTERFACE | |
1171 GDBJITInterface::CodeTag tag; | |
1172 if (kind_ == Code::LOAD_IC) { | |
1173 tag = GDBJITInterface::LOAD_IC; | |
1174 } else if (kind_ == Code::KEYED_LOAD_IC) { | |
1175 tag = GDBJITInterface::KEYED_LOAD_IC; | |
1176 } else if (kind_ == Code::STORE_IC) { | |
1177 tag = GDBJITInterface::STORE_IC; | |
1178 } else { | |
1179 tag = GDBJITInterface::KEYED_STORE_IC; | |
1180 } | |
1181 GDBJIT(AddCode(tag, *name, *code)); | |
1182 #endif | |
1183 } | |
1184 | |
1185 | |
1186 void BaseLoadStoreStubCompiler::InitializeRegisters() { | 1162 void BaseLoadStoreStubCompiler::InitializeRegisters() { |
1187 if (kind_ == Code::LOAD_IC) { | 1163 if (kind_ == Code::LOAD_IC) { |
1188 registers_ = LoadStubCompiler::registers(); | 1164 registers_ = LoadStubCompiler::registers(); |
1189 } else if (kind_ == Code::KEYED_LOAD_IC) { | 1165 } else if (kind_ == Code::KEYED_LOAD_IC) { |
1190 registers_ = KeyedLoadStubCompiler::registers(); | 1166 registers_ = KeyedLoadStubCompiler::registers(); |
1191 } else if (kind_ == Code::STORE_IC) { | 1167 } else if (kind_ == Code::STORE_IC) { |
1192 registers_ = StoreStubCompiler::registers(); | 1168 registers_ = StoreStubCompiler::registers(); |
1193 } else { | 1169 } else { |
1194 registers_ = KeyedStoreStubCompiler::registers(); | 1170 registers_ = KeyedStoreStubCompiler::registers(); |
1195 } | 1171 } |
1196 } | 1172 } |
1197 | 1173 |
1198 | 1174 |
1199 Handle<Code> BaseLoadStoreStubCompiler::GetICCode(Code::Kind kind, | 1175 Handle<Code> BaseLoadStoreStubCompiler::GetICCode(Code::Kind kind, |
1200 Code::StubType type, | 1176 Code::StubType type, |
1201 Handle<Name> name, | 1177 Handle<Name> name, |
1202 InlineCacheState state) { | 1178 InlineCacheState state) { |
1203 Code::Flags flags = Code::ComputeFlags(kind, state, extra_state(), type); | 1179 Code::Flags flags = Code::ComputeFlags(kind, state, extra_state(), type); |
1204 Handle<Code> code = GetCodeWithFlags(flags, name); | 1180 Handle<Code> code = GetCodeWithFlags(flags, name); |
1205 IC::RegisterWeakMapDependency(code); | 1181 IC::RegisterWeakMapDependency(code); |
1206 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); | 1182 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); |
1207 JitEvent(name, code); | |
1208 return code; | 1183 return code; |
1209 } | 1184 } |
1210 | 1185 |
1211 | 1186 |
1212 Handle<Code> BaseLoadStoreStubCompiler::GetCode(Code::Kind kind, | 1187 Handle<Code> BaseLoadStoreStubCompiler::GetCode(Code::Kind kind, |
1213 Code::StubType type, | 1188 Code::StubType type, |
1214 Handle<Name> name) { | 1189 Handle<Name> name) { |
1215 ASSERT_EQ(kNoExtraICState, extra_state()); | 1190 ASSERT_EQ(kNoExtraICState, extra_state()); |
1216 Code::Flags flags = Code::ComputeHandlerFlags(kind, type, cache_holder_); | 1191 Code::Flags flags = Code::ComputeHandlerFlags(kind, type, cache_holder_); |
1217 Handle<Code> code = GetCodeWithFlags(flags, name); | 1192 Handle<Code> code = GetCodeWithFlags(flags, name); |
1218 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); | 1193 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); |
1219 JitEvent(name, code); | |
1220 return code; | 1194 return code; |
1221 } | 1195 } |
1222 | 1196 |
1223 | 1197 |
1224 void KeyedLoadStubCompiler::CompileElementHandlers(MapHandleList* receiver_maps, | 1198 void KeyedLoadStubCompiler::CompileElementHandlers(MapHandleList* receiver_maps, |
1225 CodeHandleList* handlers) { | 1199 CodeHandleList* handlers) { |
1226 for (int i = 0; i < receiver_maps->length(); ++i) { | 1200 for (int i = 0; i < receiver_maps->length(); ++i) { |
1227 Handle<Map> receiver_map = receiver_maps->at(i); | 1201 Handle<Map> receiver_map = receiver_maps->at(i); |
1228 Handle<Code> cached_stub; | 1202 Handle<Code> cached_stub; |
1229 | 1203 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 Handle<FunctionTemplateInfo>( | 1403 Handle<FunctionTemplateInfo>( |
1430 FunctionTemplateInfo::cast(signature->receiver())); | 1404 FunctionTemplateInfo::cast(signature->receiver())); |
1431 } | 1405 } |
1432 } | 1406 } |
1433 | 1407 |
1434 is_simple_api_call_ = true; | 1408 is_simple_api_call_ = true; |
1435 } | 1409 } |
1436 | 1410 |
1437 | 1411 |
1438 } } // namespace v8::internal | 1412 } } // namespace v8::internal |
OLD | NEW |