From 70d3296087f7e4417daf55b2c8f0b18a4ff27d85 Mon Sep 17 00:00:00 2001 From: "kaznacheev@chromium.org" Date: Fri, 6 Aug 2010 08:49:59 +0000 Subject: [PATCH] Reapplying r5174 (Avoid GC when compiling CallIC stubs). I could not find a way to introduce simple yet useful assertions, so I removed the assertions that broke tests. The new patch just fixes the actual problem (GC triggered while raw pointers are held in LookupResult). Review URL: http://codereview.chromium.org/3030049 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5196 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/stub-cache-arm.cc | 26 +++++++++++++++++--------- src/ia32/stub-cache-ia32.cc | 35 +++++++++++++++++++++-------------- src/stub-cache.cc | 7 ------- src/stub-cache.h | 8 +++----- src/x64/stub-cache-x64.cc | 28 +++++++++++++++++----------- 5 files changed, 58 insertions(+), 46 deletions(-) diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc index ff3007c..8c8e702 100644 --- a/src/arm/stub-cache-arm.cc +++ b/src/arm/stub-cache-arm.cc @@ -1252,9 +1252,11 @@ void CallStubCompiler::GenerateNameCheck(String* name, Label* miss) { } -void CallStubCompiler::GenerateMissBranch() { - Handle ic = ComputeCallMiss(arguments().immediate(), kind_); - __ Jump(ic, RelocInfo::CODE_TARGET); +Object* CallStubCompiler::GenerateMissBranch() { + Object* obj = StubCache::ComputeCallMiss(arguments().immediate(), kind_); + if (obj->IsFailure()) return obj; + __ Jump(Handle(Code::cast(obj)), RelocInfo::CODE_TARGET); + return obj; } @@ -1286,7 +1288,8 @@ Object* CallStubCompiler::CompileCallField(JSObject* object, // Handle call cache miss. __ bind(&miss); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(FIELD, name); @@ -1337,7 +1340,8 @@ Object* CallStubCompiler::CompileArrayPushCall(Object* object, // Handle call cache miss. __ bind(&miss); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(function); @@ -1388,7 +1392,8 @@ Object* CallStubCompiler::CompileArrayPopCall(Object* object, // Handle call cache miss. __ bind(&miss); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(function); @@ -1561,7 +1566,8 @@ Object* CallStubCompiler::CompileCallConstant(Object* object, } __ bind(&miss_in_smi_check); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(function); @@ -1610,7 +1616,8 @@ Object* CallStubCompiler::CompileCallInterceptor(JSObject* object, // Handle call cache miss. __ bind(&miss); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(INTERCEPTOR, name); @@ -1694,7 +1701,8 @@ Object* CallStubCompiler::CompileCallGlobal(JSObject* object, // Handle call cache miss. __ bind(&miss); __ IncrementCounter(&Counters::call_global_inline_miss, 1, r1, r3); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(NORMAL, name); diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc index 48f08a9..c21dd4f 100644 --- a/src/ia32/stub-cache-ia32.cc +++ b/src/ia32/stub-cache-ia32.cc @@ -1287,9 +1287,11 @@ void CallStubCompiler::GenerateNameCheck(String* name, Label* miss) { } -void CallStubCompiler::GenerateMissBranch() { - Handle ic = ComputeCallMiss(arguments().immediate(), kind_); - __ jmp(ic, RelocInfo::CODE_TARGET); +Object* CallStubCompiler::GenerateMissBranch() { + Object* obj = StubCache::ComputeCallMiss(arguments().immediate(), kind_); + if (obj->IsFailure()) return obj; + __ jmp(Handle(Code::cast(obj)), RelocInfo::CODE_TARGET); + return obj; } @@ -1340,7 +1342,8 @@ Object* CallStubCompiler::CompileCallField(JSObject* object, // Handle call cache miss. __ bind(&miss); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(FIELD, name); @@ -1487,7 +1490,8 @@ Object* CallStubCompiler::CompileArrayPushCall(Object* object, } __ bind(&miss); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(function); @@ -1570,7 +1574,8 @@ Object* CallStubCompiler::CompileArrayPopCall(Object* object, 1); __ bind(&miss); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(function); @@ -1633,8 +1638,8 @@ Object* CallStubCompiler::CompileStringCharCodeAtCall(Object* object, __ ret((argc + 1) * kPointerSize); __ bind(&miss); - - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(function); @@ -1700,9 +1705,8 @@ Object* CallStubCompiler::CompileStringCharAtCall(Object* object, __ ret((argc + 1) * kPointerSize); __ bind(&miss); - // Restore function name in ecx. - - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(function); @@ -1856,7 +1860,8 @@ Object* CallStubCompiler::CompileCallConstant(Object* object, FreeSpaceForFastApiCall(masm(), eax); } __ bind(&miss_in_smi_check); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(function); @@ -1920,7 +1925,8 @@ Object* CallStubCompiler::CompileCallInterceptor(JSObject* object, // Handle load cache miss. __ bind(&miss); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(INTERCEPTOR, name); @@ -2005,7 +2011,8 @@ Object* CallStubCompiler::CompileCallGlobal(JSObject* object, // Handle call cache miss. __ bind(&miss); __ IncrementCounter(&Counters::call_global_inline_miss, 1); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(NORMAL, name); diff --git a/src/stub-cache.cc b/src/stub-cache.cc index bc29d06..6a0c93e 100644 --- a/src/stub-cache.cc +++ b/src/stub-cache.cc @@ -822,13 +822,6 @@ void StubCache::Clear() { // StubCompiler implementation. -// Support function for computing call IC miss stubs. -Handle ComputeCallMiss(int argc, Code::Kind kind) { - CALL_HEAP_FUNCTION(StubCache::ComputeCallMiss(argc, kind), Code); -} - - - Object* LoadCallbackProperty(Arguments args) { ASSERT(args[0]->IsJSObject()); ASSERT(args[1]->IsJSObject()); diff --git a/src/stub-cache.h b/src/stub-cache.h index 8c00ee8..0be32f1 100644 --- a/src/stub-cache.h +++ b/src/stub-cache.h @@ -336,10 +336,6 @@ Object* CallInterceptorProperty(Arguments args); Object* KeyedLoadPropertyWithInterceptor(Arguments args); -// Support function for computing call IC miss stubs. -Handle ComputeCallMiss(int argc, Code::Kind kind); - - // The stub compiler compiles stubs for the stub cache. class StubCompiler BASE_EMBEDDED { public: @@ -688,7 +684,9 @@ class CallStubCompiler: public StubCompiler { void GenerateNameCheck(String* name, Label* miss); - void GenerateMissBranch(); + // Generates a jump to CallIC miss stub. Returns Failure if the jump cannot + // be generated. + Object* GenerateMissBranch(); }; diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc index e67000a..4c15715 100644 --- a/src/x64/stub-cache-x64.cc +++ b/src/x64/stub-cache-x64.cc @@ -820,9 +820,11 @@ void CallStubCompiler::GenerateNameCheck(String* name, Label* miss) { } -void CallStubCompiler::GenerateMissBranch() { - Handle ic = ComputeCallMiss(arguments().immediate(), kind_); - __ Jump(ic, RelocInfo::CODE_TARGET); +Object* CallStubCompiler::GenerateMissBranch() { + Object* obj = StubCache::ComputeCallMiss(arguments().immediate(), kind_); + if (obj->IsFailure()) return obj; + __ Jump(Handle(Code::cast(obj)), RelocInfo::CODE_TARGET); + return obj; } @@ -975,7 +977,8 @@ Object* CallStubCompiler::CompileCallConstant(Object* object, // Handle call cache miss. __ bind(&miss_in_smi_check); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(function); @@ -1029,7 +1032,8 @@ Object* CallStubCompiler::CompileCallField(JSObject* object, // Handle call cache miss. __ bind(&miss); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(FIELD, name); @@ -1186,8 +1190,8 @@ Object* CallStubCompiler::CompileArrayPushCall(Object* object, } __ bind(&miss); - - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(function); @@ -1270,8 +1274,8 @@ Object* CallStubCompiler::CompileArrayPopCall(Object* object, argc + 1, 1); __ bind(&miss); - - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(function); @@ -1357,7 +1361,8 @@ Object* CallStubCompiler::CompileCallInterceptor(JSObject* object, // Handle load cache miss. __ bind(&miss); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(INTERCEPTOR, name); @@ -1442,7 +1447,8 @@ Object* CallStubCompiler::CompileCallGlobal(JSObject* object, // Handle call cache miss. __ bind(&miss); __ IncrementCounter(&Counters::call_global_inline_miss, 1); - GenerateMissBranch(); + Object* obj = GenerateMissBranch(); + if (obj->IsFailure()) return obj; // Return the generated code. return GetCode(NORMAL, name); -- 2.7.4