From ef31d0480ae771619fb569b44b3c25675cf0def7 Mon Sep 17 00:00:00 2001 From: "kmillikin@chromium.org" Date: Mon, 24 Oct 2011 10:55:00 +0000 Subject: [PATCH] Handlify the remaining stub compiler functions for call ICs. Handlify StubCompiler functions for CallIC and KeyedCallIC cases Megamorphic, Arguments, DebugBreak, and DebugPrepareStepIn. R=ulan@chromium.org BUG= TEST= Review URL: http://codereview.chromium.org/8372029 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9750 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/ic-arm.cc | 10 ++--- src/ia32/ic-ia32.cc | 34 +++++++-------- src/ia32/stub-cache-ia32.cc | 16 +++---- src/ic.h | 5 +++ src/mips/ic-mips.cc | 10 ++--- src/stub-cache.cc | 101 ++++++++++---------------------------------- src/stub-cache.h | 6 --- src/x64/ic-x64.cc | 10 ++--- 8 files changed, 65 insertions(+), 127 deletions(-) diff --git a/src/arm/ic-arm.cc b/src/arm/ic-arm.cc index 88a68f8..18d4a9f 100644 --- a/src/arm/ic-arm.cc +++ b/src/arm/ic-arm.cc @@ -382,10 +382,10 @@ Object* CallIC_Miss(Arguments args); // The generated code does not accept smi keys. // The generated code falls through if both probes miss. -static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, - int argc, - Code::Kind kind, - Code::ExtraICState extra_ic_state) { +void CallICBase::GenerateMonomorphicCacheProbe(MacroAssembler* masm, + int argc, + Code::Kind kind, + Code::ExtraICState extra_state) { // ----------- S t a t e ------------- // -- r1 : receiver // -- r2 : name @@ -395,7 +395,7 @@ static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, // Probe the stub cache. Code::Flags flags = Code::ComputeFlags(kind, MONOMORPHIC, - extra_ic_state, + extra_state, NORMAL, argc); Isolate::Current()->stub_cache()->GenerateProbe( diff --git a/src/ia32/ic-ia32.cc b/src/ia32/ic-ia32.cc index 1cd7549..1168932 100644 --- a/src/ia32/ic-ia32.cc +++ b/src/ia32/ic-ia32.cc @@ -860,10 +860,10 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, // The generated code does not accept smi keys. // The generated code falls through if both probes miss. -static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, - int argc, - Code::Kind kind, - Code::ExtraICState extra_ic_state) { +void CallICBase::GenerateMonomorphicCacheProbe(MacroAssembler* masm, + int argc, + Code::Kind kind, + Code::ExtraICState extra_state) { // ----------- S t a t e ------------- // -- ecx : name // -- edx : receiver @@ -873,11 +873,11 @@ static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, // Probe the stub cache. Code::Flags flags = Code::ComputeFlags(kind, MONOMORPHIC, - extra_ic_state, + extra_state, NORMAL, argc); - Isolate::Current()->stub_cache()->GenerateProbe(masm, flags, edx, ecx, ebx, - eax); + Isolate* isolate = masm->isolate(); + isolate->stub_cache()->GenerateProbe(masm, flags, edx, ecx, ebx, eax); // If the stub cache probing failed, the receiver might be a value. // For value objects, we use the map of the prototype objects for @@ -903,9 +903,9 @@ static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, // Check for boolean. __ bind(&non_string); - __ cmp(edx, FACTORY->true_value()); + __ cmp(edx, isolate->factory()->true_value()); __ j(equal, &boolean); - __ cmp(edx, FACTORY->false_value()); + __ cmp(edx, isolate->factory()->false_value()); __ j(not_equal, &miss); __ bind(&boolean); StubCompiler::GenerateLoadGlobalFunctionPrototype( @@ -913,8 +913,7 @@ static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, // Probe the stub cache for the value object. __ bind(&probe); - Isolate::Current()->stub_cache()->GenerateProbe(masm, flags, edx, ecx, ebx, - no_reg); + isolate->stub_cache()->GenerateProbe(masm, flags, edx, ecx, ebx, no_reg); __ bind(&miss); } @@ -1044,7 +1043,7 @@ void CallICBase::GenerateMiss(MacroAssembler* masm, void CallIC::GenerateMegamorphic(MacroAssembler* masm, int argc, - Code::ExtraICState extra_ic_state) { + Code::ExtraICState extra_state) { // ----------- S t a t e ------------- // -- ecx : name // -- esp[0] : return address @@ -1055,9 +1054,10 @@ void CallIC::GenerateMegamorphic(MacroAssembler* masm, // Get the receiver of the function from the stack; 1 ~ return address. __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); - GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, extra_ic_state); + CallICBase::GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, + extra_state); - GenerateMiss(masm, argc, extra_ic_state); + GenerateMiss(masm, argc, extra_state); } @@ -1159,10 +1159,8 @@ void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { __ bind(&lookup_monomorphic_cache); __ IncrementCounter(counters->keyed_call_generic_lookup_cache(), 1); - GenerateMonomorphicCacheProbe(masm, - argc, - Code::KEYED_CALL_IC, - Code::kNoExtraICState); + CallICBase::GenerateMonomorphicCacheProbe(masm, argc, Code::KEYED_CALL_IC, + Code::kNoExtraICState); // Fall through on miss. __ bind(&slow_call); diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc index 139d7f5..b14f669 100644 --- a/src/ia32/stub-cache-ia32.cc +++ b/src/ia32/stub-cache-ia32.cc @@ -165,25 +165,23 @@ void StubCache::GenerateProbe(MacroAssembler* masm, Register scratch, Register extra, Register extra2) { - Isolate* isolate = Isolate::Current(); Label miss; - USE(extra2); // The register extra2 is not used on the ia32 platform. - // Make sure that code is valid. The shifting code relies on the - // entry size being 8. + // Assert that code is valid. The shifting code relies on the entry size + // being 8. ASSERT(sizeof(Entry) == 8); - // Make sure the flags does not name a specific type. + // Assert the flags do not name a specific type. ASSERT(Code::ExtractTypeFromFlags(flags) == 0); - // Make sure that there are no register conflicts. + // Assert that there are no register conflicts. ASSERT(!scratch.is(receiver)); ASSERT(!scratch.is(name)); ASSERT(!extra.is(receiver)); ASSERT(!extra.is(name)); ASSERT(!extra.is(scratch)); - // Check scratch and extra registers are valid, and extra2 is unused. + // Assert scratch and extra registers are valid, and extra2 is unused. ASSERT(!scratch.is(no_reg)); ASSERT(extra2.is(no_reg)); @@ -197,7 +195,7 @@ void StubCache::GenerateProbe(MacroAssembler* masm, __ and_(scratch, (kPrimaryTableSize - 1) << kHeapObjectTagSize); // Probe the primary table. - ProbeTable(isolate, masm, flags, kPrimary, name, scratch, extra); + ProbeTable(isolate(), masm, flags, kPrimary, name, scratch, extra); // Primary miss: Compute hash for secondary probe. __ mov(scratch, FieldOperand(name, String::kHashFieldOffset)); @@ -209,7 +207,7 @@ void StubCache::GenerateProbe(MacroAssembler* masm, __ and_(scratch, (kSecondaryTableSize - 1) << kHeapObjectTagSize); // Probe the secondary table. - ProbeTable(isolate, masm, flags, kSecondary, name, scratch, extra); + ProbeTable(isolate(), masm, flags, kSecondary, name, scratch, extra); // Cache miss: Fall-through and let caller handle the miss by // entering the runtime system. diff --git a/src/ic.h b/src/ic.h index b1c4302..81aa6b7 100644 --- a/src/ic.h +++ b/src/ic.h @@ -245,6 +245,11 @@ class CallICBase: public IC { static void GenerateNormal(MacroAssembler* masm, int argc); + static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, + int argc, + Code::Kind kind, + Code::ExtraICState extra_state); + Code::Kind kind_; friend class IC; diff --git a/src/mips/ic-mips.cc b/src/mips/ic-mips.cc index 4203d03..ca6383c 100644 --- a/src/mips/ic-mips.cc +++ b/src/mips/ic-mips.cc @@ -384,10 +384,10 @@ Object* CallIC_Miss(Arguments args); // The generated code does not accept smi keys. // The generated code falls through if both probes miss. -static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, - int argc, - Code::Kind kind, - Code::ExtraICState extra_ic_state) { +void CallICBase::GenerateMonomorphicCacheProbe(MacroAssembler* masm, + int argc, + Code::Kind kind, + Code::ExtraICState extra_state) { // ----------- S t a t e ------------- // -- a1 : receiver // -- a2 : name @@ -397,7 +397,7 @@ static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, // Probe the stub cache. Code::Flags flags = Code::ComputeFlags(kind, MONOMORPHIC, - extra_ic_state, + extra_state, NORMAL, argc); Isolate::Current()->stub_cache()->GenerateProbe( diff --git a/src/stub-cache.cc b/src/stub-cache.cc index 67e2a14..0c30a1d 100644 --- a/src/stub-cache.cc +++ b/src/stub-cache.cc @@ -1508,14 +1508,6 @@ Handle StubCompiler::CompileCallNormal(Code::Flags flags) { Handle StubCompiler::CompileCallMegamorphic(Code::Flags flags) { - CALL_HEAP_FUNCTION(isolate(), - (set_failure(NULL), TryCompileCallMegamorphic(flags)), - Code); -} - - -MaybeObject* StubCompiler::TryCompileCallMegamorphic(Code::Flags flags) { - HandleScope scope(isolate()); int argc = Code::ExtractArgumentsCountFromFlags(flags); Code::Kind kind = Code::ExtractKindFromFlags(flags); Code::ExtraICState extra_state = Code::ExtractExtraICStateFromFlags(flags); @@ -1524,46 +1516,26 @@ MaybeObject* StubCompiler::TryCompileCallMegamorphic(Code::Flags flags) { } else { KeyedCallIC::GenerateMegamorphic(masm(), argc); } - Object* result; - { MaybeObject* maybe_result = - TryGetCodeWithFlags(flags, "CompileCallMegamorphic"); - if (!maybe_result->ToObject(&result)) return maybe_result; - } + Handle code = GetCodeWithFlags(flags, "CompileCallMegamorphic"); isolate()->counters()->call_megamorphic_stubs()->Increment(); - Code* code = Code::cast(result); - USE(code); PROFILE(isolate(), CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG), - code, code->arguments_count())); - GDBJIT(AddCode(GDBJITInterface::CALL_MEGAMORPHIC, Code::cast(code))); - return result; + *code, code->arguments_count())); + GDBJIT(AddCode(GDBJITInterface::CALL_MEGAMORPHIC, *code)); + return code; } Handle StubCompiler::CompileCallArguments(Code::Flags flags) { - CALL_HEAP_FUNCTION(isolate(), - (set_failure(NULL), TryCompileCallArguments(flags)), - Code); -} - - -MaybeObject* StubCompiler::TryCompileCallArguments(Code::Flags flags) { - HandleScope scope(isolate()); int argc = Code::ExtractArgumentsCountFromFlags(flags); KeyedCallIC::GenerateNonStrictArguments(masm(), argc); - Code::Kind kind = Code::ExtractKindFromFlags(flags); - Object* result; - { MaybeObject* maybe_result = - TryGetCodeWithFlags(flags, "CompileCallArguments"); - if (!maybe_result->ToObject(&result)) return maybe_result; - } - Code* code = Code::cast(result); - USE(code); + Handle code = GetCodeWithFlags(flags, "CompileCallArguments"); PROFILE(isolate(), - CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG), - code, code->arguments_count())); - GDBJIT(AddCode(GDBJITInterface::CALL_MEGAMORPHIC, Code::cast(code))); - return result; + CodeCreateEvent(CALL_LOGGER_TAG(Code::ExtractKindFromFlags(flags), + CALL_MEGAMORPHIC_TAG), + *code, code->arguments_count())); + GDBJIT(AddCode(GDBJITInterface::CALL_MEGAMORPHIC, *code)); + return code; } @@ -1615,43 +1587,19 @@ MaybeObject* StubCompiler::TryCompileCallMiss(Code::Flags flags) { #ifdef ENABLE_DEBUGGER_SUPPORT Handle StubCompiler::CompileCallDebugBreak(Code::Flags flags) { - CALL_HEAP_FUNCTION(isolate(), - (set_failure(NULL), TryCompileCallDebugBreak(flags)), - Code); -} - - -MaybeObject* StubCompiler::TryCompileCallDebugBreak(Code::Flags flags) { - HandleScope scope(isolate()); Debug::GenerateCallICDebugBreak(masm()); - Object* result; - { MaybeObject* maybe_result = - TryGetCodeWithFlags(flags, "CompileCallDebugBreak"); - if (!maybe_result->ToObject(&result)) return maybe_result; - } - Code* code = Code::cast(result); - USE(code); - Code::Kind kind = Code::ExtractKindFromFlags(flags); - USE(kind); + Handle code = GetCodeWithFlags(flags, "CompileCallDebugBreak"); PROFILE(isolate(), - CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_DEBUG_BREAK_TAG), - code, code->arguments_count())); - return result; + CodeCreateEvent(CALL_LOGGER_TAG(Code::ExtractKindFromFlags(flags), + CALL_DEBUG_BREAK_TAG), + *code, code->arguments_count())); + return code; } Handle StubCompiler::CompileCallDebugPrepareStepIn(Code::Flags flags) { - CALL_HEAP_FUNCTION( - isolate(), - (set_failure(NULL), TryCompileCallDebugPrepareStepIn(flags)), - Code); -} - - -MaybeObject* StubCompiler::TryCompileCallDebugPrepareStepIn(Code::Flags flags) { - HandleScope scope(isolate()); - // Use the same code for the the step in preparations as we do for - // the miss case. + // Use the same code for the the step in preparations as we do for the + // miss case. int argc = Code::ExtractArgumentsCountFromFlags(flags); Code::Kind kind = Code::ExtractKindFromFlags(flags); if (kind == Code::CALL_IC) { @@ -1660,24 +1608,19 @@ MaybeObject* StubCompiler::TryCompileCallDebugPrepareStepIn(Code::Flags flags) { } else { KeyedCallIC::GenerateMiss(masm(), argc); } - Object* result; - { MaybeObject* maybe_result = - TryGetCodeWithFlags(flags, "CompileCallDebugPrepareStepIn"); - if (!maybe_result->ToObject(&result)) return maybe_result; - } - Code* code = Code::cast(result); - USE(code); + Handle code = GetCodeWithFlags(flags, "CompileCallDebugPrepareStepIn"); PROFILE(isolate(), CodeCreateEvent( CALL_LOGGER_TAG(kind, CALL_DEBUG_PREPARE_STEP_IN_TAG), - code, + *code, code->arguments_count())); - return result; + return code; } -#endif +#endif // ENABLE_DEBUGGER_SUPPORT #undef CALL_LOGGER_TAG + Handle StubCompiler::GetCodeWithFlags(Code::Flags flags, const char* name) { // Create code object in the heap. diff --git a/src/stub-cache.h b/src/stub-cache.h index 4f99472..89ee9d7 100644 --- a/src/stub-cache.h +++ b/src/stub-cache.h @@ -392,17 +392,11 @@ class StubCompiler BASE_EMBEDDED { Handle CompileCallArguments(Code::Flags flags); Handle CompileCallMiss(Code::Flags flags); - MUST_USE_RESULT MaybeObject* TryCompileCallMegamorphic(Code::Flags flags); - MUST_USE_RESULT MaybeObject* TryCompileCallArguments(Code::Flags flags); MUST_USE_RESULT MaybeObject* TryCompileCallMiss(Code::Flags flags); #ifdef ENABLE_DEBUGGER_SUPPORT Handle CompileCallDebugBreak(Code::Flags flags); Handle CompileCallDebugPrepareStepIn(Code::Flags flags); - - MUST_USE_RESULT MaybeObject* TryCompileCallDebugBreak(Code::Flags flags); - MUST_USE_RESULT MaybeObject* TryCompileCallDebugPrepareStepIn( - Code::Flags flags); #endif // Static functions for generating parts of stubs. diff --git a/src/x64/ic-x64.cc b/src/x64/ic-x64.cc index 12225f0..1518668 100644 --- a/src/x64/ic-x64.cc +++ b/src/x64/ic-x64.cc @@ -735,10 +735,10 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, // The generated code does not accept smi keys. // The generated code falls through if both probes miss. -static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, - int argc, - Code::Kind kind, - Code::ExtraICState extra_ic_state) { +void CallICBase::GenerateMonomorphicCacheProbe(MacroAssembler* masm, + int argc, + Code::Kind kind, + Code::ExtraICState extra_state) { // ----------- S t a t e ------------- // rcx : function name // rdx : receiver @@ -748,7 +748,7 @@ static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, // Probe the stub cache. Code::Flags flags = Code::ComputeFlags(kind, MONOMORPHIC, - extra_ic_state, + extra_state, NORMAL, argc); Isolate::Current()->stub_cache()->GenerateProbe(masm, flags, rdx, rcx, rbx, -- 2.7.4