From: iposva@chromium.org Date: Wed, 4 Mar 2009 06:14:34 +0000 (+0000) Subject: Add a meaningful name when disassembling code. This makes it easier X-Git-Tag: upstream/4.7.83~24590 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be0c1e26e9b98905786c099cfa756a681762f299;p=platform%2Fupstream%2Fv8.git Add a meaningful name when disassembling code. This makes it easier to match generated code to the originating source. Review URL: http://codereview.chromium.org/39014 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1408 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/builtins.cc b/src/builtins.cc index c4991c3..12e985d 100644 --- a/src/builtins.cc +++ b/src/builtins.cc @@ -699,10 +699,10 @@ void Builtins::Setup(bool create_heap_objects) { // Log the event and add the code to the builtins array. LOG(CodeCreateEvent("Builtin", Code::cast(code), functions[i].s_name)); builtins_[i] = code; -#ifdef DEBUG +#ifdef ENABLE_DISASSEMBLER if (FLAG_print_builtin_code) { PrintF("Builtin: %s\n", functions[i].s_name); - code->Print(); + Code::cast(code)->Disassemble(functions[i].s_name); PrintF("\n"); } #endif diff --git a/src/code-stubs.cc b/src/code-stubs.cc index 417806f..06c4dcd 100644 --- a/src/code-stubs.cc +++ b/src/code-stubs.cc @@ -68,10 +68,12 @@ Handle CodeStub::GetCode() { LOG(CodeCreateEvent("Stub", *code, GetName())); Counters::total_stubs_code_size.Increment(code->instruction_size()); -#ifdef DEBUG +#ifdef ENABLE_DISASSEMBLER if (FLAG_print_code_stubs) { +#ifdef DEBUG Print(); - code->Print(); +#endif + code->Disassemble(GetName()); PrintF("\n"); } #endif diff --git a/src/codegen.cc b/src/codegen.cc index 13a6b3b..cfd8f8f 100644 --- a/src/codegen.cc +++ b/src/codegen.cc @@ -179,7 +179,7 @@ Handle CodeGenerator::MakeCode(FunctionLiteral* flit, PrintF("\n\n"); } PrintF("--- Code ---\n"); - code->Disassemble(); + code->Disassemble(*flit->name()->ToCString()); } #endif // ENABLE_DISASSEMBLER diff --git a/src/flag-definitions.h b/src/flag-definitions.h index a93f8bd..0239506 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -246,9 +246,6 @@ DEFINE_args(js_arguments, JSArguments(), DEFINE_bool(enable_slow_asserts, false, "enable asserts that are slow to execute") -// code-stubs.cc -DEFINE_bool(print_code_stubs, false, "print code stubs") - // codegen-ia32.cc / codegen-arm.cc DEFINE_bool(trace_codegen, false, "print name of functions for which code is generated") @@ -346,6 +343,9 @@ DEFINE_string(logfile, "v8.log", "Specify the name of the log file.") #define FLAG FLAG_READONLY #endif +// code-stubs.cc +DEFINE_bool(print_code_stubs, false, "print code stubs") + // codegen-ia32.cc / codegen-arm.cc DEFINE_bool(print_code, false, "print generated code") DEFINE_bool(print_builtin_code, false, "print generated code for builtins") diff --git a/src/objects-debug.cc b/src/objects-debug.cc index a41c0ab..5b1e0b3 100644 --- a/src/objects-debug.cc +++ b/src/objects-debug.cc @@ -658,7 +658,7 @@ void Oddball::OddballVerify() { void Code::CodePrint() { HeapObject::PrintHeader("Code"); #ifdef ENABLE_DISASSEMBLER - Disassemble(); + Disassemble(NULL); #endif } diff --git a/src/objects.cc b/src/objects.cc index 14d9778..3214046 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -4795,10 +4795,13 @@ const char* Code::ICState2String(InlineCacheState state) { } -void Code::Disassemble() { - PrintF("kind = %s", Kind2String(kind())); +void Code::Disassemble(const char* name) { + PrintF("kind = %s\n", Kind2String(kind())); + if ((name != NULL) && (name[0] != '\0')) { + PrintF("name = %s\n", name); + } - PrintF("\nInstructions (size = %d)\n", instruction_size()); + PrintF("Instructions (size = %d)\n", instruction_size()); Disassembler::Decode(NULL, this); PrintF("\n"); diff --git a/src/objects.h b/src/objects.h index bf1ff05..b01f330 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2157,7 +2157,7 @@ class Code: public HeapObject { // Printing static const char* Kind2String(Kind kind); static const char* ICState2String(InlineCacheState state); - void Disassemble(); + void Disassemble(const char* name); #endif // ENABLE_DISASSEMBLER // [instruction_size]: Size of the native instructions diff --git a/src/stub-cache-arm.cc b/src/stub-cache-arm.cc index 45fa1c9..211b643 100644 --- a/src/stub-cache-arm.cc +++ b/src/stub-cache-arm.cc @@ -488,13 +488,14 @@ Object* StubCompiler::CompileLazyCompile(Code::Flags flags) { // Do a tail-call of the compiled function. __ Jump(r2); - return GetCodeWithFlags(flags); + return GetCodeWithFlags(flags, "LazyCompileStub"); } Object* CallStubCompiler::CompileCallField(Object* object, JSObject* holder, - int index) { + int index, + String* name) { // ----------- S t a t e ------------- // -- lr: return address // ----------------------------------- @@ -538,7 +539,7 @@ Object* CallStubCompiler::CompileCallField(Object* object, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(FIELD); + return GetCode(FIELD, name); } @@ -659,7 +660,11 @@ Object* CallStubCompiler::CompileCallConstant(Object* object, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(CONSTANT_FUNCTION); + String* function_name = NULL; + if (function->shared()->name()->IsString()) { + function_name = String::cast(function->shared()->name()); + } + return GetCode(CONSTANT_FUNCTION, function_name); } @@ -679,7 +684,7 @@ Object* CallStubCompiler::CompileCallInterceptor(Object* object, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(INTERCEPTOR); + return GetCode(INTERCEPTOR, name); } @@ -712,7 +717,7 @@ Object* StoreStubCompiler::CompileStoreField(JSObject* object, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(transition == NULL ? FIELD : MAP_TRANSITION); + return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); } @@ -767,7 +772,7 @@ Object* StoreStubCompiler::CompileStoreCallback(JSObject* object, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(CALLBACKS); + return GetCode(CALLBACKS, name); } @@ -819,13 +824,14 @@ Object* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(INTERCEPTOR); + return GetCode(INTERCEPTOR, name); } Object* LoadStubCompiler::CompileLoadField(JSObject* object, JSObject* holder, - int index) { + int index, + String* name) { // ----------- S t a t e ------------- // -- r2 : name // -- lr : return address @@ -840,13 +846,14 @@ Object* LoadStubCompiler::CompileLoadField(JSObject* object, GenerateLoadMiss(masm(), Code::LOAD_IC); // Return the generated code. - return GetCode(FIELD); + return GetCode(FIELD, name); } Object* LoadStubCompiler::CompileLoadCallback(JSObject* object, JSObject* holder, - AccessorInfo* callback) { + AccessorInfo* callback, + String* name) { // ----------- S t a t e ------------- // -- r2 : name // -- lr : return address @@ -860,13 +867,14 @@ Object* LoadStubCompiler::CompileLoadCallback(JSObject* object, GenerateLoadMiss(masm(), Code::LOAD_IC); // Return the generated code. - return GetCode(CALLBACKS); + return GetCode(CALLBACKS, name); } Object* LoadStubCompiler::CompileLoadConstant(JSObject* object, JSObject* holder, - Object* value) { + Object* value, + String* name) { // ----------- S t a t e ------------- // -- r2 : name // -- lr : return address @@ -881,7 +889,7 @@ Object* LoadStubCompiler::CompileLoadConstant(JSObject* object, GenerateLoadMiss(masm(), Code::LOAD_IC); // Return the generated code. - return GetCode(CONSTANT_FUNCTION); + return GetCode(CONSTANT_FUNCTION, name); } @@ -902,7 +910,7 @@ Object* LoadStubCompiler::CompileLoadInterceptor(JSObject* object, GenerateLoadMiss(masm(), Code::LOAD_IC); // Return the generated code. - return GetCode(INTERCEPTOR); + return GetCode(INTERCEPTOR, name); } @@ -929,7 +937,7 @@ Object* KeyedLoadStubCompiler::CompileLoadField(String* name, __ bind(&miss); GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - return GetCode(FIELD); + return GetCode(FIELD, name); } @@ -955,7 +963,7 @@ Object* KeyedLoadStubCompiler::CompileLoadCallback(String* name, __ bind(&miss); GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - return GetCode(CALLBACKS); + return GetCode(CALLBACKS, name); } @@ -982,7 +990,7 @@ Object* KeyedLoadStubCompiler::CompileLoadConstant(String* name, GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); // Return the generated code. - return GetCode(CONSTANT_FUNCTION); + return GetCode(CONSTANT_FUNCTION, name); } @@ -1007,7 +1015,7 @@ Object* KeyedLoadStubCompiler::CompileLoadInterceptor(JSObject* receiver, __ bind(&miss); GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - return GetCode(INTERCEPTOR); + return GetCode(INTERCEPTOR, name); } @@ -1030,7 +1038,7 @@ Object* KeyedLoadStubCompiler::CompileLoadArrayLength(String* name) { __ bind(&miss); GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - return GetCode(CALLBACKS); + return GetCode(CALLBACKS, name); } @@ -1055,7 +1063,7 @@ Object* KeyedLoadStubCompiler::CompileLoadStringLength(String* name) { GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - return GetCode(CALLBACKS); + return GetCode(CALLBACKS, name); } @@ -1068,7 +1076,7 @@ Object* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) { // ----------------------------------- GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - return GetCode(CALLBACKS); + return GetCode(CALLBACKS, name); } @@ -1108,7 +1116,7 @@ Object* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(transition == NULL ? FIELD : MAP_TRANSITION); + return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); } diff --git a/src/stub-cache-ia32.cc b/src/stub-cache-ia32.cc index ad1eb4c..7810eef 100644 --- a/src/stub-cache-ia32.cc +++ b/src/stub-cache-ia32.cc @@ -465,13 +465,14 @@ Object* StubCompiler::CompileLazyCompile(Code::Flags flags) { __ lea(ecx, FieldOperand(eax, Code::kHeaderSize)); __ jmp(Operand(ecx)); - return GetCodeWithFlags(flags); + return GetCodeWithFlags(flags, "LazyCompileStub"); } Object* CallStubCompiler::CompileCallField(Object* object, JSObject* holder, - int index) { + int index, + String* name) { // ----------- S t a t e ------------- // ----------------------------------- Label miss; @@ -514,7 +515,7 @@ Object* CallStubCompiler::CompileCallField(Object* object, __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(FIELD); + return GetCode(FIELD, name); } @@ -634,7 +635,11 @@ Object* CallStubCompiler::CompileCallConstant(Object* object, __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(CONSTANT_FUNCTION); + String* function_name = NULL; + if (function->shared()->name()->IsString()) { + function_name = String::cast(function->shared()->name()); + } + return GetCode(CONSTANT_FUNCTION, function_name); } @@ -707,7 +712,7 @@ Object* CallStubCompiler::CompileCallInterceptor(Object* object, __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(INTERCEPTOR); + return GetCode(INTERCEPTOR, name); } @@ -742,7 +747,7 @@ Object* StoreStubCompiler::CompileStoreField(JSObject* object, __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(transition == NULL ? FIELD : MAP_TRANSITION); + return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); } @@ -797,7 +802,7 @@ Object* StoreStubCompiler::CompileStoreCallback(JSObject* object, __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(CALLBACKS); + return GetCode(CALLBACKS, name); } @@ -850,7 +855,7 @@ Object* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(INTERCEPTOR); + return GetCode(INTERCEPTOR, name); } @@ -893,13 +898,14 @@ Object* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(transition == NULL ? FIELD : MAP_TRANSITION); + return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); } Object* LoadStubCompiler::CompileLoadField(JSObject* object, JSObject* holder, - int index) { + int index, + String* name) { // ----------- S t a t e ------------- // -- ecx : name // -- esp[0] : return address @@ -913,13 +919,14 @@ Object* LoadStubCompiler::CompileLoadField(JSObject* object, GenerateLoadMiss(masm(), Code::LOAD_IC); // Return the generated code. - return GetCode(FIELD); + return GetCode(FIELD, name); } Object* LoadStubCompiler::CompileLoadCallback(JSObject* object, JSObject* holder, - AccessorInfo* callback) { + AccessorInfo* callback, + String* name) { // ----------- S t a t e ------------- // -- ecx : name // -- esp[0] : return address @@ -934,13 +941,14 @@ Object* LoadStubCompiler::CompileLoadCallback(JSObject* object, GenerateLoadMiss(masm(), Code::LOAD_IC); // Return the generated code. - return GetCode(CALLBACKS); + return GetCode(CALLBACKS, name); } Object* LoadStubCompiler::CompileLoadConstant(JSObject* object, JSObject* holder, - Object* value) { + Object* value, + String* name) { // ----------- S t a t e ------------- // -- ecx : name // -- esp[0] : return address @@ -954,7 +962,7 @@ Object* LoadStubCompiler::CompileLoadConstant(JSObject* object, GenerateLoadMiss(masm(), Code::LOAD_IC); // Return the generated code. - return GetCode(CONSTANT_FUNCTION); + return GetCode(CONSTANT_FUNCTION, name); } @@ -974,7 +982,7 @@ Object* LoadStubCompiler::CompileLoadInterceptor(JSObject* receiver, GenerateLoadMiss(masm(), Code::LOAD_IC); // Return the generated code. - return GetCode(INTERCEPTOR); + return GetCode(INTERCEPTOR, name); } @@ -1003,7 +1011,7 @@ Object* KeyedLoadStubCompiler::CompileLoadField(String* name, GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); // Return the generated code. - return GetCode(FIELD); + return GetCode(FIELD, name); } @@ -1033,7 +1041,7 @@ Object* KeyedLoadStubCompiler::CompileLoadCallback(String* name, GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); // Return the generated code. - return GetCode(CALLBACKS); + return GetCode(CALLBACKS, name); } @@ -1062,7 +1070,7 @@ Object* KeyedLoadStubCompiler::CompileLoadConstant(String* name, GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); // Return the generated code. - return GetCode(CONSTANT_FUNCTION); + return GetCode(CONSTANT_FUNCTION, name); } @@ -1090,7 +1098,7 @@ Object* KeyedLoadStubCompiler::CompileLoadInterceptor(JSObject* receiver, GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); // Return the generated code. - return GetCode(INTERCEPTOR); + return GetCode(INTERCEPTOR, name); } @@ -1118,7 +1126,7 @@ Object* KeyedLoadStubCompiler::CompileLoadArrayLength(String* name) { GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); // Return the generated code. - return GetCode(CALLBACKS); + return GetCode(CALLBACKS, name); } @@ -1144,7 +1152,7 @@ Object* KeyedLoadStubCompiler::CompileLoadStringLength(String* name) { GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); // Return the generated code. - return GetCode(CALLBACKS); + return GetCode(CALLBACKS, name); } @@ -1170,7 +1178,7 @@ Object* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) { GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); // Return the generated code. - return GetCode(CALLBACKS); + return GetCode(CALLBACKS, name); } diff --git a/src/stub-cache.cc b/src/stub-cache.cc index 35b5be3..97d16d0 100644 --- a/src/stub-cache.cc +++ b/src/stub-cache.cc @@ -100,7 +100,7 @@ Object* StubCache::ComputeLoadField(String* name, Object* code = receiver->map()->FindInCodeCache(name, flags); if (code->IsUndefined()) { LoadStubCompiler compiler; - code = compiler.CompileLoadField(receiver, holder, field_index); + code = compiler.CompileLoadField(receiver, holder, field_index, name); if (code->IsFailure()) return code; LOG(CodeCreateEvent("LoadIC", Code::cast(code), name)); Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); @@ -119,7 +119,7 @@ Object* StubCache::ComputeLoadCallback(String* name, Object* code = receiver->map()->FindInCodeCache(name, flags); if (code->IsUndefined()) { LoadStubCompiler compiler; - code = compiler.CompileLoadCallback(receiver, holder, callback); + code = compiler.CompileLoadCallback(receiver, holder, callback, name); if (code->IsFailure()) return code; LOG(CodeCreateEvent("LoadIC", Code::cast(code), name)); Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); @@ -138,7 +138,7 @@ Object* StubCache::ComputeLoadConstant(String* name, Object* code = receiver->map()->FindInCodeCache(name, flags); if (code->IsUndefined()) { LoadStubCompiler compiler; - code = compiler.CompileLoadConstant(receiver, holder, value); + code = compiler.CompileLoadConstant(receiver, holder, value, name); if (code->IsFailure()) return code; LOG(CodeCreateEvent("LoadIC", Code::cast(code), name)); Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); @@ -434,7 +434,7 @@ Object* StubCache::ComputeCallField(int argc, Object* code = map->FindInCodeCache(name, flags); if (code->IsUndefined()) { CallStubCompiler compiler(argc); - code = compiler.CompileCallField(object, holder, index); + code = compiler.CompileCallField(object, holder, index, name); if (code->IsFailure()) return code; LOG(CodeCreateEvent("CallIC", Code::cast(code), name)); Object* result = map->UpdateCodeCache(name, Code::cast(code)); @@ -788,7 +788,7 @@ Object* StubCompiler::CompileCallInitialize(Code::Flags flags) { HandleScope scope; int argc = Code::ExtractArgumentsCountFromFlags(flags); CallIC::GenerateInitialize(masm(), argc); - Object* result = GetCodeWithFlags(flags); + Object* result = GetCodeWithFlags(flags, "CompileCallInitialize"); if (!result->IsFailure()) { Counters::call_initialize_stubs.Increment(); Code* code = Code::cast(result); @@ -803,7 +803,7 @@ Object* StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) { HandleScope scope; int argc = Code::ExtractArgumentsCountFromFlags(flags); CallIC::GenerateInitialize(masm(), argc); - Object* result = GetCodeWithFlags(flags); + Object* result = GetCodeWithFlags(flags, "CompileCallPreMonomorphic"); if (!result->IsFailure()) { Counters::call_premonomorphic_stubs.Increment(); Code* code = Code::cast(result); @@ -818,7 +818,7 @@ Object* StubCompiler::CompileCallNormal(Code::Flags flags) { HandleScope scope; int argc = Code::ExtractArgumentsCountFromFlags(flags); CallIC::GenerateNormal(masm(), argc); - Object* result = GetCodeWithFlags(flags); + Object* result = GetCodeWithFlags(flags, "CompileCallNormal"); if (!result->IsFailure()) { Counters::call_normal_stubs.Increment(); Code* code = Code::cast(result); @@ -833,7 +833,7 @@ Object* StubCompiler::CompileCallMegamorphic(Code::Flags flags) { HandleScope scope; int argc = Code::ExtractArgumentsCountFromFlags(flags); CallIC::GenerateMegamorphic(masm(), argc); - Object* result = GetCodeWithFlags(flags); + Object* result = GetCodeWithFlags(flags, "CompileCallMegamorphic"); if (!result->IsFailure()) { Counters::call_megamorphic_stubs.Increment(); Code* code = Code::cast(result); @@ -848,7 +848,7 @@ Object* StubCompiler::CompileCallMiss(Code::Flags flags) { HandleScope scope; int argc = Code::ExtractArgumentsCountFromFlags(flags); CallIC::GenerateMiss(masm(), argc); - Object* result = GetCodeWithFlags(flags); + Object* result = GetCodeWithFlags(flags, "CompileCallMiss"); if (!result->IsFailure()) { Counters::call_megamorphic_stubs.Increment(); Code* code = Code::cast(result); @@ -862,7 +862,7 @@ Object* StubCompiler::CompileCallMiss(Code::Flags flags) { Object* StubCompiler::CompileCallDebugBreak(Code::Flags flags) { HandleScope scope; Debug::GenerateCallICDebugBreak(masm()); - Object* result = GetCodeWithFlags(flags); + Object* result = GetCodeWithFlags(flags, "CompileCallDebugBreak"); if (!result->IsFailure()) { Code* code = Code::cast(result); USE(code); @@ -878,7 +878,7 @@ Object* StubCompiler::CompileCallDebugPrepareStepIn(Code::Flags flags) { // the miss case. int argc = Code::ExtractArgumentsCountFromFlags(flags); CallIC::GenerateMiss(masm(), argc); - Object* result = GetCodeWithFlags(flags); + Object* result = GetCodeWithFlags(flags, "CompileCallDebugPrepareStepIn"); if (!result->IsFailure()) { Code* code = Code::cast(result); USE(code); @@ -889,45 +889,55 @@ Object* StubCompiler::CompileCallDebugPrepareStepIn(Code::Flags flags) { } -Object* StubCompiler::GetCodeWithFlags(Code::Flags flags) { +Object* StubCompiler::GetCodeWithFlags(Code::Flags flags, char* name) { CodeDesc desc; masm_.GetCode(&desc); Object* result = Heap::CreateCode(desc, NULL, flags, masm_.CodeObject()); -#ifdef DEBUG +#ifdef ENABLE_DISASSEMBLER if (FLAG_print_code_stubs && !result->IsFailure()) { - Code::cast(result)->Print(); + Code::cast(result)->Disassemble(name); } #endif return result; } -Object* LoadStubCompiler::GetCode(PropertyType type) { - return GetCodeWithFlags(Code::ComputeMonomorphicFlags(Code::LOAD_IC, type)); +Object* StubCompiler::GetCodeWithFlags(Code::Flags flags, String* name) { + if (FLAG_print_code_stubs && (name != NULL)) { + return GetCodeWithFlags(flags, *name->ToCString()); + } + return GetCodeWithFlags(flags, reinterpret_cast(NULL)); +} + + +Object* LoadStubCompiler::GetCode(PropertyType type, String* name) { + Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, type); + return GetCodeWithFlags(flags, name); } -Object* KeyedLoadStubCompiler::GetCode(PropertyType type) { - return GetCodeWithFlags(Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, - type)); +Object* KeyedLoadStubCompiler::GetCode(PropertyType type, String* name) { + Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, type); + return GetCodeWithFlags(flags, name); } -Object* StoreStubCompiler::GetCode(PropertyType type) { - return GetCodeWithFlags(Code::ComputeMonomorphicFlags(Code::STORE_IC, type)); +Object* StoreStubCompiler::GetCode(PropertyType type, String* name) { + Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); + return GetCodeWithFlags(flags, name); } -Object* KeyedStoreStubCompiler::GetCode(PropertyType type) { - return GetCodeWithFlags(Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, - type)); +Object* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) { + Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); + return GetCodeWithFlags(flags, name); } -Object* CallStubCompiler::GetCode(PropertyType type) { +Object* CallStubCompiler::GetCode(PropertyType type, String* name) { int argc = arguments_.immediate(); Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, type, argc); - return GetCodeWithFlags(flags); + return GetCodeWithFlags(flags, name); } diff --git a/src/stub-cache.h b/src/stub-cache.h index ec93c80..c922845 100644 --- a/src/stub-cache.h +++ b/src/stub-cache.h @@ -362,7 +362,8 @@ class StubCompiler BASE_EMBEDDED { static void GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind); protected: - Object* GetCodeWithFlags(Code::Flags flags); + Object* GetCodeWithFlags(Code::Flags flags, char* name); + Object* GetCodeWithFlags(Code::Flags flags, String* name); MacroAssembler* masm() { return &masm_; } @@ -374,19 +375,24 @@ class StubCompiler BASE_EMBEDDED { class LoadStubCompiler: public StubCompiler { public: - Object* CompileLoadField(JSObject* object, JSObject* holder, int index); + Object* CompileLoadField(JSObject* object, + JSObject* holder, + int index, + String* name); Object* CompileLoadCallback(JSObject* object, JSObject* holder, - AccessorInfo* callback); + AccessorInfo* callback, + String* name); Object* CompileLoadConstant(JSObject* object, JSObject* holder, - Object* value); + Object* value, + String* name); Object* CompileLoadInterceptor(JSObject* object, JSObject* holder, String* name); private: - Object* GetCode(PropertyType); + Object* GetCode(PropertyType type, String* name); }; @@ -412,7 +418,7 @@ class KeyedLoadStubCompiler: public StubCompiler { Object* CompileLoadFunctionPrototype(String* name); private: - Object* GetCode(PropertyType); + Object* GetCode(PropertyType type, String* name); }; @@ -428,7 +434,7 @@ class StoreStubCompiler: public StubCompiler { Object* CompileStoreInterceptor(JSObject* object, String* name); private: - Object* GetCode(PropertyType type); + Object* GetCode(PropertyType type, String* name); }; @@ -440,7 +446,7 @@ class KeyedStoreStubCompiler: public StubCompiler { String* name); private: - Object* GetCode(PropertyType type); + Object* GetCode(PropertyType type, String* name); }; @@ -448,7 +454,10 @@ class CallStubCompiler: public StubCompiler { public: explicit CallStubCompiler(int argc) : arguments_(argc) { } - Object* CompileCallField(Object* object, JSObject* holder, int index); + Object* CompileCallField(Object* object, + JSObject* holder, + int index, + String* name); Object* CompileCallConstant(Object* object, JSObject* holder, JSFunction* function, @@ -462,7 +471,7 @@ class CallStubCompiler: public StubCompiler { const ParameterCount& arguments() { return arguments_; } - Object* GetCode(PropertyType type); + Object* GetCode(PropertyType type, String* name); };