説明を見る。00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "v8.h"
00029
00030 #include "bootstrapper.h"
00031 #include "code-stubs.h"
00032 #include "factory.h"
00033 #include "macro-assembler.h"
00034
00035 namespace v8 { namespace internal {
00036
00037 Handle<Code> CodeStub::GetCode() {
00038 uint32_t key = GetKey();
00039 int index = Heap::code_stubs()->FindNumberEntry(key);
00040 if (index == -1) {
00041 HandleScope scope;
00042
00043
00044 Counters::code_stubs.Increment();
00045
00046
00047 MacroAssembler masm(NULL, 256);
00048
00049
00050 masm.set_allow_stub_calls(AllowsStubCalls());
00051
00052
00053 masm.set_generating_stub(true);
00054 Generate(&masm);
00055
00056
00057 CodeDesc desc;
00058 masm.GetCode(&desc);
00059
00060
00061 Code::Flags flags = Code::ComputeFlags(Code::STUB);
00062 Handle<Code> code = Factory::NewCode(desc, NULL, flags);
00063 code->set_major_key(MajorKey());
00064
00065
00066 Bootstrapper::AddFixup(*code, &masm);
00067
00068 LOG(CodeCreateEvent("Stub", *code, GetName()));
00069 Counters::total_stubs_code_size.Increment(code->instruction_size());
00070
00071 #ifdef DEBUG
00072 if (FLAG_print_code_stubs) {
00073 Print();
00074 code->Print();
00075 PrintF("\n");
00076 }
00077 #endif
00078
00079
00080 Handle<Dictionary> dict =
00081 Factory::DictionaryAtNumberPut(Handle<Dictionary>(Heap::code_stubs()),
00082 key,
00083 code);
00084 Heap::set_code_stubs(*dict);
00085 index = Heap::code_stubs()->FindNumberEntry(key);
00086 }
00087 ASSERT(index != -1);
00088
00089 return Handle<Code>(Code::cast(Heap::code_stubs()->ValueAt(index)));
00090 }
00091
00092
00093 const char* CodeStub::MajorName(CodeStub::Major major_key) {
00094 switch (major_key) {
00095 case CallFunction:
00096 return "CallFunction";
00097 case GenericBinaryOp:
00098 return "GenericBinaryOp";
00099 case SmiOp:
00100 return "SmiOp";
00101 case Compare:
00102 return "Compare";
00103 case RecordWrite:
00104 return "RecordWrite";
00105 case StackCheck:
00106 return "StackCheck";
00107 case UnarySub:
00108 return "UnarySub";
00109 case RevertToNumber:
00110 return "RevertToNumber";
00111 case ToBoolean:
00112 return "ToBoolean";
00113 case Instanceof:
00114 return "Instanceof";
00115 case CounterOp:
00116 return "CounterOp";
00117 case ArgumentsAccess:
00118 return "ArgumentsAccess";
00119 case Runtime:
00120 return "Runtime";
00121 case CEntry:
00122 return "CEntry";
00123 case JSEntry:
00124 return "JSEntry";
00125 case GetProperty:
00126 return "GetProperty";
00127 case SetProperty:
00128 return "SetProperty";
00129 case InvokeBuiltin:
00130 return "InvokeBuiltin";
00131 case JSExit:
00132 return "JSExit";
00133 default:
00134 UNREACHABLE();
00135 return NULL;
00136 }
00137 }
00138
00139
00140 } }