From 11d24334fc63e7f813b149e093ebb6e617e7bbd3 Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Fri, 4 May 2012 09:16:38 +0000 Subject: [PATCH] Implement ClearFunctionTypeFeedback for test cases. R=danno@chromium.org TEST=mjsunit/compiler/inline-construct Review URL: https://chromiumcodereview.appspot.com/10332010 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11509 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mark-compact.cc | 11 +---------- src/objects.cc | 14 ++++++++++++++ src/objects.h | 1 + src/runtime.cc | 13 +++++++++++++ src/runtime.h | 1 + test/mjsunit/compiler/inline-construct.js | 6 ++++-- 6 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/mark-compact.cc b/src/mark-compact.cc index 507ad84090..4216e16409 100644 --- a/src/mark-compact.cc +++ b/src/mark-compact.cc @@ -1186,16 +1186,7 @@ class StaticMarkingVisitor : public StaticVisitorBase { Heap* heap = map->GetHeap(); Code* code = reinterpret_cast(object); if (FLAG_cleanup_code_caches_at_gc) { - Object* raw_info = code->type_feedback_info(); - if (raw_info->IsTypeFeedbackInfo()) { - TypeFeedbackCells* type_feedback_cells = - TypeFeedbackInfo::cast(raw_info)->type_feedback_cells(); - for (int i = 0; i < type_feedback_cells->CellCount(); i++) { - ASSERT(type_feedback_cells->AstId(i)->IsSmi()); - JSGlobalPropertyCell* cell = type_feedback_cells->Cell(i); - cell->set_value(TypeFeedbackCells::RawUninitializedSentinel(heap)); - } - } + code->ClearTypeFeedbackCells(heap); } code->CodeIterateBody(heap); } diff --git a/src/objects.cc b/src/objects.cc index 083a332f1c..970fc24550 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -8320,6 +8320,20 @@ void Code::ClearInlineCaches() { } +void Code::ClearTypeFeedbackCells(Heap* heap) { + Object* raw_info = type_feedback_info(); + if (raw_info->IsTypeFeedbackInfo()) { + TypeFeedbackCells* type_feedback_cells = + TypeFeedbackInfo::cast(raw_info)->type_feedback_cells(); + for (int i = 0; i < type_feedback_cells->CellCount(); i++) { + ASSERT(type_feedback_cells->AstId(i)->IsSmi()); + JSGlobalPropertyCell* cell = type_feedback_cells->Cell(i); + cell->set_value(TypeFeedbackCells::RawUninitializedSentinel(heap)); + } + } +} + + #ifdef ENABLE_DISASSEMBLER void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) { diff --git a/src/objects.h b/src/objects.h index 5a0fef07ae..e3a1fd0d25 100644 --- a/src/objects.h +++ b/src/objects.h @@ -4440,6 +4440,7 @@ class Code: public HeapObject { void CodeVerify(); #endif void ClearInlineCaches(); + void ClearTypeFeedbackCells(Heap* heap); // Max loop nesting marker used to postpose OSR. We don't take loop // nesting that is deeper than 5 levels into account. diff --git a/src/runtime.cc b/src/runtime.cc index 1305f8b5c8..0b80effbf2 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -8277,6 +8277,19 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeoptimizeFunction) { } +RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearFunctionTypeFeedback) { + HandleScope scope(isolate); + ASSERT(args.length() == 1); + CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); + Code* unoptimized = function->shared()->code(); + if (unoptimized->kind() == Code::FUNCTION) { + unoptimized->ClearInlineCaches(); + unoptimized->ClearTypeFeedbackCells(isolate->heap()); + } + return isolate->heap()->undefined_value(); +} + + RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) { #if defined(USE_SIMULATOR) return isolate->heap()->true_value(); diff --git a/src/runtime.h b/src/runtime.h index 9ae1383fbc..a09d9cc3cc 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -89,6 +89,7 @@ namespace internal { F(NotifyDeoptimized, 1, 1) \ F(NotifyOSR, 0, 1) \ F(DeoptimizeFunction, 1, 1) \ + F(ClearFunctionTypeFeedback, 1, 1) \ F(RunningInSimulator, 0, 1) \ F(OptimizeFunctionOnNextCall, -1, 1) \ F(GetOptimizationStatus, 1, 1) \ diff --git a/test/mjsunit/compiler/inline-construct.js b/test/mjsunit/compiler/inline-construct.js index af9e69c940..7a3f1e44bd 100644 --- a/test/mjsunit/compiler/inline-construct.js +++ b/test/mjsunit/compiler/inline-construct.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --expose-gc --inline-construct +// Flags: --allow-natives-syntax --inline-construct // Test inlining of constructor calls. @@ -68,7 +68,9 @@ function TestInAllContexts(constructor) { %DeoptimizeFunction(value_context); %DeoptimizeFunction(test_context); %DeoptimizeFunction(effect_context); - gc(); // Makes V8 forget about type information for *_context. + %ClearFunctionTypeFeedback(value_context); + %ClearFunctionTypeFeedback(test_context); + %ClearFunctionTypeFeedback(effect_context); }